Last active
June 18, 2019 10:16
-
-
Save nwjlyons/a87afe5a2db6038039c8118c577d0078 to your computer and use it in GitHub Desktop.
Python 2/3 add keyword arg
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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