<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:syn="http://purl.org/rss/1.0/modules/syndication/" xmlns:admin="http://webns.net/mvcb/">
  <channel rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor">
    <title>gmane.comp.python.tutor</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor</link>
    <description/>
    <syn:updatePeriod>hourly</syn:updatePeriod>
    <syn:updateFrequency>1</syn:updateFrequency>
    <syn:updateBase>1901-01-01T00:00+00:00</syn:updateBase>
    <items>
      <rdf:Seq>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81839"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81838"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81837"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81836"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81835"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81834"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81833"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81832"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81831"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81830"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81829"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81828"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81827"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81826"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81825"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81824"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81823"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81822"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81821"/>
        <rdf:li rdf:resource="http://permalink.gmane.org/gmane.comp.python.tutor/81820"/>
      </rdf:Seq>
    </items>
    <image rdf:resource="http://gmane.org/img/gmane-25t.png"/>
    <textinput rdf:resource=""/>
  </channel>
  <image rdf:about="http://gmane.org/img/gmane-25t.png">
    <title>Gmane</title>
    <url>http://gmane.org/img/gmane-25t.png</url>
    <link>http://gmane.org</link>
  </image>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81839">
    <title>Re: why can you swap an immutable tuple?</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81839</link>
    <description>&lt;pre&gt;
I think your confusion might arise from not understanding that the
meaning of the comma differs depending on whether it is on the left or
the right side of an equals sign.

On the right: it combines the 5 and the 8 to create a tuple, as yet un-named.

On the left: it says to unpack the tuple-on-the-right into two
independent values and assign them to the names a and b. So here it is
effectively a=5 and b=8.

So, there is no tuple on the left hand side. The statement does not
create a tuple, because the comma on the left side means "unpack the
tuple-on-the-right".

To assign a name to a tuple, there must be no comma on the left side, like this:
name_of_tuple = 5, 8
_______________________________________________
Tutor maillist  -  Tutor&amp;lt; at &amp;gt;python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

&lt;/pre&gt;</description>
    <dc:creator>David</dc:creator>
    <dc:date>2013-05-26T01:34:38</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81838">
    <title>Re: why can you swap an immutable tuple?</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81838</link>
    <description>&lt;pre&gt;
The anonymous tuple object is immutable, but you just build one 
temporarily, extract both items from it, and destroy it.


The a,b on the left hand side is a tuple-unpacking-syntax, where it 
takes whatever tuple (or list, or whatever else supports the protocol), 
and extracts the elements in order.  a,b are not tied together in any sense.


Here you build another anonymous tuple that happens to be in the reverse 
order as the earlier one.  Then you unpack it into two arbitrary 
variables, that only happen to be the same ones as you used before, and 
only happens to be the same ones as used on the right side.


Now you're building yet another tuple, and actually binding a name to 
it.  So it won't go away at the end of the statement.


This time you ARE trying to change a tuple, for the first time.


&lt;/pre&gt;</description>
    <dc:creator>Dave Angel</dc:creator>
    <dc:date>2013-05-25T20:52:04</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81837">
    <title>Re: why can you swap an immutable tuple?</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81837</link>
    <description>&lt;pre&gt;
On 2013-5月-25, at 上午11:56, Jim Mooney wrote:



I think you're confusing mutating the tuples with assigning the immutable tuples different names.  The variable names are just labels you attach to them.  The tuple values themselves cannot change.  

That said, your example here isn't a tuple but a pair of singleton values. 

If you said 
tuple1 = 1,2,3,4
tuple2 = 5,6,7,8

you create two tuples which are, yes, immutable.  They happen to be called tuple1 and tuple2 but that's beside the point of immutability.  If you pass them to a function, they'll be known locally there under different names but they're still immutable tuples.

Does that help?
--steve
_______________________________________________
Tutor maillist  -  Tutor&amp;lt; at &amp;gt;python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
&lt;/pre&gt;</description>
    <dc:creator>Steve Willoughby</dc:creator>
    <dc:date>2013-05-25T19:29:48</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81836">
    <title>Re: making a random list, then naming it</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81836</link>
    <description>&lt;pre&gt;
Or even lists(3, 8) if lists is a function.
_______________________________________________
Tutor maillist  -  Tutor&amp;lt; at &amp;gt;python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

&lt;/pre&gt;</description>
    <dc:creator>Oscar Benjamin</dc:creator>
    <dc:date>2013-05-25T19:27:36</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81835">
    <title>Re: why can you swap an immutable tuple?</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81835</link>
    <description>&lt;pre&gt;
You've defined two names a and b so where's the tuple?


You've redefined two names a and b to take the values that were held in 
b and a so still no tuple.


Finally a tuple.


Exactly as expected.  So what precisely don't you understand?

&lt;/pre&gt;</description>
    <dc:creator>Mark Lawrence</dc:creator>
    <dc:date>2013-05-25T19:23:39</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81834">
    <title>why can you swap an immutable tuple?</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81834</link>
    <description>&lt;pre&gt;I thought tuples were immutable but it seems you can swap them, so I'm
confused:

a,b = 5,8

print a  # result 5

a,b = b,a

print a  # result 8, so they swapped

# but if I test the type of a,b I get a tuple

testit = a,b
print type(testit)  #comes out as a tuple

print testit, # result is (8,5)

# So how am I swapping elements of a tuple when a tuple is immutable?

#t rying so change a tuple since I just did it

testit[1] = 14  #program crashes - *TypeError: 'tuple' object does not
support item assignment *so the tuple I just changed is indeed immutable

&lt;/pre&gt;</description>
    <dc:creator>Jim Mooney</dc:creator>
    <dc:date>2013-05-25T18:56:51</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81833">
    <title>Re: Fwd: Difference between types</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81833</link>
    <description>&lt;pre&gt;
IIRC Alex Martelli argued that you don't need a singleton, you need a 
borg.  I'll leave those interested to look this up :)

&lt;/pre&gt;</description>
    <dc:creator>Mark Lawrence</dc:creator>
    <dc:date>2013-05-25T15:09:01</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81832">
    <title>Re: Fwd: Difference between types</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81832</link>
    <description>&lt;pre&gt;      &amp;lt;SNIP&amp;gt;

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_Pat&lt;/pre&gt;</description>
    <dc:creator>Dave Angel</dc:creator>
    <dc:date>2013-05-25T14:56:35</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81831">
    <title>Re: Fwd: Difference between types</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81831</link>
    <description>&lt;pre&gt;

Dave means a two-tuple here.




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 wit&lt;/pre&gt;</description>
    <dc:creator>Steven D'Aprano</dc:creator>
    <dc:date>2013-05-25T13:24:46</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81830">
    <title>Re: Flip the coin 10x and count heads and tails: It works now!</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81830</link>
    <description>&lt;pre&gt;

Don't do this. It's not 1971 any more, we've had for loops for forty years :-)

Use while loops when you don't know how many loops you need. When you know how many loops you will have, use a for loop.

for flip in range(10):
     print(flip)

will print 0 1 2 3 ... 9 which makes ten loops altogether. If you want to start counting at 1 instead of 0, use:

for flip in range(1, 11):
     print(flip)

which will print 1 2 3 ... 9 10.


There's no need to count the number of heads and tails separately, since every loop is guaranteed to give either head or tails. So just count the number of heads, then the number of tails will be ten less the number of heads.




&lt;/pre&gt;</description>
    <dc:creator>Steven D'Aprano</dc:creator>
    <dc:date>2013-05-25T13:13:38</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81829">
    <title>Re: Fwd: Difference between types</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81829</link>
    <description>&lt;pre&gt;


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).

&amp;lt;snip&amp;gt;
_______________________________________________
Tutor maillist  -  Tutor&amp;lt; at &amp;gt;python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

&lt;/pre&gt;</description>
    <dc:creator>Albert-Jan Roskam</dc:creator>
    <dc:date>2013-05-25T12:54:18</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81828">
    <title>Re: Flip the coin 10x and count heads and tails: It worksnow!</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81828</link>
    <description>&lt;pre&gt;
How about flips = heads = 0
tails can then be calculated from flips - heads.
--
best regards,
Robert S.
_______________________________________________
Tutor maillist  -  Tutor&amp;lt; at &amp;gt;python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

&lt;/pre&gt;</description>
    <dc:creator>Robert Sjoblom</dc:creator>
    <dc:date>2013-05-25T12:50:28</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81827">
    <title>Re: Flip the coin 10x and count heads and tails: It works now!</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81827</link>
    <description>&lt;pre&gt;
On 05/25/2013 05:25 AM, Rafael Knuth wrote:
May I suggest that instead of:

flips = 0
heads = 0
tails = 0

how about:

flips = heads = tails = 0

Ken

_______________________________________________
Tutor maillist  -  Tutor&amp;lt; at &amp;gt;python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

&lt;/pre&gt;</description>
    <dc:creator>Ken G.</dc:creator>
    <dc:date>2013-05-25T12:42:54</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81826">
    <title>Flip the coin 10x and count heads and tails: It works now!</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81826</link>
    <description>&lt;pre&gt;Gents,

thank you all for your help. One of you guys asked me to try out your
suggestions and then tell you how it goes. Here we go! First, let me
recap briefly what the expected outcome of my program was and which
difficulties I encountered at the beginning. I was writing a program
in Python 3.3.0 which flips a coin 10 x times and then counts the
number of heads and tails. It obviously did something else than I
intended:

import random

print ("""

This program flips a coin 10 times.
It then counts the number of heads and tails.

""")

flips = 0
heads = 0
tails = 0

while flips &amp;lt; 10:
    flips = flips + 1
    if random.randint(1,2) == 1:
        heads = heads + 1
        print("We've got " + str(heads) + " heads here."
    if random.randint(1,2) == 2:
        tails = tails + 1
        print("We've got " + str(tails) + " tails here.")

This is what I got as output:

This program flips a coin 10 times.
It then counts the number of heads and tails.

We've got 1 tails here.
We've got 1 heads here.
We've got 2 t&lt;/pre&gt;</description>
    <dc:creator>Rafael Knuth</dc:creator>
    <dc:date>2013-05-25T09:25:13</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81825">
    <title>Jion list!</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81825</link>
    <description>&lt;pre&gt;Hi,i am JiangtaoSheng!!
_______________________________________________
Tutor maillist  -  Tutor&amp;lt; at &amp;gt;python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
&lt;/pre&gt;</description>
    <dc:creator>jiangtao sheng</dc:creator>
    <dc:date>2013-05-25T06:34:58</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81824">
    <title>Re: challenge-chapter 2</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81824</link>
    <description>&lt;pre&gt;
But it can be used as a variable name in some languages. "if" is at least *potentially* a variable name, in the sense that somebody might try to use it as a name.



While you are strictly correct, you are missing the point of the exercise, which is to distinguish between strings which can be used as variable names:

pedant
variable
constant
this_is_not_a_variable
pi
tau
alpha1234


and those that can't:

1234alpha
*$%^
for
return
this-is-a-variable


A better name for this is "identifier" rather than "variable name", and Python 3 defines a string method to test whether or not something is a valid identifier:

http://docs.python.org/3/library/stdtypes.html#str.isidentifier


&lt;/pre&gt;</description>
    <dc:creator>Steven D'Aprano</dc:creator>
    <dc:date>2013-05-25T02:57:30</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81823">
    <title>Re: Parentheses and tuples [was Re: Fwd: Difference betweentypes]</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81823</link>
    <description>&lt;pre&gt;
And except that the trailing comma is not optional. So, they are
special after all.

&lt;/pre&gt;</description>
    <dc:creator>Devin Jeanpierre</dc:creator>
    <dc:date>2013-05-25T02:49:12</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81822">
    <title>Parentheses and tuples [was Re: Fwd: Difference betweentypes]</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81822</link>
    <description>&lt;pre&gt;


Because round brackets are also used for grouping. You can group any expression:

z = (x+1)*y


Even an expression consisting of a single element:

z = (x+1)*(y)


That might not be a sensible thing to do, but it's not worth special-casing the parser to reject parentheses in this case. Now bring in tuples. Tuples are created by the comma operator, NOT the parentheses:

a = 23, 42, None

creates a tuple. At least one comma is necessary to distinguish an element from a tuple of one element:

a = 23  # a is the int 23
a = 23,  # a is a one-item tuple containing 23

Sometimes you use round brackets to group the tuple item, either because you need to change the precedence:

a = 23, (2, 4, 8), None

groups the three elements 2, 4, 8 into a tuple, which in turn is in a tuple:

print a
=&amp;gt; (23, (2, 4, 8), None)


Or we use round brackets to make a tuple just because it looks better, and matches the display of them:

a = (23, 42, None)
print a
=&amp;gt; (23, 42, None)

But make no mistake: it is the comma, not the bracket&lt;/pre&gt;</description>
    <dc:creator>Steven D'Aprano</dc:creator>
    <dc:date>2013-05-25T02:35:37</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81821">
    <title>Re: keyboard interrupt</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81821</link>
    <description>&lt;pre&gt;
This should be done sparingly for answers. But it's very common for
questions since inexperienced users almost always get the markdown
wrong.
_______________________________________________
Tutor maillist  -  Tutor&amp;lt; at &amp;gt;python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

&lt;/pre&gt;</description>
    <dc:creator>eryksun</dc:creator>
    <dc:date>2013-05-25T02:27:13</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81820">
    <title>Re: keyboard interrupt</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81820</link>
    <description>&lt;pre&gt;
Yes; I think that the idea is that it allows people to fix spelling
errors and/or reference mistakes, or maybe add things to clarify
something that the answer glossed over to begin with. I'm not entirely
sure how it works other than that you can edit answers and it's then
moderated by someone -- maybe the person who initially wrote the
answer? Or maybe you get moderator rights when reach a certain score.
--
best regards,
Robert S.
_______________________________________________
Tutor maillist  -  Tutor&amp;lt; at &amp;gt;python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

&lt;/pre&gt;</description>
    <dc:creator>Robert Sjoblom</dc:creator>
    <dc:date>2013-05-25T02:27:34</dc:date>
  </item>
  <item rdf:about="http://permalink.gmane.org/gmane.comp.python.tutor/81819">
    <title>Re: keyboard interrupt</title>
    <link>http://permalink.gmane.org/gmane.comp.python.tutor/81819</link>
    <description>&lt;pre&gt;


You can edit *other* people's questions and answers??!??!??

What. The. Hell.



&lt;/pre&gt;</description>
    <dc:creator>Steven D'Aprano</dc:creator>
    <dc:date>2013-05-25T02:19:48</dc:date>
  </item>
  <textinput rdf:about="http://search.gmane.org/?group=$group=gmane.comp.python.tutor">
    <title>Search Engine</title>
    <description>Search the mailing list at Gmane</description>
    <name>query</name>
    <link>http://search.gmane.org/?group=$group=gmane.comp.python.tutor</link>
  </textinput>
</rdf:RDF>
