« first day (4501 days earlier)      last day (446 days later) » 

1:07 AM
cbg patch
ive been playing around with trying to make a decorator that can be used to log in depth details about functions in a pipeline I have, like input, output, internal variables at the scope of the decorator, but I've hit a bit of a roadblock on that last one and ws curious if anybody had ideas.
for now I have it in a class that can be inherited but I think that might actually be unnecessary if someone has suggestions on the change to make, I am logging to json btw
@classmethod
def logging(self, process_name, max_var_size=1024, **kwargs):
    def decorator(func):
        def wrapper(self, *args, **kwargs):
            result = func(self, *args, **kwargs)
            log_data = {}
            for var_name, var_value in dict(locals(),**kwargs).items():
                if var_name in ["max_var_size","process_name" ,"log_data","func","self","kwargs"]:
                    continue
                var_size = sys.getsizeof(var_value)
                if var_size > max_var_size:
anybody got ideas about how I can poke around to get the variables local to func
 
1:22 AM
I get nice results like:
```
"original_resolution": {
"args": [
"C:\\Users\\Skyler\\Documents\\folder\\ref.mp4"
],
"result": [
2160,
2160
],
"timestamp": "2023-02-10 19:21:02"
```
but cant save the internal stuff from the functions yet, and I'd ideally like to make this a little utility code I can drop into any project to do some deep debugging
 
 
3 hours later…
4:42 AM
@Skyler "the variables local to func only exist during the period that func is running, and are thus only accessible to code within func (or things called from there, if you inspect stack frames). The wrapper won't be able to access them because they literally aren't in memory at the time that the wrapper code is running.
You can access the names of locals that func will use, as well as compile-time constants, by inspecting the func object itself - specifically, attributes of its __code__ attribute (a code object that represents the actual bytecode and some other stuff set up at compile time) and a few other attributes like __defaults__. The object model is documented in quite painstaking detail
(technically, they might be in deallocated or otherwise inaccessible memory, I suppose)
aside from that, the entire point of the "internal stuff from the functions" is that this changes during the execution of the function, perhaps repeatedly. So there would be no good way to decide when or where to "snapshot" it, even if you could
if you're using logging in order to try to track down what a particular function is doing, and want to know the state of things partway through the execution, you are using the wrong tool. You want a debugger, not a logging system.
 
 
5 hours later…
9:42 AM
@Skyler if you want some inspiration on how to perhaps make this better (or as an alternative) look into the trace module. An example usage would be python -m trace although there are other flags, and you can also import it: docs.python.org/3/library/trace.html#command-line-usage
 
hello
 
 
6 hours later…
3:27 PM
Puzzle time! Write a generator expression such that sum(genexp) is invalid (i.e. crashes if executed) but sum([genexp]) is valid
 
apparently I can do it the other way around
 
Oh, a reverse puzzle. Challenge accepted
 
something's off though, hold on
OK, no
 
Reverse puzzle solved itself I guess
 
when you say genexp do you mean genexp = ... or is "genexp" a placeholder in sum(genexp) vs sum([genexp]), i.e. the latter being a list comp?
 
3:33 PM
As a placeholder, not a variable
 
OK, that explains it
I'll think about it during lunch
So the latter is a list comp? Or is genexp implied to include parentheses?
 
Yeah, it's a list comp
 
 
1 hour later…
4:53 PM
@Aran-Fey Do you actually have a solution for that? Because I don't see how sum would care.
 
I expect it's not sum that cares
But I guess it is. I expected forbidden syntax, though I couldn't think of anything on python 3.
 
wait, we have spoiler syntax in chat?
oh, I see, sopython has... I assume that's a base64 decoding service
 
5:19 PM
@Aran-Fey Are those glasses made of glass, or plastic? Either can be polished, if the scratch isn't too deep. But if the lenses have a coating, you probably don't want to polish that off, and even if you eliminate the scratch, the disruption to the coating will be visually annoying.
Polishing glass by hand is pretty tedious. Plastic is a lot faster. But you do have to be careful polishing optics, otherwise you will change the refraction.
 
I assume it's glass, but I don't know. I tried a few things today, and not much happened. Probably got worse rather than better though
 
The traditional polishing agent is jewellers rouge, the more modern material is cerium oxide.
I've polished plastic (Perspex, aka Lucite) using toothpaste for the initial stages. But you have to be careful: some toothpastes are surprisingly gritty.
 
I'll probably have to buy a new pair. It's just... kinda weird to spend money on glasses that aren't even the right strength
 
Yeah, it's a bit silly to fix glasses that aren't right for your eyes.
Maybe just buy some cheap generic reading glasses of the appropriate power. They aren't quite as good as proper prescription lenses, but they should be fine for screen work, unless you have strong astigmatism, or your eyes have a large difference in their refractive strength. Over here, you can buy cheap reading glasses at pharmacies & places that sell cheap sunglasses. Especially in places that have a large population of seniors.
 
5:41 PM
Oh, interesting, pharmacies weren't on my radar until now. Not sure how likely it is they'll have something in my size and strength, but having more options never hurts
 
FWIW, we have a couple of telescope makers on Astronomy.SE, who are experts at glass polishing. They haven't been active for a while, but they've written some excellent posts.
 
Haha, I think an astronomer probably would've thrown lenses like mine in the trash years ago
> Polish astronomers discover the smallest rogue planet
Thanks, google. Not quite what I'm looking for, I'm afraid
 
Polish-polish, rogue-rouge... checks out
 
Ah, the good old rogue / rouge confusion.
 
Maybe Polish polishers are great polishers.
 
5:49 PM
We have a rouge planet in the Solar System. It's called Mars. ;)
 
6:03 PM
@Aran-Fey spoiler feature is fixed? :O didn't know
 
Probably isn't. I use Kevin's userscript
 
can you point me to it? I recall Kevin mentioned he posted it, but didn't find it at the time
 
ah, didn't know this was on there. Thank you
 
6:41 PM
@Aran-Fey I thought they buffed them with cannon balls to be hardcore. Try harder
Clarify the lens with shrapnel :P
My last optician appointment was a very humiliating experience. The nurse came into the room and asked "when did you last have your eyes checked?". I told her it was like 5 years before and her response was "that's. Very. Naughty" like you might say you child. Still, I've saved over £1000 just buying contact lenses online rather than their service
It also sounds like the opening to a dodgy film, but it's so much cheaper when you know your prescription.i don't know how it works for glasses
 
7:07 PM
5 years? That's nothing!
 
@roganjosh I had a dentist who said weird stuff too. Not the same kind as this, but still weird. "oh, the root of your teeth are amazing!" Multiple times on each separate visit. There were other weird/odd sentences that were said, but I don't want to dedicate a large block of text for them
 
Is there even a point in going to an optician unless you already know you need one? You don't need a medical professional to know if your eyes are good enough
 
maybe to know more details or as a reality checks? I know that even if I needed specific glasses, and that I noticed some new behavior, I might go there at least once
 
@Aran-Fey to get the precription. I had jumped from -1.25 to -2.5. Once you have assessment, though...
The optician must have been about the same age as me. While I was wearing the ridiculous contraption- "how did you read the board for your lectures?" --> "I never went to any, so it wasn't a problem". He did not get on board with my humour
 
I bet he's heard (too) many people say "It hasn't been a problem" in earnest
 
7:21 PM
Bonus,though. I learned everyone's gait for the people I know
"That blob wobbles slightly left on every right step"
 
I guess it makes sense to go every now and then, just as a sort of sanity check. If the optician gets a heart attack when you tell them you drove the car, you probably should've gotten new glasses a while ago
@roganjosh Is -2.5 that bad? O.o
 
-2.5 sounds like a typical prescription for people who actually need glasses, to me
 
I honestly have no clue about the magnitude of these numbers
 
8:07 PM
@KarlKnechtel I can see enough together around without my contacts. I actually find it really weird since I could probably see a tree on a distant (2km?) Hill, but I can't resolve it properly. I don't understand how it works
There's a certain distance where I can't resolve features and yet I can see long distances (just with blurs that i can discern). I don't know how eyes work, it seems. I would have expected distant objects to get progressively more blurred but that's not what happens
-2.5 is definitely enough to not dare drive without contacts in. I'd takea cyclist out with no problem without them
"Together around" is a predictive text mash-up but I don't remember what I actually typed :/ rbdb
 
8:27 PM
Yeaaaah, driving is definitely an activity where you want to see well
 
8:41 PM
@Aran-Fey yes
I first went to an optometrist in my twenties, when I realised I couldn't see if students across the lecture hall were talking to each other during a mid-term. By then I had grown suspicious that the moon is not supposed to be blurred, but still I was shocked when I got -0.5 glasses or something like that and suddenly the trees in the street were fullHD. I hadn't at all realised how much I'd lost in detail, but after that the difference was so annoying that I've been wearing glasses outside.
Got a bit worse too, near -1 now. And it's really annoying. Anything beyond arm's reach is slightly blurry, anything beyond 2 meters very obviously so. I can't read blue and green LED displays either, they just blur too badly. Nor make out faces beyond 10 meters or so, sometimes can't even guess the age correctly.
I like to say that during the winter when glasses get foggy I can choose between blurry vision and sharp non-vision...
My impression is that an optometrist/optician becomes especially important for positive dioptries. With myopia you can just take any random glasses and check if you see with them. Hyperopia is a lot trickier because your eyes can compensate a lot.
 
9:09 PM
Welp, now 2.5 suddenly sounds like a lot
The foggy glasses were especially bad with the mask mandates in the last few years. There were a few times when I almost crashed into something/someone/somecar
 
yeah, I still wear a mask for public transport and it makes the issue a lot worse
 
 
1 hour later…
10:25 PM
with masks I find it's especially bothersome to have one on while using a menthol lozenge.
either as a typo, or dupe to "how do I find something in a list" etc. stackoverflow.com/questions/75423566
 
10:52 PM
Do we have a canonical for questions where webscraping using requests/bs4 isn't working b/c the page is generated using JavaScript? If not, how should they be closed?
 
Oh, okay. Thanks!
 
I don't know what that is though :D first promising hit is stackoverflow.com/questions/47730671/…
But they have to be dupes
Lot of crap at duckduckgo.com/…
 
11:10 PM
@AndrasDeak--СлаваУкраїні That's actually pretty promising, and should work for this question. It needs some work to turn into a true canonical, but it's a good start.
 
I'm sure Karl has some ideas
 
any data scientists here
 
Maybe. Just ask your question and if someone is able and willing to help, they will.
 
11:23 PM
unless it's about a recent question on the main site, cf. our rules sopython.com/chatroom
 

« first day (4501 days earlier)      last day (446 days later) »