I know about foo = []
being shorthand for foo = list()
and I was wondering if there was a list of shorthand notations for creating empty dictionaries, tuples, sets, etc. I'm specifically looking for Python 3.x but either one would be useful to have.
Answer
To create an empty dictionary, use {}
.
To create an empty tuple, use ()
.
There is no shortcut for an empty set.
As for the etc., I don't know what else you are thinking of.
No comments:
Post a Comment