« first day (4275 days earlier)      last day (656 days later) » 

7:09 AM
@AndrasDeak--СлаваУкраїні You were right. 2 out of 7 only. :(
 
stackoverflow.com/questions/23708898/… There are a lot of redundant answers here.
 
I generally stay clear of Windows questions. Just going through the first few answers I have no idea whether the py -m or python -m version is the correct one.
 
Any suggestions to check list[0th element] with dictionary key
Requirement is like this: list['item'] dict{"item=tress" : huge}
 
7:27 AM
@Jordan Can you please take the time to prepare valid and clear queries? Both list['item'] and dict{"item=tress" : huge} are just bogus syntax errors. If you want suggestions how to "heck list[0th element] with dictionary key", please clearly describe what that actually means.
People will only waste so much time guessing the gaps before they will give up for good.
 
@MisterMiyagi no need to respond if you don't know
 
Okay.
 
@Jordan That is not an appropriate response. MisterMiyagi is one of the most knowledgeable people in this room and was giving you tips on how best to get help here. Responses like this do not help your chances; please try take his feedback on board
 
 
1 hour later…
8:49 AM
Jun 20 at 9:08, by Andras Deak -- Слава Україні
@Jordan no, not "yes". If you ask for help and then ignore the help you get and later ask again it's a very strong signal that us helping you is a waste of our time and we should be ignoring you too. Please reconsider how you ask here and improve right now, otherwise you won't be able to ask here at all.
@Jordan this was your last chance. The next time you come here with a vague question or act like we don't have better things to do than help you, you're getting kicked.
@MisterMiyagi 7 is either way too many or way too few. Sad either way.
 
 
1 hour later…
10:01 AM
I'm assuming the answer is "no" but is there some generic hook I can latch onto in a python process to get it to do something before it's killed by an exception? I have a full library and it can die at any point that a user is using it, but I want it to be able to keep a log of all the interactions that were successful and try write that log somewhere before death. TBC...
The reason being is that our platform doesn't allow us to store logs in separate locations, everything is just spewed into stdout and it's a nightmare to read. The ideal scenario would be that it could very quickly export a clean, specific, set of logs to S3 before it gives up the ghost
I mean, ideally, I wouldn't have to be trying some weird trick at all, but the logs are never gonna be more than a single, combined stdout garbage heap
 
@roganjosh does atexit help?
 
This looks like it could be ideal, thanks. I can probably just tag on a mini module that automatically registers a function as soon as you start using the library
 
Universal solution to missing context managers :P Just don't segfault...
 
I don't want to say that can't happen, but only that it hasn't happened so far. It's usually just fields unexpectedly missing in customer data being run through another library using my library. It's horrible to try track down where this happens so it'd be nice if the library just kept an independent checklist of things you'd managed to get it to do before it went boom
 
10:17 AM
So you'd keep a package global log to print?
 
10:42 AM
cbg
something puzzles me. if you have this checklist of things you managed to get done before the exception hits, what's stopping you from just logging that checklist as you go? Or are you saying you do log it, but it gets mixed up in all the other logs
 
11:06 AM
I including this in my curriculum, great write man :)
Also a typo:
play_again = input("Would you like to play again? ")
        if (play_again == 'n' or play_again == 'N' or
            play_again == 'no' or play_again == 'No'):
            breakak
 
hmm?
ah, meant to be a reply to the message pointing to aran-fey.github.io/programming-guides/readable-code.html, cc @Aran-Fey ^
 
Let's see if I still know how to rebuild and republish this thing...
 
11:30 AM
fixed
 
11:41 AM
@JonClements This is definitely a problem that I've personally encountered, just about every time I've played a game in the idle/clicker genre. "given that my money gained per second is num_gold_miners * miner_efficiency_rating, is it better to hire one additional gold miner, or to multiply my efficiency rating by 1.05?". I suspect the answer varies depending on your end goal.
Or, well, I've oversimplified the typical mechanics a bit... It's pretty easy to calculate the better choice here. But let's say you could also buy a recruiter, which grants you one additional miner every ten seconds... Now we're starting to get some fun looking graphs.
 
Kevin, what you call "idle clickers" require phd in mathematics to figure out, i am not falling for that again. :P
 
I'm pretty sure some of these games legitimately require hypergeometry to play efficiently. So, I can't blame you there.
 
for some reason I read "phd in mathematics" as "php in mathematics" - and shrugged
 
11:58 AM
well, for some reason i read "php in mathematics" as "phd in mathematics" and was very confused about what you were trying to say.
amusing how that works :P
 
@ParitoshSingh same :D
@Aran-Fey Neat :) I assume you are fine with sharing this as widely as possible for educational purposes?
 
Sure, just don't expect any new content
 
What's on there is already plenty :)
 
Here is a little non-interactive demo of a simple idle game where you can spend 4$ to purchase a miner, and every miner earns you $1 per tick. The virtual player here is using the most straightforward strategy -- buy miners as soon as possible. It takes them 24 ticks to reach their goal of $100.
But even in a simple scenario like this, it's possible to optimize. Suppose the player stopped purchasing miners on tick 19, when they have 37 already. It would take them three ticks to earn 3*37 dollars, and reach their goal. Two ticks faster than the naive approach. So evidently it's valuable to consider diminishing returns.
In real idle games, the cost of purchasing an additional miner usually goes up by ~10% every time you purchase one. In that case, the diminishing returns are far more evident. Your 100th miner will cost $55,122, and it still only makes you $1 per tick, so it's not a very attractive return on investment.
 
12:25 PM
Dear Jon Clements,

24 hours remain to cast your ballot for the 2022 PSF Board of Directors Election! You have not yet cast your ballot!

Your vote is crucial to helping the PSF meet its quorum of 1/3 of voting membership to establish an election result.
 
Here is v1.1, which estimates when it's a good idea to stop making purchases. It looks like you can do even better than my "stop at 37 miners" scenario. I'm curious if it's possible to calculate the best stopping point in O(1) time.
@JonClements Vote for me, I promise not to go mad with power
 
@JonClements highest bid wins
 
Running in the election under the name "" so that I automatically receive any vote that wasn't cast
 
I'll represent the nihilist party. My policy is to do nothing.
 
12:40 PM
@AndrasDeak--СлаваУкраїні Mr. Null so often gets pointed at... sighs
 
@AndrasDeak--СлаваУкраїні yeah... zero point in throwing it in the void
 
1:10 PM
@Kevin It's actually really easy to implement a perfect AI, since there is never a reason to spend only some of your money. You either spend all of it or nothing. If you're going to win within the next 4 turns, you do nothing, otherwise you spend all your money on miners. But if you want to calculate the turn when this'll happen at the start of the game, that's more difficult
 
1:28 PM
Yeah. I think you could apply principles of exponential growth, if this was a continuous problem, and you could make purchases at time t, where t is any real number. Restricting it to integers makes the problem chunky in an inconvenient way.
 
 
1 hour later…
2:34 PM
Terminology question: 23 and 43 are integers. "second" and "meter" are units. "23 seconds" and "43 meters" are...? Unit-ful numbers?
 
if there's a term for that it should be nearby en.wikipedia.org/wiki/Dimensionless_quantity
astropy.units calls these a Quantity
In Hungarian we definitely say "dimensioned quantity", but that doesn't quite sound right in English.
> dimensioned

1. Possessing dimension, non-dimensionless, dimensionful.
I guess that's it then
 
2:57 PM
United numbers
 
united, but not united, I presume
 
Both. United and united with their unit
 
"Unitted"
I think Quantity will suffice for now, thanks
 
 
1 hour later…
4:32 PM
@AndrasDeak--СлаваУкраїні Made a nice mini package for this that I've called eulogy with a singleton and a @eulogise decorator to give function call history. It was a bit clunky to stop it printing on anything other than an unhandled exception
if self._epitaph:
    try:
        if not force:
            with open(os.devnull, 'w') as f:
                with redirect_stderr(f):
                    traceback.print_last()
        print()
        print("##### EULOGY RECITAL #####")
        for row in self._epitaph:
            print(row)
    except ValueError:
        pass
 
When can you get a ValueError?
 
If there is no unhandled exception
I tried multiple ways to get at the stack but I couldn't seem to get it to work
 
Do you want this to run without an unhandled exception?
I'm wondering if you should put the try-except around the traceback stuff
 
No, not unless you force it
So the behavior is right; if the code doesn't crash, there's no eulogy
I just thought there'd be a cleaner method to determine whether there was an unhandlee exception than just forcing a handled one
 
4:44 PM
I only 50% understand the problem, and only 50% understand audithook, so we're starting at a 3/4 chance of failure right out of the gate
 
That looks cleaner! I was looking in the wrong place
The problem is that everything (logging, stdout, stderr) get mashed into one place in our system. So I've made a barebones logger that you can use to track optional events that only spews its guts on atexit if the workflow crashes out
 
Another thing I'll throw at the wall to see if it sticks: sys._current_exceptions
 
The closest I can get to an isolated log
 
The leading underscore means that it's forbidden and therefore powerful
I wonder if you could encode your logging and stdout and stderr so that you can un-mash them after the fact. For example, put <logging>tags around your</logging> <stderr>output, like</stderr> <stdout>this.</stdout>
Plus some elbow grease to ensure it doesn't fall apart if the code actually wants to print a string containing </stdout>
 
That presupposes we have anything even vaguely approaching control in this system
 
4:56 PM
Yes :^)
 
We can only see the logs in the browser panel
 
I'll write you an unmasher in javascript, for a modest fee
 
I've got eulogy now though :P
I'm not good at typing and walking apparently
 
It's hard to keep the keyboard steady, I imagine
Unless you have professional equipment of course
 
I thought it's the sound of footsteps disrupting the speech-to-text engine
 
5:03 PM
Or perhaps you mean "I'm not good at type annotation and walking". Maybe get a whiteboard on wheels.
 
5:17 PM
@Kevin at that point one could probably use structlog
 
Yeah
 
 
3 hours later…
8:14 PM
stackoverflow.com/questions/16043797 It turns out I already had this in my bookmarks.
Maybe this is the real canonical. The problem is that OPs try a lot of different strategies for the same problem, (all but two of which are basically nonsense, and those are the two that don't end up with the need to ask a question)
The secondary problem is that abusing globals is easy to land on accidentally.
Finally, OPs model what the problem is in multiple different ways. "I want to communicate between functions." "I want to get a result from the function." "I want to see the function's variables." [iterative descent into madness follows]
 
sounds more like a recursive descent into madness
 
IMO the general misconception is that variables are things. Questions asking about doing stuff with variables are a different bag from those where folks already realise they want to do stuff with values.
The answer to "how do I get the variable" is "LOL no", and the answer to "how do I get the value" is "LOL return".
 
@MisterMiyagi That's a very guru view of the problem. It's 100% correct but until a green bean groks that there's a distinction and what that really means, they won't be able to understand the explanation. And if they understand the distinction they are halfway to guruhood.
"there is no spoon"
And "no one answers": in 26 minutes, at a time when it's past 10 PM in Europe.
 
Right. Some people have papers to salvage on a tight deadline!
Speaking for a friend, of course...
@AndrasDeak--СлаваУкраїні In that case, I think explaining the misconception is actually the right thing to do. Blindly guessing a solution won't really answer the question, even if its a question the OP doesn't know they have asked and an answer they don't know they need.
That... doesn't make things easier for curation, of course.
But, perhaps, it gives the appropriate warnings signs not to listen to me in this regard.
 
8:36 PM
@MisterMiyagi I agree, but: 1. that's very difficult, 2. that doesn't fit a Q&A platform, 3. even if you try that, the kind of people who ask on SO instead of dipping a toe in a proper tutorial will say "OK, so after a = value I added a = object(), so now it's a value and not a variable. It still doesn't work." instead of "oh, my fundamental understanding of the language is flawed, I must ponder this new development in the company of structured information aimed at beginners.".
 
8:48 PM
I think we both agree in full, I just wouldn't have been able to put it into nice words. :P
 
 
1 hour later…
10:05 PM
stackoverflow.com/questions/3013449 I used this to close a beginner-level "how do I filter a list?" question, because it shows the important stuff in the question already. I feel like it should be possible to do better, though.
@AndrasDeak--СлаваУкраїні I don't see why questions that can only plausibly be asked by beginners, can't just tutorialize appropriately in the answers.
assuming a Q&A fit is concocted, I mean.
I guess stackoverflow.com/questions/1314314/… is closer to the mark.
actually stackoverflow.com/questions/4587915 is higher quality, but needs editing to be more general purpose. (The topic is also related to stackoverflow.com/questions/25082410/…, because a list comprehension does both)
 

« first day (4275 days earlier)      last day (656 days later) »