« first day (3705 days earlier)      last day (1468 days later) » 

01:35
@roganjosh tysm josh, it’s a startup company that deals with chatbots and AI stuff. But I was hired to work using python and go. He wanted me to learn Async and Dask in python. So I’m guessing it’s related to that.
 
6 hours later…
07:13
@Mikhail that sounds like a lot of work for very little, if any, gain. Python isn't typed, trying to force it is Sisyphus work.
And I say that as someone wo does a fair bit of typing in python, I am not at all opposed to it. Including run-time assertions through third-part libraries like pydantic. But only in circumstances where I feel that I get a lot of value out of it, like parsing data from an unknown source or when writing function signatures, never on principle.
07:59
hello folks, just mentioning a bounty I answered as allowed by the Room rules. Please do check it and see if it adds value to SO and if it's useful for you folks as well. Thanks! stackoverflow.com/questions/65043850/…
08:17
@Mikhail Proper type checking can be extremely expensive. Everything but the most primitive types is hell to check at runtime. Consider something like list[int] being passed around – that's O(n) to type-check at runtime on every assignment.
The entire point of type systems is that you don't have to check them. You proof them statically once, and then know they don't need any checking at runtime.
Good point @MisterMiyagi
08:47
any one know how to filter calculated property in django admin
@MisterMiyagi Yeah, but we don't have that kind of static checkin in python, so we have to do this instead. The solution to the list heterogeneity check is to optionally ignore it. But having an O(N) check isn't that bad.
@Arne it sounds like very little work, aka just append runtime type checking to typing.cast (which requires a little bit more work for handling type checking of types...)
09:04
@Mikhail I'm very happy with the checking that MyPy and various IDEs do, so I don't see how "we don't have that".
And turning a common O(1) check into O(N) (or worse!) sounds pretty bad to me.
Python isn't all that fast to begin with...
Its checked_args(args) where N=len(args)
I don't immediately have an answer why MyPy doesn't work. But this large code base I have is already checked with MyPy but I keep finding runtime (and valid) type errors. As I'm converting portions to C++ the type mismatches are kinda critical.
Perhaps when this is done I'll write an article on Medium and get a viral post on HackerNews :-)
@Mikhail In case you have a concrete case, it might be worth bringing them up here.
The mypy gitter is also a pretty good place to have typing issues looked at.
Yeah, I didn't quite have any issues, it just didn't find all the problems.
That sounds very much like an issue, TBH.
09:19
Get 30% off PyCharm before December 31, 2020. All the money raised will go toward the Python Software Foundation. jetbrains.com/lp/support-python
im using read() to get the file size
how do i stop the read function ? from reading the file ?
uh
why do you want the read function to stop doing what it's meant to do?
also take a look at this , Was the first result of "get size of file in python"
when i want to save that file , wit hread () still active the file has no content
Ah, i think you're probably misunderstanding what's going on. If the file has no content, that's probably because you never closed the file handler. You should use with open to work with files, so that the handlers close properly. Also, reading and writing are two separate operations, so you might want to consider making a small example showing what you want to do/ what you are doing right now.
09:37
I have this flask request object from a post request
uploaded_file = request.files['file']
I want to check the file size of that object with
blob = uploaded_file.read()  # read file
            #
            size = len(blob)  # get length of file

            print(f'the size of the file is{size}')

            if size > Config.MAX_CONTENT_LENGTH:
                print(f"file is {size}, its to big!")
                abort(400)
after saving that file the file has no content probably because the file is still open as u sad
@Mikhail it means you have to manually cast every value you use rather than using the my_value: int = foo syntax, which makes for hard-to-read code, and if you have a big and complex argument like List[Dict[str, List[MyObject]]] that is type-checked on every function it gets passed through, then your code will get slow
python already gets bad rep when C-ish code gets ported to it, don't make its speed any worse when you could just fix/improve your mypy-compliant static checks.
09:55
Hello,

import json

# some JSON:
x = '{ "name":"John", "age":30, "city":"New York", "productName": "SONICWALL NS<span style="vertical-align: sub;font-style: italic;">a</span> 5650 Japan"}'

# parse x:
y = json.loads(x)

# the result is a Python dictionary:
print(y["age"])
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 1 column 88 (char 87)
How do I take care of -  "productName": "SONICWALL NS<span style="vertical-align: sub;font-style: italic;">a</span> 5650 Japan" while parsing?
yeah, that's just not valid json
where'd you get that data from?
I get this from MongoDB which will be in compressed format. After decompressing, this is the result
It is a huge string. But only this part has invalid format
...how did this mess get into your database though?
i.e. who is responsible for screwing it up?
That is some server side code which is written in C#.
So if it's the server's fault that your data is not valid json, go fix your server. Or, if it's not your own server, submit a bug report
10:08
"SONICWALL NS<span style="vertical-align: sub;font-style: italic;" This part is going to be problematic, this is easily going to throw any parser off.
hmm
Agreed with Aran. Fix this issue upstream
Sure. Thanks
10:20
Experimenting on this year's AOC has further waned my enthusiasm for Python pattern matching. In my Rust AOC, pattern matching was crucial for unwrapping Option<T> and other type shenanigans. In my Python AOC, that's just... not an issue at all.
@MisterMiyagi wait isn't that a good thing?
I guess he meant that new PEP for matching patterns
I'm not sure I understand the english. But something not being an issue at all, sounds like a positive thing or was that sarcasm?
PEPs it is right now, I think.
@Hakaishin There are plans to provide a solution to this issue, thus my random musing of the day.
 
1 hour later…
11:50
Hello, Can somebody help me with this: stackoverflow.com/questions/65099562/… please?
Hmm, I'm not too familiar with html5 <audio>
@ChrisP Your question isn't very clear, all I see is a wall of code. Elaborate on the exact ask, like what isn't working with your code that you've put up? Do you get an error? Or nothing plays?
I interpret the question as "I'm recording and streaming audio from a web browser. Python can see the stream, but how do I make pyqt5 play it?"
Step 1 would be to figure out what codec MediaRecorder is using. The MDN docs are... not entirely clear.
12:14
AFAICT several codecs are supported out of the box, which might be a good thing if some of them are easier to stream than others
WeWeWelcome back
Today I continue to bang rocks together trying to understand network communication... I don't know why I'm getting so much ethernet traffic when there's no ethernet cable plugged into my laptop
12:31
rolls over a rock that says "localhost?"
Possibilities: "the wifi adapter is turning wifi packets into ethernet packets at the hardware level", "wireshark can't tell the difference between eth and wifi packets, so it just says it's all eth", "Kevin doesn't know anything about layers and is asking the wrong question"
I don't actually need to solve this mystery to accomplish the thing I'm trying to do, but it's worrying when the Check Engine light comes on in my mental model
12:56
@Mikhail Holden's First Law: any software specification containing the phrases "all we have to do ..." or "just ..." is suspect.
It's true, I spent six hours yesterday on the "just..." part of my program
The primary obstacle being "oh, to Just X I have to build this library from source and the authors have ideological reasons to pretend that Windows doesn't exist"
Philosophically I support every developer's right to write works-on-my-machine certified code, but on a practical level this is inconvenient to me
@real_hagrid The only way to read the file contents is to upload them from the client, so by doing the check that way you are performing the very action that you seek to avoid. flask.palletsprojects.com/en/1.1.x/patterns/fileuploads/… gives some advice on avoiding over-large uploads.
Also pythonhosted.org/Flask-Uploads might be useful.
@Kevin When you say "I'm getting so much Ethernet traffic", how are you observing this?
Why wouldn't it say the wifi packets are Ethernet packets?
Since technically they are Ethernet II, aren't they?
3 dest bytes, 3 src bytes and 2 type bytes, right? The wifi interface throws away all the wifi framing.
Or so I understand, and Wireshark appears to agree.
13:19
Sounds like my "the wifi adapter is turning wifi packets into ethernet packets" guess is close to the truth
Or hmm
The wifi frame has a four-byte prefix as shown in witestlab.poly.edu/blog/802-11-wireless-lan-2, but that framing is swallowed by the hardware driver, leaving the Ethernet frame.
You might be able to see more with the interface in management mode, but I've never looked for the wifi framing so that's speculation.
Windows user? You may be in luck ... wifinigel.blogspot.com/2019/11/…
Ok, so here is what I see when I browse through packets in wireshark
Ethernet II appears in every packet
This is is surprising to me because Wikipedia describes wifi as a "sibling" to ethernet. So I might expect them to be mutually exclusive within a packet.
Probably what's muddling things here is that the ethernet protocol spans several layers. Perhaps the physical layer of ethernet is a sibling to wifi's physical layer, but one or two layers in they become identical
I'm tempted to say that wireshark shows layer 2 packet information but not layer 1, but then it should show Ethernet II's trailing 4 byte CRC checksum, and it doesn't...
13:49
IEEE 802.11 specifies Wifi framiing, IIRC. At the physical layer it encapsulates either 802.3 or Ethernet II frames. I can no longer remember the differences between them, and both are commonly called "Ethernet".
I wouldn't worry about it over-much. It's starting to sound like displacement activity.
When you read a physical Ethernet interface you don't see the framing information (pre-amble) there, either, so why would you expect to see it for Wifi?
"Wifi encapsulates Ethernet" matches my intuition, it's just the details get watery when I focus my third eye on them
I'm not hugely worried about it. It should be sufficient to earmark this segment of my mental model as "scrutinize this the next time your program fails in a seemingly impossible way" and move on
But it is a fun puzzle, moreso than the tkinter configuration I should be doing
And/or writing a parser for ipv6 headers, definitely putting that one off
Technically layer 2 contains a MAC sub-layer and an LLC (logical link control) sublayer, but that's not usually important (IIRC 802.3 uses LLC and Ethernet II doesn't). Layer 1 is concerned with point-to-point transfer of bit streams, and wireshark only deals with byte streams.
If you want to drive yourself nuts with the details, fill your boots: public.cnrood.com/public/docs/…
Mm, minutae
14:23
@Kevin If the checksum fails the packet is discarded, so there's little point in showing it.
14:46
morning cabbages folks!
15:39
And also good morning cbg to all - I've been mostly lurking lately, working on prep for my online job interview this week, doing hackerrank puzzles to brush of some data structure cobwebs
Oh, that sort of interview? :-(
15:53
Streaming Advent of Code day 7: twitch.tv/davidism
16:15
If you mix languages in a project do you keep the two projects in the same git repo or make two different repos?
cool kids use leetcode for interview prep
@Hakaishin CPython has one repo that contains both Python and C :-)
plus batch files and html and markup documents but those sort of don't count
Hmmm, I decided to keep them seperate, because pycharm is bad at looking at c++ and clion is bad at looking at python.
Also valid honestly
In a sense, the answer is in the question. If the components are distinct enough that you can call them "the two projects", then you can probably keep them separately
@python_learner When the company says "practice with hackerrank", you practice with hackerrank
16:30
ahh so its one of those companies that have their screening (coding test etc) in hackerank, got it
tbh you have pyparsing that is used by some top level orgs, why would they still bother you with DS / Algo?
I always assumed coding interviewers were for beginner to mid level job seekers
There are no absolutes in the interview biz
You can't assume. I've interviewed a couple guys in my last job who, by reputation, I assumed were obvious hires, but during the interview, they really did not know even the basics.
this is news to me
Some people can develop a reputation by acquiring progressively more impressive looking jobs, even if they're not particularly good at any of them.
Especially in the US where checking references usually doesn't give you more information than "yes, X worked at Y during time period Z". Past employers don't want a libel/slander lawsuit on their hands for saying "X? Do not hire, He's the worst"
Hmm, I wonder if it's libel to say "we wrote down the following in X's employment records: 'do not hire, he's the worst'". That sentence is technically objectively true regardless of whether X is the worst.
Anonymous sources inform me that X doesn't recycle and he steals candy from babies. Hey, don't shoot the messenger -- sue the anonymous sources if you don't like it
16:55
@PaulMcG If you want to work at a company that says "practice with hackerrank", but I don't know your situation or the position.
@Kevin I suspect there would be a liability of some kind, America being as litigious as it is. Did I mention I'm being sued for $2.1m (fortunately behind the protection of an insurance company)?
Ouch. I'm cheering for your insurance company to remain stalwart.
Oh, even if their lawyer loses (which sounds improbable) my liability was discharged when I checked the third-party insurance box and paid for the rental. Which I am heartily glad I did, naturally.
(But at the same time I want to remind readers that the perception of America as unusually litigious is at least partially because of a smear campaign by big companies in order to make actually aggrieved individuals too embarrassed to seek renumeration)
Thanks, new information to me. Can I trust you on that? One rarely knows on non-technical matters. Please excuse my confusion.
I heard that too from a non-Kevin source
for all we know Kevin could be a shill for Big Litigious, trying to spread misinformation to smear big companies
17:06
One notable example is en.wikipedia.org/wiki/Liebeck_v._McDonald%27s_Restaurants, which is often used as "the poster child of excessive lawsuits" even though the actual facts don't really justify it as such
The related documentary Hot Coffee "contends that corporations have spent millions promoting misconceptions of tort cases in order to promote tort reform"
Perhaps I'm wrong to indicate "embarrassment" as the principal mechanism at work here -- perhaps they're not trying to change the minds of the aggrieved, but of the lawmakers/judges/juries that create/change/interpret/uphold tort law
A general miasma of negative sentiment will do there, no need to single out embarrassment
Hmm, I see yalemedlaw.com/frivolous-lawsuits-and-how-we-perceive-them is down -- must have been targeted by McDonald's hacker team
There's a similar position over here with regard to compensation paid to claimants, now I remember. Media are forever inflating claims, and conflating legal costs with compensation.
@Kevin If they were it was a DNS hack. That name purports to be unresolvable.
All that said, I wonder if there's an element of a vicious cycle at work here -- people see news stories about how easy it is to win a frivolous lawsuit, and think "hmm, I've got to get me a piece of that"
Sure enough dig reports no answers.
"If everyone calls me a rube with questionable moral fortitude for suing Kroger after I slipped in their store, I'll dry my tears using my eight figure settlement check"
Yes, the best kind of crying: all the way to the bank.
17:29
I should probably be reverse engineering IPV6 right now instead of looking up statistics for US lawsuits per year
Claim that you have a quantum walk approach to getting things done. Like photosynthesis.
Gonna sue Wikipedia for always distracting me
18:06
is there a way to get a variable from inner scope of a function to outer scope of the same function without using globals?
return?
nonlocal?
thanks didnt know about nonlocal
18:46
Can someone explain this RegEx to me?
Its for finding the even number of A's non-consecutive
^[^A]*(A[^A]*A[^A]*)*$
^          #start of string
[^A]*      #any character that isn't A, any number of times
(          #group 1
    A      #an A
    [^A]*  #any character that isn't A, any number of times
    A      #an A
    [^A]*  #any character that isn't A, any number of times
)*         #repeat group 1 any number of times
$          #end of string
But because "any number" can also include 0, it will also match strings with consecutive A's, for example "xAAx"
19:13
hey
Can you help me with this regex. Why default is not selecting
\b(estoppel)\b(?![^<a]*>|[^<>]*</a>|^.*\bdefault\b.)
The problem is that there's an estoppel match between the start of the line and the default. Because you have a start-of-line anchor ^ before default, any other match in the same line will prevent default from being matched forget I said anything, I parsed the regex wrong
Sorry about the question. I mean how can I exclude the word default
What do you mean? "exclude" it from what?
I have data searches which are 'estoppel' is a dictionary of words I just used it static for sample code. And currently the regex is excluding the <a> tag and now I want to exclude a specific word of 'default'
here is the full code new RegExp( "\\b("+data.title+")\\b(?![^<a]*>|[^<>]*</a>)"  , 'i');
at the current code I want to exclude the word 'default'
I still don't get it. Are you saying that if "default" shouldn't be matched even if it is included in this dictionary of words?
19:26
@winresh24 Do you want it to not match 'estoppel' when there is 'default' in the line afterwards? Try \b(estoppel)\b(?![^<a]*>|[^<>]*</a>|.*\bdefault\b)
By the way, I'm 99% sure that there's something wrong with this regex, even though I can't put my finger on it. And additionally I'm 100% sure that using regex on HTML is a bad idea
@Aran-Fey 'This is an estoppel default-line' and I have a dictionary with estoppel and default. Currently in my code 'default' in 'default-line' is matching. So basically I want to exclude that default-line to be specific.
@BožoStojković
The regex you posted doesn't match the "default" in "'This is an estoppel default-line"
Oh, you mean the regex would be like \b(estoppel|default)\b?
\b(words)\b(?![^<a]*>|[^<>]*</a>|^.*\bdefault\b.) - just replace the estoppel with words so it won't be specific
words compose of dictionary title
Maybe \b(default)\b(?![^<a]*>|[^<>]*</a>|-line)
I'm still not understanding what you want though...
19:33
I mean, why not just remove "default" from words then?
@Aran-Fey, it can't be. Since 'default' belongs to the dictionary. My issue @BožoStojković regex should not match a default word with default-line.
@winresh24 Well, it doesn't match 'default' if it's 'default-line'
I feel like we've passed multiple red flags at this point, but... maybe you want \b(?!default\b)(words)\b then?
Provide an example input line and show us what needs to be matched. Otherwise, we will go in circles.
Regex code = new RegExp( "\\b("+data.title+")\\b(?![^<a]*>|[^<>]*</a>)" , 'i');
data.title = is a dictionary item that compose of different words
Current code functions = currently the code find the word to html and skip the with <a> tag
Want to happen = there is a word in the dictionary which is 'default' and it's matching with 'default-line' and 'default-section' that it should not be. @Aran-Fey @BožoStojković
19:50
@winresh24 Example input line, as in the line that you are matching against?
'This is an estoppel page default-line' - let say the data.title here is estoppel and default. Default with - should not be match or to be specific 'default-line' should not match
Will this negative lookahead work?
    Regex code = new RegExp( "\\b((?!"+data.title+"-)"+data.title+")\\b(?![^<a]*>|[^<>]*</a>)" , 'i');
@PaulMcG I have other words with dash so I just want to be specific with default with dash.
So have you tried \b(?!default\b)(words)\b yet?
Regex code = new RegExp( "\\b((?!default-)"+data.title+")\\b(?![^<a]*>|[^<>]*</a>)" , 'i');
And if you use raw string literals (strongly encouraged when regexing), you can skip the doubling up of the backslashes.
19:57
You say that as if this was python code
Isn't this the room for an argument?
Come to think of it, why are we helping with javascript regex anyway?
Hey, what is that "new" word doing there?
@Aran-Fey it looks like working fine. Phython with js sorry guys
 
2 hours later…
21:30
A little confused on scope of class attributes in metaprogramming land. If I have a metaclass that adds attributes to the namespace in __prepare__ I can access them at class definition within the class body scope. But if I add them in __new__, I can't (though they are still class attributes). What's the difference here? I was under the impression that the result of __prepare__ gets passed right into __new__ so I dunno why either is different
Actually I think the docs set me straight. In docs.python.org/3/reference/datamodel.html#metaclasses it says the order is "namespace is prepared, class body is executed, class object is created" so the class body is executed after __prepare__ but before __new__.

« first day (3705 days earlier)      last day (1468 days later) »