python

Django Forms Help needed

Hi All, Im new to django and trying to make a user registration form with few validations. Apart from this I also want a username suggestion code which will tell the user if the username he is trying to register is available or already in use. Then it should give few suggestions that might be available to choose from. Can anyone who migh...

Posting messages in two RabbitMQ queue, instead of one (using py-amqp)

I've got this strange problem using py-amqp and the Flopsy module. I have written a publisher that sends messages to a RabbitMQ server, and I wanted to be able to send it to a specified queue. On the Flopsy module that is not possible, so I tweaked it adding a parameter and a line to declare the queue on the init_ method of the Publisher...

best framework on gae(python) ,like jquery on javascript ? has it ?

i want to find a framework to make my work simple on gae , has it ? thanks i found one, but not very good http://code.google.com/p/appengine-framework/ ...

pivots using pyExcelerator/xlrd

How can I go about creating a worksheet (within an excel workbook) with a pivot table using python libs like pyExcelerator / xlrd? I need to generate a daily report that has a pivot table to summarize data on other sheets. One option would be to have a blank template that I copy and populate with the data. In this case, is there a way to...

Upgrading all packages with Pip

Is it possible to upgrade all python packages at one time with Pip? I saw someone made this a issue: http://bitbucket.org/ianb/pip/issue/4/add-upgrade-and-upgrade-all-commands ...

multi-line pattern matching in pyhon

A periodic computer generated message (simplified): Hello user123, - (604)7080900 - 152 - minutes Regards Using python, how can I extract "(604)7080900", "152", "minutes" (i.e. any text following a leading "- " pattern) between the two empty lines (empty line is the \n\n after "Hello user123" and the \n\n before "Regards"). Even bet...

Python: Figure out local timezone

I want to compare UTC timestamps from a log file with local timestamps. When creating the local datetime object, I use something like: >>> local_time=datetime.datetime(2010, 4, 27, 12, 0, 0, 0, tzinfo=pytz.timezone('Israel')) I want to find an automatic tool that would replace thetzinfo=pytz.timezone(...

What does "str indices must be integers" mean?

I'm working with dicts in jython which are created from importing/parsing JSON. Working with certain sections I see the following message: TypeError: str indices must be integers This occurs when I do something like: if jsondata['foo']['bar'].lower() == 'baz': ... Where jsondata looks like: {'foo': {'bar':'baz'} } What does ...

Python: Traffic-Simulation (cars on a road)

Hello! I want to create a traffic simulator like here: http://www.doobybrain.com/wp-content/uploads/2008/03/traffic-simulation.gif But I didn't thougt very deep about this. I would create the class car. Every car has his own color, position and so on. And I could create the road with an array. But how to tell the car where to go? Co...

django - How to cross check ModelAdmin and its inlines?

I have two models (ModelParent and ModelChild) with same m2m fields on Subject model. ModelChild has a foreign key on ModelParent and ModelChild is defined as inline for ModelParent on admin page. ### models.py ### class Subject(Models.Model): pass class ModelParent(models.Model): subjects_parent = ManyToManyField(Subject)...

how to remove attribute of a etree Element ?

I've Element of etree having some attributes - how can we delete the attribute of perticular etree Element. ...

Why are my two date fields not identical when I copy them?

I use django, and have two models with a models.DateTimeField(). Sometimes I need a copy of a date - but look at this: >>>myobject.date = datetime.datetime.now() >>>print myobject.date >>>2010-04-27 12:10:43.526277 >>>other_object.date_copy = myobject.date >>>print other_object.date_copy >>>2010-04-27 12:10:43 Why are these two date...

Use Twisted's getPage as urlopen?

Hi folks, I would like to use Twisted non-blocking getPage method within a webapp, but it feels quite complicated to use such function compared to urlopen. This is an example of what I'm trying to achive: def web_request(request): response = urllib.urlopen('http://www.example.org') return HttpResponse(len(response.read())) I...

python: examine XSD xml schema

Hello, I would like to examine a XSD schema in python. Currently I'm using lxml which is doing it's job very very well when it only has to validate a document against the schema. But, I want to know whats inside of the schema and access the elements in the lxml behavior. The schema: <?xml version="1.0"?> <xsd:schema xmlns:xsd="http:/...

Strange error installing Psyco in Python

I have installed psyco in one machine with no problem, but i'm getting an strange error while installing in one other machine. I'm not able to use easy_install, since it gives me an error: C:\Python26\Downloads\psyco-1.6>easy_install psyco Searching for psyco Reading http://pypi.python.org/simple/psyco/ Reading http://psyco.sourceforge....

How does large text file viewer work? How to build a large text reader

how does large text file viewer work? I'm assuming that: Threading is used to handle the file The TextBox is updated line by line Effective memory handling is used Are these assumptions correct? if someone were to develop their own, what are the mustsand don'ts? I'm looking to implement one using a DataGrid instead of a TextBox I...

how to trigger a script located on a machine in one domain from a machine on another domain

Hi, I am basically from QA. What we testers do each day is 1. Open a web browser. Type in http://11.12.13.27.8080/cruisecontrol (since we are in a particular network, only we can access this) 2. Check if the latest nightly build has been successful. If it is successful, deploy it on a test environment by clicking on 'Deploy this build' ...

optimize pymssql code

i am inserting records to sql server from python using pymssql. The database takes 2 milliseconds to execute a query, yet it insert 6 rows per second. The only problem is at code side. how to optimize following code or what is the fastest method to insert records. def save(self): conn = pymssql.connect(host=dbHost, user=dbUser, ...

One letter game problem?

Recently at a job interview I was given the following problem: Write a script capable of running on the command line as python It should take in two words on the command line (or optionally if you'd prefer it can query the user to supply the two words via the console). Given those two words: a. Ensure they are of equal length b. Ensur...

Fastest way to generate delimited string from 1d numpy array

I have a program which needs to turn many large one-dimensional numpy arrays of floats into delimited strings. I am finding this operation quite slow relative to the mathematical operations in my program and am wondering if there is a way to speed it up. For example, consider the following loop, which takes 100,000 random numbers in a nu...