how two join and arrange two files together

2009-07-18 Thread amrita
Hi, I have two files having entries like:-- fileA 8 ALA H = 7.85 N = 123.95 CA = 54.67 HA = 2.98 C = 179.39 15 ALA H = 8.05 N = 119.31 CA = 52.18 HA = 4.52 C = 177.18 23 ALA H = 8.78 N = 120.16 CA = 55.84 HA = 4.14 C = 179.93 and fileB ChainA: ALA8-67.217297 -37.131330 ChainA: ALA21 -

Python import Error

2009-07-18 Thread Kalyan Chakravarthy
Hi All, I am using* Python 2.6, MySQL 4.0* , I have successfully Instaled MySQLdb (*MySQL-python-1.2.3c1.win32-py2.6*) in my system. I tested through command prompt with "import MySQLdb ", its not shwing any errors (means its instaled successfully), I set Eneceranment variable fo

Re: how two join and arrange two files together

2009-07-18 Thread Chris Rebert
On Sat, Jul 18, 2009 at 12:09 AM, wrote: > > Hi, > > I have two files having entries like:-- > fileA > 8  ALA H = 7.85 N = 123.95 CA = 54.67 HA = 2.98 C = 179.39 > 15 ALA H = 8.05 N = 119.31 CA = 52.18 HA = 4.52 C = 177.18 > 23 ALA H = 8.78 N = 120.16 CA = 55.84 HA = 4.14 C = 179.93 > and > fileB

Re: how two join and arrange two files together

2009-07-18 Thread amrita
I tried to join these two files together using command... from itertools import izip from os.path import exists def parafiles(*files): vec = (open(f) for f in files if exists(f)) data = izip(*vec) [f.close() for f in vec] return data for data in parafiles('/home/amrita/alache

Re: how two join and arrange two files together

2009-07-18 Thread Peter Otten
amr...@iisermohali.ac.in wrote: > I tried to join these two files together using command... > > from itertools import izip > from os.path import exists > > def parafiles(*files): > vec = (open(f) for f in files if exists(f)) > data = izip(*vec) > [f.close() for f in vec] > re

Re: how two join and arrange two files together

2009-07-18 Thread amrita
I want to join column of two different data file but i want that the entries will match (example i mentioned in my first mail, the position of ALA eill match) if its not matching then it will get printed as such. > amr...@iisermohali.ac.in wrote: > >> I tried to join these two files together using

Re: missing 'xor' Boolean operator

2009-07-18 Thread Mark Dickinson
On Jul 17, 12:06 pm, Jean-Michel Pichavant wrote: > I was saying that using boolean operators with object instead of boolean > values is error prone, I agree with this to some extent. After all, Python conditional expressions were eventually introduced in response to buggy uses of the 'a and b o

difference in printing to screen Mac / Windows

2009-07-18 Thread Mark Bakker
Hello list I notice a difference between running the following script on my Mac and on a PC: from time import sleep for i in range(10): print i, sleep(2) On my PC this prints a number every 2 seconds. This is the behavior I want. On my Mac Python waits 10*2 = 20 seconds, and then prints 0

Re: how two join and arrange two files together

2009-07-18 Thread Peter Otten
amr...@iisermohali.ac.in wrote: >> Can you make an effort to express clearly what you want, preferrably with >> a simple and unambiguous example? > I want to join column of two different data file but i want that the > entries will match (example i mentioned in my first mail, the position of > AL

Re: difference in printing to screen Mac / Windows

2009-07-18 Thread Tim Chase
I notice a difference between running the following script on my Mac and on a PC: from time import sleep for i in range(10): print i, sleep(2) On my PC this prints a number every 2 seconds. This is the behavior I want. On my Mac Python waits 10*2 = 20 seconds, and then prints 0 1 2 3 4 5

Python graphics / imaging library

2009-07-18 Thread Peter Chant
Chaps, what's the most appropriate (maintained) graphics library to use? PIL seems to have last been updated in 2006 http://www.pythonware.com/products/pil/ and GD seems to be even older. Don't want to go down a dead end. Pete -- http://www.petezilla.co.uk -- http://mail.python.org/mailman/l

Re: Python graphics / imaging library

2009-07-18 Thread Michiel Overtoom
Peter Chant wrote: what's the most appropriate (maintained) graphics library to use? PIL seems to have last been updated in 2006 http://www.pythonware.com/products/pil/ and GD seems to be even older. Don't want to go down a dead end. Contrary to organic material, software doesn't rot when it

Re: Python graphics / imaging library

2009-07-18 Thread Peter Chant
Michiel Overtoom wrote: > Peter Chant wrote: > >> what's the most appropriate (maintained) graphics library to use? PIL >> seems to have last been updated in 2006 >> http://www.pythonware.com/products/pil/ >> and GD seems to be even older. Don't want to go down a dead end. > > Contrary to orga

Auto Send URL

2009-07-18 Thread Victor Subervi
Hi; I am trying to script code that automatically sends a Web site visitor to an URL. Specifically, when they enter a value in a search box, I have that form sent to a script that writes an URL acceptable to Google, then I want to send the visitor off without him having to click another button. How

Re: Python graphics / imaging library

2009-07-18 Thread Benjamin Kaplan
On Sat, Jul 18, 2009 at 7:50 AM, Peter Chant < rempete...@cappetezilla.italsco.uk> wrote: > Michiel Overtoom wrote: > > > Peter Chant wrote: > > > >> what's the most appropriate (maintained) graphics library to use? PIL > >> seems to have last been updated in 2006 > >> http://www.pythonware.com/p

Re: Python graphics / imaging library

2009-07-18 Thread Peter Chant
Peter Chant wrote: > > No, it does not. However, if PIL was updated last in 2006. Python in > 2009 > has gone to version 3.1. If PIL is compatible with 3.1 then I'm fine. > But I don't want to have to stick with Python 2.5 as the rest of the world > moves on. BTW, this was not a critisism o

Re: Python graphics / imaging library

2009-07-18 Thread Michiel Overtoom
Peter Chant wrote: what do people generally use now? I can only speak for myself... I use PIL ;-) Greetings, -- http://mail.python.org/mailman/listinfo/python-list

Re: Python graphics / imaging library

2009-07-18 Thread Max Erickson
Peter Chant wrote: > No, it does not. However, if PIL was updated last in 2006. > Python in 2009 has gone to version 3.1. If PIL is compatible > with 3.1 then I'm fine. But I don't want to have to stick with > Python 2.5 as the rest of the world moves on. > > Pete > > Various messages to

Re: Beginners question

2009-07-18 Thread Rhodri James
On Sat, 18 Jul 2009 03:03:32 +0100, gabrielmonnerat wrote: Ronn Ross wrote: How do you define a global variable in a class. I tried this with do success: class ClassName: global_var = 1 def some_methos(): print global_var This doesn't work. What am I doing wrong? You ne

Re: Python import Error

2009-07-18 Thread David Stanek
On Sat, Jul 18, 2009 at 3:14 AM, Kalyan Chakravarthy wrote: > Hi All, >    I am using Python 2.6, MySQL 4.0 , I have successfully > Instaled MySQLdb (MySQL-python-1.2.3c1.win32-py2.6) in my system. I tested > through command prompt with "import MySQLdb ", its not shwing any errors >

Unpack Expects the Wrong Number of Bytes

2009-07-18 Thread Timothy Crone
Hello, I have noticed that for certain format strings, struct.unpack expects the wrong number of bytes. For example, this works fine header = "4si4s4si2h2i3h4s" data = list(unpack(header,f.read(42))) however, this header = "4si4s4si2h2i3h4si" data = list(unpack(header,f.read(46))) returns the

Re: setup.py not found

2009-07-18 Thread Aahz
In article <3be2bdce-680d-4b32-ad0c-ef46caf55...@f10g2000vbf.googlegroups.com>, larry.mart...@gmail.com wrote: > >I'm trying to install a package (cx_Oracle) on a mac running 10.5.7. >I've done this on other platforms, but never on a mac. I followed the >instructions given, but when I try and run

Re: Unpack Expects the Wrong Number of Bytes

2009-07-18 Thread John Machin
On Jul 19, 12:34 am, Timothy Crone wrote: > Hello, > > I have noticed that for certain format strings, struct.unpack expects > the wrong number of bytes. [snip] > header = "si" > data = list(unpack(header,f.read(5))) > > throws > > struct.error: unpack requires a string argument of length 8 > > So

Re: Try... except....Try again?

2009-07-18 Thread MRAB
Xavier Ho wrote: Darn it. On Sat, Jul 18, 2009 at 8:55 AM, Dave Angel > wrote: You don't need a counter. len() will tell you the size of the list of primes. Does len() go through and count by itself, or does it actually keep track of the size and just return

Re: Unpack Expects the Wrong Number of Bytes

2009-07-18 Thread Ross Ridge
Timothy Crone wrote: >header = "s" >data = list(unpack(header,f.read(1))) > >however this: > >header = "si" >data = list(unpack(header,f.read(5))) > >throws > >struct.error: unpack requires a string argument of length 8 > >So unpack expects 7 additional bytes when an integer is added to the >form

Re: invoke method on many instances

2009-07-18 Thread Alan G Isaac
> On Fri, 17 Jul 2009 05:19:50 +, Alan G Isaac wrote: >> def apply2(itr, methodname, *args, **kwargs): >> f = operator.methodcaller(methodname, *args, **kwargs) >> for item in itr: >> f(item) On 7/17/2009 3:45 AM Steven D'Aprano apparently wrote: > for obj in objects: > ge

Re: A Bug By Any Other Name ...

2009-07-18 Thread Tom Kermode
Maybe the IDE is the best place to warn you of something like that. You could have an IDE where you specify which language you're more familiar with and then have it display warnings likely to be relevant to you. People could collaborate to add support for gradually more niche languages. Python

Re: Python graphics / imaging library

2009-07-18 Thread Peter Chant
Max Erickson wrote: > More recent months contain updates to the status of 1.1.7, it is > headed towards a release. Preliminary tarballs and binaries are > available on effbot.org: > > http://effbot.org/downloads/#imaging > http://effbot.org/downloads/#pil Excellent. From a very brief look it se

Re: Python graphics / imaging library

2009-07-18 Thread Marcus Wanner
On 7/18/2009 11:41 AM, Peter Chant wrote: Max Erickson wrote: More recent months contain updates to the status of 1.1.7, it is headed towards a release. Preliminary tarballs and binaries are available on effbot.org: http://effbot.org/downloads/#imaging http://effbot.org/downloads/#pil Excell

Rus Python script interactively

2009-07-18 Thread Gnarlodious
In an interactive session (I am using iPython), what is the most elegant way to run a Python script from Terminal? Right now I am saying: import subprocess subprocess.call("python /path/to/scriptname.py", shell=True) But I am calling a shell process and I'd rather not. The script just runs, no in

Re: Rus Python script interactively

2009-07-18 Thread Diez B. Roggisch
Gnarlodious schrieb: In an interactive session (I am using iPython), what is the most elegant way to run a Python script from Terminal? Right now I am saying: import subprocess subprocess.call("python /path/to/scriptname.py", shell=True) But I am calling a shell process and I'd rather not. The

Re: Rus Python script interactively

2009-07-18 Thread Lie Ryan
Gnarlodious wrote: > In an interactive session (I am using iPython), what is the most > elegant way to run a Python script from Terminal? Right now I am > saying: > > import subprocess > subprocess.call("python /path/to/scriptname.py", shell=True) > > But I am calling a shell process and I'd rath

Re: Rus Python script interactively

2009-07-18 Thread Marcus Wanner
On 7/18/2009 12:32 PM, Gnarlodious wrote: In an interactive session (I am using iPython), what is the most elegant way to run a Python script from Terminal? Right now I am saying: import subprocess subprocess.call("python /path/to/scriptname.py", shell=True) But I am calling a shell process and

Re: Rus Python script interactively

2009-07-18 Thread Peter Otten
Gnarlodious wrote: > In an interactive session (I am using iPython), what is the most > elegant way to run a Python script from Terminal? Right now I am > saying: > > import subprocess > subprocess.call("python /path/to/scriptname.py", shell=True) > > But I am calling a shell process and I'd rat

python command running old version

2009-07-18 Thread Tim Edwards
My brain is running in n00b mode this morning...must find coffee. I upgraded python this morning and entering python from the command line runs the old version. Just looked and it appears the old version is in /usr/bin while the new one is in /usr/local/bin/ Besides changing the path order, how

Re: python command running old version

2009-07-18 Thread Chris Rebert
On Sat, Jul 18, 2009 at 10:25 AM, Tim Edwards wrote: > My brain is running in n00b mode this morning...must find coffee. > > I upgraded python this morning and entering python from the command > line runs the old version. Which OS? How did you install it? Cheers, Chris -- http://blog.rebertia.co

Re: Auto Send URL

2009-07-18 Thread Chris Rebert
On Fri, Jul 17, 2009 at 6:02 AM, Victor Subervi wrote: > Hi; > I am trying to script code that automatically sends a Web site visitor to an > URL. Specifically, when they enter a value in a search box, I have that form > sent to a script that writes an URL acceptable to Google, then I want to > sen

Re: python command running old version

2009-07-18 Thread Christian Heimes
Tim Edwards wrote: > Besides changing the path order, how do I ensure it runs the new > version? I'm sure I'll bang my head on the desk in shame as soon as > I'm reminded. hash -r Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: python command running old version

2009-07-18 Thread Tim Edwards
> Which OS? How did you install it? Sorry (see I need that coffee) Installed on redhat from source -- http://mail.python.org/mailman/listinfo/python-list

Re: python command running old version

2009-07-18 Thread Tim Edwards
>> Besides changing the path order, how do I ensure it runs the new >> version? I'm sure I'll bang my head on the desk in shame as soon as >> I'm reminded. > > hash -r Thanks. -- http://mail.python.org/mailman/listinfo/python-list

Re: python command running old version

2009-07-18 Thread Lie Ryan
Tim Edwards wrote: >> Which OS? How did you install it? > > Sorry (see I need that coffee) > > Installed on redhat from source You should consult the distro's (i.e. RedHat's) documentation/mailing list about changing the default python interpreter. In most cases, you will need to make sure all p

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-18 Thread akhil1988
Thanks Nobody-38, it solved my problem immediately. --Thanks Again, Akhil Nobody-38 wrote: > > On Thu, 16 Jul 2009 20:26:39 -0700, akhil1988 wrote: > >> Well, you were write: unintentionally I removed strip(). But the problem >> does >> not ends here: >> >> I get this error now: >> >> File

Re: UnicodeEncodeError: 'ascii' codec can't encode character u'\xb7' in position 13: ordinal not in range(128)

2009-07-18 Thread akhil1988
Thanks David, it solved my problem immediately. I will follow your advise from next time but honestly I am new to python with not much knowledge about text formats. And the main portion of my project was not to deal with these, so I just wanted to get this solved as I was already struck at this

Re: python command running old version

2009-07-18 Thread Tim Edwards
> You should consult the distro's (i.e. RedHat's) documentation/mailing > list about changing the default python interpreter. In most cases, you > will need to make sure all python-related packages are compatible with > the new python version. In popular distros, there should be a script > that wil

Re: multiprocessing and freezing on Windows

2009-07-18 Thread SK
Thanks Gabriel. Posted as: http://bugs.python.org/issue6461 The multiprocessing author has tentatively confirmed the bug. -- http://mail.python.org/mailman/listinfo/python-list

How to receive a data file of unknown length using a python socket?

2009-07-18 Thread twgray
I am attempting to send a jpeg image file created on an embedded device over a wifi socket to a Python client running on a Linux pc (Ubuntu). All works well, except I don't know, on the pc client side, what the file size is? The following is a snippet: [code] f = open("frame.jpg",mode =

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread Irmen de Jong
twgray wrote: I am attempting to send a jpeg image file created on an embedded device over a wifi socket to a Python client running on a Linux pc (Ubuntu). All works well, except I don't know, on the pc client side, what the file size is? You don't. Sockets are just endless streams of bytes.

Re: Rus Python script interactively

2009-07-18 Thread Gnarlodious
Thanks for all the suggestions! The last solution is the one I was ooking for, I am really starting to like iPython. Learning all kinds of new tricks!. -- Gnarlie -- http://mail.python.org/mailman/listinfo/python-list

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread Tycho Andersen
On Sat, Jul 18, 2009 at 4:43 PM, Irmen de Jong wrote: > twgray wrote: >> >> I am attempting to send a jpeg image file created on an embedded >> device over a wifi socket to a Python client running on a Linux pc >> (Ubuntu).  All works well, except I don't know, on the pc client side, >> what the fi

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread twgray
On Jul 18, 4:43 pm, Irmen de Jong wrote: > twgray wrote: > > I am attempting to send a jpeg image file created on an embedded > > device over a wifi socket to a Python client running on a Linux pc > > (Ubuntu).  All works well, except I don't know, on the pc client side, > > what the file size is?

Re: invoke method on many instances

2009-07-18 Thread Terry Reedy
Alan G Isaac wrote: On Fri, 17 Jul 2009 05:19:50 +, Alan G Isaac wrote: def apply2(itr, methodname, *args, **kwargs): f = operator.methodcaller(methodname, *args, **kwargs) for item in itr: f(item) On 7/17/2009 3:45 AM Steven D'Aprano apparently wrote: for obj in objects:

uniicode and executing a process with subprocess.call, or os.system

2009-07-18 Thread Rick King
Hello, I want to copy files using subprocess.call or os.system where the file names are non-ascii, e.g. Serbian(latin), c's and s's with hacheks,etc. Windows stores all the file names in unicode so they are displayed ok in explorer, and I can read them into my program with listdir(u'.'), etc.

Re: uniicode and executing a process with subprocess.call, or os.system

2009-07-18 Thread MRAB
Rick King wrote: Hello, I want to copy files using subprocess.call or os.system where the file names are non-ascii, e.g. Serbian(latin), c's and s's with hacheks,etc. Windows stores all the file names in unicode so they are displayed ok in explorer, and I can read them into my program with lis

Re: uniicode and executing a process with subprocess.call, or os.system

2009-07-18 Thread Chris Rebert
On Sat, Jul 18, 2009 at 3:30 PM, Rick King wrote: > Hello, > I want to copy files using subprocess.call or os.system where the file names > are non-ascii, e.g. Serbian(latin), c's and s's with hacheks,etc. Windows > stores all the file names in unicode so they are displayed ok in explorer, > and I

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread John Machin
On Jul 19, 8:04 am, twgray wrote: > send a 4 byte address from the embedded device, how do I convert that, > in Python, to a 4 byte, or long, number? struct.unpack() is your friend. Presuming the embedded device is little-endian, you do: the_int = struct.unpack('http://docs.python.org/library/s

Newbie question - running a command and looking at output

2009-07-18 Thread Dave
I'm trying to run a command (arch -k) and check if the value returned is 'sun4v' or not. kir...@t2:[~] $ arch -k sun4v In fact, I want to do 3 three things 1) Check if the system is Solaris. 2) If it is Solaris, check if 'arch -k' prints 'sun4v' 3) If both 1 and 2 are true, copy a file. Sin

Re: python command running old version

2009-07-18 Thread Aahz
In article , Tim Edwards wrote: > >I upgraded python this morning and entering python from the command >line runs the old version. > >Just looked and it appears the old version is in /usr/bin while the >new one is in /usr/local/bin/ > >Besides changing the path order, how do I ensure it runs the

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread Nobody
On Sat, 18 Jul 2009 14:33:48 -0700, twgray wrote: > It appears to be locking up in 'data=self.s.recv(MAXPACKETLEN)' on > the final packet, which will always be less than MAXPACKETLEN. > > I guess my question is, how do I detect end of data on the client side? recv() should return zero when the

Re: Newbie question - running a command and looking at output

2009-07-18 Thread Dave
Dave wrote: I'm trying to run a command (arch -k) and check if the value returned is 'sun4v' or not. kir...@t2:[~] $ arch -k sun4v In fact, I want to do 3 three things 1) Check if the system is Solaris. 2) If it is Solaris, check if 'arch -k' prints 'sun4v' 3) If both 1 and 2 are true, copy

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread MRAB
Nobody wrote: On Sat, 18 Jul 2009 14:33:48 -0700, twgray wrote: It appears to be locking up in 'data=self.s.recv(MAXPACKETLEN)' on the final packet, which will always be less than MAXPACKETLEN. I guess my question is, how do I detect end of data on the client side? recv() should return zero

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread MRAB
twgray wrote: On Jul 18, 4:43 pm, Irmen de Jong wrote: twgray wrote: I am attempting to send a jpeg image file created on an embedded device over a wifi socket to a Python client running on a Linux pc (Ubuntu). All works well, except I don't know, on the pc client side, what the file size is?

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread John Machin
On Jul 19, 7:43 am, Irmen de Jong wrote: > twgray wrote: > > I am attempting to send a jpeg image file created on an embedded > > device over a wifi socket to a Python client running on a Linux pc > > (Ubuntu).  All works well, except I don't know, on the pc client side, > > what the file size is?

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread twgray
On Jul 18, 7:33 pm, MRAB wrote: > Nobody wrote: > > On Sat, 18 Jul 2009 14:33:48 -0700, twgray wrote: > > >> It appears to be locking up in  'data=self.s.recv(MAXPACKETLEN)' on > >> the final packet, which will always be less than MAXPACKETLEN. > > >> I guess my question is, how do I detect end of

Re: How to receive a data file of unknown length using a python socket?

2009-07-18 Thread Aahz
In article , MRAB wrote: > >If you send the length as 4 bytes then you'll have to decide whether >it's big-endian or little-endian. An alternative is to send the length >as characters, terminated by, say, '\n' or chr(0). Alternatively, make it a fixed-length string of bytes, zero-padded in front