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
Post a Comment