[Python-ideas] Should function attributes be properties?

Guido van Rossum guido at python.org
Wed May 2 22:22:06 CEST 2007


You're misunderstanding descriptors. Descriptors only work when placed
in a class.

On 5/2/07, Joel Bender <jjb5 at cornell.edu> wrote:
> I was expecting this to work:
>
>      class myprop(property):
>          def __get__(self, obj, cls): print "get", obj, cls
>          def __set__(self, obj, value): print "set", obj, value
>
>      def f(x):
>          print 'f'
>          f.p
>
>      f.p = myprop()
>
> So it comes out like this:
>
>      >>> f(2)
>      f
>      get <function f at 0x61270> None
>
> Is this a bug?  Or was it not in the scope of what properties would be
> used for?  Is this PEP material?
>
>
> Joel
>
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-ideas mailing list