On 25/05/13 22:54, Albert-Jan Roskam wrote:


From: Dave Angel <da...@davea.name>

So   x = 3,4

makes a one-tuple out of 3 and 4.

Dave means a two-tuple here.


If you want a one-tuple (which is NOT
a singleton), you need a silly-looking comma to specify it:

So you say the term singleton is reserved to one-item sets?


Nope. "Singleton" has various meanings.

1) A singleton tuple (or set, or list) is a tuple with a single item in it. 
This is a fairly unusual definition in Object Oriented programming circles, 
since it clashes with the next definition, but it's more common in functional 
programming and the more heavily mathematical end of computer science theory.

2a) A singleton is a class that only allows a single instance to be created.

2b) The lone instance of a singleton class is also called a singleton. E.g. 
None is a singleton.

3) (Informal) A class that only allows a fixed, and small, number of instances 
to be created, where there is exactly one instance for each possible value. 
E.g. sometimes people will call True and False singletons, even though there 
are two of them, because Python guarantees that there will be exactly one True 
instance, and exactly one False instance.


Dave is, I think, referring to the common use in programming circles of 
"singleton" to refer to a class with exactly one instance, like None. This is 
very widespread, but not all programming languages have a concept of instances, so it is 
not a universal definition.



--
Steven
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to