[Tutor] Fwd: Difference between types

Dave Angel davea at davea.name
Sat May 25 16:56:35 CEST 2013


On 05/25/2013 08:54 AM, Albert-Jan Roskam wrote:
>
>
>> From: Dave Angel <davea at davea.name>
>>
      <SNIP>
>>
>> The empty tuple is specified with ().  But for any tuple with one or
>> more members, it's the commas that turn it into a tuple.  The parens are
>> not necessarily needed unless the statement is complex enough that we
>> need them for precedence.
>>
>> So   x = 3,4
>>
>> makes a one-tuple out of 3 and 4.  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? I looked it up and: "In mathematics, a singleton, also known as a unit set, is a set with exactly one element. For example, the set {0} is a singleton.The term is also used for a 1-tuple (a sequence with one element)".(http://en.wikipedia.org/wiki/Singleton_%28mathematics%29).
>
> <snip>
>
>

Thanks for that reference.  I had forgotten the usage of singleton in 
pure mathematics.  In computer software the only way I can recall it 
used (in about 45 years) is the design pattern singleton.  For example 
None is a singleton.  You cannot create another instance of NoneType.

http://en.wikipedia.org/wiki/Singleton_pattern

Now even that is a little different than I've seen used.  I've seen True 
and False considered singletons, even though they're the same class. 
But each value (of two legal values) of that class can only be 
instantiated once.

If the term is also used to represent one-tuples or one-item sets in 
software, that seems to me to be very confusing and misleading.  So I'm 
not saying you're wrong, only that I hope you are.

(Flash:) I just spotted Steven's post.  Thanks for the correction about 
3,4  which was just a typo.  And yes, I was referring to meanings two 
and three in your list.  And indirectly to the Gang of Four book,
     http://en.wikipedia.org/wiki/Design_Patterns


-- 
DaveA


More information about the Tutor mailing list