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

Noam Raphael noamraph at gmail.com
Sat Jun 17 23:44:52 CEST 2006

2006/6/17, "Martin v. Löwis" <martin at v.loewis.de>:
> Noam Raphael wrote:
> > I meant the extra code for writing a special class to handle scalars,
> > if I decide that the "x[()]" syntax is too ugly or too hard to type,
> > so I write a special class which will allow the syntax "x.value".
> What I cannot understand is why you use a zero-dimensional array to
> represent a scalar. Scalars are directly supported in Python:
> x = 5

I need a zero-dimensional array as a single cell - an object that
holds a value that can change over time. It works just like a cell in
a spreadsheet: For example, say that if you change the value of cell
A1 to 0.18, cell A2 changes to 5. When using the library I design, you
would write "sheet1[0, 0] = 0.18", and, magically, "sheet1[0, 1]" will
become 5. But in my library, everything is meaningful and doesn't have
to be two-dimensional. So, if in the spreadsheet example, A1 meant the
income tax rate, you would write "income_tax[] = 0.18", and,
magically, "profit['Jerusalem', 2005]" will become 5.

I hope I managed to explain myself - my use case and why the simplest
way to treat scalars like income_tax is as zero-dimensional arrays.

> Also, in an assignment, what are you putting on the right-hand side?
> A read access from another zero-dimensional array?
I hope my example explained that, but you can put there any object -
for example, you can write "income_tax[] = 0.18"

(If I didn't yet manage to explain myself, please say so - it seems
that it's not a very simple example and I'm not a very good explainer,
at least in English.)


More information about the Python-Dev mailing list