Using dictionary to hold regex patterns?

John Machin sjmachin at lexicon.net
Sun Nov 23 17:13:40 EST 2008


On Nov 24, 7:49 am, Thomas Mlynarczyk <tho... at mlynarczyk-webdesign.de>
wrote:
> John Machin schrieb:
>
> > General tip: Don't us a data structure that is more complicated than
> > what you need.
>
> Is "[ ( name, regex ), ... ]" really "simpler" than "{ name: regex, ...}"? Intuitively, I would consider the dictionary to be the simpler
>
> structure.

Hi Thomas,

Rephrasing for clarity: Don't use a data structure that is more
complicated than that indicated by your requirements.

Judging which of two structures is "simpler" should not be independent
of those requirements. I don't see a role for intuition in this
process.

Please see my belated response in your "My first Python program -- a
lexer" thread.

Cheers,
John




More information about the Python-list mailing list