Determining if a filename is greater than X characters

hokiegal99 hokiegal99 at hotmail.com
Mon Aug 4 08:23:24 EDT 2003


Thank you both for the information on strings. I got it to work with
this:

   old_fname = files
   for old_fname in files:
      new_fname = old_fname + '.txt'
      print new_fname

I am reading the tutorials, but I'm also learning as I go. This board
is very helpful to me along with the documentation. Thanks!!!


Alex Martelli <aleax at aleax.it> wrote in message
> You cannot change a given string-object, any more than you can change
> a given number-object -- the object 23 will always have value 23 (never
> 22 nor 24 nor any other number), the object 'foo' will always have
> value 'foo' (never 'bar' nor 'foobar' nor any other string).
> 
> However, you can re-bind a name to refer to a different object than
> the one it previously referred to.  Thus, for example:
> 
>     x = 23
>     x = x + 1
> 
> this has not changed the number 23, whose value IS still 23, but name 
> x now refers to a different number, namely, the number 24.  Similarly:
> 
>     x = 'foo'
>     x = x + '.txt'
> 
> this has not changed the string 'foo', whose value IS still 'foo', but name 
> x now refers to a different string, namely, the string 'foo.txt'.
> 
> The unchangeability of strings doesn't inhibit string manipulation any
> more than the unchangeability of numbers inhibits arithmetics.  Simply,
> operations on strings build and return new strings, just like operations
> on numbers build and return new numbers, and in either case you may, if
> you wish, re-bind some pre-existing name to refer to the new objects.
> 
> 
> Alex




More information about the Python-list mailing list