python

How to print a string of variables without spaces in Python (minimal coding!).

I have something like : print "\n","|",id,"|",var1,"|",var2,"|",var3,"|",var4,"|" It prints with spaces for each variable. | 1 | john | h | johnny | mba | I want something like this : |1|john|h|johnny|mba| I have 20 variables that I have to print and I hate use sys.stdout.write(var) for each one of them. Thanks Pythonistas! ...

ORM in Django vs. PHP Doctrine

I am a PHP guy. In PHP I mainly use Doctrine ORM to deal with database issues. I am considering move to Python + Django recently. I know Python but don't have experience with Django. Can anyone who has good knowledge of both Doctrine and ORM in Django give me a comparison of features of these two ORM implementations? ...

Django view function calling xmlrpc client

I have a view function which needs to perform an xmlrpc call to my engine which runs on twisted. I have googled around for something like that, but there doesn't seem to be any material on django + xmlrpc CLIENT (there's tons of literature on xmlrpc server + django). The reason behind this is because I am not really familiar with WSGI a...

Using Deque.popleft as args for function

Hi, I am attempting to store a list of commands to send down a serial cable using deque in Python. My function "send_command" accepts 3 values; The command, an int. pause and a boolean wait. its definition is as follows. def send_command(self, command, pause=0, wait=False): What I would like to do is, rather than calling this functi...

Loading a config file from operation system independent place in python

Hi, under Linux I put my configs in "~/.programname". Where should I place it in windows? What would be the recommendated way of opening the config file OS independent in python? Thanks! Nathan ...

How can Twisted Deferred errors without errbacks be tested with trial?

I have some Twisted code which creates multiple chains of Deferreds. Some of these may fail without having an errback which puts them back on the callback chain. I haven't been able to write a unit test for this code - the failing Deferred causes the test to fail after the test code has completed. How can I write a passing unit test f...

how to change page selection in wxNotebook or wxChoicebook?

Is there any way to change the page of a wxNotebook or wxChoicebook programmatically? Looking at the documentation I would have thought that wxChoicebook::ChangeSelection was the way to go, or wxChoicebook::SetSelection if I want the page changing/changed events to be sent. However, I don't know what these functions expect as input. T...

Minimizing, maximizing exe's..

How do I maximize, minimize, check whether the program is minimized ? ...

How to efficiently output dictionary as csv file using Python's csv module? Out of memory error.

I am trying to serialize a list of dictionaries to a csv text file using Python's CSV module. My list has about 13,000 elements, each is a dictionary with ~100 keys consisting of simple text and numbers. My function "dictlist2file" simply calls DictWriter to serialize this, but I am getting out of memory errors. My function is: def ...

Python twisted asynchronous write using deferred

With regard to the Python Twisted framework, can someone explain to me how to write asynchronously a very large data string to a consumer, say the protocol.transport object? I think what I am missing is a write(data_chunk) function that returns a Deferred. This is what I would like to do: data_block = get_lots_and_lots_data() CHUNK_SI...

Visualize and clustering

Earlier on i post a question about visualization and clustering. I guess my question was not quite clear enough so I post it again. I hope i make a better explanation this time . I also apologize for not "accept answer" for my old questions. I didn't know i can do that until a guy point it out. I will definitely do it from now on. Oka...

How do I modify program files in Python?

In the actual window where I right code is there a way to insert part of the code into everyline that I already have. Like insert a comma into all lines at the first spot>? ...

Django boilerplate template code

Hi, I am a django newbie and in creating my first project I have come to realize that a lot of my boilerplate code (the lists on the side of my page). I have to recreate them in every view and I am trying to stick with DRY but I find myself rewriting the code every time. Is there a way to inherit from my base views and just modify a fe...

Python: KeyError with form.getfirst

I have a dtml page, which calls a function, with this code: <dtml-var public_blast(form.getfirst('job_ID'))> But i get a key error? stating "KeyError: "public_blast(form.getfirst('job_ID'))" ". I can see the job_ID variable at the top of the page. So i know it is being passed to the URL. I cant see where im going wrong? ...

inserting text with python

Possible Duplicate: How do I modify program files in Python? I need to insert some text at the beginnnig and the end of each line of a text file. how can I use python to do this? ...

Access MP3 music data using Python.

I'm trying to write a Python script for searching out duplicate mp3/4 files using the song's data as the base for comparison. My situation involves many mp3/4 files with similar file names, but different ID3 tags. At first I tried looping through and using md5 to find duplicate files (ignoring file names). This, of course, didn't work...

Using Windows Python from Cygwin

I've been using Cygwin on Windows recently. I want to use the Windows installation of Python, so during testing I'm using /cygdrive/c/Python26/python.exe myfile.py rather than python myfile.exe. This is working almost perfectly, except for printing. When I run the Windows Python from Cygwin the output doesn't print until execution finis...

Django form does not display when only one field is being used

I have a django model and model form that look like this: -models.py class Menu_Category(models.Model): merchant = models.ForeignKey(Merchant, related_name='menu_categories') name = models.CharField(max_length=64) test_field = models.CharField(max_length=20) def __unicode__(self): return self.name -forms.py cla...

How can I use PIL with Netbeans 6.8 (Python version 2.6.5)

Hi all, I have installed Python Imaging Library (PIL) version 1.1.7 on a Windows 7 computer. I have configured Netbeans to use Python (instead of Jython). I added a reference to C:\Python26\Lib\site-packages\PIL to the project but when I attempt this code: import Image, ImageDraw img = Image.new("RGB", (100,150),(255,255,255)) I get...

extract from a list of lists

How can I extract elements in a list of lists and create another one in python. So, I want to get from this: all_list = [['1 2 3 4','2 3 4 5'],['2 4 4 5', '3 4 5 5' ]] a new list like this: list_of_lists = [[('3','4'),('4','5')], [('4','5'),('5','5')]] Following is what I did, and it doesn't work. for i in xrange(len(all_lists)): ...