python gripes survey

smarter_than_you davesum99 at yahoo.com
Tue Aug 26 00:35:53 EDT 2003


How about this for a symmetrical, Pythonesque syntax:

def sumdif(a, b):
  sum = a + b
  dif = a - b
  return sum, dif

#normal syntax:
s, d = sumdif(5,7)

#additional syntax with named returns:

(s=sum, d=dif)=sumdif(5, 7)

#eqivalent to:

(d=dif, s=sum)=sumdif(5, 7)

#I call it 'symmetrical' because we can do this:

(s=sum, d=dif)=sumdif(a=5, b=7)

Not sure how easy to implement this would be, or how it affects the
scope of locals and such, but it looks nice on paper.


sismex01 at hebmex.com wrote in message news:<mailman.1061851794.28843.python-list at python.org>...
> [Ryan Lowe]
> >  is it that hard to send a dictionary? i dont know how that 
> >  compares to a tuple in terms of speed/memory usage, but its
> >  not a whole lot harder to use than a tuple.
> 
> And much more flexible.  You can also create a "holder" kind
> of class, which goes something like:
> 
> 
> class Values:
>    def __init__(self, **values):
>       self.__dict__.update(values)
> 
> >  
> >  def fruit() :
> >      return {'apple' : 'A', 'orange' : 'B'}
> >  
> >  >>> food = fruit()
> >  >>> food['apple']
> >  ... 'A'
> >  
> 
> Or, using the above Values class:
> 
> ...
>        return Values(apple="A", orange="B")
> 
> What you use the class for, is up to your own imagination
> and needs.
> 
> >  
> >  ... are there more
> >  complicated uses of code blocks that would make them more 
> >  powerful than python's generators?
> >
> 
> Generators yielding to other generators, to form a
> quasi-cooperative-multitasking environ seems quite
> powerful to me.
> 
> -gustavo
> 
> 
> Advertencia:La informacion contenida en este mensaje es confidencial y
> restringida, por lo tanto esta destinada unicamente para el uso de la
> persona arriba indicada, se le notifica que esta prohibida la difusion de
> este mensaje. Si ha recibido este mensaje por error, o si hay problemas en
> la transmision, favor de comunicarse con el remitente. Gracias.




More information about the Python-list mailing list