|
From: Michael F. <fuz...@vo...> - 2009-01-12 16:01:12
|
Jeffrey Barish wrote:
> On Monday 12 January 2009 08:16:57 Michael Foord wrote:
>
>> Jeffrey Barish wrote:
>>
>>> I write the repr of a tuple to my configuration file on exit. Usually, I
>>> find "<tuple>" in my configuration file afterward, but occasionally the
>>> quotation marks are missing. I have not been able to detect a pattern.
>>> Any suggestions?
>>>
>> Is it actually causing any problems?
>>
>
> When I subsequently read the value from the configuration file, I get a list
> instead of a string. For example, when I write
>
> ('a', ['b'])
>
> I expect to see
>
> "('a', ['b'])"
>
> in the configuration file. When I read that value, I get a string. I eval
> the string to get the original tuple. Occasionally I find
>
> ('a', ['b'])
>
> in the configuration file. When I read that value, I get
>
> ["('a'", "['b'])"]
>
> When I eval that value, I get an error. It seems that I could circumvent the
> problem by restoring the string when I get a list, but the unexpected
> behavior is disturbing.
>
Hmmm... that is a problem. Quoting behaviour should be correct if the
value needs quoting - so it sounds like there is a bug somewhere in the
quoting logic. It will be deterministic - so it should be possible to
reproduce.
If you set the value to be the tuple instead of the repr of the tuple it
will get written out as a list however.
Michael
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
|