[Tutor] making proigress
andy surany
mongo57a@comcast.net
Tue Dec 17 01:36:33 2002
Hi Kirk,
I just tried the logic in question (aliasline.find(listname+':/"')==-1)
and the expression works fine (python 2.2.1). Note that I simply tried
it in python command line using a string variable versus reading a line
in the file.
Being not much more than a newbie myself, you might try the same thing.
Go to your command line and execute the basic logic. Won't take you more
than a minute to write - and you can determine whether this is a 1.5.2
problem or not.
Here is the logic I used:
import string
listname='ok'
a='jjj ok:/" lll'
a.find(listname+':/"') # You get an answer of 4 here
a='jjj kkk'
a.find(listname+':/"') # You get an answer of -1 here
a=''
a.find(listname+':/"') # You get an answer of -1 here
HTH.
Regards,
Andy
-----Original Message-----
From: Kirk Bailey <idiot1@netzero.net>
To: tutor@python.org <tutor@python.org>
Date: Tuesday, December 17, 2002 1:02 AM
Subject: [Tutor] making proigress
>OK, I added some code.
>f1 = open('./lists/aliases.tinylist','r') #180 open the aliases
fi$
>f2 = open('./lists/aliases.new','w') # and a temp file
> while 1: # create a loop
> aliasline=string.strip(f1.readline()) #
> print aliasline,'\n<br>' ###TESTCODE###
> if aliasline=="":
> break # break the loop!
> if aliasline.find(listname+':/"')==-1: # if this is
NOT
> f2.write(aliasline+"\n")#
> f1.close() # close the
files
> f2.close() #190
>
>
>and I got this error:
>Traceback (innermost last):
> File "/www/www.tinylist.org/cgi-bin/TLlistkill2.py", line 187, in ?
> if aliasline.find(listname+':/"')==-1: # if this is NOT
>AttributeError: 'string' object has no attribute 'find'
>
>Advice? this is python 1.5.2, is this important?
>--
>
>end
>
>Respectfully,
> Kirk D Bailey
>
>
>+---------------------"Thou Art Free." -Eris-----------------------+
>| http://www.howlermonkey.net mailto:highprimate@howlermonkey.net |
>| KILL spam dead! http://www.scambusters.org/stopspam/#Pledge |
>| http://www.tinylist.org +--------+ mailto:grumpy@tinylist.org |
>+------------------Thinking| NORMAL |Thinking----------------------+
> +--------+
>
>---------------------------------------------
>Introducing NetZero Long Distance
>1st month Free!
>Sign up today at: www.netzerolongdistance.com
>
>_______________________________________________
>Tutor maillist - Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor