[Tutor] James D Mcclatchey is out of the office.

2008-07-30 Thread James D Mcclatchey
I will be out of the office starting 07/30/2008 and will not return until 08/04/2008. I will respond to your message when I return. ***IMPORTANT NOTICE: This communication, including any attachment, contains information that may be confidential or privileged, and is intended solely for the e

[Tutor] help with augumented assignment y += 1

2008-07-30 Thread Norman Khine
Hello, I am writing a poll application, which has two XML files: 1) survey.xml Is an augumented assignment such as 'x = x + 1' the same as x += 1? Yes No Don't know The statement 'x *= y + 1' is equivalent to: 'x = (x * y) + 1' 'x = x * (y + 1) 'x = (y + 1) * x' All of

Re: [Tutor] How to run a Python program under Windows.

2008-07-30 Thread bob gailer
Morgan Thorpe wrote: Hey Again. Okay i don't think my sad explantion did help at all. Would you be able to explain step by step what i need to do to run the simplest of simple program's everyone else has asked about where it is and what not. According to them i have everything where it needs t

Re: [Tutor] help with augumented assignment y += 1

2008-07-30 Thread Emile van Sebille
Norman Khine wrote: Hello, I am writing a poll application, which has two XML files: Is this entire question consistent? I ask because when you get to asking your question below, it sounds like you're trying to tie together two outputs: > This returns: > ['1'] ['1', '2', '2', '2'] [1, 1

Re: [Tutor] help with augumented assignment y += 1

2008-07-30 Thread Norman Khine
Hi, Appologies, there was a typo, in that the first line is: ['1'] ['a1', 'a2', 'a2', 'a2'] [1, 1, 2, 4] The way the first line relates to the survey is such that, it looks at the response.xml file and returns what the individual user has submitted. So that: ['1'] ['a1', 'a2', 'a2', 'a2'] [1, 1

Re: [Tutor] help with augumented assignment y += 1

2008-07-30 Thread Emile van Sebille
Norman Khine wrote: Hi, Appologies, there was a typo, in that the first line is: ['1'] ['a1', 'a2', 'a2', 'a2'] [1, 1, 2, 4] Yes -- that helps. So, working from your xml samples, by doing something like: responses = [ [a,b,c] for a,b,c in responseAnalysisGenerator ] you can end up with resp

[Tutor] Communication between threads

2008-07-30 Thread James
All, I'm looking for some thoughts on how two separate threads can communicate in Python. From what I've read in a few Python books, sharing data between threads can be done by writing and reading a global variable in the parent of both threads. Is this the "best" way? Is it the *only* way? Also,

[Tutor] understanding join

2008-07-30 Thread Steve Poe
Hi tutor list, Just trying to add some clarity to the built-in function strings using join. The Python help screen says it returns a string which is a concatenation of strings in sequence. I am concatenating the string I am working on that maybe an issue of its own. Here's my example: stri

Re: [Tutor] Communication between threads

2008-07-30 Thread Emile van Sebille
James wrote: All, I'm looking for some thoughts on how two separate threads can communicate in Python. From what I've read in a few Python books, sharing data between threads can be done by writing and reading a global variable in the parent of both threads. Is this the "best" way? Is it the *on

Re: [Tutor] understanding join

2008-07-30 Thread John Fouhy
On 31/07/2008, Steve Poe <[EMAIL PROTECTED]> wrote: > Hi tutor list, > > Just trying to add some clarity to the built-in function strings using > join. The Python help > screen says it returns a string which is a concatenation of strings in > sequence. I am concatenating > the string I am workin

Re: [Tutor] understanding join

2008-07-30 Thread John Fouhy
On 31/07/2008, Steve Poe <[EMAIL PROTECTED]> wrote: > Good point. I guess I am surprised a little that Python does not error > on that you cannot assign a variable to a module name. I know I need > to learn proper coding techniques. Well, that wouldn't really work because you don't know what o

Re: [Tutor] understanding join

2008-07-30 Thread Kent Johnson
> On 31/07/2008, Steve Poe <[EMAIL PROTECTED]> wrote: >> Okay, I can see the order of the join is the same as mine, but >> the join still seems to be out of sequence. I am thinking it should be >> 'abcABC' or 'ABCabc' not at the beginning, middle, and end of the >> original string. At least, I

[Tutor] checking for expected types from input file

2008-07-30 Thread Bryan Fodness
I am populating a dictionary from an input file, and would like to create an error code if a string is sent to a variable that expects a float or int. INPUT = {} for line in open(infile): input_line = line.split(' = ') INPUT[input_line[0].strip()] = input_line[1].strip() if INPUT.has_key(

Re: [Tutor] checking for expected types from input file

2008-07-30 Thread Steve Poe
Bryan, How about checking your input to see if they are digits or not? >>> input_data = '123ABC' >>> print input_data.isdigit() False >>> input_data = '1234567889' >>> print input_data.isdigit() True >>> input_data = '123ABC' >>> print input_data.isdigit() False or something like: while INPUT.h

Re: [Tutor] Memory error - how to manage large data sets?

2008-07-30 Thread Kepala Pening
def sumEvenFibonacci( limit ): a, b = 1, 1 # don't waste with a = 0 sum = 0 while b < limit: if b%2 == 0: sum += b a, b = b, a + b return sum print sumEvenFibonacci( 200 ) - Original Message - From: Chris Fuller <[EMAI

Re: [Tutor] understanding join

2008-07-30 Thread Steve Poe
Does this look useful? In [3]: people = [ 'Tom', 'Dick', 'Harry' ] In [4]: ', '.join(people) Out[4]: 'Tom, Dick, Harry' Your confusion is in thinking about the string 'ABC' as a single entity. For the purposes of join(), it is a sequence of three letters. The argument to join() is a sequence of

Re: [Tutor] understanding join

2008-07-30 Thread Steve Poe
Say I have a sequence seq and a string s, and I call s.join(seq). Here's what it does: s.join(seq) == seq[0] + s + seq[1] + s + seq[2] + s + ... + seq[-2] + s + seq[-1] So if you call 'abc'.join('ABC'), you get: 'ABC'[0] + 'abc' + 'ABC'[1] + 'abc' + 'ABC'[2] which is: 'A' + 'abc' + 'B'

Re: [Tutor] understanding join

2008-07-30 Thread John Fouhy
On 31/07/2008, Steve Poe <[EMAIL PROTECTED]> wrote: > Your explanation is very help. It does make be wonder the usefulness > of join with strings. Do you have a practical example/situation? Kent's example is common: you might have a list of strings that you want to display to the user, so you ca

Re: [Tutor] checking for expected types from input file

2008-07-30 Thread John Fouhy
On 31/07/2008, Bryan Fodness <[EMAIL PROTECTED]> wrote: > I am populating a dictionary from an input file, and would like to create an > error code if a string is sent to a variable that expects a float or int. > > INPUT = {} > for line in open(infile): > input_line = line.split(' = ') > IN

Re: [Tutor] Memory error - how to manage large data sets?

2008-07-30 Thread Alan Gauld
"Kepala Pening" <[EMAIL PROTECTED]> wrote def sumEvenFibonacci( limit ): a, b = 1, 1 # don't waste with a = 0 sum = 0 while b < limit: if b%2 == 0: sum += b a, b = b, a + b return sum print sumEvenFibonacci( 200 ) Does it work for limit = 2? Alan G. __

Re: [Tutor] understanding join

2008-07-30 Thread Alan Gauld
"Steve Poe" <[EMAIL PROTECTED]> wrote In [3]: people = [ 'Tom', 'Dick', 'Harry' ] Okay, now let's join people to people and what do we get? An error, join only works on a single string. It joins the elements of a sequence of strings into a single string using the 'owning' string. In some w

Re: [Tutor] checking for expected types from input file

2008-07-30 Thread Alan Gauld
"Bryan Fodness" <[EMAIL PROTECTED]> wrote I have many variables of different types, and I want to do a check in case something like ReferencePositionX = abc occurs. In Python its usual to tackle that using try/except. If you get a TypeError then try type conversion. The saying goes somethinn

Re: [Tutor] understanding join

2008-07-30 Thread Alan Gauld
"Steve Poe" <[EMAIL PROTECTED]> wrote Your explanation is very help. It does make be wonder the usefulness of join with strings. Do you have a practical example/situation? Its not really intended for strings but it needs to work that way to be consistent because strings are just another type

[Tutor] key/value order in dictionaries

2008-07-30 Thread Steve Poe
Hi tutor list, In dictionaries, I know that the keys are immutable, and the values can change What about the place/order of the key/order? I thought that they were sequential and they do not change. >>> D={"AAA":1234,"BBB":3456,"CCC":7890} >>> print D {'AAA': 1234, 'BBB': 3456, 'CCC': 7890} >

Re: [Tutor] Memory error - how to manage large data sets?

2008-07-30 Thread Kepala Pening
Since the question is less than 200, I used b < limit. However, to have limit = 2, perhaps I should do while b <= limit. Thanks Alan for pointing it out. - Original Message - From: "Alan Gauld" <[EMAIL PROTECTED]> To: tutor@python.org Date: Thu, 31 Jul 2008 06:39:32 +0