defining information out of class

Posted by calccrypto on Stack Overflow See other posts from Stack Overflow or by calccrypto
Published on 2010-05-02T23:08:46Z Indexed on 2010/05/02 23:17 UTC
Read the original article Hit count: 236

Filed under:
|

is there a way to define a value within a class in the __init__ part, send it to some variable outside of the class without calling another function within the class?

like

class c:
     def __init__(self, a):
           self.a = a
           b = 4           # do something like this so that outside of class c, 
                           # b is set to 4 automatically when i use class c

     def function(self):
         ...               # whatever. this doesnt matter

i have multiple classes that have different values for b. i could just make a list that tells the computer to change b, but i would rather set b within each class

© Stack Overflow or respective owner

Related posts about python

Related posts about class-design