+ 7

So, when/why would you want to use an empty tuple or an empty dictionary?

10th Mar 2016, 4:54 AM
Shea Culbertson
Shea Culbertson - avatar
5 odpowiedzi
+ 13
You might want to store the arguments to a function as a tuple, without knowing the structure of the function in advance. If it happens that the function you need to store the parameters for, takes no parameters, you will need to store an empty tuple. Or another use might be when returning a result. You might need an empty result set, if, for example, the result is blank.
23rd May 2016, 10:40 AM
James Flanders
+ 2
when we have to store any value about which we don't know whether it is a string,list,tuple etc.
26th Nov 2016, 2:35 PM
Rahul
+ 1
An empty dictionary means assigning a variable to be type dict..... which can later be altered by adding or removing elements. Similar to integer assignment in C/C++.
18th Jun 2016, 9:38 AM
Piyush Doorwar
Piyush Doorwar - avatar
0
I would use an empty dictionary instead of an empty tuple, or even an empty list, because tuples and string aren't able to be modified, instead of list and dictionaries that you can change the key or the value related to that key, and lists are also capable to be modified any time too.
24th Nov 2016, 11:58 PM
Daniel
Daniel - avatar
0
initializing a constant of any sort with zero or as an empty set is often useful when you want a reference from which to compare or reset variables to later in the course of a programs logic flow I hope that helps! .
1st Dec 2016, 4:34 AM
tallship
tallship - avatar