Re: [Tutor] elif statement

2010-08-10 Thread Adam Bark
On 11/08/10 02:34, Sudarshana Banerjee wrote: Hi: I am trying to teach myself Python, and am stuck at the indentation with the elif statement. This is what I am trying to type (as copied from the textbook): x=3 if x==0: print "x is 0" elif x&1 ==1: print "x is a odd number" elif x&1==0

[Tutor] elif statement

2010-08-10 Thread Sudarshana Banerjee
Hi: I am trying to teach myself Python, and am stuck at the indentation with the elif statement. This is what I am trying to type (as copied from the textbook): x=3 if x==0: print "x is 0" elif x&1 ==1: print "x is a odd number" elif x&1==0: -- Line 6 print "x is a even number" If I

Re: [Tutor] Making String

2010-08-10 Thread Steven D'Aprano
On Wed, 11 Aug 2010 06:09:28 am Joel Goldstick wrote: > The str part of str.join() is the string where the result is stored, > so you can start off with an empty string: "" I don't understand what you mean by that. I can only imagine you think that the string part is a fixed-width buffer that has

Re: [Tutor] Making String

2010-08-10 Thread Corey Richardson
Joel and Hugo: Thanks a lot! That clears it right up. ~Corey Richardson ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Making String

2010-08-10 Thread Joel Goldstick
On Tue, Aug 10, 2010 at 3:49 PM, Corey Richardson wrote: > Hello, tutors. > > I'm attempting to make a string from the items of a list. > For example, if the list is ["3", "2", "5", "1", "0"], I desire the string > "32510". > > a = ["3", "2", "5", "1", "0"] my_string = "".join(a) Or, this even w

Re: [Tutor] Making String

2010-08-10 Thread Hugo Arts
On Tue, Aug 10, 2010 at 2:49 PM, Corey Richardson wrote: > Hello, tutors. > > I'm attempting to make a string from the items of a list. > For example, if the list is ["3", "2", "5", "1", "0"], I desire the string > "32510". > > I've looked into str.join(), but I can't figure it out. Can someone ei

Re: [Tutor] Lost in the control flow

2010-08-10 Thread Adam Bark
On 10/08/10 20:39, Eduardo Vieira wrote: Hello, list! I'm trying to parse a text file. I'm getting confuse with my strategy, and flags or how to use a sequence of ifs or elifs, continue, etc. Anyhow, after several experiments this is close to what I'd like to get, except, I can't find a way to in

[Tutor] Making String

2010-08-10 Thread Corey Richardson
Hello, tutors. I'm attempting to make a string from the items of a list. For example, if the list is ["3", "2", "5", "1", "0"], I desire the string "32510". I've looked into str.join(), but I can't figure it out. Can someone either point me in a different direction, or explain how join() work

[Tutor] Lost in the control flow

2010-08-10 Thread Eduardo Vieira
Hello, list! I'm trying to parse a text file. I'm getting confuse with my strategy, and flags or how to use a sequence of ifs or elifs, continue, etc. Anyhow, after several experiments this is close to what I'd like to get, except, I can't find a way to include all the pin numbers (12 number sequen

Re: [Tutor] problem loading and array from an external file

2010-08-10 Thread Hugo Arts
On Tue, Aug 10, 2010 at 9:59 AM, bob gailer wrote: > On 8/10/2010 10:42 AM, Bill Allen wrote: >> >> Bob, >> >> I was really off on that algorithm and had way over complicated it. >> I have it working correctly now, but for the sake of those who saw my >> earlier really botched code, here is the re

Re: [Tutor] os.urandom()

2010-08-10 Thread Dave Angel
Steven D'Aprano wrote: On Tue, 10 Aug 2010 02:24:00 pm Dave Angel wrote: Any suggestions how to fix the Windows console to interpret utf8? I don't know about Windows, but under Linux there is a menu command for most xterms that let you set it. Googling led me to this page: which, if

Re: [Tutor] problem loading and array from an external file

2010-08-10 Thread bob gailer
On 8/10/2010 10:42 AM, Bill Allen wrote: Bob, I was really off on that algorithm and had way over complicated it. I have it working correctly now, but for the sake of those who saw my earlier really botched code, here is the resultant code that works. The entire inner loop and intermediate varia

Re: [Tutor] problem loading and array from an external file

2010-08-10 Thread Bill Allen
On Tue, Aug 10, 2010 at 8:21 AM, bob gailer wrote: > On 8/9/2010 11:13 PM, Bill Allen wrote: >> >> Bob, >> >> Thanks for the feedback.  I have been stepping through it in the IDLE >> debugger.  However, it may be that I am letting the debugger get in my >> way as I am new to it also.  You are righ

Re: [Tutor] os.urandom()

2010-08-10 Thread Steven D'Aprano
On Wed, 11 Aug 2010 12:33:11 am Steven D'Aprano wrote: > > Any suggestions how to fix the Windows console to interpret utf8? > > I don't know about Windows, but under Linux there is a menu command > for most xterms that let you set it. > > Googling led me to this page: Oops, forgot to paste the l

Re: [Tutor] os.urandom()

2010-08-10 Thread Tim Golden
On 10/08/2010 15:33, Steven D'Aprano wrote: On Tue, 10 Aug 2010 02:24:00 pm Dave Angel wrote: [...] Any suggestions how to fix the Windows console to interpret utf8? There are several tracker issues relating to this one. The current position seems to be: it's not easy. I've done no more than

Re: [Tutor] os.urandom()

2010-08-10 Thread Steven D'Aprano
On Tue, 10 Aug 2010 02:24:00 pm Dave Angel wrote: > > repr() returns the string > > representation, not the byte representation. Try this: > > That's what I was missing. Somehow I assumed it was converting to > byte strings. > > I had assumed that it reverted to /u or /U whenever a >

Re: [Tutor] problem loading and array from an external file

2010-08-10 Thread bob gailer
On 8/9/2010 11:13 PM, Bill Allen wrote: Bob, Thanks for the feedback. I have been stepping through it in the IDLE debugger. However, it may be that I am letting the debugger get in my way as I am new to it also. You are right. I'll get out the old yellow legal pad and step through it by han