[PYTHON DB-SIG] Converting strings to numbers

Fredrik Lundh fredrik_lundh@ivab.se
Wed, 23 Oct 1996 12:07:07 +0200


> This can not only be done from string reps of a number to a numeric
> type, but also from string reps of anything (lists, tuples, dicts
> etc..) to thier actual type. ( nice for reading plaintext datafiles
> ).

Note that eval is compact but dangerous; consider the following (on a
Unix box):

	eval('os.remove("rm -rf ~/*")')

Use string.atoi() and string.atof() when you need to be on the safe
side.

	/F

=================
DB-SIG  - SIG on Tabular Databases in Python

send messages to: db-sig@python.org
administrivia to: db-sig-request@python.org
=================