[EMAIL PROTECTED] wrote:
> This is good... try this:
>
> value = 'test'
> value
> 'test'
> type(value)
> <type 'str'>
> value = type(value) is type('') and Upper(value) or value
> value
> 'TEST'
> type(value)
> <class '__main__.Upper'>
Try again with
value = ""
This makes Upper(value) a False value in a boolean context:
>>> class Upper(str):
... pass
...
>>> Upper("")
''
>>> type(Upper(""))
<class '__main__.Upper'>
>>> type(Upper("") or "")
<type 'str'>
versus
>>> type(Upper("x") or "x")
<class '__main__.Upper'>
Peter
--
http://mail.python.org/mailman/listinfo/python-list