Skip to content
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

instantiation #93

Open
AlinDavid opened this issue Jan 15, 2021 · 2 comments
Open

instantiation #93

AlinDavid opened this issue Jan 15, 2021 · 2 comments

Comments

@AlinDavid
Copy link

AlinDavid commented Jan 15, 2021

I'n not an expert but i would like to know if there wasn't better to type the init method like this:

class Shape:
def init(self, color=None):
if color == None:
self.color = ""
else:
self.color = color

since the input for color is expected to be a string type

@joeyajames
Copy link
Owner

Isn't this simpler, and does the same thing?
class Shape:
def init(self, color=''):
self.color = color

@AlinDavid
Copy link
Author

AlinDavid commented Mar 4, 2021

It is simpler but instantiating objects like that will maybe became troublesome because every instance will receive the same reference to the "" string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants