« first day (4277 days earlier)      last day (894 days later) » 

00:10
okay, here is my proposal:
1) Using the sample from the accepted answer on https://stackoverflow.com/questions/12788217/how-to-extract-a-single-value-from-json-response, back-form what the `repr` of the parsed data and a prettified JSON would look like
2) Edit the question to remove noise, elide the request-getting code, show the parsed JSON result, and directly ask how to get one specific value (say, the `resp_dict['value']['queryInfo']['creationTime']` result from the accepted answer). This process should end up with a proper MRE
@KarlKnechtel stackoverflow.com/questions/72640162/… because I hammered his first identical question with that
thanks for the heads-up; I can edit the dupe for that, then
Perhaps we could get a mod to merge some good answers from stackoverflow.com/questions/67351031/…, and then I can fix them up a bit for the new context.
yeah sounds good
actually that might not be great. there are only two such answers and they don't have huge explanatory power. I'll just write my own.
I flagged this stackoverflow.com/questions/72835581/… as opinion based, but turns out there's a dupe stackoverflow.com/questions/41972261/…
00:32
@KarlKnechtel stackoverflow.com/questions/12788217/… might want to change the question and/or answer too, the original was a string, may be useful to edit the question further to reflect that
though I think what you did is fine, it narrowed down the problem
I am going to change the answer. Based on my read of the original question, OP had figured out how to parse the JSON, but the original answerer didn't pick up on that.
fair call
(tomato... I deliberately split my editing work into several steps, and the backend squashed it all.)
yeah, there's a 5-minute grace period for edits
00:58
good to know, will abuse^W keep in mind in the future
It's also broken if someone leaves a comment. Not sure about votes cast on the post. I'm sure it's semidocumented somewhere on the metas.
Perhaps we could merge in cs95's answer from https://stackoverflow.com/questions/48193502/access-a-particular-field-in-arbitrarily-nested-json-data ? I re-hammered a couple of questions, but this isn't a terrible target either, it's just arguably not quite as good.

In any event, the new canonical is lacking IMO:
* an example involving lists, especially mixed lists and dicts
* an explanation of the technique for analyzing the data and figuring out the "path"
actually we should definitely use both questions as canonicals. The new one is for purely what to do with the data; cs95's old canonical also covers actually loading JSON.
No, wait, I read more carefully. cs95's question is also talking about dealing with JSON that contains strings that are themselves separate JSON documents.
That should be un-duped, retitled, and stand separately.
01:23
stackoverflow.com/questions/28218173 This one seems too broad, but not a dupe in any way
01:55
stackoverflow.com/questions/20199126/reading-json-from-a-file what is the equivalent of this for reading from an API? (ideally, something that mentions that json.load can accept a file-like response object, and also talks about the Requests .json` method)
I accidentally and wrongly used stackoverflow.com/questions/6578986/… a couple of times.
How come stackoverflow.com/… doesn't find stackoverflow.com/questions/20199126/…, but if I remove the word from (even though the title of the question includes from, in the same place!!!) it shows up?
02:39
stackoverflow.com/questions/70797/… This asks two completely different questions, both of which have better canonicals. It also is a dupe target itself, inexplicably, and has over a million views. Yam.
Hey y'all, looking for input. Any reason I shouldn't do this?
in SO Close Vote Reviewers, 3 mins ago, by Karl Knechtel
Any chance of merging stuff from https://stackoverflow.com/questions/20063/whats-the-best-way-to-parse-command-line-arguments into https://stackoverflow.com/questions/1009860/how-to-read-process-command-line-arguments ?
oh, I was in the middle of trying to write it up myself
More detail as to why it's a good idea is welcome, this is just my lazy way of starting the discussion :-p
It also may just be so obviously correct that no argument is needed because everyone thinks it seems like a good idea.
I find that the latter is just a much better question; it isn't phrased as subjective and it includes some useful reference links. The top answer on the old one, though, is very good; it shows what you get from argparse, not just how to use it.
There's also an answer that talks about docopt which is a good option to list: stackoverflow.com/a/16377263/523612 that's sort of redundant with stackoverflow.com/a/14790373/523612 in the new one, though. Maybe the bit about python-fire could be an answer on its own.
the former also includes stackoverflow.com/a/27069329/523612, which is a better explanation of click than would otherwise be available.
03:19
https://stackoverflow.com/questions/72835944/printing-with-reversed-range

I know that any obvious attempt would be too broad, but I really feel the need for some kind of canonical for "what are some techniques for writing these tomato-splattered brainteaser programs that make a pretty pattern with `*`s and whitespace on the standard output?"
04:11
Karl, look my question related to this question: chat.stackoverflow.com/transcript/message/54614839#54614839 :P
04:43
to your question*
 
3 hours later…
07:37
good lord CI for a python project of mine started failing because _Py_HashRandomization_Init flaked out, wtf is going on
clearly it's a sign I shouldn't code on a Saturday
I don't know enough to help debug that problem but it seems like such a weird component to fail and someone else to have it in 3.9
@davidism That's insane, I don't think I've ever seen something vaguely similar. Major kudos!
07:59
@RyanM I'm not super opposed to merging those questions, but I don't really see the point? As far as I can tell, both questions have fairly similar answers. IMO merging them will only result in a question with far too many answers, where a lot of them are near-duplicates of other answers
yeah I did come across that specific question
my problem failed for Python 3.10 on Windows, via GitHub actions
appveyor just straight up don't work across all versions now
 
4 hours later…
12:32
I'm so glad that Stranger Things took on all the fan feedback about the dire last series. This one is absolutely phenomenal
It's really rare for shows to do that these days instead of having the directors just double down against the criticism. The only criticism from me is that Journey's Worlds Apart didn't get the same kind of air time as Kate Bush. I wanted them to make that song even more epic!
13:29
Wow, that video couldn't be more eighties even if it tried youtube.com/watch?v=LatorN4P9aA
good guy youtube telling me to listen to Alice Cooper's Poison
folks, which library do u preffer? argparser OR click ??
13:44
@AndrasDeak--СлаваУкраїні better get in The Corrosion by Sisters of Mercy while you're at it!
This* corrosion
Thanks AD. To discoMonkey, I've used neither. However, I'd suggest avoiding pinging people in general, unless there's some prior conversation going or there's been some indication that pings are welcome, call it part of room etiquette.
14:12
One that I should know but not sure I have the right letters - "condition of having the same properties in all directions" I _ O _ N _ _ _. Not sure about the N
Yeah, that's "maintenance" out the window for the N then :/
Should've been more hinty, sorry. Replied in a rush.
Nah, I was looking for an answer to get unstuck :P
We need a room for discussing TLA+. TLA+ is used in order to test the models of any program.
including python testing,
14:18
You are free to make rooms on chat if you want that
is it a bug? or hack?
bad questions all over. also cabbage.
@discoMonkey no, probably Microsoft web stack.
It's telling me maintenance
Probably as some sick joke on my wrong crossword answer
 
2 hours later…
16:46
Hi all.

Did you know you could use Enums like so :

from enum import Enum

class Status(Enum):
NO_STATUS = -1
NOT_STARTED = 0
IN_PROGRESS = 1
COMPLETED = 2

print(Status.IN_PROGRESS.name) # IN_PROGRESS
print(Status.COMPLETED.value) # 2
17:24
Yes; that's a perfectly typical use of enum.Enum, which has existed since... 3.4 IIRC?
Kinda weird that enums have a value. As far as I'm concerned, enums only have a name
they need a value because they're objects. even if the value could only equal the name, it would be a value. It's common enough to use integer values a) because tradition and b) back when they were popularized by C, people found a lot of justifications for doing arithmetic with them.
(of course - the tradition, in turn, is because the C enums would be syntactic sugar around an integral value, which is the simplest way to interpret a few bytes of memory)
But why is there a .value?
@Marco well, good to know that it's not a new phenomenon, I guess. (Drawing pre-defined letter shapes is a bit outside the problem domain I have in mind, though.)
There is a .value because it's useful. the documentation shows a variety of nice things that can be done with the class, not to mention variants like IntEnum
The docs show off some examples of .value, but none of those examples have any context that would explain why the value is needed or useful. In fact, the Planet example would be better without a .value
IntEnum in particular doesn't need a .value because the enum instance is the value
18:23
@Aran-Fey you're just wrong.
If you're going to ping me, please say something with substance
Is that a trick question? Because if it is, I'm not answering it
Can we get to the point without playing silly games?
so you said that the enum instance is the value 42.
Then I am asking what is the type?!
Well no, I didn't say that. I said the enum instance is "the value", but I never said it's 42 or anything else in particular
18:30
"IntEnum in particular doesn't need a .value because the enum instance is the value"
I still think IntEnum is mostly mistake though.
The value of AnttisIntEnum.FORTY_TWO is <AnttisIntEnum object at 0xcoffee>. Does that make sense?
There is no reason why this thing needs a .value that's equal to 42
So what exactly am I wrong about?
Gonna go eat dinner, will respond later (assuming there's something to respond to)
How to calculate packet rate for each ip address in server [network programming]
Any socket programming guy here?
why IntEnum is wrong:
integer enumerations of different types can also be compared to each other:

>>> Shape.circle == Request.post
True
18:57
@ChiragArora What exactly are you trying to do?
Counting packets for a server usually isn't done on a socket directly.
19:10
@AnttiHaapala--СлаваУкраїні So what happened to our conversation? I asked a question that you haven't answered yet. Are we just going to discontinue it?
@MisterMiyagi I'm trying to make an IP blacklister server which can blacklist ip addresses based upon their packet rate to avoid ddos attacks. Any help would be appreciated
@AnttiHaapala--СлаваУкраїні Heads up: I'm tired of your self-righteous style of conversation where you say things as if they were facts, but it takes 10 minutes of effort from my side to make you say something that actually has a meaning. Our last 2 "conversations" were like this, and that's quite enough. Because you're a RO, I will give you one more chance, but if that wasn't the case you would already be blocked now.
@ChiragArora I'm guessing you're looking for something like fail2ban then. But I'm still not entirely sure where socket programming and servers come into this.
Hello, in aiortc is there any way to run code after: web.run_app(...) ?
basically I want to calculate pps value at which different clients are sending packets to my server
and block those who are attempting a ddos attack
and sockets because its network programming using sockets
@AnttiHaapala--СлаваУкраїні IntEnum is just a thin wrapper to an int then. Without strong typing that prevents different enums or non-enums being compare to each other (in BDSM languages like VHDL). IntEnum inherits diagonally from both int, Enum. Shouldn't be hard to construct bad examples. Like defining constants with similar names to re.flags but differing values. But there is also IntFlag docs.python.org/3/library/enum.html#enum.IntFlag
@Aran-Fey It's not weird that enums have a value, that goes all the way back to C, stuff like the constants in C's open(), you had to be able to do boolean mungeing to combine them. It wouldn't be Pythonic to have an enum that knows it's an enum but makes its value impossible to obtain. But yeah this implementation is just a wrapper over int, it isn't strongly-typed.
You could subclass and override Enum.__eq__ if you wanted strict behavior. I'm sure people have done/proposed it.
20:09
I don't know C, but I can't see any values documented on the page you linked, only names. The docs don't tell you the value of O_CREAT or O_EXCL or any of the other flags anywhere, right? Which proves my point: Enum members are just names, no values
You can use an enum as an abstraction over some lower-level API that uses int values or whatever, in which case it's useful if the enum members can have an internal value. But there certainly shouldn't be a public value attribute forced onto you by the enum library
@Aran-Fey The enums used in C libraries do have values, and they have to be defined by the C standard (and have been since the 1970s/80s), otherwise C compilers wouldn't work or interoperate with OS's. I just quoted you the Gnu libc manual to illustrate the point, not the ISO C standard which will define them, somewhere. Couldn't find a very user-friendly link on WP.
@smci his point is that developers don't have to know about the value, just the name. Hence "internal value"
20:28
@AndrasDeak--СлаваУкраїні Right if the constant isn't standardized and used widely, no. He wrote IntEnum in particular doesn't need a .value because the enum instance is the value. In principle this is true for ints, but given the way Enum class was subclassed to IntEnum (which is then subclassed to IntFlag and RegexFlag), probably unavoidable.
now we're somehow back to python enums, but that's not what we were talking about one message earlier
@AndrasDeak--СлаваУкраїні Andras I don't need you to tell me what I wrote. Aran-Fey was asking about Python 3.4's (cr*ppy, essentially-untyped) implementation of enums: yes, even integer enums have unnecessary public .value attributes. Yes, technical debt. Yes, unnecessary and clunky. See PEP 435 for the backstory, and the older PEP 354 which was rejected in 2005. Also, the PEPs on bools.
wow everyone is rude here
I thought programmers were nice
Not everyone is rude, but no, not every programmer is nice.
20:43
balanced, as all things should be
many experienced programmers develop a habit of assuming that everyone else is always wrong, which can lead to abrasion when there's more than one experienced programmer in a room
I only just caught up with the GvR: there will never be a Python 4.0 from 12/2021. The downside of the 2->3 transition ("overlearning the lesson of PERL 6.0") is that everyone now wants to shoehorn features into 3.x in some way, no matter how crufty, that will arrive within a year and maintain backward-s-compatibility; noone wants a feature that might arrive in a decade, and not get much uptake initially.
@smci Oh man, I didn't even consider that there is a PEP for enums. At a quick glance, it doesn't seem to contain a rationale for the .value attribute though, sadly
Ethan Furman is the one core dev who sometimes comes here so it's not impossible for you to catch them and ask :P
I might do that, but I have a feeling the answer will be disappointing
I'm expecting more of a "it seemed like a good idea at the time" than a "here's a good reason for it" kind of thing
20:48
If we assume that values are a bad idea, is there a point to IntEnums?
If values are a bad idea then IntEnums are basically an oxymoron
Hmm, I did use IntEnum once. I needed the int values to match an underlying C library. That might be a reasonable reason.
@ChiragArora There exists at least one programmer somewhere in the galaxy who is invariably nice, under all circumstances. But seriously, I was just trying to sort out the conclusions of the earlier, ahem, robust discussion. Our beloved language is now acquiring serious technical debt and bloat in the builtin classes, as features get shoehorned on in every 3.xx version, and there will likely never be a Python 4. [think of the embedded Java wars in the early 2000s]
@AndrasDeak--СлаваУкраїні I'd say that's... acceptable, I guess. It invites a bunch of potential problems (for example, what should the result of IntEnum.FORTY_TWO == 42 be?), but if you're ok with that, then so be it. Personally though, I'd abstract that away and hide the int value in the internals.
For the users of the library it was. But the implentation has things like LightType(self.GetLightType()) which gives you a nice pythonic object based on the int code returned by the C library. One could define a list of values and index into that using the return value (if there were no enum values), but this seems a bit cleaner.
21:05
@AndrasDeak--СлаваУкраїні simply that they subclass Enums, and maintain compatibility with the class interface. Consistency. The language would be a mess if we had IntEnums that were incompatible with other enums. See PEP 435: "Proposed semantics for the new enumeration type" section discussing the idifferent use-cases, IntEnum, etc.:
> for the vast majority of code, Enum is strongly recommended, since IntEnum breaks some semantic promises of an enumeration (by being comparable to integers, and thus by transitivity to other unrelated enumerations). It should be used only in special cases where there’s no other choice; for example, when integer constants are replaced with enumerations and backwards compatibility is required with code that still expects integers.
@AndrasDeak--СлаваУкраїні Not sure I understand what that's doing, but it sounds like you want to provide an easy way to map enum members to the corresponding int value and vice versa? In that case I'd say it would be best to provide a factory method (LightType.from_int(42)) and an attribute LightType.FORTY_TWO.int_value). I don't think the enum members should be ints
How do I search for all uses of 'IntEnum' in the source github.com/python/cpython ?
@Aran-Fey Like I said, this is not part of the public API. Or, rather, this is exactly a property that converts int C enum codes to Python enum elements.
any network programmer here????
The underlying library uses ints to encode the types, and this wrapper class gives you an enum element instead, exactly so that you can refer to CAMERA_LIGHT instead of 2.
And it wasn't crucial that these enums are also ints, but it was convenient in a few similar places.
21:12
Ok, fair enough. It's kind of a mess, but well, that's programming for you
yeah
"pragmatic" is probably the best keyword
@Aran-Fey The pros and cons and use-cases wre discussed back in PEP 435: "Proposed semantics for the new enumeration type" section. Can't satisfy all of the use-cases all of the time...
Are any of you actually able to search source code for all uses of 'IntEnum' in the source github.com/python/cpython They seem to have disabled github search? on cpython repo or all repos?
They used to forbid source code search for unauthenticated users IIRC
Maybe that's the case now too
Github search works fine for me (and I'm not even logged in!). Here are a few results: 1, 2, 3
@vaultah I thought I'm authenticated. Can you or anyone else try that github search and post the results? (which modules use IntEnum)?
21:22
strikethrough is ~~~, I think? ~~~test~~~
Welp
@vaultah Thanks. Kevin: useful to add to sopython.com/wiki/…
@Aran-Fey Thanks. and IntFlag?
@smci at the risk of telling you what to do or what you already know: there's an official chat FAQ that explains this in black and white, among other things.
Here and here. Those are the only results outside of tests
@smci see help, it's on the bottom right link of this chat's room website
21:29
specifically, "guide to formatting code" would be a terrible place for "how to format plain text"
@AndrasDeak--СлаваУкраїні Then you're objecting to the title. "Code formatting guide" is one of the two things prominently linked to in the top right of this room. "Chatroom formatting guide" would be a better title that covers both plaintext and code; that section can simply link in turn to "For formatting plaintext/ messages, see ...". FYI as an 11-year user of SO, I knew how to do strikethrough in posts (which has changed, multiple times) but not in chat.
Anyway, appreciate the link.
hmm, guess it should be soi' instead :P
21:40
"Obafbve" (rot-3)
nah, for some reason if we're to remove some part of the word, it would generally be at the beginning :)
'soir is spot on
when going to sleep during "boyscouts" weekends, 'nuit would be the official signal that if someone were to break the silence, we had the right to throw them things
maybe just should add a link between these 2
@AnttiHaapala--СлаваУкраїні Ok, but I didn't know SO chat happened to be in markdown, so people like me wouldn't ever search for "markdown formatting". (It's certainly a different markdown to programming-language markdowns). whereas "Chat formatting" or "Chatroom formatting" are clear and unambiguous; or even "Plantext formatting for chat". Also, I'd still mention+link them from "Code formatting guide".
@AnttiHaapala--СлаваУкраїні 👍
invalid device parameters from device driver.
Do you need a formatting guide, Marco? We have a few ;)
Oh God
Please continue practicing in the sandbox.
@smci I think this is a conversation for the Meta Python room
@AndrasDeak--СлаваУкраїні It was just some little annoying typo in the link formatting, actually had to test it in the Sandbox room
22:17
22:40
Somebody please help me
Is there some way to determine packet per second for each client connected to a server?
I've gone crazy with this from 2 days
id use wireshark (if applicable ymmv) + math
23:27
@roganjosh sorry, not my jam at all

« first day (4277 days earlier)      last day (894 days later) »