Re: [Tutor] Simple string processing problem

2005-05-13 Thread Mark Thomas
On 13 May 2005 21:59:58 +0100, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > The file: > > ScerACTAACAAGCTGGTTTCTCC-TAGTACTGCTGTTTCTCAAGCTG > Sparactaacaagctggtttctcc-tagtactgctgtttctcaagctg > Smikactaacaagctgtttcctct

Re: [Tutor] Testing for commandline args

2005-05-13 Thread Danny Yoo
> > If I have arguments, the "different stuff" happens beautifully, thank > you very much. If I don't have arguments I get this: > > if sys.argv[1]: > IndexError: list index out of range] > > So I'm doing something wrong. I looked at getopt, but that seemed to be > doing what I was already doing,

Re: [Tutor] Testing for commandline args

2005-05-13 Thread Max Noel
On May 14, 2005, at 01:30, William O'Higgins wrote: > if sys.argv[1]: > do stuff > else: > do different stuff > > If I have arguments, the "different stuff" happens beautifully, thank > you very much. If I don't have arguments I get this: > > if sys.argv[1]: > IndexError: list index out

[Tutor] Testing for commandline args

2005-05-13 Thread William O'Higgins
I am writing a tiny commandline utility (re-writing it from Perl) and I want the behaviour to change based on the presence of arguments. The conditional in Perl looks like this: if (defined $ARGV[0]) { do stuff } else { do different stuff In Python I've nearly been successful, but someth

Re: [Tutor] Linux variable to Python

2005-05-13 Thread Alberto Troiano
And again I'm gonna say BINGO! It's like you were doing the same app as I am Thanks Alberto >From: Danny Yoo <[EMAIL PROTECTED]> >To: Alberto Troiano <[EMAIL PROTECTED]> >CC: tutor@python.org >Subject: Re: [Tutor] Linux variable to Python >Date: Fri, 13 May 2005 14:00:50 -0700 (PDT) >

Re: [Tutor] Simple string processing problem

2005-05-13 Thread Danny Yoo
On 13 May 2005 [EMAIL PROTECTED] wrote: > Your help has made me realise the problem is more complex than I first > though though...I've included a small sample of an actual file I need to > process. The structure is the same as in the full versions though; some > lowercase, some uppercase, then

Re: [Tutor] Linux variable to Python

2005-05-13 Thread Danny Yoo
On Fri, 13 May 2005, Alberto Troiano wrote: > Here is an example of what I want to do: > > I run over Linux shell the following command: > > [EMAIL PROTECTED] root]# fec=cam`date +%Y%m%d%H%M%S`.jpg > [EMAIL PROTECTED] root]# echo $fec > cam2005051255702.jpg > [EMAIL PROTECTED] root]# mv hola.txt

Re: [Tutor] Simple string processing problem

2005-05-13 Thread cgw501
Thanks! Your help has made me realise the problem is more complex than I first though though...I've included a small sample of an actual file I need to process. The structure is the same as in the full versions though; some lowercase, some uppercase, then some more lowercase. One is that I nee

Re: [Tutor] Linux variable to Python

2005-05-13 Thread Lee Harr
>import os os.system("fec=cam`date +%Y%m%d%H%M%S`.jpg") >0 os.system("echo $fec") >0 os.system("mv hola.txt grabacion/$fec") >0 Each system() call gets a fresh shell, and a fresh env ... >>>import os >>>os.environ['foo'] = 'bar' >>>os.system('echo $foo') bar 0 >>>os.system('foo=zzz')

Re: [Tutor] Linux variable to Python

2005-05-13 Thread Max Noel
On May 13, 2005, at 21:03, Alberto Troiano wrote: os.system("fec=cam`date +%Y%m%d%H%M%S`.jpg") > 0 > os.system("echo $fec") > 0 > os.system("mv hola.txt grabacion/$fec") > 0 > > Then I check for the file and turns out that it moved hola.txt to > grabacion > with th

Re: [Tutor] Simple string processing problem

2005-05-13 Thread Max Noel
On May 13, 2005, at 20:36, [EMAIL PROTECTED] wrote: > Hi, > > i am a Biology student taking some early steps with programming. I'm > currently trying to write a Python script to do some simple > processing of a > gene sequence file. Welcome aboard! > A line in the file looks like: > SCER

Re: [Tutor] Python Resources

2005-05-13 Thread Andrei
Greg Lindstrom wrote on Fri, 13 May 2005 07:52:54 -0500: > would like to list some resources. I have the Python home page, "Dive > Into Python", the Python Gems" page, but would like to ask what > resources would any of you suggest? I'd like between 5 and 10, with a > short description of ea

[Tutor] Linux variable to Python

2005-05-13 Thread Alberto Troiano
Hey Another problem Here is an example of what I want to do: I run over Linux shell the following command: [EMAIL PROTECTED] root]# fec=cam`date +%Y%m%d%H%M%S`.jpg [EMAIL PROTECTED] root]# echo $fec cam2005051255702.jpg [EMAIL PROTECTED] root]# mv hola.txt grabacion/$fec To explain for those w

Re: [Tutor] map() and lambda to change class instance attribute (fwd)

2005-05-13 Thread Bernard Lebel
Hi Kent, So if I undestand you right, mapping a function with map() when it is a built-in function will/may be faster than a for loop, but if it's a custom function (ie. a def one), it will most likely be slower? Thanks Bernard On 5/13/05, Kent Johnson <[EMAIL PROTECTED]> wrote: > Bernard Lebe

[Tutor] Simple string processing problem

2005-05-13 Thread cgw501
Hi, i am a Biology student taking some early steps with programming. I'm currently trying to write a Python script to do some simple processing of a gene sequence file. A line in the file looks like: SCER ATCGATCGTAGCTAGCTATGCTCAGCTCGATCagctagtcgatagcgat Ther are many lines like this. What I

Re: [Tutor] Perl to Python phrasebook

2005-05-13 Thread William O'Higgins
On Fri, May 13, 2005 at 10:39:55AM -0700, Terry Carroll wrote: >A "Perl-to-Python phrasebook," showing a number of common tasks in Perl, >and how to do the equivalent in Python, is at >. > >I'll bet a lot of readers know about it a

Re: [Tutor] creation of a module

2005-05-13 Thread Cedric BRINER
> > hi, > > > > 1) > > I'm trying to create my _first_ own module. I've decided to write each > > class into a separate file. OB> > > > /MyModule|-bunch.py > > |-a.py > > |-b.py > > `-c.py > > You also need MyModule/__init__.py to signal to Python that MymModule is a

[Tutor] Perl to Python phrasebook

2005-05-13 Thread Terry Carroll
A "Perl-to-Python phrasebook," showing a number of common tasks in Perl, and how to do the equivalent in Python, is at . I'll bet a lot of readers know about it already, but I just stumbled on it and thought that some readers migh

Re: [Tutor] map() and lambda to change class instance attribute (fwd)

2005-05-13 Thread Kent Johnson
Bernard Lebel wrote: > The authors even go as far as saysing, on page 228 (first paragraph) > that map() used that way has a performance benefit and is faster than > a for loop. That may well be correct, at least in the case where the function passed to map is a builtin. Mapping a builtin to ove

Re: [Tutor] Python Resources

2005-05-13 Thread John Purser
Greg, Thanks for taking one for the team! How about some OS specific resources like the Active State (I think I have that right. At work so I can't check) stuff for windows/com and the debian-python mailing list that came up the other day. I even ran across some AS-400 python stuff a while back

Re: [Tutor] Help with time module

2005-05-13 Thread Alberto Troiano
Thank you so much Kent That's exactly what I was lookin for Regards Alberto http://graphics.hotmail.com/emvamp.gif"; width=12> Gaucho >From: Kent Johnson <[EMAIL PROTECTED]> >CC: tutor@python.org >Subject: Re: [Tutor] Help with time module >Date: Fri, 13 May 2005 09:56:17 -0400 > >Albe

Re: [Tutor] map() and lambda to change class instance attribute (fwd)

2005-05-13 Thread Bernard Lebel
The authors even go as far as saysing, on page 228 (first paragraph) that map() used that way has a performance benefit and is faster than a for loop. Cheers Bernard On 5/13/05, Alan Gauld <[EMAIL PROTECTED]> wrote: > How bizarre. I'm astonished that Lutz/Ascher even show that as a means > of

Re: [Tutor] Why use apply()?

2005-05-13 Thread Bernard Lebel
All right, thank you. Bernard On 5/12/05, Bob Gailer <[EMAIL PROTECTED]> wrote: > At 02:17 PM 5/12/2005, Bernard Lebel wrote: > > Just a generic question: why one would use apply()? > > In Learning Python, on page 357, there is an example of generating an > instance using apply(): > >

Re: [Tutor] Help with time module

2005-05-13 Thread Kent Johnson
Alberto Troiano wrote: > I have two strings like this > > hour1="14:30" > hour2="15:30" > > I want to compare them like this: > > if local_time between hour1 and hour2: > print True > else > print False > > Can anyone tell me how to make that comparison to work??? (I don't know > h

[Tutor] Help with time module

2005-05-13 Thread Alberto Troiano
Hey everyone I have two strings like this hour1="14:30" hour2="15:30" I want to compare them like this: if local_time between hour1 and hour2: print True else print False Can anyone tell me how to make that comparison to work??? (I don't know how to take only the time in this form

[Tutor] Python Resources

2005-05-13 Thread Greg Lindstrom
Hello- I have been asked to write an article for the IEEE "IT Pro" magazine dealing with using Python in the medical field. The editors asked for about half the article dealing with using Python and the other half giving a short tutorial. They also asked for three "sidebars"; I'm going with

Re: [Tutor] py2exe

2005-05-13 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Hi > > Thanks for this. But do you know how I can achieve a single exe file with > the dist and build folders. Is it possible to run a single exe file without > the other dependencies? The most common approach on Windows seems to be to use py2exe to create the executa

Re: [Tutor] URLLIB

2005-05-13 Thread Kent Johnson
Servando Garcia wrote: > Hello list > I am on challenge 5. I think I need to some how download a file. I have > been trying like so > > X=urllib.URLopener(name,proxies={'http':'URL').distutils.copy_file('SomeFileName') > urlopener() returns a file-like object - something that behaves like an o

[Tutor] URLLIB

2005-05-13 Thread Servando Garcia
Hello list I am on challenge 5. I think I need to some how download a file. I have been trying like so X=urllib.URLopener(name,proxies={'http':'URL').distutils.copy_file('SomeFileName') but with no luck. Servando Garcia John 3:16 For GOD so loved the world.._

Re: [Tutor] py2exe

2005-05-13 Thread jfouhy
Quoting "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>: > Thanks for this. But do you know how I can achieve a single exe file > with the dist and build folders. Is it possible to run a single exe file > without the other dependencies? There is another freezer here: http://starship.python.net/crew/atu

Re: [Tutor] creation of a module

2005-05-13 Thread Kent Johnson
Cedric BRINER wrote: > hi, > > 1) > I'm trying to create my _first_ own module. I've decided to write each class > into a separate file. > > /MyModule|-bunch.py > |-a.py > |-b.py > `-c.py You also need MyModule/__init__.py to signal to Python that MymModule is a pack

Re: [Tutor] help: threading + cron in python?

2005-05-13 Thread Pierre Barbier de Reuille
Ok, there is an easy way :) You can write something like : from datetime import datetime import time def run_at( t, fct, fct_args = (), fct_words = {}): now = datetime.today() delta = (t-now).minutes time.sleep(delta) fct(*fct_args, **fct_kwords) Now you can just launch this function

Re: [Tutor] map() and lambda to change class instance attribute (fwd)

2005-05-13 Thread Joe Healy
Alan Gauld wrote: >>now I always used map() to perform a looped call on a function that >>would change the attribute value, as shown in Mark Lutz & David >>Ascher's Learning Python: >> >># Perform attribute value change on a single instance >>def iterateInstances( oInstance ): >> oInstance.va

[Tutor] creation of a module

2005-05-13 Thread Cedric BRINER
hi, 1) I'm trying to create my _first_ own module. I've decided to write each class into a separate file. /MyModule|-bunch.py |-a.py |-b.py `-c.py {a,b,c}.py contains respecetively classA,classB,classC more some unittest and bunch.py will contains some usefull functio

Re: [Tutor] py2exe

2005-05-13 Thread ray007
Hi Thanks for this. But do you know how I can achieve a single exe file with the dist and build folders. Is it possible to run a single exe file without the other dependencies? Thanks for you help. ray >-- Original-Nachricht -- >Date: Thu, 12 May 2005 22:38:18 +1200 (NZST) >From: [EMAIL PROTECT