Skip to content

Instantly share code, notes, and snippets.

@nwjlyons
Last active June 18, 2019 10:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nwjlyons/a87afe5a2db6038039c8118c577d0078 to your computer and use it in GitHub Desktop.
Save nwjlyons/a87afe5a2db6038039c8118c577d0078 to your computer and use it in GitHub Desktop.
Python 2/3 add keyword arg
# python 2
class Person(object):
def __init__(self, name, age):
self.name = name
self.age = age
class Employee(Person):
def __init__(self, *args, **kwargs):
self.job_title = kwargs.pop('job_title')
super(Employee, self).__init__(*args, **kwargs)
# python 3
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
class Employee(Person):
def __init__(self, *args, job_title, **kwargs):
super().__init__(*args, **kwargs)
self.job_title = job_title
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment