python

Recommend me an Embedded RDBMS to use with Python

Actual Question: As the title implies, I am having confusion in choosing a better embedded RDBMS for a simple website, only few pages need some server side scripting language otherwise all HTML. I have already chosen Python for that, now could you folks recommend me which embedded database system I should use. The requirement goes lik...

HTML tags within JSON (in Python)

I understand its not a desirable circumstance, however if I NEEDED to have some kind of HTML within JSON tags, e.g.: { "node": { "list":"<ul><li class="lists">Hello World</li><ul>" } } is this possible to do in Python without requiring to to be escaped beforehand? It will be a string initially so I was thinking a...

tab view in css with tables

I need a tab view in css with each tab showing a dynamic table. The complete table is dynamically constructed in loop and only after that should the tabs should hide and show each of the table corresponding to each tab. Any suggestions? The content of the tab is within list item and in loop only. The development is in Django/Python on ap...

How can I instantiate a comment element programatically using lxml?

Hi there I'm using lxml to programatically build HTML and I need to include a custom comment in the output. Whilst there is code in lxml to cope with comments (they can be instantiated when parsing existing HTML code) I cannot find a way to instantiate one programatically. Can anyone help? ...

Zipping dynamic files in App Engine (Python)

Hello! Is there anyway I can zip dynamically generated content, such as a freshly rendered html template, into a zip file using zipfile? There seem to be some examples around for zipping static content, but none for zipping dynamic ones. Or, is it not possible at all? One more question: Is it possible to create a zip file with a bunch...

[Appengine + Django] Can't seem to get list() working

I am trying to convert a set object to list...for example "p=list('abc')" is not working. any ideas or is it inherent in appengine ...

how is this Strategy Pattern written in Python? (the sample in Wikipedia)

In the Wikipedia entry for the Strategy Pattern: http://en.wikipedia.org/wiki/Strategy_pattern Most other code sample is doing something like: a = Context.new(StrategyA.new) a.execute #=> Doing the task the normal way b = Context.new(StrategyB.new) b.execute #=> Doing the task alternatively c = Context.new(StrategyC.new) c.execute #...

How should I debug Trac plugins?

I'm about to start a fair amount of work extending Trac to fit our business requirements. So far I've used pythonWin and now Netbeans 6.5 as the development environments - neither of these seem to provide any way of debugging the plugin I am working on. I'm totally new to Python so probably have not set up the development environment h...

python formating float numbers

my input is 3.23 , but when i use float on it , it becomes 3.2 , when my input is 3.00 , when i do float on it , it becomes 3.0 when i convert to float from string , i still want it to be 3.00 and not 3.0 is it possible? i want to know the code to make it possible , and when i am doing a problem in which the decimal point till 2 di...

how to remove text between <script> and </script> using python?

how to remove text between <script> and </script> using python? ...

Patching classes in Python

Suppose I have a Python class that I want to add an extra property to. Is there any difference between import path.MyClass MyClass.foo = bar and using something like : import path.MyClass setattr(MyClass, 'foo', bar) ? If not, why do people seem to do the second rather than the first? (Eg. here http://concisionandconcinnity.blog...

Django : Adding a property to the User class. Changing it at runtime and UserManager.create_user

For various complicated reasons[1] I need to add extra properties to the Django User class. I can't use either Profile nor the "inheritance" way of doing this. (As in http://stackoverflow.com/questions/44109/extending-the-user-model-with-custom-fields-in-django ) So what I've been doing is including the User class in my local_settings ...

Find a HAL object based on /dev node path

Hi, I'm using python-dbus to interface with HAL, and I need to find a device's UDI based on it's path in the /dev hierarchy. So given a path such as /dev/sdb, I want to get a value back like /org/freedesktop/Hal/devices/usb_device_10. ...

Python: Reading part of a text file

HI all I'm new to python and programming. I need to read in chunks of a large text file, format looks like the following: <word id="8" form="hibernis" lemma="hibernus1" postag="n-p---nb-" head-"7" relation="ADV"/> I need the form, lemma and postag information. e.g. for above I need hibernis, hibernus1 and n-p---nb-. How do I tell p...

<option> Level control of Select inputs using Django Forms API

I'm wanting to add a label= attribute to an option element of a Select form input using the Django Forms API without overwriting the Select widget's render_options method. Is this possible, if so, how? Note: I'm wanting to add a label directly to the option (this is valid in the XHTML Strict standard) not an optgroup. ...

Python - simple reading lines from a pipe

I'm trying to read lines from a pipe and process them, but I'm doing something silly and I can't figure out what. The producer is going to keep producing lines indefinitely, like this: producer.py import time while True: print 'Data' time.sleep(1) The consumer just needs to check for lines periodically: consumer.py import ...

What's the official way of storing settings for python programs?

Django uses real Python files for settings, Trac uses a .ini file, and some other pieces of software uses XML files to hold this information. Are one of these approaches blessed by Guido and/or the Python community more than another? ...

Unicode Problem with SQLAlchemy

I know I'm having a problem with a conversion from Unicode but I'm not sure where it's happening. I'm extracting data about a recent Eruopean trip from a directory of HTML files. Some of the location names have non-ASCII characters (such as é, ô, ü). I'm getting the data from a string representation of the the file using regex. If i ...

debug variable in python

I want to separate the debug outputs from production ones by defining a variable that can be used throughput the module. It cannot be defined in environment. Any suggestions for globals reused across classes in modules? Additionally is there a way to configure this variable flag for telling appengine that dont use this code. ...

Python error

a=[] a.append(3) a.append(7) for j in range(2,23480): a[j]=a[j-2]+(j+2)*(j+3)/2 When I write this code, it gives an error like this: Traceback (most recent call last): File "C:/Python26/tcount2.py", line 6, in <module> a[j]=a[j-2]+(j+2)*(j+3)/2 IndexError: list assignment index out of range May I know why and how to debug...