I have a class with two class methods (using the classmethod() function) for getting and setting what is essentially a static variable. I tried to use the property() function with these, but it results in an error. I was able to reproduce the error with the following in the interpreter:
>>> class foo(object):
... _var=5
... de...
Are there any good packages or methods for doing extensive CRUD (create-retrieve-update-delete) interfaces in the Turbogears framework. The FastDataGrid widget is too much of a black box to be useful and CRUDTemplate looks like more trouble than rolling my own. Ideas? Suggestions?
...
I'd like to set a cookie via Django with that has several different values to it, similar to .NET's HttpCookie.Values property. Looking at the documentation, I can't tell if this is possible. It looks like it just takes a string, so is there another way?
I've tried passing it an array ([10, 20, 30]) and dictionary ({'name': 'Scott', 'id...
I am putting together a Samba-based server as a Primary Domain Controller, and ran into a cute little problem that should have been solved many times over. But a number of searches did not yield a result. I need to be able to remove an existing user from an existing group with a command line script. It appears that the usermod easily ...
Sometimes I find myself in the situation where I want to execute several sequential commands like such:
try:
foo(a, b)
except Exception, e:
baz(e)
try:
bar(c, d)
except Exception, e:
baz(e)
...
This same pattern occurs when exceptions simply need to be ignored.
This feels redundant and the excessive syntax causes it t...
How does one write a test that fails only if a function doesn't throw an expected exception?
...
Is there any way to get Python to use my ActiveTcl installation instead of having to copy the ActiveTcl libraries into the Python/tcl directory?
...
Please share your book or tutorial recommendations for the latest release (1.0) of Django.
...
python's time module seems a little haphazard. For example, here is a list of methods in there, from the docstring:
time() -- return current time in seconds since the Epoch as a float
clock() -- return CPU time since process start as a float
sleep() -- delay for a number of seconds given as a float
gmtime() -- convert seconds since Epo...
The Python list comprehension syntax makes it easy to filter values within a comprehension. For example:
result = [x**2 for x in mylist if type(x) is int]
Will return a list of the squares of integers in mylist. However, what if the test involves some (costly) computation and you want to filter on the result? One option is:
result...
[NOTE: This questions is similar to but not the same as this one.]
Visual Studio defines several dozen "Macros" which are sort of simulated environment variables (completely unrelated to C++ macros) which contain information about the build in progress. Examples:
ConfigurationName Release
TargetPath D:\work\foo\win\R...
I would like to find out if a particular python datetime object is older than X hours or minutes. I am trying to do something similar to:
if (datetime.now() - self.timestamp) > 100
# Where 100 is either seconds or minutes
but this obviously gives a type error. So my question is what is the proper way to do date time comparison in py...
I want my Python script to copy files on Vista. When I run it from a normal cmd.exe window, no errors are generated, yet the files are NOT copied. If I run cmd.exe "as administator" and then run my script, it works fine.
This makes sense since UAC normally prevents many file system actions.
Is there a way I can, from within a Python ...
I plan to serialize a Django model to XML when it's saved or updated. (The XML's going to be imported into a flash movie). Is it better to listen for a post_save() or pre_save() signal and then perform the serialization, or to just handle it in the model's save() methon
...
I have this code:
chars = #some list
try:
indx = chars.index(chars)
except ValueError:
#doSomething
else:
#doSomethingElse
I want to be able to do this because I don't like knowfully causing Exceptions:
chars = #some list
indx = chars.index(chars)
if indx == -1:
#doSomething
else:
#doSomethingElse
Is there a wa...
Are there any packages that provide to following:
Integration with python application with minimal dependencies (beyond existing depends we use such as wx and matplotlib)
Visual design tool to make it easier for less technical users to design their own reports
Able to work with MySQL and Oracle databases
Cross platform (Linux and Windo...
I have this Python application that gets stuck from time to time and I can't find out where.
Is there any way to signal Python interpreter to show you the exact code that he's running (somekind of stacktrace on-the-fly)?
...
I have to make a presentation at work to convince everyone why they should try coding in Python. So, I thought of taking a poll here...
What is it about Python (features, etc) over other languages that you love?
The reason I usually give is that in Python you forget about the complexities and frills of programming languages and can jus...
I would like to translate some C code to Python code or bytecode. The C code in question is what i'd call purely algorithmic: platform independent, no I/O, just algorithms and in-memory data structures.
An example would be a regular expression library. Translation tool would process library source code and produce a functionally equival...
I want a regex which can match conditional comments in a HTML source page so I can remove only those. I want to preserve the regular comments.
I would also like to avoid using the .*? notation if possible.
The text is
foo
<!--[if IE]>
<style type="text/css">
ul.menu ul li{
font-size: 10px;
font-weight:normal;
padding-...