reading dictionary's (key,value) from file

ankitks.mital at gmail.com ankitks.mital at gmail.com
Mon Apr 7 15:41:22 EDT 2008


On Apr 7, 11:55 am, Robert Bossy <Robert.Bo... at jouy.inra.fr> wrote:
> ankitks.mi... at gmail.com wrote:
> > Folks,
> > Is it possible to read hash values from txt file.
> > I have script which sets options. Hash table has key set to option,
> > and values are option values.
>
> > Way we have it, we set options in a different file (*.txt), and we
> > read from that file.
> > Is there easy way for just reading file and setting options instead of
> > parsing it.
>
> > so this is what my option files look like:
>
> > 1opt.txt
> > { '-cc': '12',
> >   '-I': r'/my/path/work/'}
>
> > 2opt.txt
> > {  '-I': r/my/path/work2/'}
>
> > so my scipt how has dictionary
> > options = { '-cc' :'12'
> >                 '-I': r'/my/path/work/:/my/path/work2/'}
>
> > I am trying to avoid parsing
>
> For this particular case, you can use the optparse module:http://docs.python.org/lib/module-optparse.html
>
> Since you're obviously running commands with different set of options, I
> suggest you listen to Diez.
>
> Cheers,
> RB- Hide quoted text -
>
> - Show quoted text -

I think I am missing lot regarding optparser module. My only option is
to have option file, and I have couple of those..each user creates
it's own. How can optparser help me in this regard

Thank you



More information about the Python-list mailing list