Can __iter__ be used as a classmethod?

Michele Simionato mis6 at pitt.edu
Fri Mar 7 11:40:25 EST 2003


Alex Martelli <aleax at aleax.it> wrote in message news:<_2Q9a.16879$pG1.418706 at news1.tin.it>...
> You can use almost any argument at your choice:
> 
> 
> >>> def f(x): return x
>  ...
> >>> f
>  <function f at 0x4043725c>
> >>> c = classmethod(f)
> >>> c.__get__(int).im_func
>  <function f at 0x4043725c>
> >>> c.__get__(c).im_func
>  <function f at 0x4043725c>
> >>> c.__get__(23).im_func
>  <function f at 0x4043725c>
> >>> c.__get__('as you like it').im_func
>  <function f at 0x4043725c>
> >>>
> 
> You can't use None specifically, but thee is no need
> for you to create a dummy class for the purpose, either.
> 
> 
> Alex

WHAT A DIRTY TRICK! ;)

Thanks,

                              M.




More information about the Python-list mailing list