python

python binding of variable to particular expression

I am developing a simple application which hava a file Constants.py containing all configuration, it is like this x = y during execution of program , the value of y changes , I want value of x o get updated too , automatically, this can be reffered as binding, how can I achieve this ...

Subprocess fails to catch the standard output

I am trying to generate tree with fasta file input and Alignment with MuscleCommandline import sys,os, subprocess from Bio import AlignIO from Bio.Align.Applications import MuscleCommandline cline = MuscleCommandline(input="c:\Python26\opuntia.fasta") child= subprocess.Popen(str(cline), stdout = subprocess.PIPE,...

Openid not working in OSQA hosted on hostgator

Hi, I have installed osqa on server hosted on hostgator. Openid is not working at all. When i click on google under login i get Page not found (404) error. I am unable to figure out the reason for the same? Please help me on this Thanks ...

How does Python's website generate its online documentation?

Created using Sphinx 0.6.5. I know Python's documentation uses reStructuredText, but it has different sections like http://docs.python.org/whatsnew/2.6.html and http://docs.python.org/tutorial/index.html. How do you do this in reStructuredText? Do you run rst2html in a bunch of directories, keeping its structure? I know that it us...

Can pydoc/help() hide the documentation for inherited class methods and attributes?

When declaring a class that inherits from a specific class: class C(dict): added_attribute = 0 the documentation for class C lists all the methods of dict (either through help(C) or pydoc). Is there a way to hide the inherited methods from the automatically generated documentation (the documentation string can refer to the base c...

SSL and WSGI apps - Python

Hi folks, I have a WSGI app that I would like to place behind SSL. My WSGI server is gevent. What would a good way to serve the app through SSL in this case be? ...

feedparser fails during script run, but can't reproduce in interactive python console

It's failing with this when I run eclipse or when I run my script in iPython: 'ascii' codec can't decode byte 0xe2 in position 32: ordinal not in range(128) I don't know why, but when I simply execute the feedparse.parse(url) statement using the same url, there is no error thrown. This is stumping me big time. The code is as simple ...

How can I create a GUI on top of a Python APP so it can do either GUI or CLI?

Hello, I am trying to write an app in python to control a motor using serial. This all works in a CLI situation fine and is generally stable. but I was wondering how simple it was to add a GUI on top of this code base? I assume there will be more code, but is there a simple way of detecting something like GTK, so it only applied the co...

Webapp best practice template_dict

Hi, After just been coding for about 6-9 months. I probably changed my coding style a number of times after reading some code or read best practices. But one thing I haven't yet come a cross is a good why to populate the template_dict. As of now I pass the template_dict across a number of methods (that changes/modifies it) and returns...

mechanize with pfx certificate

Hi all, Can someone show me an example of using mechanize (python version) with PFX certificates? ...

Why doesn't appending binary pickles work?

I know this isn't exactly how the pickle module was intended to be used, but I would have thought this would work. I'm using Python 3.1.2 Here's the background code: import pickle FILEPATH='/tmp/tempfile' class HistoryFile(): """ Persistent store of a history file Each line should be a separate Python object Usually...

Django Inlines user permissions + view only - permissions issues

I'm not sure if this is a bug or I'm just missing something (although I have already parsed the documentation about inlines), but: Let's say I have a model A. Model A is an inline of model B. User U has full access to model B, but only change permissions to model A (so, no add, nor delete). However, when editing model B, user U can sti...

python: calling constructor from dictionary?

I'm not quite sure of the terminology here so please bear with me.... Let's say I have a constructor call like this: machineSpecificEnvironment = Environment( TI_C28_ROOT = 'C:/appl/ti/ccs/4.1.1/ccsv4/tools/compiler/c2000', JSDB = 'c:/bin/jsdb/jsdb.exe', PYTHON_PATH = 'c:/appl/python/2.6.4', ) except I would like to replace ...

how to load a module within python debugger

This looks like something simple but I could not find the answer so far - I have just learnt python and need to start learning pdb. In my module I have the usual if __name__ == __main_ trick to execute some code when the module is run as a program. So far I have been running it via python -m mymod arg1 arg2 syntax Now I want to do exa...

Timestamp server rfc3161 response token generation in Python

Hello! I'm trying to implement tsa server on python using twisted. Currently I'm using openssl binary to generate response, but this seems ugly to me, that's why I'm trying to figure out how to make response token with m2crypto. Thanks in advance for help! Maris. EDITED: how to achieve with m2crypto?: openssl ts -reply -section tsa_...

[Python]Download an image embedded in a mime multipart message

Hi, I have to download some images from links. This links return me a file where is embedded a multipart mime and a tiff image. I have writed this code but it downloads the file with mime. How I can remove the mime from this file and have the image returned? Can I do this with wget or curl? My code: def download(url,local): import ...

Python: Why "is" keyword has different behavior when there is dot in the string?

>>> x = "google" >>> x is "google" True >>> x = "google.com" >>> x is "google.com" False >>> Can someone give me some hints why its like that? Edit: to make sure above, I have just tested on python 2.5.4, 2.6.5, 2.7b2, python 3.1 on windows and python 2.7b1 on linux Looks its consistence across all, so its by design and Am I missing ...

python: equivalent to Javascript "||" to override non-truthful value

In Javascript I can do this: function A(x) { return x || 3; } This returns 3 if x is a "non-truthful" value like 0, null, false, and it returns x otherwise. This is useful for empty arguments, e.g. I can do A() and it will evaluate as 3. Does Python have an equivalent? I guess I could make one out of the ternary operator a if b else ...

Python: converting string to flags

If I have a string that is the output of matching the regexp [MSP]*, what's the cleanest way to convert it to a dict containing keys M, S, and P where the value of each key is true if the key appears in the string? e.g. 'MSP' => {'M': True, 'S': True, 'P': True} 'PMMM' => {'M': True, 'S': False, 'P': True} '' => {'M': False, 'S...

Execute a BASH command in Python-- in the same process

I need to execute the command . /home/db2v95/sqllib/db2profile before I can import ibm_db_dbi in Python 2.6. Executing it before I enter Python works: baldurb@gigur:~$ . /home/db2v95/sqllib/db2profile baldurb@gigur:~$ python Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1] on linux2 Type "help", "copyright", "credits" or "...