[Tutor] Redirecting output + calling dos commands with input tail

cino hilliard hillcino368@hotmail.com
Wed Jun 18 01:28:01 2003


Thanks Lloyd,

def pypari(cmd):                              #call and execute a pari 
command
    f=open("pari.txt","w")                    #save command to a file
#  p=instr(cmd,">")                           #check for dos redirection ">" 
command
    p=cmd.find(">")                            # better intrinsic function 
to find occurrences
[snip]

Works fine. No need for a new wheel here. In the meantime, I reviewed the 
docs on string services
and found a lot of stuff that will take care of most of my wish list.

Moreover, the intrinsic function is 10 times faster than the user defined 
function instr().

Thanks for your work!

>From: Lloyd Kvam <pythontutor@venix.com>
>To: cino hilliard <hillcino368@hotmail.com>
>CC: tutor@python.org
>Subject: Re: [Tutor] Redirecting output + calling dos commands with input 
>tail
>Date: Tue, 17 Jun 2003 19:13:51 -0400
>
>Your instr function could be replaced by an intrinsic python method.
>
>p=instr(cmd,">")  # becomes
>p=cmd.find(">")
>
>find returns -1 if there is no match.  Your instr function assumes that 0
>is a safe return value, but in other contexts you would not be able to
>distinguish between found in the first (zeroth) position and not found at 
>all.
>
>Since a cmd can not legally begin with >, it isn't a problem here.

  3         3        3         3        3        6            2              
  (0^0)
2   +  13  +  33  +  43  =  49   =  7    =  343   = 117649

_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail