integer - Python typecasting string to int fails -


i error when try simple typecasting string integer in python (2.7):

year = device.time[year_pos:].strip() # '1993' t = int(year) # throws exception: "unboundlocalerror: local variable 'int' referenced before assignment" 

why? :)

the unboundlocalerror sounds if you've assigned name int in other scope in code (i.e., code throwing exception inside function, , you've used int name store variable in global code, or somewhere else). there's a blog post unboundlocalerror can read more kind of problem, issue, i'd recommend not using builtin names store variables.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -