Learning/relearning Python. Grotesquely simple question:
How do I get hold of the value of y from outside this class?
Code:
#! /usr/bin/python
# Try to work out how classes are called.
# classUnderstand.py
class C:
def __init__(self, x):
print "init called", self, x
def f(self, x):
print "f called", self, x
y = x + 1
....I want to put something like:
print C(4).f(4).y
anticipating it will print the number 5. It never will.
How do I name the value of y? Does the class need changing somehow?
Thanks any help.