Re: [Tutor] append vs list addition

2014-05-06 Thread Denis Heidtmann
On Tue, May 6, 2014 at 1:21 PM, Dave Angel wrote: > You're right to be confused; my fingers were confused typing my > last sentence. It should have ended: >... you should use + . > > Likewise the previous thought should have said: > > But in any similar > example, if list2 is t

Re: [Tutor] append vs list addition

2014-05-06 Thread Dave Angel
Denis Heidtmann Wrote in message: > On Sun, May 4, 2014 at 6:44 PM, Dave Angel wrote: >> C Smith Wrote in message: >>> Sorry. >>> >>> I meant for example: >>> list1 = [1,2,3] >>> list2 = [3,4,5] >>> >>> newList = list1 + list2 >>> >>> versus >>> >>> for x in list2: >>> list1.append(x) >>> >>

Re: [Tutor] sending email via SMTP: code review requested

2014-05-06 Thread Alan Gauld
On 05/05/14 18:53, Steven D'Aprano wrote: And, as I side note, could anyone explain why changing a first world of a body line 'From' to '>From' is the preferred standard? Because it's a dirty, nasty hack invented by somebody who wasn't thinking very carefully at the time, and now everybody doe

Re: [Tutor] Alice_in_wonderland Question

2014-05-06 Thread Peter Otten
Jake Blank wrote: > I finally got it. > This was the code: > for k in sorted(word_count, key=lambda x:word_count[x], reverse=True): > print (k, word_count[k]) > > The only question i have now is how to limit the amount of returns the > program runs to the first 15 results. Hint:

Re: [Tutor] PyCountry currency formatting woes

2014-05-06 Thread Peter Otten
Sithembewena Lloyd Dube wrote: > Thanks, i was actually getting the error information to update the post. > Apoligies to waste your time posting here - I could not find an > appropriate PyCountry discussion list and my next best bet seemed to be a > Python users' list. > > For those who care to l

Re: [Tutor] Alice_in_wonderland Question

2014-05-06 Thread Alan Gauld
On 05/05/14 04:13, Jake Blank wrote: I did have one more question though. import os from wordtools import extract_words source_filepath=input("Enter the path to the source file:") dest_filepath =input("Enter the path to the destination file:") I'm wondering how I can make it so the program ca

Re: [Tutor] Keeping change-in-place vs. copy methods straight

2014-05-06 Thread Alan Gauld
On 04/05/14 13:54, Dave Angel wrote: Alan Gauld Wrote in message: I assumed (never assume!) that it returned a reference to the original. I really, really, hate the way Python handles this :-( It's not clear to me what you would change. Would you only provide methods (like sort) that mang

Re: [Tutor] Final review

2014-05-06 Thread Alan Gauld
On 06/05/14 04:43, Scott Dunning wrote: I have another question. I don’t understand why below would give an error? greeting = 'Hello World' greeting [len(greeting)] Because list indexing starts at zero but len() returns the actual length. So the last element of a list is mylist[len(mylis

Re: [Tutor] append vs list addition

2014-05-06 Thread Denis Heidtmann
On Sun, May 4, 2014 at 6:44 PM, Dave Angel wrote: > C Smith Wrote in message: >> Sorry. >> >> I meant for example: >> list1 = [1,2,3] >> list2 = [3,4,5] >> >> newList = list1 + list2 >> >> versus >> >> for x in list2: >> list1.append(x) >> >> Which is the preferred way to add elements from on

Re: [Tutor] PyCountry currency formatting woes

2014-05-06 Thread Alan Gauld
On 04/05/14 21:25, Sithembewena Lloyd Dube wrote: currency = pycountry.currencies.get(numeric=country.numeric) Have you tried using locales? import locale as loc loc.setlocale(loc.LC_ALL,'') # selects default - do this at start ... print(loc.currency(myNum_here)) I don't know the module yo

Re: [Tutor] append vs list addition

2014-05-06 Thread Dave Angel
C Smith Wrote in message: > Sorry. > > I meant for example: > list1 = [1,2,3] > list2 = [3,4,5] > > newList = list1 + list2 > > versus > > for x in list2: > list1.append(x) > > Which is the preferred way to add elements from one list to another? Thank you for switching to text mail. The

Re: [Tutor] Final review

2014-05-06 Thread Danny Yoo
On Mon, May 5, 2014 at 9:04 PM, Scott W Dunning wrote: > > On May 1, 2014, at 5:30 AM, Steven D'Aprano wrote: > > Awesome, thanks everyone! I understand lists a lot better now. > > I have another question. I don’t understand why below would give an error? > greeting = 'Hello World’

Re: [Tutor] attributes vs globals (was Re: global list)

2014-05-06 Thread Albert-Jan Roskam
> From: Alan Gauld >To: tutor@python.org >Sent: Friday, April 25, 2014 12:15 AM >Subject: Re: [Tutor] attributes vs globals (was Re: global list) > > >On 24/04/14 21:48, Mark Lawrence wrote: >> On 24/04/2014 21:30, Albert-Jan Roskam wrote: >>> >>> As a side not

Re: [Tutor] Final review

2014-05-06 Thread Scott Dunning
On May 1, 2014, at 5:30 AM, Steven D'Aprano wrote: > Awesome, thanks everyone! I understand lists a lot better now. I have another question. I don’t understand why below would give an error? >>> greeting = 'Hello World' >>> greeting [len(greeting)] __

Re: [Tutor] PyCountry currency formatting woes

2014-05-06 Thread Sithembewena Lloyd Dube
Thanks for this response, this is exactly what I needed to know. On Mon, May 5, 2014 at 6:26 AM, Marc Tompkins wrote: > On Sun, May 4, 2014 at 1:55 PM, Sithembewena Lloyd Dube > wrote: > >> Thanks, i was actually getting the error information to update the post. >> Apoligies to waste your time