I don’t even know if this is possible.
I want to do something like:
>>> foo = float
>>> x = foo('2')
>>> x
2
But when I try it I get a type object in foo:
>>> foo = float
>>> foo
<type 'int'>
I want to save a structure like object that holds the correct function to call when converting values to be read from a file.
Thanks in advance for any help.
It’s certainly possible; the identifiers for builtins are no different from any other identifiers, and there’s no reason you can’t bind your own identifiers to the same objects.
If you’re not getting the expected results, check and make sure you haven’t accidentally rebound the identifiers to other values.