Create a simple class of dictionaries to make a dictionary of dictionaries. No need for generators, iterators or lambdas. Use a deck of cards for example.
There are multiple ways to do it. Some are platform dependent.The best way is probably through socket, but you can use platform and os too.
If you want to set a cell to a pixmap, ok no problem, but what about setting individual liststore values to a pixmap? You can’t do it directly unless you’re using a gtk.STOCK_ image. Here’s a way around that little problem.
You don’t need heavyweight communication layers for very simple message passing between threads in python. It’s pretty simple to use pipes and implement your own thread class.
If you like the standard window decorations and dont need/want to create your own buttons to handle custom events, closing a dialog without destroying it is a simple one-liner in pygtk. This is helpful when you have logic that replaces individual widgets inside a dialog and you don’t want to recreate the whole dialog.
If you need this, you’re probably doing it wrong. But if you really must check to see if a variable has been assigned yet, there’s nothing really stopping you. Here’s one way of implementing it.
So you want to kill a thread… Dangerous. How about asking a thread to die instead? Of course it’s unsafe to just kill a thread dead in its tracks. What if the thread has some resource acquired or is controlling other threads itself? It’s much better to communicate with a thread and tell it to stop, then just wait for it to kill itself.
I needed to encrypt some strings before sending them out over the network to another process and I don’t want to rely on another mechanism for handling the encryption, so here’s my simple AES encryption class. You can load plain text out of the vault by providing a cipher or save an encrypted message by supplying the plain text.
There are a few hidden easter eggs in python. So next time you fire up the python shell try to import hello and this. I wonder how many other hidden gems there are.
Even if you’ve only dabbled with python for a minute or two, you’ve probably already figured out that you can print variables using placeholders. You might have tried concatenation too. However, did you know you can print using %s but with the variable names directly?