Dictionary assignment

John J Lee jjl at pobox.com
Fri Aug 15 19:07:36 EDT 2003


On Fri, 15 Aug 2003, Mark Daley wrote:

> I'm becoming aware that my coding techniques leave much to be desired.
> That's ok, because I'm really just a hack with no education whatsoever.  At

No need for self-flaggelation, the only mistake I noticed (apart from your
failing to attempt to debug the code before posting, apparently ;) was a
Python-specific pitfall that everyone new to Python will fall into at some
point.


> any rate, I realize I didn't supply enough information.  Here is the core of
> my dilemma:
>
> format[self.formats.get()][key] = current[key]
>
> Now, all disgust from my example aside, shouldn't this line cause a new key
> (whatever self.formats get() produces) whose contents are an exact copy of
> current?

I'm not sure where to start.  Try debugging like I explained, then come
back if you get stuck.


> BTW, I do this to avoid those location references.  I need to get an actual
> copy and this is the only way I can (currently) guarantee it.  Believe me,

Parse error.


John






More information about the Python-list mailing list