Jojo Mwebaze wrote:
Hello Tutor
I would like to compare two souce code files but ignoring doc strings,
comments and space (and perharps in future statement by statement
comparision)
e.g
class Foo
def foo():
# prints my name
return 'my name'
class Boo
def boo():
print 'my name'
Want to check if Foo and Boo are the same. At functional level one can use
boo.func_code.co_code == foo.func_code.co_code
What is the class level equivlant of this?
Foo.foo.func_code.co_code == Boo.boo.func_code.co_code
To check if the classes are equivalent, something like this will get you
started:
if dir(Foo) == dir(Boo):
for attr in dir(Foo):
if getattr(Foo, attr) != getattr(Boo, attr):
print "Unequal"
break
--
Steven
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor