[Tutor] help on string replacement in a file
Clay Shirky
clay at shirky.com
Tue Aug 12 11:01:57 EDT 2003
> Thank you for your code.
> may i know what i does it means by inplace?
Lots of operations modify an existing piece of data to produce a new piece
of data. For example,
my_long = long(my_hex, 16)
takes a string, my_hex, expressed in hexadecimal and assigns it to my_long
as a long integer. You started with one piece of data, performed an
operation on it, and now you have two pieces of data, the original my_hex
and the new my_long.
An in-place operation, by contrast, modifies data, well, in place. When you
say my_list.sort(), for example, you end up with a sorted version of
my_list, but no longer have the unsorted version. In this case, you started
with one piece of data, performed an in-place operation on it, and now you
still have one piece of data, the newly sorted my_list.
-clay
More information about the Tutor
mailing list