-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solution #1187
base: master
Are you sure you want to change the base?
Solution #1187
Conversation
app/main.py
Outdated
@@ -1 +1,58 @@ | |||
# write your code here | |||
class SoftwareEngineer: | |||
skills = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skills
is mutable object (a list), is shared among all instances and subclasses, leading to unpredictable behavior when its contents are modified. This means that adding skills in one instance can affect all others that inherit from this class. You should move skills to an instance-level variable within the constructor, ensuring each instance has its own separate list of skills.
app/main.py
Outdated
def __init__(self, name: str) -> None: | ||
super().__init__(name) | ||
self.skills = ( | ||
BackendDeveloper(self.name).skills | ||
+ FrontendDeveloper(self.name).skills | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__init__
method redundant here
app/main.py
Outdated
class FrontendDeveloper(SoftwareEngineer): | ||
def __init__(self, name: str) -> None: | ||
super().__init__(name) | ||
self.skills = ["JavaScript", "HTML", "CSS"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.skills = ["JavaScript", "HTML", "CSS"] | |
self.skills += ["JavaScript", "HTML", "CSS"] |
Don't override skills, but updated them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not fixed
app/main.py
Outdated
class FrontendDeveloper(SoftwareEngineer): | ||
def __init__(self, name: str) -> None: | ||
super().__init__(name) | ||
self.skills = ["JavaScript", "HTML", "CSS"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still not fixed
app/main.py
Outdated
def __init__(self, name: str) -> None: | ||
super().__init__(name) | ||
self.skills += ["JavaScript", "HTML", "CSS"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init method redundant here
app/main.py
Outdated
def __init__(self, name: str) -> None: | ||
super().__init__(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__init__
method redundant here
app/main.py
Outdated
|
||
ben = FullStackDeveloper("Ben") | ||
print(ben.skills) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this two line
No description provided.