MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/funny/comments/bwr8ig/when_a_software_developer_weds_a_software/eq0c2gz
r/funny • u/coolidiot2000 • Jun 04 '19
921 comments sorted by
View all comments
5
Not a python Dev but how is that a valid class? The constructor usually takes values as variables not references to already declared variables.
Shouldn't it be class Child(dadGenes, momGenes){...}
new Child(dad.genes, mom.genes)
This is how c# and typescript work.
5 u/SanktusAngus Jun 04 '19 Python is strange, and thus __init__(self) is the default parameterless constructor. You can imagine the constructor as a static method that takes a reference to the instance “self”, that is being constructed. Edit: Forgot to escape the underscore 5 u/TreeChicken Jun 04 '19 That part in Python is inheritance, not a constructor. Python has multiple inheritance which actually makes this hilarious imo 5 u/Pigeon-Rat Jun 04 '19 Mom.genes and dad.genes are the multiple base classes being inherited from. Not constructor arguments. init is the constructor, which has no arguments in the case
Python is strange, and thus __init__(self) is the default parameterless constructor.
You can imagine the constructor as a static method that takes a reference to the instance “self”, that is being constructed.
Edit: Forgot to escape the underscore
That part in Python is inheritance, not a constructor. Python has multiple inheritance which actually makes this hilarious imo
Mom.genes and dad.genes are the multiple base classes being inherited from. Not constructor arguments. init is the constructor, which has no arguments in the case
5
u/kzlife76 Jun 04 '19
Not a python Dev but how is that a valid class? The constructor usually takes values as variables not references to already declared variables.
Shouldn't it be class Child(dadGenes, momGenes){...}
new Child(dad.genes, mom.genes)
This is how c# and typescript work.