[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Is this function attribute weirdness a feature or bug?
From:       Roy Katz <katz () Glue ! umd ! edu>
Date:       2001-08-18 3:08:18
[Download RAW message or body]

Hello!

I am using Python 2.2a1.  This works ok:


  def f(): pass
  f.att = 3


HOWEVER--this:

  class C:
      def g(): pass

  C.g.att = 3

yields: 
     
   Traceback (most recent call last):
     File "<stdin>", line 1, in ?
   TypeError: read-only attribute: att

I get the same for instances.  Now,  when I attach 'f' to C, I again
get an error:

  C.f = f
  C.f.att2 = 3

  <same exception here>

However, I can still assign attributes to global f(): 

  f.att2 = 4
  print C.f.att2   # prints '4'


So is this a design feature or a bug? 

Thanks, 
Roey

   





-- 
http://mail.python.org/mailman/listinfo/python-list

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic