« first day (3853 days earlier)      last day (1094 days later) » 

1:01 AM
cbg :)
@WaqasAli old does not mean it wont work, you can still use them as long as the steps haven't been changed drastically
 
Implementation will mostly be similar even with significant changes, sometimes
@python_user cbg :) potato?
 
cbg
 
yeah doing ok, how about you though? working on anything ?
how much of a chore it is to write a JS extension that will just show me an alt text for salad words?
I know zero JS, not even looping
 
What languages do you know? other than python
@python_user wouldn't be too hard... something like a dictionary
 
nothing else really :D, kinda wrote Go at work but not anymore
 
1:12 AM
For loops in go are similar to javascript
just variable declaration is different
for (var i=0; i<10;i++) this loops the same as for i in range(10):
 
I need to get around learning a new language one of these days, we all know how that will go
 
Laurel, it would depend on the language
I'm learning java right now for school, it's going way too slow for my taste
Anyway, I rbrb, cya
 
rbrb
even though salad words are vegetables, this is the fist time I actually googled rhubarb, I would never have thought that to be a veggie
 
Honestly, idek what rhubarb really is....
 
1:27 AM
nice word though
 
2:01 AM
Rhubarb is pretty sour when eaten raw, but when cooked into a pie with strawberries and a large amount of sugar, strawberry-rhubarb pie is one of the best pies there are (well, peanut butter cream crumble pie is pretty good too, but you were talking about rhubarb).
 
2:43 AM
I just created a bookmarklet to help me with linking to helpful links in comments.... only to find out that comments have their special quicklinks already
 
I dont know if they sell rhubarb in my area or even country , if they do, it will probably be overpriced
 
What country?
 
3:23 AM
@PaulMcG I've never had this, it sounds good.
 
 
2 hours later…
5:14 AM
FileNotFoundError: [Errno 2] No such file or directory:
Having trouble with the error, followed CFE tutorial, but got this error.
 
 
1 hour later…
6:38 AM
cbg
 
@DerekPK In 99% of cases, No such file or directory literally means there is no such file or directory. Check whether the paths used are those you expect.
 
7:21 AM
guys when trying to load a list of dictionaries into pandas I receive this:
AttributeError: 'NoneType' object has no attribute 'keys'
Not quite sure why as isn't the first one have loaded with similar data any idea why this would happen?
 
Because at least one of your dicts is actually None
any(dct is None for dct in list_of_dicts)
 
Thanks adras wnt for
df = pd.DataFrame(filter(None.__ne__, data))
to get around
 
ugh
 
that bad? o.0
 
Did you learn that from piR2? :P
 
7:30 AM
lol actually just used kite.com/python/answers/… to and implemented... is bad idea?
 
Most people prefer list comprehensions to filter (unless the predicate is a pre-existing callable), and it's frowned upon to use dunders when it's not necessary
What's kite.com?
 
I believe kite is an extention for vscode just found it online may use list comp then lol
 
@Kwsswart bad form. 9.8/10 people would go with [dct for dct in data if data is not None]. Although you might want to skip empty dicts as well, so [dct for dct in data if dct] would work too. But then you can use filter(None, data).
 
Taking a third option: Figure out why you have Nones when you only expect dicts.
 
I am going to look at the origin code now and try figure that out... trying to clean the data and looking at the source and fixing that at the same time
 
7:39 AM
@AndrasDeak it has been gaining popularity lately, iirc spyder / anaconda installation process asks if you want to install Kite plugin
 
OK, but is kite.com/python/answers something official, or community-written? I didn't enable JS to find out.
 
I heard kite got some bad rep a few years ago, some scandal with data harvesting something like that
@AndrasDeak you browse the web without js?
 
Initially, yes
If I'm desperate enough I might enable it on sites. But a full-JS page where I know I'll find crap information: nope.
If I open a page and see nothing there's a high chance I'll leave it that way
 
@AndrasDeak I dont think it is official
 
@AndrasDeak "Kite adds AI powered code completions to your code editor, giving developers superpowers." I think that just about says it all.
 
7:45 AM
ugh
So I guess the name comes from "high as a kite"
 
Doesn't help my trust in our new AI overlords.
There's probably something to be said about democracy and expert tasks and Nobby Nobbs.
 
laurel, AI sells things, Kite also mentions Deep Learning for code completion, another buzzword to sell things
Kite has some big name investors though, from their About Page DropBox, GitHub, PayPal to name a few
 
Associations of deepfake and deep dreaming are exactly what I want in my codebase
 
New challenge: publish enough code to get IDE-AI to use not not not a instead of not a.
Pro level: get it to choke not (not not)+ a
 
7:55 AM
Actually, a lot of code examples on random websites could have been generated by AI
It looks alright from a distance, but if you actually focus on any part and how they're connected it's all wrong.
 
Tripped over an AI-generated SO clone once. Took me a while to figure out the answers were excreted by an AI and not written by humans...
 
Who knows if there is a bot among us... eye emoji
 
8:57 AM
Is using pyscaffolding still a good idea? I used it in older projects but I'm starting something new and I wonder if it's still useful or if there are better options
 
9:52 AM
It's still getting regular updates on github, so I reckon it is still about as good as it was when you used it last time
I can't answer "are there better options?" as my knowledge of the packaging ecosystem is pretty limited
 
I've stopped all attempts to use packaging templates. Didn't simplify much (still have to configure things, many of which you don't need) and my main problem is to keep packaging up to date.
 
That's how I feel too, I just used it because it was already used. But I think about going without one and this sounds encouraging, but maybe other regulars have some opinions about it
 
Well, it could just be old age creeping up on me. goes back to carving code out of wood
 
10:07 AM
My favorite packaging workflow is to put my single code file on pastebin and link it in here
 
10:52 AM
Oops, I think in this ten part math problem, I put down m = a * b * c in part 2 when I should have done m = c * b * a... Time to redo everything after that
My bad math detector didn't go off because it's not trained on noncommutative multiplication
 
matrix multiplication?
 
Yeah.
 
typing man kill makes me giggle :D
 
I enjoy writing #terminate the child more than I should
(It's ok, it's a daemon child)
 
11:29 AM
I have a weird issue, If I send sigterm to my process it ends as expected. But if I in supervisor press stop which should send by default sigterm to the process, it shoes that it stopped, but it never logs that it stopped and I still see the node online. Now I added stopsignal=TERM just to be sure, but still the same. Anybody got experience with supervisor?
 
@Kevin put it in an orphanage and let the reaper do its business
@Hakaishin Can you give a TLDR on what supervisor is?
 
supervisord.org a process control system
 
11:47 AM
I use command=/bin/bash -c 'source "$0" && exec "$@"' /home/usr/ros2_foxy/install/setup.bash ros2 launch node node.launch but googling exec tells me it keeps the same pid so that shouldn't be an issue
 
That's at least something you could rule out by not using exec.
Though at least systemd has no problem with either setup, and I'd assume it's the same in your case.
 
12:11 PM
It doesn't work without exec, because I need to source the setup.bash
 
Finally getting a sensible result for my practical test case
The result is off by like three pixels but I don't think I can do anything about that unless I hack MS Paint to accept non-integer stretch/skew values
 
@Hakaishin Ah, you are right. I think I read the nesting wrong.
 
@Kevin useless, but impressive :D
 
The exact two properties all of my projects strive for!
 
12:31 PM
cbg
 
12:47 PM
type("foo")==str I did not know that this worked
It's probably how isinstance works though
 
@12944qwerty I was wondering if this is forbidden jutsu the other day
 
isinstance is Dark Magic Cthulhu Vodoo D:
 
@Hakaishin what? wdym "other day"
 
isinstance(x,y) is not equivalent to type(x) == y because isinstance also works for subclasses. Example:
>>> isinstance(True, int)
True
>>> type(True) == int
False
If you want to satisfy the Liskov Substitution Principle (a foundation of good OOP design), then you should always use isinstance unless you have a good specific reason to do otherwise
 
a few days ago?
so it is forbidden jutsu, my gut feeling was right, thanks :)
 
12:55 PM
It's perfectly fine if you actually want exact type equality.
Usually, you don't.
 
@MisterMiyagi this :P
 
Wisdom. "I actually want exact type equality" is the good specific reason that you'll come upon in the majority of cases where type(x) == y is applicable
 
Hush. It's type(x) is y or isinstance(x, y).
Someone, somewhere, out there will override == for types.
 
Ok, type(x) is y if you prefer. All my dire warnings apply to that as well.
 
Still surprised the typing craze hasn't led to type(x) <= y.
Yet.
 
1:01 PM
The other day I wrote a safe_aririthmetic_eval function that used isinstance on ast.Node instances to decide what operation to perform -- addition for ast.Add, division for ast.Div, that kind of thing. In retrospect I think I could have justified using exact referential equality checking, since 1) I don't think anything inherits from the various concrete binary operator types; 2) If anything did, I don't think my evaluator should try to handle them.
2 days ago, by Kevin
@CoolCloud here is a quick framework for four-function arithmetic evaluation. 99.999% guaranteed to not let you get hacked
making ops into a dict would save me a couple lines and a couple cpu flops, but it's only possible if I ditch isinstance
 
ugh, i'm trying to teach someone how to assign a variable and they're trying to do OOP :/
 
If anybody was wondering the same thing as me, I checked -- ast.FloorDiv does not inherit from ast.Div, nor vice versa
Bah, I was hoping ast.Add() == ast.Add() would be True, which would let me skip type checking entirely. But it's False, even though Add binop tokens contain no state.
 
@12944qwerty Consider me morbidly fascinated...
@Kevin That's a pity. I've found proper eq/hash to be super useful for AST optimisations.
 
1:19 PM
Ah, the old exchange:
Querent: How do I do complicated thing X? I've tried fundamentally incorrect approach Y.
Commenter: I can tell from your code that you haven't yet learned how to A, B, or C yet. Focus on those before attempting X.
Querent: I don't see how that will get my program done quickly. Can't you just do X for me?
You must learn to crawl before you can build nuclear reactors
 
And then hopefully you can still crawl away from that nuclear reactor in time.
On a scale from 0 to 10: How bad is "let's use __pychache__ for our own needs"?
 
They've been thinking that defining methods are actually assigning variables
 
To be fair, SO has (by design?) a 9:1 ratio of giving a man a fish and teaching him to fish, so advocating for the latter isn't the hill I want to die on
defining functions is a lot like assigning a variable, under the hood. Methods... Are more complicated.
 
I asked them how they normally assigned variables and they showed me a bunch of methods' definitions
 
Possibly he does know how normal assignment works, but doesn't know the correct terminology for it. So many problems in our field are just terminology mismatches.
 
1:25 PM
Maybe
But I am now 99% sure he's expecting to be spoonfed
Like just look at the code that's found in the answer and copy and paste to see if it works... without looking at the explanation
 
@MisterMiyagi Reading something from __pycache__: 10/10. Writing your own stuff into __pycache__... hmm... I'm on the fence about that one. Probably like 7/10, mostly because it's already standard practice to make your own cache folder (see mypy, pytest, etc)
 
Hmm, he's refusing the fish you gave him? Now that's advanced spoonfeeding.
"wait, before you feed me. Is this a locally sourced gluten free fish?"
 
I didn't give anything. Someone else answered pointing out where the error was in a code block... and I think that the OP just copied that without understanding that it wasn't supposed to work...
 
Any idea why this hangs?
foo = subprocess.Popen("-c source $0 && exec $@ /home/usr/ros2_foxy/install/setup.bash ls", executable="/bin/bash")
foo.communicate()
 
I think I'm just gonna leave that question... for now
 
1:29 PM
@Aran-Fey Hm, 7/10 is enough to make me reconsider other optimisations first, at least.
 
@Hakaishin Pretty sure the executable argument doesn't do what you think it does. Why don't you put /bin/bash into the command?
 
@Hakaishin Have you tried buffering it off and on again?
 
/bin/bash: source: No such file or directory weird
 
Hmm, according to the docs this should fail spectacularly because it interprets the entire string as a path
> On POSIX, if args is a string, the string is interpreted as the name or path of the program to execute. However, this can only be done if not passing arguments to the program.
Okay, I have no idea how passing the arguments as a string interacts with executable
 
Agh, I'm doing a dirty workaround, I don't like this shadow world
Everything is ugly down there
 
1:46 PM
Lets see, in POSIX, args is passed to _execute_child (tee hee)
It supposedly delegates to os.posix_spawn. ctrl-f for posix_spawn in the os source doesn't turn up a definition, so it's probably doing string construction tomfoolery on __all__
Looks like it's dumping the namespace of posix into os. Now where is posix's source...
Normally I can get a hint via the_module.__file__, but I can't import posix on Windows, natch
I guess there's no source and it's just executing the OS's man7.org/linux/man-pages/man3/posix_spawn.3.html via ctypes or similar
 
2:14 PM
There are way too many tasks lately, where I know exactly how to do them, but they still take quite some time to do, from days to weeks. Like I think if you know exactly how to to something, there should be a shortcut button to just do it instantly :P
 
if posix_spawn fails, then python will try github.com/python/cpython/blob/…, which calls one of the execv family, which AFAIK are also not forgiving of putting args in the executable name
And if that fails, then the function crashes. Conclusion: Hakaishin's program is failing spectacularly because it interprets the entire string as a path, and any evidence otherwise is a collective hallucination.
 
And then I think it replaces the -c with /bin/bash and fails spectacularly again
 
Hmm, re-evaluating which code branches are executed when args is a string and executable isn't null, I think it correctly locates /bin/bash and runs it, but possibly with surprising arguments
If bash shrugs and runs without error even if you hand it nonsense on the command line, then there's no reason to expect an exception here
Yeah, I think that's what happens. Python properly locates bash, and executes it with argv equal to ["-c source $0 && exec $@ /home/usr/ros2_foxy/install/setup.bash ls"]. This is a valid operation from Python' perspective, even though it violates the usual convention of making argv[0] be the process' name.
Perhaps bash is developed defensively and it has checks to see if it was called with a malformed execv. For simple command arguments I'd expect it to be able to deduce the properly formed arguments, and continue on as if there's no problem.
 
2:35 PM
But then how does the "/bin/bash: source: No such file or directory" error happen?
 
If that error occurs when you do Popen("/bin/bash -c whatever"), it's because it's looking for a file named exactly "bash -c whatever", and can't find it. If that error occurs when you do Popen("-c whatever", executable="/bin/bash"), then I don't know why it would do that.
Oh, I misread the error message. Let me backpedal.
 
I have a friend who always tries to cheat at everything he does. Does somebody have a good article or resource explaining why this is a bad idea? It's kinda annoying to have to explain it to him time and again. The best argument I found is because it lowers enforcement costs of all operations in society and thus benefits everybody. Something like this, but a bit fleshed out.
 
Speculation: bash does have malformed execv handling, but all it does is check whether argv has length one, and whether it looks like it could be split into multiple args. If so, it splits it, but doesn't do any additional magic to make sure the args are lined up.
So when argv is initially ["-c source whatever"], it splits it up into ["-c", "source", "whatever"]. The bad news is, this is still a malformed command, because argv[0] is supposed to be "bash", and all the other arguments are supposed to be shifted over by one. You're effectively doing bash source whatever with a bash executable that got nicknamed "-c"
@Hakaishin Sorry Hakaishin, I can't help you until I finish helping Hakaishin
linux.die.net/man/1/bash says (AFAICT) that bash source whatever will trigger the "arguments remain after option processing" case, at which point "the first argument is assumed to be the name of a file containing shell commands", with the rest being the arguments to that file. So bash looks for a file named "source" and complains that it can't find it.
WayTLDR: Depending on how forgiving of malformed arguments the target program is, Popen(some_string, executable=s) will produce anywhere between 0-3 nasal demons. Even if you're confident that you're one of the lucky 25% that will get exactly the desired behavior, consider it doing the prescribed way anyway and pass a list of args.
 
2:54 PM
Yeah, that's definitely where that error message comes from. But I have no clue at what point that command string is split into command line arguments for bash. Popen shouldn't split it at any point (although it might, when it needs to replace the first token with the executable), linux most definitely shouldn't, and bash shouldn't either
 
I'm 99% sure that Popen doesn't split the args, and 85% sure that Linux doesn't, and 0% sure that bash doesn't
 
It would be a silly thing to do, but when has that ever stopped bash?
 
Sometimes you have to do silly things to keep your silly users from logging support tickets
The customer is always right, in scenarios where caving in to them results in less work
 
@Aran-Fey Correction: It doesn't need to replace the first token, but it's possible that it does
 
AFAICT, args never gets mutated to contain executable's value. I didn't explore the entire thorny bramble that surrounds execv though.
Oh, it does it when shell is Truthy, which is sensible. I don't think it bothers otherwise.
 
3:05 PM
i have a question regrading Networkx python programming.
 
ok
@Hakaishin "sever the relationship and it stops being your problem" is always on the table.
 
How do you do that demo button on answers/questions? Is that something made by the poster or can it also be done by SO?
 
I think it shows up automatically if the markup engine is moderately sure that your code block is written in a language that supports demos. sometimes it guesses wrong.
There's a way to specify the language explicitly, but I don't know the syntax.
Last I checked, it can't demo Python code, but I last checked like four years ago
 
```python
?
 
3:17 PM
¯\_(ツ)_/¯
 
1
A: Create dictionary of dictionaries using list of labels

iotaYou can use a dictionary comprehension with zip: result = {key: val for key, val in zip(labels, dicts)} Demo

this is what I mean, they have a demo button here
 
@Kevin Is that an emoticon or the required text to specify text as python code?
 
@12944qwerty Ah, that one specifically was custom made by the author. It's just a regular hyperlink that's been styled to look like a button, thanks to the <kbd> markup.
@piRSquared ¯\_(ツ)_/¯
 
Ah, ok.
 
Native SO snippets look like the box at meta.stackoverflow.com/questions/372355/…
 
3:23 PM
Yeah, those haven't supported python yet unfortunately.
 
The easier it is to execute the language within the client's browser, the more likely the language is to be supported by SO snippets. Javascript requires a single eval call, so it's about as supported as it gets. I don't like the chances of every other language in the world.
Not until someone writes a C compiler in clientside JS at least
Google suggests that it's been attempted, but it would ideally have as many bells and whistles as gcc, which isn't likely for a proof of concept project
 
SO can probably use js to request another IDE to do it
with an API or something
 
It would be pretty easy to send the program to the SO servers and have it execute it on their hardware, but that would be an unacceptable security risk. Sending it to an online IDE, for example ideone.com, is plausible... They'd probably have to negotiate usage rights though.
 
@Kevin Like WASM?
 
3:39 PM
Yeah :-)
Wikipedia says WASM-powered Python needs better native support for garbage collection before it's fast enough to be useful. WASM devs, please do the needful.
It looks like the typical workflow for WASM/C is to use enscripten/LLVM/Clang to precompile your C code into WASM ahead of time, and just serve the finished executable to the user. I wonder if you could compile enscripten/LLVM/Clang to WASM, so the user can compile code on demand...
 
@Kevin They have a widget
 
@Kevin No one would ever do such a thing... shifty eyes
 
@12944qwerty Cool, so that confirms it's technically feasible*. I see you need an account with their service to embed it on your site, and they don't mention the price, which probably means it's negotiable and dependent on what you intend to do with it.
 
TIL: tuple with += (x,) is faster than list with .append(x).
Sample size one, 95868 calls.
 
Wow, you guess where way too much into that malformed popen call xD I finished my workaround halfway trough the discussion :P
 
3:51 PM
If SO's intent is "run this on tens of thousands of pages, and probably add a fat percentage onto our revenue thanks to the shiny new feature", then IDEOne will probably want a slice of that pie
 
Should I go ask on meta? 👀
 
As in, ask "have you guys considered partnering with IDEOne to make SO Snippets more useful?"? Sure, IMO that's a valid question to ask.
 
Idk how I would word it though.... I suck at wording honestly
 
Likely responses in descending order: silence, "we don't want to", "yeah, but the budget didn't work out", "hey, good idea"
 
@Kevin You play MTG Arena, right? I need to know... is the RNG rigged in favor of new players? After 2 days of playing, I own so many rare and mythic rare cards that I'm starting to feel bad about all the money I spent on booster packs as a kid :|
 
3:57 PM
There are a lot of people that will swear to high heaven that the RNG isn't truly random. I'm considerably skeptical of the vast majority of these, since confirmation bias is a powerful beast.
 
I'm gonna go and ask when I have more time after school.
 
But... There are super pros that objectively know more about statistics than me, judging from their articles on hypergeometric distributions. Those types of players are a bit more tight lipped on their opinion of the RNG, but I think I recall hearing some whispers...
 
Admittedly, I got a ton of booster packs from promo codes. But still, 7 mythic rares + 2 mythic rare wildcards on day 2?!
 
If the hypergeometry pros say there's a bias, I'm willing to listen to their argument. If they have data, I'm falling out of my seat
 
@Kevin 14 day trial for free or we negotiate yup
I'll find something else then kek
 
4:02 PM
Even if you find a "download and run free!" embedded IDE, they might have a footnote in their EULA that says "(*free only for individuals that are not million dollar tech support / knowledge base companies)"
 
Probably
 
 
3 hours later…
6:48 PM
I mean I like it. It's free if you pass it on for free. It costs if you make money with it, sounds like a sensible model
Also for sure rng at the beginning is rigged for mtg arena. I played for a year and the pack quality dropped so hard after half a year
Kept going for another half but it wasn't fun without grinding a lot or buying more packs
 
7:10 PM
I've been positively surprised by how enjoyable the games are. Usually I find one or two decks I like and play those forever, but in MTG every deck kinda has its own appeal. I didn't even dislike playing the red aggro deck
But man, playing ranked is rough. In the last card game I played, I'm pretty sure I didn't lose a single match until I'd ranked up twice. Here, I'm getting absolutely wrecked in Bronze 2
 
7:56 PM
You know your dreams are crushed when Gordon Linoff says no with SQL. At least I have an excuse for some spaghetti in my code
 
 
3 hours later…
10:59 PM
cbg y'all
 
Folks, I have two bytearray buffers and I do buffer1[:] = buffer2 and the buffers aren't the same size.
Does the buffer1[:] = buffer2 operation always resize buffer1 to be the same size as buffer2 ?
 
It would do that for lists, I don't know bytearrays
 
@AndrasDeak What is the name of the language syntax that allows me to write buffer1[:] = buffer2 ? I want to look up the the docs, but I don't know what this syntax is called.
 
"slice assignment" perhaps?
 
11:12 PM
Yeah, probablhy something like that. I know that for lists the corresponding C function is list_ass_slice
@NickAlexeev syntax alone won't help you, you have to see what bytearrays specifically do.
The same syntax will resize lists but won't resize numpy arrays, for instance.
 
@bad_coder stop
 
@AndrasDeak ok. why?
 
What is cv-pls?
 
I've ran a few test cases, and it looks like that syntax can expand a destination bytearray if source is longer that destination.
 
11:14 PM
@bad_coder Because traffic is low and I don't want you to flood the room when most users aren't involved in close voting. Go to SOCVR.
@12944qwerty sopython.com/wiki/cv-pls. But don't use it.
@NickAlexeev then you probably have your answer
 
@AndrasDeak SOCVR sent me here, because they put a 6 month limit on requests. But I understand the concern about flooding the room, so I'll do this only during busy hours.
 
SOCVR? goes to chatroom lists
oh, it's an anagram
 
@bad_coder and not too frequently, please.
@12944qwerty acronym
 
@bad_coder I'd suggest doing it only when it is really needed
 
@AndrasDeak so what would work best in your opinion?
 
11:18 PM
@AndrasDeak I mix them up :(
 
@12944qwerty I'd suggest you not making suggestions when you had no idea about the topic 5 minutes ago
@bad_coder one per hour seems like a reasonable rule of thumb to me
 
I did, I just didn't connect what it meant immediately.
 
@AndrasDeak I wanted to ask about that. Perhaps 1 block of 4 once per day (something like that) during peak hours.
 
@NickAlexeev the closest I can find is in docs.python.org/3/library/stdtypes.html#mutable-sequence-types which from context (e.g. at docs.python.org/3/library/stdtypes.html#bytearray) hints that it applies to bytearrays as well
 
ok, 1 per hour seems good.
 
11:21 PM
I'm not a huge fan of blocks
 
Dunno, I generally find a block more convenient than having the cv-pls spread. But I'll follow your lead and we'll see how it goes.
 
I admit this is 100% subjective. But if I see a wall of crap to vote on I'm much less likely to do so (partly why I don't do reviews).
it would also come across as more spammy to me
 
This is amazing, the SOCVR crowd loves nothing better than a long wall of carp to cast 10 easy close-votes in a minute, LOL :D
 
You might notice that I'm not a regular there...
 

« first day (3853 days earlier)      last day (1094 days later) »