Loading a Python collection from an text-file
Larry Bates
larry.bates at websafe.com
Tue Jan 24 12:08:48 EST 2006
Take a look at ConfigParser module. The format of the file would be
something like:
[members]
peter=16
anton=21
People are accustomed to this format file (windows .ini format).
-Larry
Ilias Lazaridis wrote:
> within a python script, I like to create a collection which I fill with
> values from an external text-file (user editable).
>
> How is this accomplished the easiest way (if possible without the need
> of libraries which are not part of the standard distribution)?
>
> something like:
>
> text-file:
> {peter, 16},
> {anton, 21}
>
> -
>
> within code:
>
> users.load(text-file.txt)
>
> for user in users
> user.name
> user.age
>
> .
>
More information about the Python-list
mailing list