On or about 2009 Oct 19, at 3:57 PM, Sander Sweers indited:
I missed that the try: did not return anything. I was thinking more of
something like this.

def upperfy(item):
   try:
       item.upper()
       return item
   except AttributeError:
       return item

Thanks for correcting me!

Depending on what 'item' is, item.upper() might return an new thing, but the code looks as if you're expecting .upper() to modify item itself. If item is a string, item.upper() will return a new string and leave item alone (since strings are immutable in Python).

-Doug
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to