[Python-3000] PEP 3113 (Removal of Tuple Parameter Unpacking)

Greg Ewing greg.ewing at canterbury.ac.nz
Mon Mar 5 01:02:06 CET 2007


Raymond Hettinger wrote:

>     def contact_info_update(timestamp, sequence_number, (name, address, phone, 
> email), backup=True):

Things like that are probably better done with something
like the named-tuple idea that was discussed recently.

Writing code that depends on long sequences having things
in particular positions is an anti-pattern, IMO. It's
convenient at first, but it rapidly becomes unmaintainable.
I wrote a lot of code like that in one of my recent projects,
and it's one of the first things I'll change if I get around
to re-doing it.

> Another example comes from a spherical navigation module with several tuple
> representations for movement  (lat_offset, long_offset) versus (dist, 
> direction).

That could be addressed by giving the arguments descriptive
names, such as lat_long and dist_dir.

--
Greg


More information about the Python-3000 mailing list