« first day (2326 days earlier)      last day (2605 days later) » 

12:17 AM
cabbages
 
 
1 hour later…
1:26 AM
I found different answers on the web for this question. So I am posting it here. I have the following dictionary {1: 3, 2: 4, 3: 2}. Using for loop, I need to do logical computation with the value. I have the loop definition as for key in dict1: I want to check if value of each key is even or not. i.e. something like dict1[key].value %2 ==0. How can this be done in simple way ?
 
what have you tried?
what issues are you currently facing?
 
@ShrijanAryal Why are you doing .value? Your dict values are simple integers.
all(u%2==0 for u in dict1.values())
 
1:42 AM
Thanks I was able to solve it. I have been writing a lot of codes today. That is why I had difficulty understanding how to loop with the values of each key in my dictionary. Turned out I was doing a silly mistake.
 
 
4 hours later…
5:15 AM
recbg
 
 
1 hour later…
6:22 AM
cbg 0/
 
7:15 AM
I have an algorithmic question to sort the list by the number of occurence of each item. I started off with populating the dictionary with keys as the item in the list and value as the number of occurences of that item. Then I used another for loop to print the key "n" times where n is the number of occurences. But I am having a hard time figuring out how to sort the keys by the number of occurences.
I had the following input list: "[2,'pie', 6,-12, 'pie','pie','pie', 9, 6, 7, 9,9,9 ]". The output should have been " ['pie','pie','pie','pie', 9,9,9,9,6,6,2,-12,7]" , but now it is "[2, 6, 6, 7, 9, 9, 9, 9, 'pie', 'pie', 'pie', 'pie', -12]". The link to my code is as follows: gist.github.com/shreezan123/d843f1353d2371ca447da6eb35e969b8 . Please do not use sorting methods directly as this question did not allow importing any subclasses or using inbuilt sorting methods.
 
@wim idk what was the problem you were having, but now I am using some cookiecutter that is supposed to set up everything, and py.test doesn't work, whereas tox works :(
@ShrijanAryal you're not sorting anything
you need to sort the tuples somehow, write your own sorting method
 
I reached to a part where i grouped the similar items in the list together but they are not yet sorted according to the frequency (you may already know that but still) then i could not figure put what to afterwards. Because i thought that whatever I did would only take me round and round with no result
 
you can have tuples of (frequency, key) easily
then you'd want to sort these tuples; you'd write any sorting algorithm you can think of, in python.
that is basically the point, it is testing if you can come up with a sorting method
on your own
 
7:34 AM
@AnttiHaapala thank you. I got it. I will implement a sorting algorithm. I know merge sort. I didnot want to do it at first place because it would increase my code by atleast 30 lines.
 
that is the very point of the question
you can't sort things without sorting really
 
@ShrijanAryal Selection sort is easy to implement. Sure, it's O(n²), but it's fine for small lists. It's common for hybrid sorting functions to use an O(nlogn) sort like mergesort or quicksort for large large lists but switch to selection sort when the list size gets down to 20 or less.
FWIW, here's a recent question about sorting by number of occurrences. stackoverflow.com/questions/42394627/…
 
7:54 AM
Cabbage
 
user6845426
8:21 AM
cbg o/
 
cbg
 
8:41 AM
cabbage
We want to execute periodic tasks for the analytics jobs. Some jobs will be hourly, where as some will be daily (during midnight). Any suggestion for the tool/frameworks?
I am thinking of using Luigi. It looks promising.
Is anyone having experience with Luigi? Pros/Cons?
PS: The purpose of jobs will be to fetch the data from one DB, process the data, and save the data to another database.
 
9:01 AM
recbg
 
9:16 AM
cbg
 
I bet Guido wouldn't say that this is a great answer... stackoverflow.com/a/42481927/4014959
Python 2, using filter with a lambda instead of a proper range, operator.mul instead of int.__mul__
 
9:58 AM
>>> a = datetime.datetime(2016, 9, 4, 0, 13, 0)
>>> b = datetime.datetime(2016, 9, 4, 0, 10, 0)
>>> print(b-a)
-1 day, 23:57:00
Shouldn't it be -03:00?
Got a bit confused now
 
In [12]: from dateutil.relativedelta import relativedelta

In [15]: import datetime

In [16]: a = datetime.datetime(2016, 9, 4, 0, 13, 0)

In [17]: b = datetime.datetime(2016, 9, 4, 0, 10, 0)

In [18]: relativedelta(a, b)
Out[18]: relativedelta(minutes=+3)
The 3rd party utility seems better in this case @BhargavRao
 
Ah, yes. That class is there. Thanks. Totally forgotten python
 
@BhargavRao shame on ou
 
@AshishNitinPatil Yep, I've installed that, but I've forgotten.
@khajvah Been working on Java from 8 months. Need python for a small project. So yeah. :(
 
I am doing java too now :(
 
10:05 AM
I spent 2 mins wondering why, .trim() was not working.
 
@PM2Ring I don't understand a lot of this, it looks so complex it me D: Oh the flipped list was just a test list I used it should have been removed.
 
10:20 AM
cbg
 
anyone here using pynacl?
they have the shittiest documentation ever, and the library is not safe at all
they just decide to omit all the important stuff from the documentation.
 
10:42 AM
I want to make a Qt app with Python, but I want my window to be able to go over a full-screen YouTube movie (for note-taking), how can I achieve this effect?
 
11:01 AM
Mornin'
 
Oh, ok. Which bits don't you understand? Do you understand what nx, ny = x + dx, y + dy does?
 
@AnttiHaapala is it the pynacl of crappy development?
recbg
 
harhar
 
I gather you should take their documentation with a grain of salt.
 
11:20 AM
yes.
 
@gloriousCatnip That sounds tricky. Full-screen windows don't tend to be good at sharing the display, and the details vary depending on the OS & window manager. But I guess that Qt may provide a way to do it that handles the messy details for you, since it's a multi-platform framework. But I don't know Qt, so I can't offer any solid advice... except to suggest that you just try to make it work on a normal window, not a full-screen window. ;)
 
or, you can read the documentation, but the small print is what is important
> Alice is keeping that key all to herself. Bob can put items in the box then put the padlock onto it. But once the padlock snaps shut, the box cannot be opened by anyone who doesn’t have Alice’s private key.
@AndrasDeak ^
how do you understand that sentence :?
then one reads forward and:
> The same shared key will be generated from both pairing of keys, so given two keypairs belonging to Alice (pkalice, skalice) and Bob (pkbob, skbob), the key derived from (pkalice, skbob) will equal that from (pkbob, skalice).
 
11:48 AM
@AnttiHaapala I understood the first one quite literally
 
@AndrasDeak so compare with the second...
 
I don't know what to do about the second one, lacking domain knowledge
 
the second says: "either alice's or bob's secret key can open the message"
 
do they really refer to the same scenario?
 
11:49 AM
aren't they just two different cases_
 
they're just 3 paragraphs after each other.
 
oh, didn't read the link yet
 
and I was thinking for 10 minutes that this is the primitive that I need based on how I understood the first paragraph.
then I did some google searches and found out I was wrong...
 
OK, it doesn't say that Bob can open the box. It only says that both shared key pairings are the sme
 
@AndrasDeak yes,
but that is the key to the box :D
the key is the combination is the one public key and the other private key...
and both are symmetric for the same message
 
11:52 AM
hmmmm
I think I see what you mean, and it doesn't sound safe to me at all.
but wait
I guess the point is that Bob knows what's in the box anyway?
and Bob can't open boxes closed by Alice+Cecil
 
morning
 
then again this might imply that the encryption is weakened compared to the case where only Alice can open it...
@Xitas hi
 
I just started learning python please guide me how to understand it better
 
i am tutorial from here
 
11:57 AM
I just tried to guide you how to understand it better
the official tutorial is actually really good, if you already know programming (which you seem to)
 
can you recommend me good site for python
 
seriously?
 
@AnttiHaapala I just read the docs, and I see what they're doing, but that quoted sentence is misleading.
 
1 min ago, by Andras Deak
 
that's a link ^
 
11:58 AM
@AndrasDeak thanks
 
@PM2Ring The skalice with the palace...
 
:)
Bob can use Box(skbob, pkalice) to send a signed message to Alice via its encrypt method, or to receive a signed message from Alice, via its decrypt method. Similarly, Box(skalice, pkbob) can decrypt a message from Bob, or encrypt a message to send to Bob. However, it's not possible to compute either of the (skalice, pkbob) keys given (skbob, pkalice), or vice versa.
 
leans back and feels smug Backup solution tested in real life. Everything worked.
 
@IntrepidBrit *pats on back*
 
Morning all
 
12:08 PM
Better than the last time when I lost all my photographs, university work and startup backups
 
OR, indeed, afternoon as I have just noticed it is here.
 
The core of RSA is pretty easy to understand if you're familiar with Fermat's Little Theorem. See en.wikipedia.org/wiki/RSA_%28cryptosystem%29#Operation
 
cbg, @JRichardSnape :)
 
Cabbage @prof
 
@PM2Ring I've always thought that key exchange is the bit that people don't really get. I'm not quite sure why.
@AndrasDeak cbg (and cbg(@Bhargav))
 
12:15 PM
SyntaxError: invalid syntax
 
fair enough (True and cbg(@Bhargav))
 
Yep, Now my mind could parse the message
 
So, what's new? Apart from the top bar on the main site.
 
@JRichardSnape "To enable Bob to send his encrypted messages, Alice transmits her public key (n, e) to Bob via a reliable, but not necessarily secret route. The private key d is never distributed." The tricky bit is making the public key distribution reliable. You don't want Eve impersonating Alice and giving out her own public key claiming it's Alice's.
 
@PM2Ring exactly - that "reliable" covers a nest of confusion for many people.
 
12:22 PM
the only reason I'm not confused is that I don't go near crypto because it's hard:P
 
Also a valid position
 
And it works because I don't talk to people so I don't need to send secret messages;D
 
Excellent choices. Talking to people is overrated.
 
<people, what a bunch of bastards .mpg>
 
I can expand a tuple with an asterisk in Python 3.5, is there a similar shortcut for versions < 3.5?
 
12:34 PM
It's good to know a little bit about crypto. I'm certainly not advocating rolling your own crypto, but it's good to have some background info in order to use existing crypto programs and libraries intelligently. But of course, most people, even most programmers don't even need to do that - programs that use crypto (eg browsers accessing https sites) can handle all the details invisibly.
 
@RichardDunn depends on where you want that, but the likely answer is "no". Do you have a specific example case where you'd need it? There'll be other options.
 
@RichardDunn Only in the context of argument passing.
 
@PM2Ring it's a good thing all those implementations in the background are flawless:D
 
@AndrasDeak I'm passing some tuples as arguments, but I want to append a value to the end of the tuple first, so I'm expanding them, adding the value, and casting as a tuple again: someFunc( (*item['release'], type_id) )
 
item['release'] + (type_id,)
 
12:38 PM
But one of the servers I'm using doesn't have 3.5, and it's just easier to make this non 3.5 specific
 
haven't I told you this 2 days ago?
 
No, we discussed the * option, but I didn't think I'd have to support older versions at the time.
 
yesterday, by Richard Dunn
if i have a tuple T and a var V, and i want to pass the values of both into a function as a single tuple, with the value of V as the last element, is this the correct syntax? somefunc( (*T, V) )
yesterday, by Andras Deak
or somefunc(T+(V,)) ?
 
@AndrasDeak Well, knowing the technical details of the flaws doesn't help you avoid those flaws, and until the flaws are exposed the crypto experts are no better (or worse) off than those who are ignorant of crypto mechanics. ;)
 
Oh, I didn't remember that comment... THanks
 
12:39 PM
@Richard you're actually looking at concatenation
your 3.5 version is pretty abusive for this
 
What do you mean by abusive?
 
that I don't think it's meant to be used like that
python prefers clarity, so if you want to concatenate tuples, use concatenation
but maybe it's just me
@PM2Ring sure, I just noted that we rely a lot on these underlying systems, which is only terrifying when you think about it or when a new fundamental vulnerability is revealed:D
 
Are both methods not going to just create a new tuple?
 
not in python 3.4 :P
 
really?!
lol
 
12:43 PM
@AndrasDeak Understood. The crypto guys have a saying: it's rare to be able to prove that a crypto algorithm is perfectly safe, usually the best you can do is to say that no one has yet succeeded in proving it unsafe.
 
Yup...and it's understandable. If we were to rely on provably safe systems, we would have to talk 1-to-1 in person :P
 
@AndrasDeak I think (*T, V) is fairly clear, but at this stage T+(V,) is more readable due to familiarity. I guess it'd be interesting to do a speed test. I suspect the new way is slightly slower, since it has to split T before it can build the new tuple.
 
dunno
and I could quickly make sense of the unpacking version if I had to
 
@AndrasDeak not my function to define...
 
nevermind anyway, it was stupid
 
12:48 PM
I can't be bothered writing a proper timeit test right now, but maybe some kind person with ipython could do a quick timing test... :)
 
@PM2Ring no, this is again wrong
@PM2Ring this is not RSA.
@PM2Ring skbob+pubalice can decrypt a message encrypted to skalice+pubbob
 
In [1]: %timeit (*tuple(range(10000)),'last')
1000 loops, best of 3: 279 µs per loop

In [2]: %timeit tuple(range(10000))+('last',)
1000 loops, best of 3: 240 µs per loop
 
so it means, if bob leaks private key, that key can be used to open every message that bob has sent to anyone.
> "No. That's because NaCL public key encryption is actually combining the public/private key to come up with a shared secret, and then using that shared secret as an input to a symmetric cipher. It's not actually public/private key encryption in the traditional, RSA sense."
so it is fscking broken which is ok, if documented, but the docs are fscking borken.
 
@AnttiHaapala Oh. That sounds terrible.
 
> Ah- I'm actually (sort of) wrong, there is Sealed Boxes in libsodium now which is sort of that. It's really the same thing under the covers, two key pairs generate a shared secret for a symmetric cipher, but it has baked into it the idea that the sender side is using an emphereal key that gets thrown away after one encryption operation, which means the sender never gets access to their side of the equation so they can't then decrypt it later.
 
12:52 PM
@AndrasDeak yes, but those are not implemented in the pynacl
 
doesn't that rely a bit too much on the assumption that the sender just throws away the key?
 
"PR's accepted"
 
and isn't "emphereal" meant to be "ephemeral"?
 
also I like dstufft's misspelling of ephemeral :D
kevin'd by andras.
 
\o/
 
12:53 PM
so...
they closed the bug whose point was that the documentation is misleading,
without fixing the documentation. That is pynacl for you :(
 
apparently:D
 
@AnttiHaapala I guess it's doing something similar to Diffie–Hellman
 
@PM2Ring this is the library recommended to people who are not well-versed with cryptography so that they don't fsck up their security.
 
@PM2Ring notice that in TLS certifications, one doesn't get even grade A now if the connection doesn't support perfect forward secrecy.
and now this is like... 10 years after the sender leaks the private key and their sent data can be opened, ooops.
 
12:59 PM
@AnttiHaapala So why are people using & recommending that library? :puzzled:
 
"because one can get the crypto wrong"
 
Evidently...
 
@PM2Ring I started from here: tonyarcieri.com/…
"djb’s authenticated encryption modes in NaCl: there are two authenticated encryption modes available in the Networking and Cryptography library by Daniel J. Bernstein: crypto_secretbox and crypto_box, which respectively provide symmetric and pubkey modes of encryption and integrity checking."
In cryptography, Curve25519 is an elliptic curve offering 128 bits of security and designed for use with the elliptic curve Diffie–Hellman (ECDH) key agreement scheme. It is one of the fastest ECC curves; it is not covered by any known patents, and it is less susceptible to weak random-number generators. The reference implementation is public domain software. The original Curve25519 paper defined it as a Diffie–Hellman (DH) function. Daniel J. Bernstein has since proposed that the name Curve25519 be used for the underlying curve, and the name X25519 for the DH function. == Mathematical pr...
 
1:54 PM
Just-getting-over-the-shingles cabbage, all
 
Hi, @holdenweb. That sounds painful.
 
Here's to good health. You can't see it, but I'm raising my soda can in a toast right now.
 
It is, not going to lie. But I am back in the office after a week off work. The pain doesn't go away with the lesions, sadly, so I could be in for a long haul
|Imagine someone has smacked you on the head with a cricket bat, and the bruising has started to appear. Feels like that all the time, and is VERY sensitive to touch of any kind.
Anyway, enough of the gory details
 
@holdenweb Does an icepack help?
 
The last time I had a stomach virus, I resolved to have greater appreciation in the moment for times when I'm not ill. So every once in a while when I'm worried about something, I think "but at least I'm not barfing right now, so I've got that going for me"
I guess that point of view can also work if you're still ill but barfing is not one of the symptoms.
On the other hand, when one is in a particular state of mind, one can hear "it could be worse" and interpret it as "you are not entitled to sympathy because your suffering isn't at the theoretical maximum", which is... Not conducive to healing.
 
2:12 PM
morning everyone
 
2:24 PM
The majority of my Stack Overflow and GitHub contributions is the phrase "Please include a minimal, complete, and verifiable example." ;_;
7
cabbage all
 
\o cbg
 
o/ folks
 
I finally fixed that Flask-SQLAlchemy tablename bug, only took me all weekend to actually understand it. github.com/mitsuhiko/flask-sqlalchemy/pull/467
Now it's time to write up a changelog and release 2.2. Didn't want to do it last night before bed, I still remember what happened last time I tried that.
 
@davidism why don't you just make a davidism bot?
 
@PM2Ring Wouldn't go near it with an ice pack - it would increase the jangling by about 400%
 
2:31 PM
Ah, rightio. I was thinking it would make it numb if it got cold enough
 
@holdenweb get well soon.
 
DSM
Morning cabbage.
 
@DSM \o cbg but :-(
 
Speaking of good health, it's easter candy season, which coincides with my loss of self control at the sign of jelly beans
 
DSM
@MooingRawr: yeah. Three years now. :-(
 
2:35 PM
Felt like we were within reach but got poked away from us :-( oh well one point is one point....
 
DSM
How can it be Easter candy season?! Lent hasn't even started! I mean, I could understand eating a lot of ice cream and pancakes tomorrow, but still.
 
As soon as the leftover valentine's candy is sold out, it's time to restock with more candy. Thus, easter candy season.
 
DSM
I suppose since we have Halloween just after back-to-school sales close or whatever I shouldn't be surprised.
 
I've noticed I've been in "I shouldn't eat this, but it is a special occasion..." mode since October. Halloween + Christmas + New Year's + Valentine's Day + Easter is a true gastro gauntlet.
sprinkle in a liberal number of birthday parties to fill in the gaps. A lot of the Kevinson family are winter babies.
 
What about thanksgiving day ? does it not get a special call out ?
 
2:38 PM
Ah, yes. I forgot about it since I spent half of it in a food coma ;-)
Actually I usually don't pig out on Thanksgiving. I'm far more susceptible to candy than I am to big meals.
 
Hey, anybody here know about Tkinter? I'm having a problem rn
 
@ZeroFunter sopython.com/chatroom read the rules, just ask the question
 
I have a tk.Tk() which is a root window and at some point I call root.focus_get() and compare if it's equal to None
If it is, I do something else
Well at some point, this statement returns an error
Traceback (most recent call last):
File "C:\Users\User\Desktop\PythonPrograms\chatpack_4.1\chatclient_4.5.5.py", line 131, in update_display
print root.focus_get()
File "C:\Python27\lib\lib-tk\Tkinter.py", line 538, in focus_get
return self._nametowidget(name)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 1196, in nametowidget
w = w.children[n]
KeyError: 'None'
Which I can't understand why I get, and I can't find much online either
 
My only guess is that something is funky in either your root or something hooked up to root. KeyError: None implies that something is None when it shouldn't be. I'd open it up in PDB and start inspecting root
 
Yeah, it seems like there's a dictionary named children in tkinter's code
And at some point there's no Key "None" in there
 
2:44 PM
How would you characterize the state of your windows when this error occurs? Does everything look normal? Or does it only happen when the user does something out-of-the-ordinary, e.g. like close a window before finishing whatever operation it's used for?
 
cabbage it.....cabbage it good
 
Well, it's actually a chat programme
So, the user keeps sending messages
And his own messages are sent to the server and return back to the user, after which they're printed out
 
@idjaw cbg \o. how was your weekend
 
fantastic. Was up north
 
If the user starts spamming
 
2:46 PM
relaxing
 
After a while, this occurs
And the messages stop being printed out, but the other thread which sends the data keeps sending them
It's just like everything in the window freezes after the error occurs
What's weird to me is that all I do is check if root.focus_get() == None
If it isn't, it simply shouldn't go forward in the statement, I don't see why it throws an exception
 
DSM
That error message is a little odd. KeyError: 'None' is the error you get from checking for the string 'None', not the singleton None.
 
In my experience, Tkinter can behave strangely in the presence of threading, in particular when both threads are capable of modifying Tkinter objects. I've only found safety when exactly one thread ever communicates with Tkinter, even for non-mutating actions, like checking read-only properties.
 
You might be right. I use thread though, not threading. I just found it convenient that thread allows me to create a thread that shares everything globally with the main thread and doesn't need something like a Queue to communicate
 
Sounds like someone should have their UI thread listen for command messages from a thread safe queue and that's it
I've never used TK though, I'm going to stop talking out of my tomato now
 
2:51 PM
Well you might be right
I looked at another person's chat programme as an example to create mine
and he was using import thread;
so I used the same
Not sure if that is a good idea now
 
Is it possible that their chat program has the same bug? :)
 
@DSM Yeah it's a little non-idiomatic, which can be expected when interacting with the guts of Tcl, which isn't native Python.
I'm guessing nametowidget takes a string that uniquely identifies a window element, and retrieves the accompanying widget object. It sort of makes sense to use 'None' instead of None there, if the base Tcl implementation doesn't play nice with dynamic typing.
 
I really don't know, I'd have to download their programme and run it
 
DSM
Makes me sound glad I've kept my distance..
 
Try to cause the same error
Oh well, I just got another error by simply spamming
Seems like it's TK and threading
 
2:54 PM
@ZeroFunter Well, chatting is naturally asynchronous, so thread/threading is a natural fit. You've just got to be stringent about which threads are handling which responsibilities.
4 mins ago, by Kevin M Granger
Sounds like someone should have their UI thread listen for command messages from a thread safe queue and that's it
^This is good advice.
 
Yup I guess
But I'd have to change the entire structure of the programme now
If I were to implement something like this
 
FWIW, I just hammered a Tkinter question. I wasn't totally happy with the proposed target since all the answers just show how to fix the problem without explaining why it occurs. So I gave the OP half an hour or so to respond before hammering. stackoverflow.com/questions/42487254/…
 
Programmer problems...
 
jjj
Hi peoples, I have a question. Is it considered a good style to wrap "with" statements into functions and call those functions in the main part of your code? (I guess not, but I'm not sure)
 
FWIW there's no conclusive evidence here that threading really is the culprit behind your error. I only pointed it out as a likely cause. But for all I know you might dig deeper and find that it's all due to a misplaced parenthesis or something.
 
2:58 PM
@jjj In general sense, nope.
 
It's really weird because I keep spamming the chat and everything works fine up to a point
 
jjj
Thank you everyone
 
I don't know.
 
Then suddenly out of the blue, you get an error
 
@jjj The whole reason with statements exist is to make it shorter than try/except/finally. You would be wise to pull them out if they start getting heavily nested, though.
 
2:59 PM
And there's no specific amount of text to send before it happens
 
@jjj I'm neutral towards this. Break out your code into a function if it improves flow. Leave your code where it is if it improves flow.
 
It just happens randomly
 
It depends how you are using these context managers
how they are 'cleaning' up on __exit__
 
Could it be a tkinter internal bug?
 
DSM
I'm glad I switched windows in time to see dunderbold. :'-)
 
3:00 PM
@ZeroFunter Doubtful. The core tech is thirty years old. Not many bugs go undetected that long.
 
@ZeroFunter Well, you could try to create a MCVE that crashes in the same way to try and verify that the threading is the cause
 
I should
Actually
I found this
 
jjj
ups, I thought, I was writing a response, but I edited my answer instead. Nevermind. Thanks, everyone
 
I would have suggested an MCVE earlier, but I figured I wouldn't get one because the application involves network communication and multiple threads, which hinder "Minimal" and "Verifiable" respectively
 
It would be a PITA to totally restructure your code only to have it fail in the same way. ;)
 
Well
These two links are the closest I got to something similar
Seems to be throwing an error at that exact spot but with a different key
And the person in the link suggests this is a tkinter bug
That's why I mentioned it earlier
 
I have a suspicion that a number of unrelated problems could all exhibit their symptoms via a stack trace ending in nametowidget. Similar stack traces don't necessarily imply similar root causes.
 
Well
Anyway, I'll see how I can fix this, if I can
Another thing is
Currently I'm using the winsound library to play a notification sound in windows machines
 
I won't be so bold as to say "it definitely can't be a bug in Tkinter". Certainly if you're confident you could report a bug to the devs... Although they, too, would want an MCVE.
 
3:08 PM
Is there anything better (prefferably cross-platform) that is built-in?
 
I don't think there is a built-in sound module, no. There are modules that let you read .wav files, but not play them.
 
Alright thanks anyway
 
You can use the vlc module, just have to put the file in your project folder.
The answers on this question should help you out - stackoverflow.com/questions/20021457/playing-mp3-song-on-python
 
Would that work with pyinstaller turning it into exe later?
 
I am not sure, but yes, since it doesn't require any external dependency specifically, can't see why it should not work.
 
3:13 PM
Wouldn't it have a dependency on vlc itself?
 
Okay, thanks for the suggestion, I'll look into this
Would it? Or is it just the .py file that it needs?
 
@Kevin Yep, but I expected (as per prev suggestion) that the file needs to be included
@ZeroFunter Just the .py should do
 
If it's just the .py that is indeed convenient
 
Looks like it needs libvlc.dll on line 117. Not sure whether that's a "standard" windows dll you can expect to find on every client's machine, or what.
 
I think it's not hard to include in py2exe or pyinstaller
 
3:17 PM
Not bad. 3 upvotes in 30 seconds for a De Morgan's laws answer stackoverflow.com/questions/42489081/python-if-not
 
Unrelated: Reading Is it ok/pythonic to call another function as an optional argument?, I'm surprised that you can call a function at all inside a function definition parameter list. Somehow I was under the impression that you couldn't have arbitrary expressions there.
But looking into it, it's definitely allowed by the grammar: defparameter ::= parameter ["=" expression]
 
@Kevin I guess they'd have it if they've got VLC
 
@PM2Ring I agree. Seems like it rather defeats the purpose of bundling one's project into an executable. If you're doing that, you probably want it to run on a stranger's machine with no extra requirements.
 
never bothered to look up keyboard shortcuts in gerrit. Now that I did, I love it even more. The less I use my mouse, the better.
 
hey guys
 
3:27 PM
Greetings
 
@Kevin True. There was supposed to be a smiley on that last message, but I'm on my phone and accidentally hit return.
 
I'll just insert a smiley there using the page inspector tool... OK.
 
I suspect that the VLC.dll comprises the bulk of the VLC download , the GUI is fairly bare-bones but the CLI program can do a huge amount of stuff.
 
I like VLC. I had some encoding problems with it on my previous computer, but that was several years ago.
 
Psyching myself up is the worst part of releasing a new version. Have to convince myself I'm not forgetting anything.
 
3:34 PM
There are some elitists out there that sneer at its use, but I have no idea what their problem is.
@davidism Remember to remove your passwords and private keys from the .config files ;-)
I used to have an irrational fear that the code I was about to make public would have, like, swear words in the comments or something that I forgot about. These days I am perfectly aware of the swear words I include.
 
I'd find it a little annoying to be "forced " to install the VLC lib just to run some Python script but having no way to access the rest of its power. But I guess I'm just being old-fashioned, and people regularly waste far more bandwidth and HD space on trivial stuff these days.
 
Like, I was worried I'd get an email from the boss saying "I just reviewed your latest check-in and can't help but notice the three hundred line docstring that drunkenly describes what you really think about my managerial style"
I don't think I've ever coded while blacked out. I don't think I've ever been blacked out at all. But of course I wouldn't remember it, would I???
 
Could you remember not remembering?
 
DSM
I remember not remembering lots of things. :-(
 
@KevinMGranger Reminds me of the bit from Hitchhiker's Guide where the ship's computer detects that something has gone wrong, but can't diagnose any further because its diagnostic system isn't working. And it can't diagnose that because its backup diagnostic system isn't working either. All because a six foot diameter meteor obliterated all three components simultaneously.
 
3:42 PM
On that, note I just played "Tharsis" AKA "Cannibalism Yahtzee" this weekend. Fun game.
 
Hi everyone, i got a question: Is it possible to save Tkinter form content into a database ?
 
Yep, but I doubt that you're going to find a "batteries included" approach that does all the work automatically.
You're going to have to extract the data from the form yourself, and put the data in a database yourself.
 
@Kevin Ok, thanks !
@Kevin What's better, create a temp file and use it to fill my database or directly fill it?
 
Directly filling it, I'd say.
 
Why would you create a temp file? What's the purpose there?
 
3:47 PM
To make logs maybe
 
All other things being equal, choose the approach with fewer moving parts.
 
Ok, and after, is that possible to extract data from db to a file ?
I guess it's possible too :)
 
The answer to "is it possible to this turing complete thing in a turing complete language" is always yes, I'd say. Python is no exception
"Is it easy to" is a different question.
 
If you want diagnostic logs, it would be preferable to make it so their operation isn't necessary for the program to function. In other words, if your log file fails to get written for some reason, you'd still want the program to complete its task if able. With that in mind, it's better to insert data directly instead of writing data to a file and then inserting that
 
Ok, I know what you mean :)
Thanks a lot guys !
 
3:50 PM
It's possible to read data from, and write data to, a Tkinter form.
It's possible to read data from, and write data to, a database.
It's possible to read data from, and write data to, a text file.
Therefore, it is possible to extract data from any one of these into any other one of these.
 
seems legit, thanks <3
 
Just released Flask-SQLAlchemy version 2.2! More info here: https://github.com/mitsuhiko/flask-sqlalchemy/releases/tag/2.2
5
 
DSM
Pineapples for @davidism and co!
 
On pizza!
 

« first day (2326 days earlier)      last day (2605 days later) »