python gripes survey

sismex01 at hebmex.com sismex01 at hebmex.com
Mon Aug 25 18:44:20 EDT 2003


[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