Jonathan Fine wrote:
Giudo has suggested adding optional static typing to Python. (I hope suggested is the correct word.) http://www.artima.com/weblogs/viewpost.jsp?thread=85551
An example of the syntax he proposes is: > def f(this:that=other): > print this
This means that f() has a 'this' parameter, of type 'that'. And 'other' is the default value.
Hm; so for a slightly more concrete example, one might have
def fib_sequence(length:int=9): ...
I'm going to suggest a different use for a similar syntax.
In XML the syntax > <element this:that='other'> is used for name spaces.
Name spaces allow independent attributes to be applied to an element. For example, 'fo' attributes for fonts and layout. XSLT is of course a big user of namespaces in XML.
Namespaces seems to be a key idea in allow independent applications to apply attributes to the same element. [...] Here's an example of how it might work. With f as above: > f(this:that='value') {'that': 'value'}
I fail to see how this is a significant advantage over simply using **kwargs. It allows you to have multiple dictionaries instead of just one, that's all. And as you point out, it's trivial to construct your own nested dicts.
Besides, Python already uses the concept of namespaces by mapping them to object attributes. Module references are a namespace, exposed via the attribute-lookup mechanism. This (IMO) fails the "there should be one (and preferably only one) obvious way to do things" test. The functionality already exists, so having yet-another way to spell it will only result in more confusion. (The fact that we're borrowing the spelling from XML does little to mollify that confusion.)
3. Granted (2), perhaps function calls are first in the queue for syntactic sugar.
Huh? How much simpler of syntax do you want for calling a function? I'm not sure what you'd want as "sugar" instead of funcname().
Jeff Shannon Technician/Programmer Credit International
-- http://mail.python.org/mailman/listinfo/python-list