. Python 2.1 function attributes

Rainer Deyke root at rainerdeyke.com
Sat Jan 27 10:53:06 EST 2001


"Roy Katz" <katz at Glue.umd.edu> wrote in message
news:Pine.GSO.4.21.0101270135190.7677-100000 at y.glue.umd.edu...
> class G:
>     attr = 0
>     def __call__(self): pass
>
> g = G() long
>
> ---VERSUS---
>
> def f():
>   { 'attr':0 }
>   pass

Syntax sugar for singletons could chop another line from the class-based
idiom:


singleton g:
  attr = 0
  def __call__(): pass


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list