« first day (3503 days earlier)      last day (1442 days later) » 

wim
12:01 AM
zen of python took 10 delvotes but it was in the 200's somewhere, this one in the 300's
 
 
4 hours later…
3:55 AM
Is there a way to change the requests User Agent for all requests being sent, even those that might be being sent by another library?
I can use sessions to change it for all the requests I sent, but I'm not sure how for requests being implicitly sent
I found this stackoverflow.com/a/52497819/9044659 but I don't know if that works for implicit requests too
 
wim
it looks like that answer will work globally for requests actually coming from requests module within the same process. but maybe requests are also being made from e.g. urllib or subprocesses.
to get all of those you would have to monkeypatch in every place that they're coming from
 
4:10 AM
that should work for me since I'm primarily concerned with requests, but later I plan to do an aiohttp rewrite for async so that would probably require something different
what exactly does that code do though? and they have made it into a function even though you need to do it once 🤔
 
wim
4:24 AM
it's a monkeypatch
it replaces requests.request with their own function which injects the header
pretty gross
 
eeks, I was hoping there would be a nicer solution
 
wim
4:44 AM
yeah also this user's code looks bugged to me. I've left a comment about that.
 
5:41 AM
hmm well, let me know if you can think of a better solution!
or perhaps I should do the async rewrite and figure it out there
 
 
2 hours later…
7:37 AM
@Aran-Fey yes, if the metaclass is type. Use Type[MyMeta] otherwise. Be prepared that Type can behave unexpectedly, e.g. with being restrictive regards to subclasses. I try to avoid it. Callable[..., MyMeta] often works better, if you don't work with the metaclass object itself.
 
Doesn't Type[type] mean "type or any subclass thereof"?
 
yes, yes it does. if that's all you need, go for it.
 
Ok, thanks
 
Ah, found it. It was Type and generics that doesn't work well together. E.g. Type[UserList[UserType]] would swallow the inner type on occasion and turn it into Any.
 
You mean the type checker or typing itself?
 
7:52 AM
type checker. PyCharm in specific has problems with that, recent mypy versions seem to work.
typing itself works very well, it's usually the tooling that can't keep up.
 
 
1 hour later…
8:59 AM
@wim yeah, but it's capped. Pretty sure 200 and 300 are the same
 
9:15 AM
Is the reopen vote requirement still at 3? Because that specific Q is garnering some.
 
AFAIK it's still 3. Are we talking about the tab/space question?
 
@MisterMiyagi yes
if it gets reopened I'll flag for deletion or a historical lock
and give the reopeners a paddling
 
It looks likely that'll happen today. Going through some of the tail answers, it looks like the thread is a kind of therapy for people to discuss hardships
My name is roganjosh and I recently inherited a codebase full of tab indentation <everyone says "awww" and I am rejuvenated>
 
awwww
 
Yey, now I can live my best life!
 
9:29 AM
group hugs!
Oh my. Found a comment praising coding in MS Word because it displays tabs and spaces. Not sure if joking...
 
9:49 AM
@MisterMiyagi I write code in MS Word
superior code editor
 
Cryptic prose?
 
@MisterMiyagi *sigh*
 
I'm glad that Boston Dynamics is into tiktok. Certainly a lot less terrifying than Big Dog (I think?) that had the screeching go kart engine
 
That. Was. Epic.
 
10:07 AM
I wonder if the WFH situation for them is like taking the class hamster home for a weekend. "I just need to borrow this... for research and things"
 
Wes
Hi guys, I've a question, but I'm not sure its on topic for stackoverflow / programmers, It I guess could be taken as a software recommendation question. However It may be on topic.

I'm trying to teach my son programming so I thought that from what I heard python would be a good thing to teach him. I'd like to give him a slightly more interesting environment than just a shell, but I'm afraid if I go full GUI he's going to get distracted with the GUI itself not just the programming language. What would you recommend for a text based GUI?
Also would that question be on topic for one of the stack exchange sites?
 
How old is your son? I'm sure there are resources that allow kids to put things together like lego to create code but I'm sure kids would grow out of that pretty fast
 
Wes
He doesn't like scratch. He said that python felt more "real" his words. He's twelve and is on the ASD spectrum.
 
good kid!
 
I kinda hate myself for suggesting it, but Spyder (which comes with Anaconda) might be a decent shout because it has an interactive terminal so you can actually see what your script is doing. You say "distracted by the GUI itself" but I'm not sure exactly what that means. At the very worst, he could deconstruct the GUI itself because the codebase is on github :)
And it's also written in Python
 
10:19 AM
@Wes I can't think of one where it could be on topic
perhaps software recs?
 
Wes
Okay what I meant by distracted by GUI is something like visual basics draw a gui. Or swtDesigner that sort of thing.
 
@Wes can you explain what you mean by "more interesting environment"?
 
@Wes Have you considered jupyter notebooks? Too little GUI?
 
Wes
I thought just being able to set the text cursor to a position so he can overwrite things
 
@AndrasDeak Woops, empty message. I have tried your gist again but the same problem occurs (it got worse overnight ???). Interesting: trying "eigs" as opposed to "eigsh" does not improve the situation.
 
Wes
10:21 AM
I haven't looked at jupyter. I don't actually know python, I'm stuck in jvm world for work
 
@Wes OK, then jupyter notebooks are definitely a good candidate
 
Wes
Thanks guys, I'll look at those.
 
you can fire up a service that creates a local webapp that is sort of like an editable shell with cells
@Euryris "same problem", meaning you don't get an additional print about the matrices being unequal?
 
Indeed!
 
Wes
I've got him using vscode I assume thats an okay ide for python. Though I suspect you will say use a text editor.
 
10:22 AM
vscode is pretty heavy, which is why I suggested Spyder
 
And also the eigenvectors don't match for scipy sparse linalg eigs (w/o the hermitian extension)
 
@Euryris Now that's insane. Could you grab every eigenvalue and eigenvector with eigsh so that I can take a look?
 
But if he's comfortable with vscode then all the better
 
Example code with eigs btw: pastebin.com/5s8jtHM8
 
@Wes IDEs are fine and useful, but your son might not need one
 
10:24 AM
Produced 3/8 times: "eigenvectors don't match"
 
Wes
@AndrasDeak yeah I realise that. I just searched for python on windows and that was the first result.
 
Changing back the sparse_vals line to: sparse_vals = spl.eigsh(sparseM, 1, which = 'SA') produces 2/8 times "eigenvectors don't match"
 
Wes
So thats what I went with. Also he can have a little pride in saying he uses the same tools as I use for work. (when doing js)
 
@Euryris aaah I got different eigenvectors now but I lost it
let me start running it a few times
@Wes that works :)
 
[ 5.55111512e-17 5.55111512e-17 2.77555756e-17 -1.49429245e-01
-1.66533454e-16 5.57677536e-01 -4.08248290e-01 -3.46944695e-17
-5.55111512e-17 -4.08248290e-01 5.57677536e-01 5.55111512e-17
-1.49429245e-01 2.77555756e-17 5.55111512e-17 0.00000000e+00]
 
10:26 AM
a-ha!
 
Produced by eigsh
 
@Wes in which case, have you created an app using Flask for him? In like 10 lines of code he can have something running across your home network
 
I'm just passing eigenvectors from eigsh for the cases where it also prints: not the same eigenvectors
 
you don't have to post the same set of vectors multiple times
 
Wes
@roganjosh no I haven't looked at flask
 
10:27 AM
Sorry :P What should I post?
 
@Euryris here, nothing yet. Somewhere else: possibly every eigenvector with eigsh (i.e. for every eigenvalue). But hold on, because I could get my output to be different.
false alarm:
In [19]: np.allclose(sparse_evec + dense_evec, 0)
Out[19]: True
my test is buggy, wait
 
@AndrasDeak To be clear: I am still getting very large discrepancies between sparse and dense eigenvectors, if I print the difference every other difference is of order 1
 
Wes
with regard to flask is this going to be similar to ansible templates? only time I've used jinja
 
@Euryris I get that
my test still didn't account for the +-1 sign in eigenvectors, now it does
 
10:30 AM
@Wes if he's also working with JS then it makes sense to me. I can give you a starter script that will run on the home network and he can view it on a mobile on the same network etc.
In fact, the quickstart already shows it. You just need the --host=0.0.0.0 and it's on your home network
 
Wes
Thanks for all the advise guys.
it hard to keep kids productivly occupied during this isolation buisness.
 
@AndrasDeak This seems to have solved the issue... hmmm
But how come that last night my eigenvectors were blatantly different and yours weren't?
 
@Euryris no way
@Euryris exactly
(I'm on the phone right now, not done yet)
 
Yeah no worries, I'll head out anyway
Definitely on later to troubleshoot more...
 
OK, I'll ping you
 
10:38 AM
Sure
 
Wes
@AndrasDeak I really mean more intresting that producing a line of text at a time sequentially.
More interesting output. Web seems like a good idea though.
 
@Wes anecdotal evidence; I did exactly this when I happened to be in my local pub and people just abandoned their kids to run around. As soon as they saw stuff they wrote appearing on their phone, that was it, and finally all the screeching stopped :P The lengths I'll go to to get a quiet pint :P
 
Wes
Also its hard to teach something you don't know. :( but I strongly dislike the amount of boilerplate for java. but I've made mistakes when he asked me how to do something. Coming from a different environment.
 
@Wes I can imagine java being less "fun" for a kid with all that cruft
if you have any specific things you need help with, feel free to ask here
 
11:05 AM
@Euryris OK, so let's assume that you still get weird eigenvectors every once in a while. I'd like to see every (or almost every) eigenvalue and eigenvector from eigsh when that happens. You can't ask for every eigenvector but you can ask for all but one. I've updated my gist, please run it a few times.
If there's an eigenvector mismatch it will print every dense eigenvalue and eigenvector, and almost every sparse eigenvalue and eigenvector. If this happens I'd like you to copy-paste those somewhere, if you have github and are comfortable with it you can just leave it in a comment on my gist.
If the problem doesn't come back I'll say it was spyder. I should've told you yesterday to make sure and restart spyder rather than just restarting the kernel, in case that's what you did.
 
Restarting the kernel should be enough. I don't know of any carry-over once that is done
Well, other than what tabs are open etc. but nothing of relevance
 
11:23 AM
well I don't trust spyder at all
 
@Wes If it's your little one's cup of tea, consider handing them some game framework. PyGame isn't exactly great software design, but should be serviceable for playing around.
If it doesn't have to be Python exactly, I found Löve for Lua quite easy to build 2D games.
 
@MisterMiyagi Does that make you der König der Löve?
 
+1 for the pun, -10 for situational awareness. My cat is complaining for hours that this thing in the kitchen is not food.
Definitely not King of any felines. :/
 
have you tried turning it on and off again?
 
user11702787
hey Im an technical intern at a big factory, I offered that I could develope a software (self learned programmer, Im in the process but it takes longer then expected, they blame me for that slow progress and want to cancel the project, I find this ridiculous, waht do you think ?
 
11:39 AM
The background sounds a lot like my own career path but I can't say I have any deep thoughts when none of us have any understanding of the situation
I'm also not sure that elaborating on the situation will help, it seems like you're just venting because it's surely self-evident that what you posted can't be answered?
 
@AndrasDeak it has Wake On Hunger builtin :/
 
user11702787
basically I want some feedback from you if you had experienced that your project was canceld and wanted to know why
 
I can't use the language I would like, but sure, I've had a few things shut down
A lot of manufacturing companies will be pretty set in their ways and won't acknowledge technology. A big issue I've had is that managers want things that empower them and they couldn't care less about whether the tool is useful for people on the shop floor. That was the main take-home message for me in my efforts
"Why would they want to know about their efficiency?" being the main mentality
 
user11702787
hm can you name some reasons for canceling projects ?
 
I just did
 
Wes
12:14 PM
@MisterMiyagi I'm going to take a look at it further.
 
12:31 PM
@MisterMiyagi Just give in and start handing out the treats.
 
1:25 PM
Umm.. guys, am learning python and am currently trying to implement regexes.. However, my installation (conda) says re not found.. how do I install it?
 
Are you able to import other modules? How about import math?
 
Yeah.. The interpreter doesn't spit errors
 
Then you can import re?
 
we'll probably have to see an MCVE, because re should be as available as math
and make sure you don't have something funny like a re.py lying around
 
Curious. I wasn't aware that any of the built-in modules were optional, except for tkinter
 
1:29 PM
I named my file re.py😅
 
yay
 
Done... Thanks :)
 
But why would it say "re not found" if it can find re.py right there in the local directory...
The client was happy. But something didn't add up, and this old dog had troubles letting go. [I open the bottom drawer of my desk and retrieve the bottle of scotch. The lonely yellow streetlight through the venetian blinds colors my face with stripes of light and dark]
 
@Kevin This is my first time with spyder and am really fumbling around.. anyone knows how to add a configuration properly to pyCharm? (Because that's what I fumbled around before switching to spyder😅)
 
@Kevin spyder...
@d4rk4ng31 what kind of configuration do you mean?
 
1:35 PM
PyCharm asks to add a configuration to venv.. which I have never been able to do\
 
I knew d4k4ng3l was trouble the moment they walked in my office. From their reticence to give an MCVE, I knew they were hiding something... I had to play hardball.
"Have you tried googling it?", I said, not even bothering to lift my fashionable-for-the-time-period fedora to make eye contact.
 
@Kevin Is this the scotch speaking?
 
You'll know the scotch is talking when I get misty about my old departed partners. There's a reason the door reads "Kevin & davidism & poke & Ffisegydd & DSM & adeak Detective Agency"
They got in too deep, and I'm not much better. Let's just say I'm not making firm plans for my retirement...
 
hand me that scotch...
 
1:42 PM
In python class, we can add attributes during runtime. But in built-in class, we can not do that. How we achieved that restriction?
 
@d4rk4ng31 Can you clarify when this shows up and what it's asking precisely? For me, using a venv in PyCharm is a single flag that I don't even bother toggling off.
 
I'm 65% sure that's the default behavior for any type defined using C
 
true, things like int don't even have __slots__
 
And int.__dict__ returns a mappingproxy, implying that its attributes are stored in something other than an ordinary dict
 
1:45 PM
__slots__ itself is only a hook for used by type, similar to __metaclass__ in Py2.
 
@Kevin That is read-only dict
 
@MisterMiyagi See, the run button in the top right hand corner? Well its greyed out. And it shows an add configuration button right next to it..
 
True
 
in any case I understood the question as "how can we do that with custom classes?"
 
Me too, but since you covered that angle, I went the other way
 
1:46 PM
And after I add a configuration, it still keeps showing that button and the run button remains greyed out...
 
@AndrasDeak Yes that's what I was asking :)
 
@d4rk4ng31 in the file browser (should be to the left), you can directly right-click a file and execute it. That should also add a configuration.
 
Umm... just a sec.. lemme reinstall pycharm and will try that again... thanks :)
 
@We..are..one number one reason I ran into: "something out of my control". The only way to deal with it that works for me is to not tie the success of a work project to my self worth, and instead just try to do my best, no matter what our business decides to trow at me today.
 
@Kevin It's a rather simple check it seems: github.com/python/cpython/blob/master/Objects/…
 
1:50 PM
Nice find.
 
I mean, that covers trying to add attributes to the type itself, not an instance.
 
@MisterMiyagi Nah.. man, it says no interpreter configured...
 
If I want to contribute to the CPython project, from where I need to start? I have seen the Github page of CPython but it seems very large and doesn't get where to start from :p
 
Ok, so doing something like (1).conjugate = 23 wouldn't trigger that check, and instead trigger github.com/python/cpython/blob/…
Presumably _PyObject_GetDictPtr returns NULL for instances that don't have a dict __dict__?
 
@LordOfThunder check python.org -> documentation -> developer guide -> contributing
 
1:56 PM
@AndrasDeak OK, thanks :)
 
2:34 PM
@Kevin is KS just Python with curly brackets instead of tabs and : for formatting? xD
 
Mostly, but it also has non-Python features, such as anonymous multiline function definitions
 
ugh
 
Feel free to leave them out of HakaishinScript if you don't like them
 
haha :D Thanks. But I dont plan on writing one soon. But cool project. Do you work on it once a every two years at the beginning fo the year or do you continuously work on it but only commit then?
 
The pattern is unpredictable
 
2:41 PM
what's the easiest and cheapest way to build a read only website atm? I build one about 5years ago and I think I'm out of touch
 
Read-only as in static? Github pages perhaps.
 
static yeah
Uh that looks amazing, thanks I will check it out
 
 
2 hours later…
4:45 PM
@AndrasDeak Hi Andras, I've been looking around
I think the bug is in Spyder
If anything
Running over the command line does not reproduce the randomness of the eigenvectors
 
I find that unsurprising, unfortunately. Perhaps file the bug with them.
I know spyder does weird things with its environment. Like pre-loads subpackages. Can you tell if you're using the same env in the command line?
 
5:27 PM
13
Q: Any simple Python GUI projects for beginner/novice programming students?

FloellaI teach programming at a university, at 2 freshmen courses. My students are being introduced to programming for the first time, so we have to teach them about algorithms, variables, control flow, functions, arrays (lists), etc. So this course covers the very basics. And every single year I see th...

There is a bunch like that if you search for elementary school (even though the site is technically high school or higher - it comes up often enough).
 
I looked up CS Educators, but searching for "programming" alone suggested that this isn't their profile
 
its one of those betas that's still finding itself a bit (and the whole SE betrayal hurt it a lot - then Corvid boosted with tons of elementary questions cause "at-home")
 
I missed the SE betrayal bit
unless you mean the general situation and not something specific for CS educators
 
I still use Greenroom, Khan Academy (which I really like for middle schoolers), and Hour of code (see my comment on the accepted answer)
yeah, general situation Andras - didn't need any more than that ;)
 
sure thing
 
Wes
6:02 PM
@LinkBerest-GoodbyeSE Thank you
@LinkBerest-GoodbyeSE A Betrayal? I haven't been keeping up with the Dramas on SE I thought though that opinions had settled down.
 
@d4rk4ng31 Do you have any interpreters available? PyCharm -> Preferences -> Project <your project> -> Project Interpreter
 
@aurora please see the room rules in regards to linking questions from main. Specifically, that they should be left for 48 hours before being raised here
 
6:29 PM
@Wes You can read why the changes in user behavior affected sites in these comments which is something many sites are dealing with over or not.
Personally, I stopped answering on SO after Docs (and my frustration at trying to find interesting questions). I stopped on WB.SE after Monica - I'm still not back at either of these sites and have seen very little change to be honest (certainly some and many more promises or I wouldn't be here at all but its still very tentative)
 
6:54 PM
I reckon the env's in the command line are different
But it's quite weird, in Spyder preferences I can change the option where the console execution mode to "command line" which also fixes the issue.
Even weirder: switching back to the default setting, "execute in current console", does not again reproduce the original behaviour, but instead the eigenvectors now match with the original setting, as if something is reset
 
Are we sure that blaming Spyder isn't just a convenience here?
It's not particularly important to me personally, but it's a horrible misunderstanding of a problem if we are
 
The last part seems like some names didn't mean what one thought they meant.
 
I don't think we are at the level of understanding regardless, the example code by Andras Deak that did not account for sign ambiguity ran without prints on three boxes (by now), but not on mine
 
Good old "I accidentally shot len = 3 in another cell".
 
@Euryris I haven't really followed the conversation because I'm not on the same level as Andras but what I can do is run the code in Spyder if you give me something self-contained
 
7:10 PM
if "it works" it should print nothing, if it "doesn't work" it should print one line and 4 arrays
 
Prints nothing
 
it's also intermittent for Euryris...so try rerunning a few times. Preferably in the same kernel.
 
Run 5 times; print nothing
Run over 20 times; prints nothing
 
@roganjosh the latest update was that spyder produced an issue yesterday, and it may or may not have produced it today...
I'm not sure if Euryris still has the issue in spyder because I asked for the 4 arrays in the buggy case and haven't gotten any
 
If they give me a particular version of Spyder then I'm happy to install that; I'm not attached to the one I have. Then we can ditch it as a factor because I'm almost certain it isn't (but I'm open to being proven wrong)
 
7:17 PM
the only anecdata we have along those lines is
3 hours ago, by Euryris
Running over the command line does not reproduce the randomness of the eigenvectors
 
7:42 PM
heh, testing for results which break code in mathematically random results - always a good time
 
I can shove it all into a while True loop for a bit
There we go, burning the CPU cycles. I better add a counter :P
 
@AndrasDeak it worked at 50 times on my system (assuming works = didn't print nothing)
 
and my virtual system
 
it's worked over 50,000 times for me
 
7:47 PM
^ I'm not that dedicated to testing it, sorry ;) :)
 
Eh, I just shoved the whole lot into a loop
It's still going after 200,000 iterations. I think it unlikely that this is the issue
 
wim
8:15 PM
Wannable is the things you want. — aurora 3 hours ago
I wanna really, really, really wanna zig-a-zig ah
 
@LinkBerest-GoodbyeSE there are only two possible correct answers, so it's not that bad
 
anytime I think of "there's only a few values" I just think of Risk
and when you attacked the other player's position with 50 troops to their 2 and somehow lost every roll
...unless you were my brother and put a little clear glue on the "one" side of the die
 
@wim dangerous game, knowing people on the internet
after all people put their iphones in the microwave
 
Charges the faster, right?
Having watched stuff explode in industrial microwaves, I'd say it was a positive :P
 
9:14 PM
my peak tech experience was when I had the opportunity to sit in a Faraday cage while it was being bombarded with artificial lightning
 
That's pretty awesome! Why did they have a Faraday cage sitting around?
 
There was a science-fair kind of demo at the high-voltage laboratory at one of the faculties. My brother knew about it because he was learning at that faculty; I was an early physics student I think so I wouldn't have known. There were around a dozen people in our tour group, and when they asked who was willing to sit in the cage I had to remind myself that physics works :D
 
I think I'd still crap myself in that situation :P
 
well I didn't have to fight for the opportunity...
 
I assume they had active research that used it, or was it just a prop?
 
9:27 PM
Research slash education I think. High-voltage engineering stuff.
there's this huge hangar-like area in one of the buildings at campus where these stuff are located
 
oh, we just had "L4" with concrete blown apart by microwaves and shipping containers for the super-secret stuff. It was open on Open Day but melting people probably wouldn't be a great advert
 
L4?
 
That's just the building name. "Lab 4"
 
Ah!
destroying stuff is always fun
 
We were particularly good at that. No dielectric factor? No problem! We'll make it "kaboom" somehow
 
9:41 PM
heh
I love dielectric breakdown patterns
 
10:00 PM
It sucks on mashed potato
 
10:54 PM
@vault Just saw this, it's a really neat puzzle. What can you say a priori about a) the distribution of your own champions' strengths? and b) the enemy's? Are they like uniform numbers on the interval say [0,100]? Are they integers or floats; can there be ties, and what's the reward on a tie?
@vault c) what can you say (roughly) about the distribution of building sizes? What is min size, max size, are there more smaller than larger? If we can make some approximations for modeling, that can reduce complexity.
Although it's a general question, the best way to motivate people to post and benchmark code answers (at least on SO) might be to post say two specific examples of <your set of champions> and <building and enemy champion list>
 
wim
11:50 PM
@MisterMiyagi know any way to get the event loop back from a coro that is not sufficiently "cooperating"?
I've looked at asyncio.wait_for, which accepts a timeout kwarg, but the timeout seems to only works if the coro is well-behaved. if it blocked then the timeout doesn't work, and the asyncio.TimeoutError may not raise until much later!
and same symptom with curio.timeout_after and trio.move_on_after so does not seem specific to any particular framework but something more fundamental
 

« first day (3503 days earlier)      last day (1442 days later) »