python

Howto change Pythonpath in Python 3

I am trying to switch from using Python 2.6.5 to using Python 3.2a2. I am using OSX 10.6.4. However, when I open Idle in the Python 3.2a2 folder it cannot import any of the modules I installed to Python 2.6.5. Is there a way that I can share the same folders on Python 3.2a2 ? ...

Installing VPython in Snow Leopard?

So, i've just startet university, and we have to install python. Thats fine, cause it's build-in to OSX (Snow Leopard). I have installed matplotlib, numpy and scipy using this : http://stronginference.com/scipy-superpack/ It works perfectly, and i don't have to install the python.org version. But, now we have to install VPython, wich req...

Is it possible to check if an email contains an attachement just from the e-mail header?

I am developing an email client in Python. Is it possible to check if an email contains an attachement just from the e-mail header without downloading the whole E-Mail? ...

How to display outcoming and incoming SOAP message for ZSI.ServiceProxy in Python (version 2.1)?

Couple months ago I have asked the same question but in the context of older version of ZSI (http://stackoverflow.com/questions/1497038/how-to-display-outcoming-and-incoming-soap-message-for-zsi-serviceproxy-in-python). Now, in the new version of ZSI 2.1 there is no tacefile parameter). I tried to find a documentation for the new version...

Is there an app to create UML from django models ?

Epydoc doesn't work with django models because it needs django settings to be imported and I manage.py graph_models generate some unreadable outputs. Is there some tool to do that? ...

problems using observer pattern in django

I'm working on a website where I sell products (one class Sale, one class Product). Whenever I sell a product, I want to save that action in a History table and I have decided to use the observer pattern to do this. That is: my class Sales is the subject and the History class is the observer, whenever I call the save_sale() method of th...

Question regarding regex and tokenizing

I need to make a tokenizer that is able to English words. Currently, I'm stuck with characters where they can be part of of a url expression. For instance, if the characters ':','?','=' are part of a url, i shouldn't really segment them. My qns is, can this be expressed in regex? I have the regex \b(?:(?:https?|ftp|file)://|www\.|ft...

Multiprocess conditional/named Lock

In a multiprocess program I want to lock certain function based on arguments e.g. def calculate(spreadsheet): _do_calc(spreadsheet) Now what I want to do is based on spreadsheet, lock the function so that multiple spreadsheets can be worked on concurrently but two calls on same spreadsheet will lock e.g. def calculate(spreadsheet...

python multidimensional list.. how to grab one dimension?

my question is, is I have a list like the following: someList = [[0,1,2],[3,4,5],[6,7,8]] how would I get the first entry of each sublist? I know I could do this: newList = [] for entry in someList: newList.append(entry[0]) where newList would be: [0, 3, 6] But is there a way to do something like: newList = someList[:][0]...

Why does 0.1+0.1+0.1-0.3 results in 5.55111512313e-17?

Possible Duplicate: How is floating point stored? When does it matter? I was wondering what's the reason for the next behavior in Python: >>> print(0.1 + 0.1 + 0.1 - 0.3) 5.55111512313e-17 To fix that one must use decimal instead: >>> from decimal import Decimal >>> Decimal('0.1') + Decimal('0.1') + Decimal('0.1') - Decim...

send an email with python

Possible Duplicate: Receive and send emails in python I tried searching but couldn't find a simple way to send an email. I'm looking for something like this: from:"[email protected]"#email sender To:"[email protected]"# my email content:open('x.txt','r') Everything I've found is complicated really: my project doesn't need so man...

It's probably simpler in awk, but how can I say this in Python?

I have: Rutsch is for rutterman ramping his roe which is a phrase from Finnegans Wake. The epic riddle book is full of leitmotives like this, such as 'take off that white hat,' and 'tip,' all which get mutated into similar sounding words depending on where you are in the book itself. All I want is a way to find obvious occurrences of t...

How to convert unicode string like u'\\u4f60\\u4f60' to u'\u4f60\u4f60' in Python?

I capture the string from a html source file using regex: f = open(rrfile, 'r') p = re.compile(r'"name":"([^"]+)","head":"([^"]+)"') match = re.findall(p, f.read()) And I've tried: >>> u'\\u4f60\\u4f60'.replace('\\u', '\u') u'\\u4f60\\u4f60' >>> u'\\u4f60\\u4f60'.replace(u'\\u', '\u') u'\\u4f60\\u4f60' >>> u'\\u4f60\\u4f60'...

Cheetah compared with Jinja

how about cheetah compared with Jinja? ...

matplotlib: format axis offset-values to whole numbers or specific number

I have a matplotlib figure which I am plotting data that is always referred to as nanoseconds(1e-9). On the y-axis, if I have data that is tens of nanoseconds, ie. 44e-9, the value on the axis shows as 4.4 with a +1e-8 as an offset. Is there anyway to force the axis to show 44 with a +1e-9 offset? The same goes for my x-axis where the...

get_current_session returns None

I've been using geasessions for a while, been working great. It's simple and fast. But today I started a new project (GAE v1.3.7) and can't get it to work, get_current_session() just returns None I've split the code in to a new project that's just using gaesessions: from google.appengine.ext import webapp from google.appengine.ext.we...

Printing a line by updating an already outputted line

Hi everyone, Forgive me if the title is not lucid, but I could not better describe it in a single sentence. Consider I have the following in a loop, which increments counter each time it runs. output_string = 'Enter the number [{0}]'.format(counter) When I do a print output_string, the output goes like: Enter the number [1]: Whe...

Why does the tkinter progress bar makes things so much slower?

Hello, I have the following code for extracting a tar.gz file whilst keeping tabs on the progress: from __future__ import division import tarfile import os theArchive = "/Users/Dennis/Instances/atlassian-jira-enterprise-4.1.2-standalone.tar.gz" a = tarfile.open(theArchive) tarsize = 0 print "Computing total size" for tarinfo in a: ...

django-markitup editor passes empty POST

Hi everyone, I am a total newbie and this is my first post at stackoverflowew although I have found a lot of good info while learning python. I am trying to get this to work since days and I get more and more fustrated. I will try to include as much info as i think is needed. Your hints for debugging this will be appreciated. The edito...

Python: gettext doesn't load translations on Windows

This particular piece of code works very well on Linux, but not on Windows: locale.setlocale(locale.LC_ALL, '') gettext.bindtextdomain('exposong', LOCALE_PATH) gettext.textdomain('exposong') Code from here Even if i specify the locale in locale.setlocale (I tried different formats) it doesn't work. One problem might be that the loca...