« first day (2913 days earlier)      last day (2035 days later) » 

12:52 AM
Hi all! Is it possible to use a property on the class level (as opposed to the instance level)? Here's what I mean more clearly--if I have some instance a and some class A, where A has a property prop that returns _prop * 2 where _prop, a class attribute, equals 1, I know that a.prop will be 2 and A.prop will point to a property object in memory. However, I'd like A.prop instead to result in the value 2, the same result that a.prop yields. Any ideas on how I might do that?
 
1:13 AM
Some people take Minimal beyond to the point where they post nothing
 
1:30 AM
stackoverflow.com/questions/52684736/… , how do you cv-please thingy do i have enough rep?
rhubarb goodnight fellas see you tomorrow
 
 
2 hours later…
3:05 AM
@vash_the_stampede do you mean [tag:cv-pls]? Or do you mean an actual close vote. The latest requires a certain amount of rep, but I don't remember how much. You can find out by going to the Privileges page in the help section of the main site
@jmindel try explaining in shorter sentences
Lots of short sentences is usually better than one long sentence
 
 
4 hours later…
7:10 AM
@jmindel You mean like this‌​?
 
Also see stackoverflow.com/questions/128573/… But as you can see, it can be tricky to do it correctly. And I'm not convinced that class attribute properties are a good idea anyway.
 
@roganjosh Ned is quite authoritative
@vash_the_stampede you should've read what I told you
 
7:26 AM
@AndrasDeak Indeed. The comment by nos explains the situation well, and the dupe target is fine. The GIL is only relevant in that if you did split that serial computation up so that it could run in parallel, then you'd need processes to run it on multiple cores, rather than threads.
Any feedback on the sphere crochet pattern script?
 
Not yet, we've had a very busy week. Next week looks much more promising :)
 
No worries, I'm not in a rush. But you did say to remind you. :)
 
indeed, thanks :)
 
hi guys!
can you guys help me with a doubt on tkinter?
see basically I've 2 buttons
and 1 button calls a method which contains sleep and other button is to close the application. But once I click button 1, app freeze itself and I'm not able to close using the other button. I read we've to use multi threading. Is there any other approaches? Like using after() or something?
 
7:43 AM
@BipinB Yeah, don't call sleep in a single-threaded GUI program because it puts everything to sleep. But you didn't explain why you have sleep in that method.
 
Yes, after is the replacement for sleep in tkinter. Tkinter uses a mainloop to process all the events that happen when someone interacts with the GUI - but if your code is sleeping, then the mainloop isn't running and the GUI freezes.
 
The .after method isn't a drop-in replacement for sleep, and how you use it depends on what you're trying to do.
 
It is, actually. You can call root.after(1000) and it'll block for 1 second, then continue running your code.
 
@PM2Ring : This call back is supposed to be an infinite loop as after sleeping for x seconds I want the loop to be continue again forever untill someone clicks the BUTTON 2.
for example something like this:

Button1 = Button(top, text="Submit", command=startwebBrowser)
Button2 = Button(top, text="Stop", command=closeBrowser)

This can be anything like playing a song/video instead of starting a webBrowser
 
@BipinB Ok, that's pretty standard. The last line of the callback uses .after to call the callback again. Make button 2 set some attribute of your GUI class instance, and in the button 1 callback check that attribute to see whether the loop should continue.
@BipinB Maybe I misunderstood you. Why do you want to start a browser in a loop?
 
7:54 AM
@PM2Ring Web Browser was an example. It can be like anything. Repeatedly playing a song or video may make more correct example :)
 
I guess you do actually need threading here, since you want Button1 to start some long task & return immediately so you can continue to do stuff in the GUI.
 
say after 10 seconds of break
 
@Aran-Fey You sure about that? IIRC, .after schedules a callback to happen after the delay, but .after itself returns immediately. I guess I'll have to turn my computer on and check... or look at the docs. ;)
 
Turns out we were both right and wrong. root.after(1000) pauses for a second like I said, but the GUI freezes in the meantime. So it really is exactly like sleep...
 
But then you might as well sleep :|
tkinter sounds ugh
 
8:04 AM
That is very accurate, yes.
 
@Aran-Fey Ok. I don't think I've ever used it like that, I only use it to schedule stuff.
@AndrasDeak It's not the best GUI lib I've ever used, but it's ok when you get used to its quirks. And it's relatively small, so there isn't a vast amount of stuff to learn lime there is with full-fledged systems like GTK or qt.
 
Honestly I've found myself just making web front ends lately in the cases where I would have previously used Tkinter
 
@PM2Ring sounds like PHP
 
It's not that bad.
 
8:16 AM
@AndrasDeak :)
 
@AndrasDeak Ah, right. I've seen that before. It reminds me of Workflow.
Heh. I just got the "The last message was posted an hour ago" thing, because my desktop machine just reset its clock for daylight saving.
 
Class vs instance attr dupe, can't hunt on mobile stackoverflow.com/questions/52686710/…
@PM2Ring time for a bug report ;)
 
@AndrasDeak That's a bug I can live with. There are other things that could be improved in chat that have a much higher priority. Like giving inline code snippets a different background colour.
 
Ah, but that's a feature ;)
 
@AndrasDeak Hammered
 
8:29 AM
Thanks
 
@BipinB Here's a simple stopwatch in Tkinter that shows how to use .after stackoverflow.com/questions/44372046/… It doesn't exactly match what you want to do, but hopefully it gives you some helpful ideas.
 
@PM2Ring Thanks a lot man! :) Anyway I've almost fixed with multi-threading though :)
 
@BipinB Oh, ok. You have to be careful doing threading with Tkinter. The Tkinter GUI process should be in the main thread. If it's not, weird stuff can happen. But that shouldn't be an issue for your program.
Most of the time, you don't need to use the threading module with Tkinter, and you can achieve what you want using .after.
 
@PM2Ring ya cool. Will take care :) Thanks a lot guys @PM2Ring :)
 
@BipinB No worries.
 
9:28 AM
@vash_the_stampede don't answer unclear questions like that. Wanting to help people is fine but you should only answer well-formed questions.
We are not a tutorial site.
 
I'd like to add that we're not CodeReview. This is my personal opinion, but I think answers should get straight to the point, and not improve every minor detail in the OP's code.
 
Yup
 
@BipinB Here's a more complicated .after demo I just wrote. Use Tkinter's .after method to run several named counters in parallel.. You might find it useful. Or maybe not. :D
 
9:50 AM
@vash_the_stampede What they said. The OP didn't actually even ask a question. If you think a question could be worthwhile answering, use comments to try & encourage the OP to turn their post into a question that's worth keeping. The main problem with the OP's code is that float(BMI) on the left side of an assignment, and your answer doesn't say why that's wrong.
BTW, there's no benefit in changing a ** 2 to pow(a, 2). I guess the latter is a little more readable, OTOH, a function call is generally slower than the equivalent operator.
@Aran-Fey I know what you mean. But if it's a newbie, and they've made an effort to write a decent question, I'm happy to fix up other minor things, to stop it from turning into a chameleon question.
 
10:05 AM
Errors yes. Style and performance optimizations probably no.
 
Only errors that are relevant to the question, though. If there's some minor error in the code that doesn't really affect the question, I'd either ignore it or fix it in the question or outright remove it. If there's a 2nd major error in the code, I'd close as too broad.
 
 
4 hours later…
2:26 PM
closed
 
closed
 
3:04 PM
afternoon
 
3:35 PM
evening people , i am in need of some clarification about bytes and stuff.
can anybody help me?
 
@UbdusSamad shoot your question
 
Ove there i have a basic image manipulation code
what i want from it is to be able to do this thing with any kind of file and not just text.
but when i read a file in 'rb' mode , diffrent types of files come in differnt format and not just plain hex code that i can convert to binary and write it to my image (e.g. ELF stuff in .out files and PNG stuff in image files etc.)
 
Well, you iterated over the string and converted each character to a number. When you work with bytes, all of that happens automatically - iterating over a bytes string will yield integers. So basically just set z to a byte string, and remove the ord around the i
 
my question is how can i get these files to go directly into raw binary format , then write them to my image , and read and restore them back from my image
@Aran-Fey i tried that but ran into some truble and dicarded this theory of mine , i guess i should try again.
 
long_array = []
with open('your_file.whatever', 'rb') as z:
    for i in z.read():
        long_array += list(map(int,list(format(i, '#010b')[2:])))
 
3:50 PM
and how would i read the data back given i have a array of 8 bit array?
 
That reminds me. I should update this to Python 3 some day...
 
That I do not know. I have no idea how your code actually hides the data.
 
4:05 PM
Thanks anyway for your help.
 
 
1 hour later…
DSM
5:21 PM
@Kevin, @AndrasDeak: while it doesn't affect the approach, only the size of the resulting number, the paper whlch provided the source of the exp(exp(15)) constraint I used when we were talking about primes and 9s has a flaw. It appears the correct known bound is actually more like exp(exp(33.2)), which is way bigger.. #details
 
6:16 PM
Hey, is pip safe to install stuff willy-nilly on mac?
 
On ubuntu, it's supposed to install with --User (or whatever flag) by default, as I understand it, I'm not sure what the state is with IOS.
 
6:45 PM
@DSM same ballpark inside the function so doesn't matter ;)
@AaronHall that's because it's either --user or sudo (or virtualenv). pip can always lead to arbitrary code execution, so run it with whatever permissions you trust it with.
as I understand nothing stops a non-sudo pip install --user from erasing your home directory anyway
which is also why typosquatting is a thing
 
I guess that's another issue, I'm mostly concerned about plain pip versus conda or virtualenvs
 
weekend cabbage
 
regardless, point is moot as I left the meetup and went home... I really hate tutorials that start with pip install.
noobs who know next to nothing about Python just start blindly following them...
 
so me...
 
@AndrasDeak you here?
 
6:52 PM
@Kevin and now I reach an existential crisis...I will have to take a week off of my real job to reconsider my life choices that got me to this point...and since I have time off, I can answer even more questions on SO!
 
@Code-Apprentice could you explain something to me I know im missing something obvious
 
don't ask to ask...just ask
 
what Code Apprentice said.
 
Okay so the math or object of the function is not important, but someone needed to solve this recursion problem so I looked into it , my question is this
def get_squares(num, lista):
    if num in (1, 0):
        lista.append(num)
        print(lista)
        return lista
    else:
        lista.append(pow(num, 2))
        num -= 1
        get_squares(num, lista)

number = int(input('Enter a number: '))
print(get_squares(number, []))
why if i print(lista) it exists but when i return it , its none
 
6:55 PM
Because your else branch doesn't return anything.
return get_squares(num, lista)
 
But it only ever returns once 1 is hit , i didnt think there would be a condition where it would ever retrun in the else block
ohhhhh wait a second i see
ty ty
 
@vash_the_stampede When you return what?
 
@Code-Apprentice it was solved, I overlooked that I was just calling the function in the else block not returning the function for the recursion
 
recbg
 
7:04 PM
@AnttiHaapala rerecbg
 
 
1 hour later…
8:31 PM
@vash_the_stampede Not returning the result of a function only works for functions that don't return a value - None is returned implicitly.
 
@AaronHall aware it was an oversight, ty appreciate it
 
That includes recursive functions. That doesn't mean the recursion doesn't happen... you can recurse without returning anything explicitly...
 
9:15 PM
@vash_the_stampede am now, for a short while
 
issue resolved ty
 
OK :)
 
10:09 PM
... credit where it's due, vash here has some motivation into answering stuff
 
10:19 PM
new users with such enthusiasm often run the risk of becoming rep farmers (hence my occasional guiding remarks)
 
That commit message looked really weird on first glance.
 
what on earth are condcoms
How come WeakKeyDictionary has a big fat warning about iteration and an iteration guard? Something's fishy
 
10:42 PM
I think originally the idea was that you were supposed to use keys/values/items instead of iteration, then they put in the guard when they realized the dict API changes invalidated the old option, but they forgot to fix the docs.
 
Sounds plausible.
Boy do I hate reading stdlib code. No comment explaining why there's a function being created and assigned to self._remove in the __init__ method.
 

« first day (2913 days earlier)      last day (2035 days later) »