Re: ConfigParser and multiple option names
[EMAIL PROTECTED] wrote: that will break horribly in windows, remenber it install all it's crap in c:\Program Files Why should this break? If you split at the \n character? Florian -- http://mail.python.org/mailman/listinfo/python-list
Re: ConfigParser and multiple option names
that will break horribly in windows, remenber it install all it's crap in c:\Program Files -- http://mail.python.org/mailman/listinfo/python-list
Re: ConfigParser and multiple option names
Another option is to use a dedicated section and simply omit values for options: [dirs] /path/1: /long/path/2: /etc: Then get options for section dirs. This approach precludes using ':' or '=' in paths though. -- http://mail.python.org/mailman/listinfo/python-list
Re: ConfigParser and multiple option names
I have had this same problem before, and what I ended up doing was writing my own far more limited config parser that would create lists for repeated named assignments. Who is the maintainer of ConfigParser? Perhaps a keyword option can be added so that this kind of behaviour can be added at creation. Caleb -- http://mail.python.org/mailman/listinfo/python-list
Re: ConfigParser and multiple option names
Not tested by me, but according to docs it does support list values: http://cheeseshop.python.org/pypi/ConfigObj Regards -- http://mail.python.org/mailman/listinfo/python-list
ConfigParser and multiple option names
Hello, since ConfigParser does not seem to support multiple times the same option name, like: dir=/home/florian dir=/home/john dir=/home/whoever (only the last one is read in) I wonder what the best way to work around this. I think the best solution would be to use a seperation character: dir=/home/florian, /home/john, home/whoever What character would be best to work on various operating systems? (of what names may a path consist is the question) What do you think? Any better ideas? Thanks, Florian -- http://mail.python.org/mailman/listinfo/python-list
Re: ConfigParser and multiple option names
Alexis Roda wrote: Florian Lindner escribió: I think the best solution would be to use a seperation character: dir=/home/florian, /home/john, home/whoever RCS uses , in filenames A kommata (,) is a valid character in path names. Ok, you can use quotes. What do you think? Any better ideas? A bit ugly, but probably safer and simpler than adding arbitrary separators: [section] dir_1=/home/florian dir_2=/home/john dir_3=/home/whoever I tend to use seperators, because I think it's more common to users. (the PATH environment variable e.g.) a s(a|i)mple implementation to give you the idea, it has some bugs: [...] Thanks for your input! Florian -- http://mail.python.org/mailman/listinfo/python-list
Re: ConfigParser and multiple option names
Florian Lindner wrote: Hello, since ConfigParser does not seem to support multiple times the same option name, like: dir=/home/florian dir=/home/john dir=/home/whoever (only the last one is read in) I wonder what the best way to work around this. I think the best solution would be to use a seperation character: dir=/home/florian, /home/john, home/whoever What character would be best to work on various operating systems? (of what names may a path consist is the question) What do you think? Any better ideas? Thanks, Florian I would either use (not tested): [directories] dir_01=/home/florian dir_02=/home/john dir_03=/home/whoever and in my program do: INI=ConfigParser.ConfigParser() INI.read(inifilepath) section=directories dirs=[x for x in INI.options(section) if x.startswith('dir_')] or more easily: [init] dirs=/home/florian,/home/john,home/whoever and in program do: section=init dirs=INI.get(section, 'dirs',).split(',') Which one to use depends on how many dirs you would be supporting. If it is a lot, I like the first version. If a few, the second seems better. -Larry Bates -- http://mail.python.org/mailman/listinfo/python-list
Re: ConfigParser and multiple option names
Florian Lindner wrote: I think the best solution would be to use a seperation character: dir=/home/florian, /home/john, home/whoever What character would be best to work on various operating systems? (of what names may a path consist is the question) I don't think there are any universally-disallowed chars for path names. But I also haven't seen anyone mention os.pathsep yet. Seems like the best choice for a separator char. If you need to run on multiple platforms, your choices seem to be: 1. pick a legal-on-some-systems-but-uncommon-on-all char for dir names as a separator (iirc osx uses : in paths so ; might have to do) 2. use os.pathsep to write platform-specific config files 3. do it another way -- http://mail.python.org/mailman/listinfo/python-list
Re: ConfigParser and multiple option names
Benji York wrote: SNIP I generally do this: dirs = /home/florian /home/john /home/whoever ...and then use str.split() in my program. -- Benji York The only problem with this would be if you plan on updating the config file later in the program - I don't think ConfigParser would write the new config file with these options setup this way. -- http://mail.python.org/mailman/listinfo/python-list