Another Language Change for Debate

Michael Hudson mwh at python.net
Tue Jan 15 07:16:00 EST 2002


Gareth.McCaughan at pobox.com (Gareth McCaughan) writes:

> Ah yes. That would be a shame. So here's a variant.
> 
>     class MyClass:
>         def bar(y) [staticmethod]:
>             do_some_stuff()
>             return 123
> 
> By the way, if you define generator(x) to be the same
> as iter(x) then that lets you say
> 
>     def f(x) [generator]:
>         while 1:
>             yield x
>             x=x+1
> 
> after which f *is* a generator, not a function that returns
> a generator. I don't think this is worth doing :-).
> 
> The manic generalizer in me wants to add that if you have
> several modifiers you want to apply to a function or method,
> you can say
> 
>     def f(x) [memoized,classmethod,ignoring_errors]:
>         <stuff>
> 
> but I'm not sure whether that's elegant or gratuitous
> just yet.

Hmm, that's quite a neat idea.  Dons hacking hat...

Cheers,
M.

-- 
 As it seems to me, in Perl you have to be an expert to correctly make
 a nested data structure like, say, a list of hashes of instances.  In
 Python, you have to be an idiot not  to be able to do it, because you
 just write it down.             -- Peter Norvig, comp.lang.functional



More information about the Python-list mailing list