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
On 05/25/2013 05:25 AM, Rafael Knuth wrote:
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 beg
On 25 May 2013 14:42, Ken G. wrote:
> May I suggest that instead of:
> how about:
>
> flips = heads = tails = 0
>
> Ken
How about flips = heads = 0
tails can then be calculated from flips - heads.
--
best regards,
Robert S.
___
Tutor maillist - Tutor@
> From: Dave Angel
>To: tutor@python.org
>Sent: Friday, May 24, 2013 9:10 PM
>Subject: Re: [Tutor] Fwd: Difference between types
>
>
>On 05/24/2013 02:53 PM, Albert-Jan Roskam wrote:
>>
>>
>>> A tuple is defined by commas, depending on context. However,
>>> parentheses are typically required
On 25/05/13 19:25, Rafael Knuth wrote:
flips = 0
heads = 0
tails = 0
while flips < 10:
flips = flips + 1
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 hav
On 25/05/13 22:54, Albert-Jan Roskam wrote:
From: Dave Angel
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 on
On 05/25/2013 08:54 AM, Albert-Jan Roskam wrote:
From: Dave Angel
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
On 25/05/2013 15:56, Dave Angel wrote:
On 05/25/2013 08:54 AM, Albert-Jan Roskam wrote:
From: Dave Angel
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
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)
On 25/05/2013 19:56, Jim Mooney wrote:
I thought tuples were immutable but it seems you can swap them, so I'm
confused:
a,b = 5,8
You've defined two names a and b so where's the tuple?
print a # result 5
a,b = b,a
You've redefined two names a and b to take the values that were held in
On 25 May 2013 02:51, eryksun wrote:
> On Fri, May 24, 2013 at 9:10 PM, Dave Angel wrote:
>>
>> Is lists[(3,8)] really so much harder to type than
>> list_3_8 ?
>
> Since a comma creates a tuple, in this context you can just use
> lists[3,8] to save a couple more keystrokes.
Or even lists(
On 2013-5ζ-25, at δΈε11:56, Jim Mooney wrote:
> I thought tuples were immutable but it seems you can swap them, so I'm
> confused:
>
> a,b = 5,8
>
I think you're confusing mutating the tuples with assigning the immutable
tuples different names. The variable names are just labels you attach
On 05/25/2013 02:56 PM, Jim Mooney wrote:
I thought tuples were immutable but it seems you can swap them, so I'm
confused:
The anonymous tuple object is immutable, but you just build one
temporarily, extract both items from it, and destroy it.
a,b = 5,8
The a,b on the left hand side is
On 26/05/2013, Jim Mooney wrote:
> I thought tuples were immutable but it seems you can swap them, so I'm
> confused:
>
> a,b = 5,8
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
On 26/05/13 05:23, Mark Lawrence wrote:
On 25/05/2013 19:56, Jim Mooney wrote:
I thought tuples were immutable but it seems you can swap them, so I'm
confused:
a,b = 5,8
You've defined two names a and b so where's the tuple?
On the right hand side, 5,8 creates a tuple, which is then immedia
On 25 May 2013 18:34, David wrote:
> On 26/05/2013, Jim Mooney wrote:
> > I thought tuples were immutable but it seems you can swap them, so I'm
> > confused:
> >
> > a,b = 5,8
>
> I think your confusion might arise from not understanding that the
> meaning of the comma differs depending on whet
I'm new to this, just getting through the first Mark Lutz book.
If I start out with :
ham=list('spam');ham
['s','p','a','m']
How do I get a string back?
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mai
On 26/05/2013 04:07, Tim Hanson wrote:
I'm new to this, just getting through the first Mark Lutz book.
If I start out with :
ham=list('spam');ham
['s','p','a','m']
How do I get a string back?
___
Tutor maillist - Tutor@python.org
To unsubscribe or
On 25 May 2013 19:38, Steven D'Aprano wrote:
> On 26/05/13 05:23, Mark Lawrence wrote:
>
> On the right hand side, 5,8 creates a tuple, which is then immediately
> unpacked to two individual values. You can see this by disassembling the
> code. In 2.7, you get this:
>
> py> from dis import dis
Oops, Gmail switched me back to rich text. My apologies. Back to plain
;') I wish I could automate the mode, per-recipient, since I do need
rich text for some things. The way gmail defaults seems to change from
month to month.
--
Jim Mooney
___
Tutor ma
Greetings Tim,
: I'm new to this, just getting through the first Mark Lutz book.
Python objects, either variables your ham below or the string 'spam'
you entered manually have a specific type. Each and every variable
or object has a type.
I think you are trying to figure out how you start
On Saturday, May 25, 2013 08:31:49 pm Martin A. Brown wrote:
> Greetings Tim,
>
> : I'm new to this, just getting through the first Mark Lutz book.
>
> Python objects, either variables your ham below or the string 'spam'
> you entered manually have a specific type. Each and every variable
> or
On Sat, May 25, 2013 at 10:38 PM, Steven D'Aprano wrote:
> On 26/05/13 05:23, Mark Lawrence wrote:
>>
>> On 25/05/2013 19:56, Jim Mooney wrote:
>>>
>>> I thought tuples were immutable but it seems you can swap them, so I'm
>>> confused:
>>>
>>> a,b = 5,8
>>
>>
>> You've defined two names a and b s
On 25 May 2013 20:49, Tim Hanson wrote:
> A lot of people tend to be intimidated by Mark Lutz, and so am I, I guess.
Interesting coincidence. This is a retirement project and I just
decided on the Lutz book, which looked comprehensive, since the book
I'm using is more CompSci but PyDeficient. Ho
On Saturday, May 25, 2013 09:10:00 pm Jim Mooney wrote:
> On 25 May 2013 20:49, Tim Hanson wrote:
> > A lot of people tend to be intimidated by Mark Lutz, and so am I, I
> > guess.
>
> Interesting coincidence. This is a retirement project and I just
> decided on the Lutz book, which looked compre
On Fri, May 24, 2013 at 2:53 PM, Albert-Jan Roskam wrote:
> Why do I need to use a trailing comma to create a singleton
> tuple? Without a comma it seems to mean "parenthesized single
> object", ie the parentheses are basically not there.
Here are some technical notes and references to augment th
26 matches
Mail list logo