PyCrust 0.9.5 - The Flakiest Python Shell
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> filein=open("dh6180.csv","r")
>>> fileout=open("out.csv","w")
>>> while (1):
... a=filein.readline()
... if len(a)==0 : break
...
>>> a
''
>>> filein.rewind()
Traceback (most recent call last):
File "", line 1, in ?
AttributeError: 'file' object has no attribute 'rewind'
>>>
>>> filein=open("dh6180.csv","r")
>>> while (1):
... a=filein.readline()
... if len(a)==0 : break
...
>>>
>>>
>>> a="10 20 30 40"
>>> a.split()
['10', '20', '30', '40']
>>> b=[int(i) for i in a.split()]
>>> b
[10, 20, 30, 40]
>>> a="# This is a test"
>>> b=[int(i) for i in a.split()]
Traceback (most recent call last):
File "", line 1, in ?
ValueError: invalid literal for int(): #
>>> a=" test\n"
>>> a
' test\n'
>>> a.strip()
'test'
>>> [0]*26
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>> [0 for i in range(26)]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>> range(26)*0
[]
>>> ab="abcdefghjiklmnopqrstuvwxyz"
>>> len(ab)
26
>>> ab.index("f")
5
>>> ord("f")
102
>>> ord("a")
97
>>> ord("f")-ord("a")
5
>>> ord("1")
49
>>> ord("&")
38
>>> def countletters(word):
... word=word.lower()
... ret=[0]*26
... for i in word:
... n=ord(i)-97
... if (n>=0 and n<26) : ret[n]+=1
... return ret
...
>>> countletters("Steve Ludtke")
[0, 0, 0, 1, 3, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 2, 1, 1, 0, 0, 0, 0]
>>> countletters("Steve Ludtke")==countletters("test")
False
>>> countletters("Steve Ludtke")==countletters("evets ektdul")
True
>>> a=[1,3,4,5]
>>> b=[1,3,5,6]
>>> a
[1, 3, 4, 5]
>>> b
[1, 3, 5, 6]
>>> for i in range(4):
... if a[i]>=b[i] : break
... else: print "ok"
...
>>> for i in range(4):
... if a[i]>=b[i] : break
... else: print "ok"
...
>>>
>>> for i in range(4):
... if a[i]>=b[i] : break
... else: print "ok"
...
>>> for i in range(4):
... if a[i]>b[i] : break
... else: print "ok"
...
ok
>>> zip(a,b)
[(1, 1), (3, 3), (4, 5), (5, 6)]
>>> def countletters(word):
... word=word.lower()
... ret=[0]*26
... for i in word:
... n=ord(i)-97
... if (n>=0 and n<26) : ret[n]+=1
... return ret
...
>>> filein=open("linux.words","r")
... words=filein.readlines()
... words=[i.strip() for i in words if len(i)<=len(letters)+1]
>>> words
Traceback (most recent call last):
File "", line 1, in ?
NameError: name 'words' is not defined
>>> filein=open("linux.words","r")
>>> words=filein.readlines()
>>>