On Sun, 17 Apr 2005 01:10:47 GMT, [EMAIL PROTECTED] (Bengt Richter) wrote:
[...]
>
>The "::" expression I'm proposing generalizes capturing suite bindings into an 
>ordered sequence of (key,value)
>tuples, like an ordered vars().items() limited to the bindings produced in the 
>suite following "::"
>Thus
>    items = ::
>        x = 1
>        y = [1,2]
>        def foo():pass
>
>    print items => (('x', 1), ('y', [1, 2]), ('foo', <function foo at 
> 0x02EE8D14>))
>
Update, sorry. Galloping evolution here ;-)

The '::' unary suite operator should return an ordered dict subtype 
representing the bindings, so

     print items => {'x':1, 'y':[1, 2], 'foo':<function foo at 0x02EE8D14>}

instead. This allows cleaner suite-based keyword calling, since no 
dict(::<suite>) is necessary,

so
     def foo(**kw): print kw

followed by

     foo(**::
         x = 1
         y = [1,2]
         def foo():pass)

will print the same. Since ::<suite> is an expression, it can go anywhere an 
expression can go.
I like orthogonality ;-)

Methods allow (with order preserved from binding in suite)

    (:: x=1; y=2).keys()   # => ['x', 'y']
and
    (:: x=1; y=2).values() # => [1, 2]
and
    (:: x=1; y=2).items()  # => [('x', 1), ('y', 2)]

note that :: is ;-greedy in one-line suites, so
   :: x=1; y=2
is not
   (:: x=1); y=2

Regards,
Bengt Richter
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to