I wrote the following code to test a score-keeping class. The idea was to keep score of a game such that the score was kept across multiple classes and methods.
I'm looking for any input on being more efficient, more 'pythonic' and/or just better.
import os
class Foo():
def __init__(self):
self.stored_end = 0
def account(self, a, b):
c = float(a) + b
print a
print b
print c
self.stored_end = c
print self.stored_end
def testy(self, q, v):
print "\n"
print " _ " * 10
z = float(q) + v
print self.stored_end
self.stored_end = self.stored_end + z
print " _ " * 10
print self.stored_end
class Bar():
def __init__(self):
pass
def zippy(self, a, b):
print " _ " * 10
print "this is zippy"
foo.testy(a, b)
class Baz():
def __init__(self):
pass
def cracky(self, g, m):
y = g + m
print " _ " * 10
print "calling stored_end"
foo.stored_end = foo.stored_end + y
print " _ " * 10
print "this is cracky"
print "y = %r" % y
print foo.stored_end
os.system("clear")
foo = Foo()
foo.account(5, 11)
foo.testy(100, 100)
bar = Bar()
bar.zippy(10, 100)
baz = Baz()
baz.cracky(1000, 1)
foothat is never declared), and seems far from minimal. Could you show some runnable code which demonstrates (as simply as possible) what you need to do? – Useless Aug 21 '12 at 13:41foodeclared after it's used, which is ... unusual. – Useless Aug 21 '12 at 16:21