Is there a common pattern for propagating details of both errors and warnings? By errors I mean serious problems that should cause the flow of code to stop. By warnings I mean issues that merit informing the user of a problem, but are too trivial to stop program flow.
I currently use exceptions to deal with hard errors, and the Python l...
I've written a class in python that I want to wrap into a .net assembly via IronPython and instantiate in a C# application. I've migrated the class to IronPython, created a library assembly and referenced it. Now, how do I actually get an instance of that class?
The class looks (partially) like this:
class PokerCard:
"A card for pl...
What is an easy way in Python to format integers into strings representing thousands with K, and millions with M, and leaving just couple digits after comma?
I'd like to show 7436313 as 7.44M, and 2345 as 2,34K.
Is there some % string formatting operator available for that? Or that could be done only by actually dividing by 1000 in a l...
I'm looking into supporting HTTP/1.1 Byte serving in WSGI server/application for:
resuming partial downloads
multi-part downloads
better streaming
WSGI PEP 333 mentions that WSGI server may implement handling of byte serving (from RFC 2616 section 14.35.2 defines Accept-Range/Range/Content-Range response/request/response headers) and...
Does somebody know how "modular" is Django? Can I use just the ORM part, to get classes that map to DB tables and know how to read/write from these tables?
If not, what would you recommend as "the Python equivalent of Hibernate"?
...
In Python, I've seen the recommendation to use holding or wrapping to extend the functionality of an object or class, rather than inheritance. In particular, I think that Alex Martelli spoke about this in his Python Design Patterns talk. I've seen this pattern used in libraries for dependency injection, like pycontainer.
One problem t...
Hey there, I'm kind of new to Python and I'm trying to make a basic application that builds a string out of user input then adds it to the win32 clipboard. I'm having a problem passing the string to the clipboard.
What am I doing wrong?
Here's my code example:
http://codepad.org/aQlvPIAj
...
I am doing some prototyping for a new desktop app i am writing in Python, and i want to use SQLite and an ORM to store data.
My question is, are there any ORM libraries that support auto-generating/updating the database schema and work with SQLite?
...
I am using a C++ SDK where there is a function like (it has a python wrapper, but not docs):
getPos ( int uvId, float & u, float & v ) const
How do I specify in Python so that the passed variables are changed?
I tried this example to see if I could modify floats inside a function, but it didn't work, so printed 12.0:
def change ( a ...
Is there a more concise way of doing this in Python?:
def toDict(keys, values):
d = dict()
for k,v in zip(keys, values):
d[k] = v
return d
...
The program is supposed to take user input, turn it into html and pass it into the clipboard.
Start the program with welcome_msg()
If you enter 1 in the main menu, it takes you through building an anchor tag. You'll add the link text, the url, then the title. After you enter the title, I get the following errors:
File "<pyshell#23>", ...
for i in range(0,3):
j = 0
print 'incrementing '
j += 1
print j
prints
incrementing
1
incrementing
1
incrementing
1
How can I persist the value of 'j' so that it prints:
1
2
3
...
Hi,
Last time I asked a similar question but that was about svn related versioning info. Now I am wondering how to query windows "File version" attribute about eg. a dll. I payed attention to wmi and win32file modules as well without success. Thanks U in advance.
D.
...
I've got a fairly large string (~700k) against which I need to run 10 regexes and count all the matches of any of the regexes. My quick and dirty impl was to do something like re.search('(expr1)|(expr2)|...'), but I was wondering if we'd see any performance gains by matching in a loop instead:
In other words, I want to compare the perf...
Good morning.
As the title indicates, I've got some questions about using python for web development.
What is the best setup for a development environment, more specifically, what webserver to use, how to bind python with it. Preferably, I'd like it to be implementable in both, *nix and win environment.
My major concern when I last ...
I'm working on an multiplatform application with wxpython and I had flickering problems on windows, while drawing on a Panel.
I used to draw on a buffer (wx.Bitmap) during mouse motions events and my OnPaint method was composed of just on line:
dc = wx.BufferedPaintDC(self, self.buffer)
Pretty standard but still I had flickering probl...
I am trying to numerically integrate an arbitrary (known when I code) function in my program
using numerical integration methods. I am using Python 2.5.2 along with SciPy's numerical integration package. In order to get a feel for it, i decided to try integrating sin(x) and observed this behavior-
>>> from math import pi
>>> from scipy....
What is the correct way to initialise a python object into already existing memory (like the inplace new in c++)
I tried this code however it causes an access violation with a debug build because the _ob_prev and _ob_next are not set..
//PyVarObject *mem; -previously allocated memory
Py_INCREF(type);
//couldnt get PyObject_HEAD_INIT o...
In python we can ..
a = 5
if a == 5:
pass #Do Nothing
else:
print "Hello World"
I wonder if it a similar way to do this in C#
...
I need to create a folder that I use only once, but need to have it exist until the next run. It seems like I should be using the tmp_file module in the standard library, but I'm not sure how to get the behavior that I want.
Currently, I'm doing the following to create the directory:
randName = "temp" + str(random.randint(1000, 999...