[Python-Dev] Pre-PEP: Allow Empty Subscript List Without Parentheses

Nick Coghlan ncoghlan at gmail.com
Sun Jun 11 07:49:17 CEST 2006

Noam Raphael wrote:
> I hope that my (hopefully) better explanation made the use case more
> compelling, but I want to add two points in favour of an empty tuple:

I guess I'm really only -0 on the idea of x[] invoking x.__getitem__(), and 
allowing the class to decide whether or not to define a default value for the 
subscript. I wouldn't implement it myself, but I wouldn't object strenuously 
if Guido decided it was OK :)

For your specific use cases, though, I'd be inclined to tweak the API a bit, 
and switch to using attributes for the single-valued data:

tax_rates.income_tax = 0.18

Although the income tax rate should actually depend on the current financial 
year, since it can change over time as the government increases taxes ;)

> Why? Mental exercise is a good way to keep you mental ;)

Hehe :)


Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia

More information about the Python-Dev mailing list