Re: [Tutor] python dictionary and loop

2012-02-28 Thread Prasad, Ramit
>The two sentences I would like to use in the program is the following: >"This is line one\nThis is line two!" so I write: text_message = "This is line >one\nThis is line two!" >The dictionary name and key/value pairs will be: >my_sentences {'This':'This','is':'is','line':'line','one':'two'}   # D

Re: [Tutor] python questions about dictionary loops

2012-02-28 Thread Steven D'Aprano
justin fargus wrote: Hello, I'm new to Python. Just started a few weeks ago and I've been learning some basic things that I would like to put together but I don't even know where to began. I am trying to do the following: Make a program using two sentences of about 8 words (total between the t

Re: [Tutor] python questions about dictionary loops

2012-02-28 Thread Prasad, Ramit
Justin wrote: >I'm new to Python. Just started a few weeks ago and I've been learning some >basic things that I would like to put together but I don't even know where to >began. I am trying to do the following: >Make a program using two sentences of about 8 words (total between the two >senten

[Tutor] python dictionary and loop

2012-02-28 Thread justin fargus
Hello, I am trying to do the following: Make a program using two sentences of about 8 words (total between the two sentences). I would then like to create a dictionary {} and split the words of each sentence using one sentence as a dictionary key and using the other sentence for the dictionary v

[Tutor] python questions about dictionary loops

2012-02-28 Thread justin fargus
Hello, I'm new to Python. Just started a few weeks ago and I've been learning some basic things that I would like to put together but I don't even know where to began. I am trying to do the following: Make a program using two sentences of about 8 words (total between the two sentences). I would

Re: [Tutor] initialising all elements of a matrix

2012-02-28 Thread Peter Otten
bob gailer wrote: > On 2/28/2012 11:40 AM, Peter Otten wrote: > > def product(factors, product=1): > for factor in factors: > product *= factor > return product > > can be "simplified" > > def product(factors): >import operator >return reduce(operator.mul, factors) I

Re: [Tutor] initialising all elements of a matrix

2012-02-28 Thread bob gailer
On 2/28/2012 11:40 AM, Peter Otten wrote: def product(factors, product=1): for factor in factors: product *= factor return product can be "simplified" def product(factors): import operator return reduce(operator.mul, factors) -- Bob Gailer 919-636-4239 Chapel Hill NC _

Re: [Tutor] initialising all elements of a matrix

2012-02-28 Thread Peter Otten
Sivaram Neelakantan wrote: > > I was wondering whether there is a faster/better/cleaner way of > element wise operations of arbitrarily nested list. I wrote something > like this for 1 level nested lists and am wondering whether there are > any good idioms in python. I did this after a ridiculo

[Tutor] initialising all elements of a matrix

2012-02-28 Thread Sivaram Neelakantan
I was wondering whether there is a faster/better/cleaner way of element wise operations of arbitrarily nested list. I wrote something like this for 1 level nested lists and am wondering whether there are any good idioms in python. I did this after a ridiculous amount of bad thinking/missteps in

Re: [Tutor] new to programming and wondering about an IDE for Python on Linux (Robert Sjoblom)

2012-02-28 Thread Joaquim Santos
-- > > Message: 1 > Date: Mon, 27 Feb 2012 20:10:42 +0100 > From: Robert Sjoblom > To: Alan Gauld > Cc: tutor@python.org > Subject: Re: [Tutor] new to programming and wondering about an IDE for >Python on Linux > Message-