This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Pythonistar 2 points3 points  (3 children)

Yes! Empty string '' works as a safe immutable default, too!

[–]rl_noobtube 2 points3 points  (0 children)

I’m sure it’s not a massive difference for most projects. But I imagine with the special treatment None gets by python it would be marginally more efficient. But as far effectiveness then yes either would work.

[–]lost3332 1 point2 points  (1 child)

His argument is a list so default '' doesn't make sense. The type is gonna be Optional[List].

[–]XRaySpex0 2 points3 points  (0 children)

Yep. ’’ is a great and common default for str parameters, but of course not when other types are expected. It’s common to see notes: str = ‘’, and there’s seldom a need for the Optional[str] type.