Skip to content

Instantly share code, notes, and snippets.

@goozbach
Created October 18, 2011 19:23
Show Gist options
  • Save goozbach/1296419 to your computer and use it in GitHub Desktop.
Save goozbach/1296419 to your computer and use it in GitHub Desktop.
Inheritance/scope problem
*.sw[po]
*.pyc
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
import cmd
class FooCmd(cmd.Cmd, object):
"""Foo command processor example."""
def __init__(self, mytuple=(), **kwds):
super(FooCmd, self).__init__(**kwds)
self.mytuple = mytuple
def do_stuff(self, line):
"""Print stuff"""
print("stuff")
def do_args(self, line):
print(self.mytuple)
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
import foocmd
mycmd = foocmd.FooCmd(mytuple=('one', 'two', 'three'))
mycmd.cmdloop()
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
class Foo(object):
def __init__(self, fooarg='foob', **kwds):
self.fooarg = fooarg
class Bar(Foo):
def __init__(self, bararg='barb', **kwds):
super(Bar, self).__init__(**kwds)
self.bararg = bararg
myobj = Bar(timmy='twotone')
print(myobj.fooarg)
print(myobj.bararg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment