I am slowly but surely teaching myself Python. I learn best by doing. I'm looking for some neat system productivity kind of procedures that I could try making that you have found useful for yourself. Some of the modules I've successfully made and use are like these:
Zip a folder
Zip a whole set of folders to an archive as an automat...
I want to process uploaded photos with PIL and determine some "soft" image metrics like:
is the image contrastful or dull?
colorful or monochrome?
bright or dark?
is the image warm or cold (regarding light temperature)?
is there a dominant hue?
the metrics should be measured in a rating-style, e.g. colorful++++ for a very colorful ph...
I'm trying to test my Django apps which run on a postgis database, by following this doc:
http://docs.djangoproject.com/en/dev/topics/testing/
Normally I create a new database by copying a template:
(as user postgres)
createdb -T template_postgis -O lizard test_geodjango2
When I run ./manage.py test, I get the following mess...
How can I make a "keep alive" HTTP request using Python's urllib2?
...
If I do this:
def foo():
a = SomeObject()
Is 'a' destroyed immediately after leaving foo? Or does it wait for some GC to happen?
...
Hello.
Python has a lot of gui librarys: tknter, wxWidgets, pyGTK etc. But all this gui needs to be installed and quite heavyweight, so it's a bit complex to deploy end-user gui python apps that relay on mentioned gui librarys.
Recently, i have thinked about python build-in ctypes. Theoretically, it's possible to create pure python gui...
Hi,
I am just about to find out how python and gnuplot work together. On
http://wiki.aims.ac.za/mediawiki/index.php/Python:Gnuplot_module
I found an introduction and I wanted to execute it on my Ubuntu machine.
import Gnuplot
gp = Gnuplot.Gnuplot(persist = 1)
gp('set data style lines')
data1 = [[0, 0], [1, 1], [2, 4], [3, 9],...
Hi everyone!
I have a simple "Invoices" class with a "Number" attribute that has to
be assigned by the application when the user saves an invoice. There
are some constraints:
1) the application is a (thin) client-server one, so whatever
assigns the number must look out for collisions
2) Invoices has a "version" attribute too, so I can't...
Hello,
My scenario is as follows: I have a table of data (handful of fields, less than a hundred rows) that I use extensively in my program. I also need this data to be persistent, so I save it as a CSV and load it on start-up. I choose not to use a database because every option (even SQLite) is an overkill for my humble requirement (al...
Hi
I have a many-to-many relationship in my django application where I use the "add" method of the manager pretty heavily (ie album.photos.add() ).
I find myself needing to store some data about the many-to-many relationship now, but I don't want to lose the add method. Can I just set a default value for all the additional fields on th...
I have some some data that I would like to visualize. Each byte of the source data roughly corresponds to a pixel value of the image.
What is the easiest way to generate an image file (bitmap?) using Python?
...
Here is a screen where I should point the Wing IDE to my python files. I am using IronPython.
Am I assuming correctly that textbox one gets filled with ipy.exe ? (proper path provided)
What should be in the rest of the boxes ?
...
Hi,
url = 'abcdc.com'
print url.strip('.com')
Expect: abcdc
Resut: abcd
Now I do
url.rsplit('.com', 1)
Is there a better way..
...
When I run pyflakes on a Zope Filesystem Directory View file (as are found a lot in plone) it always returns lots of warnings that my parameters and special values like 'context' are not defined, which would be true if it were a real python script, but for a Filesystem Directory View script, they are defined by magic comments at the top,...
What would be the most pythonic way to schedule a function to run periodically as a background task? There are some ideas here, but they all seem rather ugly to me. And incomplete.
The java Timer class has a very complete solution. Anyone know of a similar python class?
...
Suppose I have a socket. What is the difference between these two lines of code?
line 1:
os.read(some_socket.fileno(), 1024)
line 2:
some_socket.recv(1024)
...other than the fact that the first one doesn't work on Windows. In other words, can I substitute the second line for the first one? I've got a codebase that hasn't really...
Trying to remove all files in a certain directory gives me the follwing error
OSError: [Errno 2] No such file or directory: '/home/me/test/*'
The code I'm running is
import os
test = "/home/me/test/*
os.remove(test)
...
Echoing my other question now need to find a way to crunch json down to one line: e.g.
{"node0":{
"node1":{
"attr0":"foo",
"attr1":"foo bar",
"attr2":"value with long spaces"
}
}}
would like to crunch down to a single line:
{"node0":{"node1":{"attr0":"foo","attr1":"foo bar","attr2":"value...
I'm using the ConfigParser to read the configuration information stored in a file. I'm able to read the content and use it across other modules in the project. I'm not sure if the configuration file is read every time I call config.get(parameters). How can I make sure that the configuration information is read only once and rest of the t...
I want to disable "return" from printing any object it is returning to python shell.
e.g A sample python script test.py looks like:
def func1():
list = [1,2,3,4,5]
print list
return list
Now, If i do following:
python -i test.py
>>>func1()
This always give me two prints on python shell.
I just want to print and get re...