[Zope] Re: Using builtin "type" function in a Python FS product
Derrick 'dman' Hudson
dman at dman13.dyndns.org
Wed Oct 15 18:56:29 EDT 2003
On Tue, Oct 14, 2003 at 09:14:31PM +0200, Gilles Lenfant wrote:
| Is there changes in this usual Python builtin ?
No.
| if type(x) == types.UnicodeType:
| Error Type: UnboundLocalError
| Error Value: local variable 'type' referenced before assignment
|
| What did I miss ?
>>> def demonstrate_programmer_error() :
... type("a string")
... type = "some other object"
...
>>> demonstrate_programmer_error()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "<stdin>", line 2, in demonstrate_programmer_error
UnboundLocalError: local variable 'type' referenced before assignment
>>>
Don't assign to 'type' in your method. Use a different name for the
local variable.
-D
--
Folly delights a man who lacks judgement,
but a man of understanding keeps a straight course.
Proverbs 15:21
http://dman13.dyndns.org/~dman/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.zope.org/pipermail/zope/attachments/20031015/d6fe97f0/attachment.bin
More information about the Zope
mailing list