Re: [Tutor] Should I use generators here?

2006-05-08 Thread Tony C
Thus you should probably do:   try:   fh=open(Onefile, "r")   Filecontents = fh.readlines()  # these files are verysmall,   # other code here   Summary[Onefile] = deepcopy(Stats)# associate each   fh.close()   except IOError:   print("\n

[Tutor] Should I use generators here?

2006-05-07 Thread Tony C
I wrote a small Python program to count some simple statistics on a Visual Basic program thatI am maintaining.The Python program counts total lines, whitespace lines, comment lines, Public & Private Subroutines, Public and Private Functions. The Python program takes about 20-40 seconds to count all

[Tutor] What does Python gain by having immutable types?

2005-03-22 Thread Tony C
A friend recently asked my this didn't modify his original string variable s1="this is a string" s1.replace("is a", "is a short") "this is a short string" print s1 "this is a string" After showing him to change it to this s1 = s1.replace("is a", "is a short") print s1 "this is a short string"