python

E-mail traceback on errors in Bottle framework

I am using the Bottle framework. I have set the @error decorator so I am able to display my customized error page, and i can also send email if any 500 error occurs, but I need the complete traceback to be sent in the email. Does anyone know how to have the framework include that in the e-mail? ...

AttributeError: 'module' object has no attribute (when using cPickle)

I am trying to load the function in a remote environment using cPickle. But I got the error "the 'module' object has no attribute ..." . Where I really stuck is the namespace has already contain that attributes , even though it fails to load Please Help import inspect import cPickle as pickle from run import run def get_source(func...

Color in python?

Possible Duplicate: Print in terminal with colors using python ? hello guys did i can do like C# in console? to make print 'hello' write hello with green color and print 'WOW am sexy' write it with red color? ...

set the implicit default encoding\decoding error handling in python

I am working with external data that's encoded in latin1. So I've add sitecustomize.py and in it added sys.setdefaultencoding('latin_1') sure enough, now working with latin1 strings works fine. But, in case I encounter something that is not encoded in latin1: s=str(u'abc\u2013') I get UnicodeEncodeError: 'latin-1' codec can't en...

how to receive a socket message with an empty data?

i have a socket client and a socket server. (the server is in python, and is synchroneous.) sometimes the clients send an empty string. i'm required to identify this situation, and return a response. with this code, the server just keeps on waiting, and the client's don't get anything in return, unless it sends something mroe "fat" ...

Is all I need the "identity url"? - OpenID

Hi folks, I'm just wondering if all I need is the identity url in order to to theoretically attach an OpenID account to a user's account. I have identity urls that look like the following: https://www.google.com/accounts/o8/id?id=YGnyuGHMUmhUI98nuhUMhu98nuN. Is this different between OpenID 1.0 and 2.0? Just in case someone asks: I'm...

comunication between python programs

I have a python program that is running as daemon on Linux I need some how send this program a signal from another python program What should I do in both this programs ? ...

python beginner syntax question

here's my code! import csv import collections import pdb def do_work(): (data,counter)=get_file('thefile.csv') b=samples_subset1(data,counter,'/pythonwork/samples_subset4.csv',1) medications_subset2(b,['BUPRENORPHINE']) def write_file(data,filename): with open(filename,'wb') as outfile: writer=csv.writer(outfile) for r...

python: if row[1].upper().find(brand)!=-1:

are these two statements equivalent? if row[1].upper().find(brand)!=-1: and if row[1].upper().find(brand): ...

Compile Error IcePy (Ice 3.3.1) : relocation against local symbol

Hello all, I have a problem when I try to build IcePy (from Ice 3.3.1) (for python 2.4.4). Compilation, testing and install of Ice itself (cpp version) is OK but when I tried to build the python interface ("py" directory) I get the following error (sorry for the truncated paths) : .../lib/python2.4/config/libpython2.4.a(abstract.o): re...

Has anyone parsed Wiktionary?

Wiktionary is a wiki dicitonary that covers many languages. It even has translations. I'd be interested in parsing it and playing with the data, has anyone does anything like this before? Is there any library I can use? (Preferable Python) ...

Best practices for doing accounting in Python

I am writing a web2py application that requires summing dollar amounts without losing precision. I realize I need to use Decimals for this, but I've found myself having to wrap every single number I get from the database with: Decimal(str(myval)) Before I go crazy adding that to all of my code, is there a better way? I'm new to Pytho...

escape characters in psycopg2

Hi, how do i escape special characters for to_tsquery in psycopg2 python? ...

IRCBot won't join a channel

Hi, I'm trying to build a very simple irc bot for now but it seems like my bot won't join the channel. Can someone point out what's wrong with the following code: from twisted.internet import reactor, protocol from twisted.words.protocols import irc class IRCProtocol(irc.IRCClient): nickname = "botnick" def connectionMade(self...

images API / Error

I'm working on a project and I used the the Images Python API . For instance in the example given in http://code.google.com/appengine/docs/python/images/usingimages.html I get an error when ever I do not upload a photo, How can I modify the code so I don't get an error when I don't post anything. thanks ...

How do I get an instance of BaseHTTPRequestHandler instantiated during request handling inside an action code?

I need to access the rfile and wfile properties of a request handler instance. AFAIK, such a handler is instantiated by the framework during request lifetime. Update: I found that rfile is accessible through request.environ['wsgi.input']. To access wfile I've do a hack with the additional line in Paste sources, httpserver.py:210: ,'wsg...

How to throw an error window in Python in Windows

What's the easiest way to generate an error window for a Python script in Windows? Windows-specific answers are fine; please don't reply how to generate a custom Tk window. ...

How to import all submodules?

I have a directory structure as follows: | main.py | scripts |--| __init__.py | script1.py | script2.py | script3.py From main.py, the module scripts is imported. I tried using pkgutils.walk_packages in combination with __all__, but using that, I can only import all the submodules directly under main using from scripts import...

Call javascript functions in IE with Python/Com

http://win32com.goermezer.de/content/view/170/291/ Tried the above. I am able to call Javascript functions declared in the html file. However, for javascript functions in external js files included in the html, I am not able to call those functions using the above method. Any work arounds for this ? ...

Python and libxml2: how to iterate in xml nodes with XPATH

I have a problem with retrieving information from a XML tree. My XML has this shape: <?xml version="1.0"?> <records xmlns="http://www.mysyte.com/foo"&gt; <record> <id>first</id> <name>john</name> <papers> <paper>john_1</paper> <paper>john_2</paper> </papers> </record> <record> <id>second</id> <...