ruby instance variable in python

roro codeath rorocodeath at gmail.com
Mon Oct 6 06:00:27 EDT 2014


for instance in ruby i can write following code:

module M
def ins_var
@ins_var ||= nil
end

def m
@ins_var = "val"
end

def m2
ins_var # => "val"
end

end

in py

# m.py

# how to def a ins_var?

def m:
    # how to set a ins_var?

def m2:
    # how to get a ins_var?



More information about the Python-list mailing list