« first day (3278 days earlier)      last day (1895 days later) » 
01:00 - 17:0017:00 - 00:00

wim
wim
01:15
@Aran-Fey option 3 please
 
2 hours later…
03:16
Pygame question: why isn't my screen updating on user input?
Do I need a second blit after every "rex.move"?
03:56
@JohnnyApplesauce If your code is longer than about 12 lines, use an external paste tool such as dpaste.com.
see also mvce
Ah, I didn't know about that. Thanks
 
1 hour later…
05:54
anyone there ?
07:16
If someone could take a look at my serializer and see if they can think of any security holes, that would be much appreciated. I've summarized how it works here, and here's my existing security-related test suite.
07:37
Uff... how do I make something iterable is closed as dupe of how do I make an iterator, isn't that just great
cbg
@Aran-Fey just so I have understood it correctly: it's basically pickle with a schema on top?
Not sure what you mean by "schema". The protocol itself is very different from pickle, but it does allow objects to customize how they're serialized by implementing functions from the pickle protocol (__reduce__, __getstate__, etc)
With some sanity checks of course
@Aran-Fey the readme lists a basic schema that is expected from the result: expected_type=typing.List[str]
didn't get much further into the code yet ^^
07:47
ah, right, that. That's actually optional, but it's recommended so you that nobody can make you deserialize a Dragon when you expected to get a TeddyBear
@Aran-Fey I still think it's risky to import the whole project during build, it means that your builder might need runtime dependencies. If it works it works, but if it ever fails I'd advise to take this ol' reliable: re.match(r"__version__ = '(.*)'", open(HERE+"secure_serialization/__init__.py").read()).group(1). He's not pretty, but arguably better than sys.path.insert(0, HERE)
Hmm, yeah, that's probably better than importing. Theoretically pip could install my module before it installs the dependencies
with setup_requires, yes
yeah, if I clone your repo and run pip install -e . I get "module not found: file_utils"
alright then, regex it is
@Aran-Fey then the thing I am wondering about is how you make pickle'able support safe? I've only found what looks like a blacklist in protocol.py.
07:56
because it's not pickle?
isn't the pickle protocol is basically "call an arbitrary object with these args"?
Whoops, that's something I definitely should've documented. The general assumption is that classes are safe to call, and everything else is not. Some classes like Popen are blacklisted, and some functions like iter are whitelisted. That code is in configuration.py
08:08
bandit says that the modules subprocess and pickle are security concerns, but you were probably aware of that :p
yep :)
Good morning guys, any idea if is it possible to make a progressbar reach 100% by the time another function finishes?
i am using threading to execute them at the same time, but right now i just calculated how much time it takes for the function to finish, and i built the progressbar accordingly, it just doesn't seem really smart
oh, I just realized I forgot to specify a dependency in my setup.py...
08:29
@Aran-Fey fyi, the same happens when pulling any of the dependencies, so they all might require the same change
yeah, I'm in the process of fixing them... got sidetracked because I discovered that one of the dependencies isn't even up on github yet... and then I got sidetracked again because I found bugs in one of the dependencies
@Rozakos do you have any way to actually measure the progress of the function?
08:45
alright, now it should be properly installable... though you might have to uninstall the dependencies first (if they were even installed) because I forgot to increment some version numbers
pip uninstall datatypes file_utils introspection secure_serialization
@MisterMiyagi i am not totally sure, it's a serial communication, so maybe byte count? Other than that i can use a stopwatch and see how long it takes :P . The time it takes for the function to finish will either be 5 secs, or ~1 minute. So i was thinking maybe make it last a minute(the progressbar), and if the other function ends let's say in 5 secs, i could make it go to 100% immediately, even though it will be in about 10%.
if you know the byte count up front, I recommend wrapping the progress monitoring directly on the I/O component.
the tqdm has some nice helpers that work directly on such streams: github.com/tqdm/tqdm
if you can't measure the progress properly, consider displaying a spinner instead of a progress bar
Spinner is smart
I am not really sure it exists in Tkinter though, only thing i can find is spinbox :<
wait no i think i found something
ty @Aran-Fey
09:10
...
  Running setup.py develop for secure-serialization
Successfully installed datatypes-1.0 file-utils-1.0 introspection-1.0 secure-serialization weaklib-1.0
@Aran-Fey 🎉
 
3 hours later…
11:50
The test suite is failing with 12/110, python3.6.8 and ubuntu18.04. Do you care about portability a lot?
Oh, that's expected. Some of those are actually not fixable. I suppose I should make them xfail
But do let me know if you find any other objects that can't be serialized
ah, alright. I didn't test it with actual input yet
I want to see how pypy and other implementations handle iterators and views and weakrefs before I continue working on those, so that's why some of the tests don't pass yet
12:19
@Aran-Fey it has some difficulties serializing 1, and in how far it's different from True
Oh, nice find. I think I know why that is...
There are infinitely many integers so it's not a huge deal if you can't serialize two of them.
9
Hmm, after sanitizing this data and graphing it, it forms a long thin smear rather than the neat rectangle I expected. I probably shouldn't have deleted the original pre-sanitized data.
how long did data generation take?
Not long, but the code is on my other computer
12:30
I see
I have discovered a method of sending information backwards in time. If I wake up in the morning feeling motivated to work on a project, then this means that some disaster will occur that blocks me from actually working.
Monday cabbage
I can exploit this to send one bit of information into the past. If Kevin at 9:00 AM wants to send the bit "1" into the past, he takes the USB drive containing a fun project, and smashes it with a hammer. If he wants to send "0", then he does nothing. Meanwhile in the past, 7:00 AM Kevin will wake up either wanting to work on the project (indicating a "1" bit), or not ("0")
Sending 1 bit of information two hours into the past, once per twenty four hours, should be sufficient for me to make millions on the stock market over the course of a few weeks
except if exploiting this is what motivates you this morning
12:46
I can never execute this scheme because some disaster will occur whenever I try to acquire the necessary materials. Perhaps the hammer store goes out of business before I can buy a hammer.
@Arne I pushed a fix. Nothing really important changed though, so if you can live with the bug you can just ignore it
I could try to anticipate this and short the stock of HammerCorp, but maybe then I'll be able to buy the hammer and it turns out the USB is hammerproof
> 9...d93: incremented the dang version number
Hey, I have a couple of those too =D
cbg
my commit log is... well... a bit of a mess :D
ha
Squasher-downer, that has to be made-up!
that's the technical term for all bulldozers produced by CAT
12:59
I'm only 80% sure it's made up. You never know what ridiculous things turn out to be real.
@Arne can't tell if pun
I vaguely feel as though this is an "attorneys general" situation and it should actually be a squasher-down or a squash-downer
@AndrasDeak just the way it should be =]
Love to Well Actually a joke from a children's book
*shakes fist at German humour*
@Kevin I was asking because Busytown has a bunch of technically correct nomenclature in my experience
13:03
I know that there are a number of languages that have amusingly literal terms for modern tech, along the lines of calling a television a "lightning box", or what have you. I don't have any specific examples though.
"Flugzeug" ("flight thing", i.e. "plane")
heh
I was trying to translate Bildschirm
I have one, from dutch: fietsje -> bike, bromfiets -> vroom-bike, aka motorbike
Bildschirm translated literally would be "picture screen" I guess
Yeah, but what is Bildschirm when translated? Screen, right? Which is like the "if you put a hotdog into a bun it becomes a hotdog" problem
although I guess you can say "screen as in project onto or protect from rain"
13:08
German ...humour? O_o
I'm sure English has some strange coined words too, but I don't have the perspective to notice them
I guess one could argue that "Schirm" translates to "screen" and "Bildschirm" translates to "video screen" or similar
There's at least one ubiquitous term that's a combination of Latin and Greek roots. I want to say "airplane", but "plane" could be either Latin or Greek
@Aran-Fey I hide my careless commit history behind behind PRs, so that the master looks more manageable. But it is a bunch of effort.
The Latin (planus / "level") makes a bit more sense in context compared to the Greek (πλάνος / planos / "wandering"), IMO
13:11
@Kevin perhaps because English has never been scrupulous about pillaging other languages for new material
Extremely true
How about helicopter? I know it's stolen, but at least it means "helix wing"
which is of course only weird if you haven't seen Leonardo's original concept
@Arne pre-commit.com might interest you
Wikipedia says both "helix" and "pteron" are Greek, and also English stole the word from French
@Kevin heh
13:13
(for those "forgot to run black", "forgot styling" commits)
If "helicopter" and "pterodactyl" share the same root word "pteron", I must insist that they be pronounced consistently. Either helicopter becomes "helicotter", or pterodactyl becomes "puh-terodactyl"
joke's on you, we pronounce the p in pterodactyl, pneumonia and psychology
This is acceptable.
but we also start xerox with a ks
Also can we get a consistent pronunciation for the Xes in "anxious" and "anxiety"
I demand either "an-zee-ious" or "ank-shi-tee"
13:16
@shad0w_wa1k3r issue is already open ^^
@Arne Sometimes, you get a reversal of that, for humorous effect. Eg, according to songwriter Luka Bloom, "acoustic motorbike" is an Irish slang term for "bicycle".
that's a new one
though it feels a little like snail mail, which completely cracked me up the first time I understood what it means
cabbage
When I first heard snail mail email was still newish, I didn't even have an email address yet I think. And the name was weird.
Now it's less snail mail, more "that one where things get lost"
How to keep track of the initial value of a variable that is being passed in a function and it is known that it would be altered. For example, if X is passed, and I know X would increase up to a certain number which is unknown to me, how to store the initial value of X. Obvious thing to me was store value of X into some variable, say A, but in python value of A is also changed.
13:19
I'd love to have DHL be our postal service, like some lucky people
@AjayMishra use a copy/deepcopy for mutable types
if it's just a number (int, float) then it's immutable and you needn't worry about references
any example?
for what?
but it is being immuted.
@AjayMishra I don't understand this message
@AjayMishra I feel like this would work better with more code. The pattern you are describing is something I'm pretty sure has multiple solutions.
13:21
@AjayMishra The verb is "mutate", which means "to alter". "Mutability" is the property that something can be altered. The lack of mutability is "immutability".
Cbg, all
leave it, I got it.
There's no way to tell what value a variable used to have before you reassigned it. If you need to keep track of that kind of thing, maybe you could use a list instead.
I think they're just worried that X_original = X at the top would be invalidated by the end of the function (due to mutation)
13:23
For example, x starts with a value of [23]. Later, you want the value to be 42, so you append it, resulting in [23, 42]. Now you have access to the most recent value, and every previous value too.
@Kevin better yet, create a decorator to implicitly keep changes of the program state. :P
create a timeline.
Or maybe what you're asking is "when I pass a mutable object as an argument to a function, how do I ensure that its value stays the same outside of the function?"
timeline oriented language...
copy.deepcopy can handle recursive lists, nice
What if git was actually a language?
13:26
I bet it's Turing complete
@AndrasDeak I can't find anything on that... huh. I want to know now.
For example, consider this bad code:
def get_max_badly(seq):
    best = float("-inf")
    while seq:
        x = seq.pop()
        best = x if x > best else best
    return best

seq = [1,2,3]
print(get_max_badly(seq))   #3
print(seq)                  #[]
Many users will try to fix this by doing a = seq and then only mutating a, but this doesn't work because a and seq reference the same list object
@Kevin MAX DESTRUCTION!
Popular solutions that actually work include:
- a = seq[:]
- a = seq.copy()
- a = deepcopy.copy(seq)
- a = [*seq] # piR version
13:32
I feel like we've over analyzed this problem.
@AndrasDeak +1
looks like i'm going to have to learn matlab soon.
poor thing
@AndrasDeak I've seen your avatar in the chatlab.
13:35
are you going to the dark side?
no, I came from there
ominous!
did you use matlab or GNU Octave?
matlab
traitor
where is your foss spirit?
13:37
cbg!
you should 1. get your hands on R2016b or newer for broadcasting, 2. say farewall to powerful syntax, 3. say farewall to sane string handling, 4. say farewell to one-liners
@Dair that's partly why I switched to python
fwiw, [*iterable] is the fastest of the bunch:
# tested with iterable = list(range(1000))
[*iterable]  # 1.46 usec
iterable[:]  # 1.71 usec
copy.copy(iterable)  # 1.97 usec
copy.deepcopy(iterable)  # 394 usec
@AndrasDeak Is this in response to GNU Octave?
nope
it's vis-a-vis python -> MATLAB
octave has more powerful syntax than MATLAB
(oh, and indices are 1-based and slices are inclusive)
13:42
2/3 "farewall", nice. I don't know what's happened to my typing these past couple of weeks
it's all that meta commotion
not unlikely
btw does anyone know if they plan to show the resigned moderators the CoC rough draft? Or just the remaining mods?
no idea
13:46
closed
Hmm, not sure how I turned −08° 12′ 05.9″ into -0.3490944544060514 radians, but I did
alright.I must admit, like a couple of the answers there: something doesn't sit well with me and the latest apology, but I'll assume good faith until the new CoC is released and then judge.
@Kevin yeah, ~pi/10
but the sign is correct
@AndrasDeak 3.4 is almost pi? I guess. I would imagine 3.14 to be almost pi...
although, I guess a physicist would consider 5 almost pi
math.degrees(-0.3490944544060514) is about -20.00, so I'm off by a factor of two
13:49
for guesstimating purposes 0.35 is as good as pi/10, which is much larger than 8 degrees
Yes
flashes back to a bunch of engineer vs physicist vs mathematician jokes
sqrt(10) is also pretty fair approx of π, if that is any help
anyone have an idea how to turn old-style coroutine/trampoline loops into list comprehensions or similar?
items = []
for request in requests:
    items.append((yield request))
13:52
we can't yield in comprehensions anymore, can we?
no, it wouldn't do the correct thing either way...
it works with await, though
too bad it's not an async API :/
stackoverflow.com/questions/58218592/… bad and opinionated attempt at a self answer, no idea how it got so many votes.
22/7 is also a good approx of pi.
Trying to debug this error without the source code has at least made me realize I didn't account for a corner case that shows up 0.3% of the time, so at least I've got that going for me
@Dair Uncle Pali was a boss
14:04
negative zero is not less than zero, turns out
I approve of that fact
So I can't expect degrees_from_degrees_minutes_and_arcminutes(0, 23, 42) to return a different value than degrees_from_degrees_minutes_and_arcminutes(-0, 23, 42)
I think the negative zero is a float in my real code, although it still won't do what I want
I didn't know you could keep the sing on a float zero though..
the only negative zeros are floats
morning cabbages, all
14:06
cbg
Yeah, all floats have a sign, even wacky ones like zero
wikipedia has a helpful article titled Signed Zero
@MisterMiyagi Maybe related? The stack of iterators pattern
rbrb got to watch some lectures.
@Kevin I think the leading sign of -0° 23' 42" implies (-0, -23, -42)
And yes, -0 == 0 evals to True, for floats and ints
14:22
@Arne can't be deleted because it's a dupe of stackoverflow.com/questions/58147272/…
(I mean dupe target)
Cabbage all
pastebin.com/hkxC7dmU has ten pieces of sample data that show how Past Kevin's calculations differ from today's calculations. The mistake can't just be "the data is off by some constant multiplier" because π3 Ori's real declination lies between Betelgeuse and Bellatrix, but π3 Ori's incorrectly calculated declination is twice as large as either of its neighbors' incorrect declinations.
@AndrasDeak o_o
As a tangential curiosity, notice that Mintaka AB's "actual radians" value is still positive even if you set its degrees to -0.0, demonstrating the rare error I described earlier
Perhaps I could fix that with if math.copysign(1, degrees) < 0:
14:40
@Kevin that's one badly nonlinear mistake
-0.14 -> -0.35 is less than a factor of three, 0.12 -> 1.10 is almost a factor of ten
any chance the items got reordered?
What is the problem here, for those who know pygame?
Nothing is broken, and the rectangle draws just as it should
@JohnnyApplesauce we need more for an MCVE. Why do you think there's a problem?
It just doesn't, you know, move.
Maybe I don't understand how rect.move() works
Or maybe there is something that I'm supposed to add to the game loop to make the game update drawing the rectangle
14:43
did you try printing inside the branches to see that the identification of key presses is correct?
What do I need?
Trying right now
(I can only rubber duck because I've never used pygame)
Hmm, nothing prints
Hold on, let me execute from command line. I think it might not be accepting input because I'm executing from npp's python extension
Alright, that didn't make a difference.
Well, it does print, but that's not the issue
Apparently, I am using the right key codes
I've used pygame once or twice. My first suspicion is that rect.move doesn't mutate the rect, and instead returns a new copy of the rect with the changes applied. If my internet ever starts working again, then I can check the documentation and see if my guess is right.
> Returns a new rectangle that is moved by the given offset. The x and y arguments can be any integer value, positive or negative.
Try rex = rex.move(0, 1) and similar for your other conditionals
my two cents' worth (jumping in mid-conversation): moving a rectangle might move it in the model of where pygame thinks the rectangle should be. But it may not update the display of said rectangle. You may need to blit it to see the moved/updated position
14:51
That didn't work.
Here's the update code
@JohnnyApplesauce (okay, but when input isn't accepted it will also never work)
Huh?
...what input?
you have to both fix your bug and run it outside npp's python extension, whatever that is
Oh no, npp doesn't block input, I just checked
It does appear, however, that the branches are never taken
so it prints, but it doesn't? :P
14:54
Outside the loop, everything prints
But a print in the branch doesn't
that's...exactly where I suggested you put prints
10 mins ago, by Andras Deak
did you try printing inside the branches to see that the identification of key presses is correct?
Try event.key instead of event.type
That wasn't working, so I put one outside the branches to test if anything was happening
14:56
as far as I know prints can be put in multiple places at once ;)
Event object has no attribute key
Lol I know that that's why there's two of them now
Try like this, maybe:
if event.type == pygame.KEYDOWN:
    if event.key == pygame.K_UP:
        acc += 1
    if event.key == pygame.K_DOWN:
        acc -= 1
using event.key, i/o event.type
@JohnnyApplesauce
Alright, the branches are executing!
haha, that's what @Aran-Fey just said...
The rectangle isn't moving, but at least the branches are executing
So we've got that far
Wait, someone said something about blitting the rectangle again
Blit it where?
15:00
@JohnnyApplesauce to whatever screen/canvas you're displaying all this on
I can't tell where I need to pass it
More data on my declination problem: pastebin.com/BJg4k0Dd. I notice that in all cases, incorrect degrees is approximately equal to correct degrees plus correct minutes. What the heck was Past Kevin doing?
@JohnnyApplesauce IIRC, it's something like myrect.blit(myscreen)
cbg al
15:03
...so blit is a method of rects too? Wh-why?
or is it myscreen.blit(myrect)?
hope everyone had a good weekend
Okay, tested it on both
Unfortunately this probably means that the correct-to-incorrect-radians function is not unambiguously reversible. (1 degrees 19 arcminutes) gets mangled to (20 degrees), and so does (19 degrees, 1 arcminutes)
Rect's don't have a blit
And displays (myscreen) has to have a surface passed in
So, I guess the real question is where on the surface I need to put the rex
15:05
I see this example:
screen = pygame.display.set_mode((150, 50))
background = pygame.Surface(screen.get_size())
screen.blit(background, (0, 0))
So far so good, I've got that far myself.
But where does the rect get passed in?
that example was blitting a background to a screen. You want to blit a rectangle to screen. So replace background with your rectangle, and that should do it!
But that doesn't work because the first item passed in must be a Surface object and not a Rect
does someone know if the deque(..., maxlen=0) optimisation is still CPython only?
ahh, apparently, you can also background.blit(text, position). I imagine you could background.blit(myRect, position) as well [ source]
15:11
Pygame used to have a nice tutorial showing the simplest possible way to render a rectangle on the screen and make it bounce around. It was very good for establishing the very basics of screen/surface/rect/sprite management. I can't find it on their redesigned site, alas.
I found an examples directory but the first few I clicked on all use DirtySpriteCollectionManagerBeanFactories, which is a bit too bells-n-whistles for my tastes
Currently trying to spin up the old tape drives in my brain so I can remember the approximately correct way to do this
<waves degausser>
@JohnnyApplesauce nooooo ;]
@JohnnyApplesauce ok, here is a way to do it, which I don't necessarily endorse as the "correct" way. dpaste.com/19MZWQT
I changed rex from a pygame.draw.Rect to a pygame.Rect. Every frame, I create a pygame.draw.Rect based on rex and draw it to surfup. That draw.rect gets erased on the next frame thanks to surfup.fill
If pi had not degaussed me, maybe I would remember whether this is the idiomatic approach. Oh well ¯\_(ツ)_/¯
IIRC, only surfaces can be blitted onto things. Primitives like circles and lines and rectangles* can't be directly blitted; you've got to use pygame.draw to draw them onto a surface, and you have to draw them every time you want to change a position/property of that primitive. So calling draw.rect once before the loop won't do what you want
How do you delete it?
I mean, the rectangle...
15:25
reblit the background on top of it!
with surface.fill. That will delete everything and replace it with a solid color.
I've not used pygame but that's how it worked when I was messing with canvas. I had to rewrite the background every time.
I believe there's a fancy way to only partially erase the screen and redraw only the primitives that have changed, but I don't know how to do that.
Ah, that works.
Thanks. So, Kevin, what's the matter?
If you're saying "so what was the problem you were working on before I came in here?", I'm trying to retrace my steps and figure out what my webpage-scraping code did in order to produce obviously wrong data. I've come to the conclusion that I can't un-break my bad math with only the information available to me, so I'm going to shelve the project until I can access my original source code this evening.
The "Dirty Rect Animation" section of pygame.org/docs/tut/newbieguide.html gives a rough explanation of partially redrawing the screen as a way of improving framerate
15:33
@Kevin Compose a dirty region bounded by old rect location and new rect location, then redraw only those objects that overlap the dirty region, in correct z-order.
That's approximately what the link describes, although it suggests creating two dirty regions corresponding to the rect's old and new locations, which I guess is more efficient than just marking the bounding box of both rects as dirty, if the rects are far apart
If using two regions, compose a set of the objects to redraw, in case a large object overlaps both - no need to draw it twice
Unfortunately, if there is an enormous object that is complex/slow to draw, even this optimization won't help much
I wonder if display.update(dirty_rects) has any clever math to make sure overlapping rects don't get redrawn more times than necessary
wim
wim
15:51
@Aran-Fey I added a re-open vote on the former (the accepted answer there is good).
oh, actually, I reopen-hammered it 😅
as for stackoverflow.com/a/24377/674039 , the accepted answer is very bad ... anyone got the balls to rewrite it with a less confusing and/or more realistic example code?
I've met my quota for thankless tasks this year, so I'll pass
@TheLittleNaruto Hey, I'm a Python programmer now. Haven't done much Android programming over the last few years.
and cbg to everyone else
16:11
cbg
@wim I agree that it's a bit ugly, but why is it very bad? IMHO, its args should use the usual Python convention that ramge & slices use (altough random.rangeint intentionally breaks that convention). And that else block is cringe-worthy, but that's easy enough to fix.
I've updated the code to actually work on Py3 and changed the __next__ logic a bit to match what range and friends do.
don't see much else to do though.
you improved the if/else as well
I don't think that makes it much easier to understand, though.
@MisterMiyagi Thanks. That looks good to me. FWIW, the author of that answer was last seen in March this year, but they haven't written an SO answer since 2012.
16:23
iterators appear to be almost as arcane to people as recursion.
16:34
@MisterMiyagi You can say that again.
I see what you did there.
Every couple of months, I go back to trying to get Cython running at work. I don't know why I don't just give up at this point, I always end up leaving grumpy :/ considering the age of C, it's quite remarkable that getting a working compiler set up is so fiddly
@Kevin Redraw in XOR?
16:49
That's one way of doing it, if your game is only two colors.
Nothing wrong with black and white graphics. That'll get you a high pedigree in the indie community
Does there exist a method of making files created by scripts get disposed of every $TIME or so?
Say you download someone else's Python script, you're not supposed to change it, and it creates a file; what could be done to automatically delete it? Would this involve making a change to Windows' file system itself, or is there a way to make a Python script that "wakes up" every time a file is created?
Ha, pypy's interactive prompt is >>>>. It's like CPython, but faster.
Doing anything every N minutes is an OS-dependent feature. Windows has scheduled tasks, Linux has cron jobs, Mac has... Something, I'm sure
Okay, not every n minutes, but n minutes after creation, every time something is created
Is that still OS?
I don't know if that's possible at all
16:56
Ah, the pitfalls of closed-source.
Well, there are things like watchdog
Perhaps my imagination is lacking but I'm not sure I see the value in a program that deletes every file I create after ten minutes
...you'll never run out of disk space?
Or even just a program that watches one directory specifically for one filename specifically and deletes that file ten minutes after it's created
01:00 - 17:0017:00 - 00:00

« first day (3278 days earlier)      last day (1895 days later) »