Possibly a stupid question: Why can't I set an environment variable with this?
os.system('set foo=bar') # on windows
I'm aware of os.environ, and that works for me. I'm just confused about why the former doesn't work.
...
Hi all,
I have a plot of two boxplots in the same figure. Due to style reasons, the axis should have the same length, so that the graphic box is squared.
I tried to use the set_aspect method, but the axis are too different by means of range
and the result is terrific.
Is it possible to have 1:1 axis even if they have not the same numbe...
This question is even harder today because I haven't had any luck using the search function on the Sphinx homepage today.
I have a group of modules that I want to be documented from the docstrings. However, these are not pure Python scripts. They won't compile as is, because they are run from a C# application that creates a new variable...
I'm developing an application using SQLAlchemy and wxPython that I'm trying to keep distributed in separated modules consisting of Business logic, ORM and GUI.
I'm not completely sure how to do this in a pythonic way.
Given that mapping() has to be called in orther for the objects to be used, I thought of putting it on the __init__.py ...
What is the cleanest and most Pythonic way to get tomorrow's date? There must be a better way than to add one to the day, handle days at the end of the month, etc.
...
Once you have learned the basic commands in Python, you are often able to solve most programming problem you face. But the way in which this is done is not really Python-ic.
What is common is to use the classical c++ or Java mentality to solve problems. But Python is more than that. It has functional programming incorporated; many libra...
I am trying to display search result data quickly. I have all absolute file paths for files on my network drive(s) in a single, ~50MB text file. The python script makes a single pass over every line in this file [kept on the local drive] in a second or less, and that is acceptable. That is the time it takes to gather results.
However, ...
Is it considered bad form to raise exceptions within __init_? If so, then what is the accepted method of throwing an error when certain class variables are initialized as None or of an incorrect type?
...
I need to check the dimensions of images in a directory. Currently it has ~700 images.
I just need to check the sizes, and if the size does not match a given dimension, it will be moved to a different folder. How do I get started?
...
I'm trying to enforce a time limit on queries in python MySQLDB. I have a situation where I have no control over the queries, but need to ensure that they do not run over a set time limit. I've tried using signal.SIGALRM to interrupt the call to execute, but this does not seem to work. The signal gets sent, but does not get caught until ...
My goal is to come up with a portable urllib2 solution that would POST a form and then redirect the user to what comes out.
The POSTing part is simple:
request = urllib2.Request('https://some.site/page', data=urllib.urlencode({'key':'value'}))
response = urllib2.urlopen(request)
Providing data sets request type to POST. Now, what I su...
Typical performance of Python scripts are about 5 times faster than PHP. What are the advantages of using faster server side scripting languages? Will the speed ever be felt by website visitors? Can PHP's performance be compensated by faster server processors?
...
I have some code where instances of classes have parent<->child references to each other, e.g.:
class Node(object):
def __init__(self):
self.parent = None
self.children = {}
def AddChild(self, name, child):
child.parent = self
self.children[name] = child
def Run():
root, c1, c2 = Node(), Node(), Node()
root.AddC...
I've seen some comparisons between Smalltalk and Ruby on the one hand and Ruby and Python on the other, but not between Python and Smalltalk. I'd especially like to know what the fundamental differences in Implementation, Syntax, Extensiabillity and Philosophy are.
For example Python does not seem to have Metaclasses. Smalltalk has no ...
def create_thumbnail(f, width=200, height=100):
im = Image.open(f)
im.thumbnail((width, height), Image.ANTIALIAS)
thumbnail_file = StringIO()
im.save(thumbnail_file, 'JPEG')
thumbnail_file.seek(0)
return thumbnail_file
It seems that my error is "IOError: cannot identify image file"...based on my traceback log....
Hi,
Just installed and configured mod_python 3.2.8 on a CentOS 5 (Apache 2.2.3) server with Python 2.4.3. It is loaded fine by Apache.
I activated the mpinfo test page and it works. So I wrote a simple "Hello World" with the following code:
from mod_python import apache
def handler(req):
req.content_type = 'text/plain'
req.wr...
Hi all,
This is partially a theoretical question:
I have a string (say UTF-8), and I need to modify it so that each character (not byte) becomes 2 characters, for instance:
"Nissim" becomes "N-i-s-s-i-m-"
"01234" becomes "0a1b2c3d4e"
and so on.
I would suspect that naive concatenation in a loop would be too expensive (it IS the bo...
I've been trying to get this working, but for some reason it's giving me errors...
How can I log my python errors?
try:
pass #CODE HERE
except:
pass #LOG TRACEBACK ERROR ...whatever that error may be
...
Hi all
Since our entire build system is written in Python, I'm wondering if there is anything like Sprouts that I could leverage to integrate Flex builds / development into our codebase?
Sprouts looks nice and all, but I don't want to introduce another build-time dependency to our projects (namely Ruby).
Thanks
...
I am about to learn Python and was wondering what is recommended, learning python 2.6 or 3.1? (any tips on learning python is welcomed as well =)
edit: Is the difference really big between the two? If I learn python 2 will i have trouble learning python 3?
...