First of all i don't have the code example on this computer, but i have an example that is quite similar.
(http://docs.python.org/library/email-examples.html)
The 4th one.
My issue lies within this bit of code
counter = 1
for part in msg.walk():
# multipart/* are just containers
if part.get_content_maintype() == 'multipart':
...
I've just started using the PythonInterpreter from within my Java classes, and it works great! However, if I try to include python modules (re, HTMLParser, etc.), I'm receiving the following exception (for re):
Exception in thread "main" Traceback (innermost last):
File "", line 1, in ?
ImportError: no module named re
How could I m...
I have a Visual Studio 2008 solution with 7 various projects included with it. 3 of these 'projects' are Web Sites (the kind of project without a project file).
I have stripped all the various Visual Sourcesafe files from all the directories, removed the Scc references in the SLN file and all the project files that exist. I deleted th...
This may seem like a dumb question, but why would you compile a python script? You can run them directly from the .py file and it works fine, so is there a performance advantage or something? I also notice that some files in my application get compiled into .pyc while others do not, why is this?
...
If I have a string such as
"17:31:51 up 134 days, 11:26, 1 user, load average: 0.22, 0.15, 0.10"
what is the best way to extract just the x3 load average values at the end? I have written a regexp that does this but is this the most efficient / fastest method?
>>> s = "17:31:51 up 134 days, 11:26, 1 user, load average: 0.22, 0.15,...
This is going to be a generic question.
I am struggling in designing a GUI application, esp. with dealing with interactions between different parts.
I don't know how I should deal with shared state. On one hand, shared state is bad, and things should be as explicit as possible. On the other hand, not having shared state introduces unwa...
Perl has the excellent module Term::ANSIScreen for doing all sorts of fancy cursor movement and terminal color control. I'd like to reimplement a program that's currently in Perl in Python instead, but the terminal ANSI colors are key to its function. Is anyone aware of an equivalent?
...
I tried overriding __and__, but that is for the & operator, not and - the one that I want. Can I override and?
...
I want to modify a few tiny details of Django's built-in django.contrib.auth module. Specifically, I want a different form that makes username an email field (and email an alternate email address. (I'd rather not modify auth any more than necessary -- a simple form change seems to be all that's needed.)
When I use autodiscover with a...
In Python, if I want my server to scale well CPU-wise, I obviously need to spawn multiple processes. I was wondering which is better (using Twisted):
A) The manager process (the one who holds the actual socket connections) puts received packets into a shared queue (the one from the multiprocessing module), and worker processes pull the ...
We are ready in our company to move everything to Python instead of C#, we are a consulting company and we usually write small projects in C# we don't do huge projects and our work is more based on complex mathematical models not complex software structures. So we believe IronPython is a good platform for us because it provides standard ...
Is it possible to have Python save the .pyc files to a separate folder location that is in sys.path?
/code
foo.py
foo.pyc
bar.py
bar.pyc
To:
/code
foo.py
bar.py
/code_compiled
foo.pyc
bar.pyc
I would like this because I feel it'd be more organized. Thanks for any help you can give me.
...
I'm doing some work on App Engine and I need to convert an XML document being retrieved from a remote server into an equivalent JSON object.
I'm using xml.dom.minidom to parse the XML data being returned by urlfetch. I'm also trying to use django.utils.simplejson to convert the parsed XML document into JSON. I'm completely at a loss as ...
In Python, when would I want to use __slots__ and when would I want to avoid it?
...
Hello friends,
I need an urgent help on importing dll.
In my Python script i m importing a dll written in vb .net.
I m callng a function of initialisation in my script.It takes 2 arguments.One path of xml file and 2nd a string.It returns an integer ,0 for success ,else error.The second argument is passed by reference.So if ...
How do I read the response headers returned from a PyCurl request?
...
Is there a way to specify a Model in Django such that is ensures that pair of fields in unique in the table, in a way similar to the "unique=True" attribute for similar field?
Or do I need to check this constraint in the clean() method?
...
I was doing the tutorial from the book teach yourself django in 24 hours and in part1 hour 4 i got stuck on this error.
Traceback (most recent call last):
File "C:\Python25\lib\site-packages\django\core\servers\basehttp.py", line 278, in run
self.result = application(self.environ, self.start_response)
File "C:\Python25\lib\s...
I created a utility function to return the expected single item from an generator expression
print one(name for name in ('bob','fred') if name=='bob')
Is this a good way to go about it?
def one(g):
try:
val = g.next()
try:
g.next()
except StopIteration:
return val
else:
...
Noob
I am trying to write a script that gives a running balance. I am messing up on the elementary declared functions of python.
I need it too:
accept a balance via input
append a list of transactions
take those out one by one in the order they were input
print a running total
use pyhtmltable to make the output in html table rea...