On 28-Sep-10 13:03, Corey Richardson wrote:
I hate doing this:
string = string.lower()
Is there a way to do it without the "string =" part? Thanks.
Depends on the class. In this specific case, string objects are
immutable (for some good reasons which are beyond the immediate point),
so once created, they can't be changed. They can, of course, be used to
create new strings, which is what string.lower() is doing. And that new
string is then given the name "string" again, replacing the old string
object (which may still have other names referencing it elsewhere).
If you were wanting to modify a mutable object in-place, Python would be
happy to oblige. But not strings.
Sorry :)
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor