Re: [Tutor] PyCountry currency formatting woes

2014-05-04 Thread Marc Tompkins
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 posting here - I could not find an appropriate > PyCountry discussion list and my next best bet seemed to be a Python users' > li

Re: [Tutor] Alice_in_wonderland Question

2014-05-04 Thread Brian van den Broek
On May 4, 2014 11:13 PM, "Jake Blank" wrote: > > To figure that last part out I just did a simple if statement. > for k in sorted(word_count, key=lambda x:word_count[x], reverse=True): > if word_count[k] >=300: > print (k, word_count[k]) > And the output was correct. Jake,

Re: [Tutor] Alice_in_wonderland Question

2014-05-04 Thread Brian van den Broek
Hi Jake, Please do be sure to use Reply All rather than just Reply. I'm sending my reply and and quotes from yours to the list; that way, others can follow along, learn and help. Also, in general, reply under the messages to which you respond, ideally trimming what isn't needed away. (You will se

Re: [Tutor] Alice_in_wonderland Question

2014-05-04 Thread C Smith
>ordered_keys = word_count.keys() >sorted(ordered_keys) sorted() does not modify the list, but returns a sorted version of the list for me on Python 2.7 my_sorted_list = sorted(ordered_keys) This will alphabetize all of the words, regardless of frequency. >print ("All the words and their frequenc

Re: [Tutor] Alice_in_wonderland Question

2014-05-04 Thread Brian van den Broek
On May 4, 2014 8:31 PM, "Jake Blank" wrote: > > Hi, > So I'm doing a problem on the Alice_in_wonderland.txt where I have to write a > program that reads a piece of text from a file specified by the user, counts > the number of occurrences of each word, and writes a sorted list of words and > th

[Tutor] Alice_in_wonderland Question

2014-05-04 Thread Jake Blank
Hi, So I'm doing a problem on the Alice_in_wonderland.txt where I have to write a program that reads a piece of text from a file specified by the user, counts the number of occurrences of each word, and writes a sorted list of words and their counts to an output file. The list of words should be so

Re: [Tutor] Stephen Mik-Novice Python Programmer(Version 3.4.0)Can't get help using Dictionaries, Lists to 'Hangman Game Problem"

2014-05-04 Thread C Smith
Hey, you will want to include some code to show your progress so far. Can you write a basic program and then work the requirements into it? Do you have some idea of where to start? Are you supposed to modify a completed version of "hangman" that is in your text, or come up with an original 'hangman

[Tutor] Stephen Mik-Novice Python Programmer(Version 3.4.0)Can't get help using Dictionaries, Lists to 'Hangman Game Problem"

2014-05-04 Thread Stephen Mik
Dear Python World:     I am almost brand new to Python 3.4.0 and am taking a beginning Python Programming class at the nearby Community College. One major problem I have is time management with beginning pseudo code and coding for my Class Assignments. The instructor prefers Office Hour help,and

[Tutor] sending email via SMTP: code review requested

2014-05-04 Thread Brian van den Broek
Hi all, I am playing with the smtp and email modules from the standard library of Python 2.7.3 (I also want it to run on 2.6.6). I've not found the going easy; the SMTP and RFC 2822 standards are not ones I have worked with before. I have something that works, but I am not confident I am doing the

Re: [Tutor] PyCountry currency formatting woes

2014-05-04 Thread Sithembewena Lloyd Dube
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 look, the error is as follows (a concise exam

Re: [Tutor] PyCountry currency formatting woes

2014-05-04 Thread Mark Lawrence
On 04/05/2014 21:25, Sithembewena Lloyd Dube wrote: Hi everyone, I have a function which accepts an alpha2 country code and a price string, where the aim is to get the country's currency and use the currency.letter property of that currency to format the supplied price string. The above works f

[Tutor] PyCountry currency formatting woes

2014-05-04 Thread Sithembewena Lloyd Dube
Hi everyone, I have a function which accepts an alpha2 country code and a price string, where the aim is to get the country's currency and use the currency.letter property of that currency to format the supplied price string. The above works fine so far - yet it falls over when called with German

Re: [Tutor] append vs list addition

2014-05-04 Thread Peter Otten
C Smith wrote: > 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? None of the above unless you need to keep the original list1. Use

Re: [Tutor] append vs list addition

2014-05-04 Thread Steven D'Aprano
On Sun, May 04, 2014 at 09:51:17AM -0400, C Smith wrote: > Sorry. > > I meant for example: > list1 = [1,2,3] > list2 = [3,4,5] > > newList = list1 + list2 This creates a new list, containing the same items as list1 and list2. > versus > > for x in list2: > list1.append(x) This can be writ

Re: [Tutor] append vs list addition

2014-05-04 Thread C Smith
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? On Sun, May 4, 2014 at 7:36 AM, Dave Angel wrote: > C Smith Wrote in message: >> >> > I had alw

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

2014-05-04 Thread Dave Angel
Alan Gauld Wrote in message: >>> (not a copy!) to the sorted item. >> >> sorted() does make a copy of the list: > > Really? That's a bummer. > 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

Re: [Tutor] Logical error?

2014-05-04 Thread Dave Angel
Danny Yoo Wrote in message: > > > > >> Hopefully, this makes the point clearer: we must not try to decode >> individual lines. By that time, the damage has been done: the act of >> trying to break the file into lines by looking naively at newline byte >> characters is invalid when certain cha

Re: [Tutor] Help With Code

2014-05-04 Thread Dave Angel
jordan smallwood Wrote in message: > > want to have the user try again if they enter in a non integer. What am I > missing: Do you perhaps mean float? If so, see the other response. -- DaveA ___ Tutor maillist - Tutor@python.org To unsubscr

Re: [Tutor] append vs list addition

2014-05-04 Thread Dave Angel
C Smith Wrote in message: > > I had always assumed that append() was more efficient, but some recent discussions seem to point at that it is the same as append(). Which is preferable and why? Please be more explicit, preferably with example code. list.append and list.__add__ don't even do th

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

2014-05-04 Thread Alan Gauld
On 04/05/14 11:31, Steven D'Aprano wrote: On Sun, May 04, 2014 at 10:00:08AM +0100, Alan Gauld wrote: For the specific case of sort you can always use the sorted() function which does return a reference (not a copy!) to the sorted item. sorted() does make a copy of the list: Really? That's

[Tutor] append vs list addition

2014-05-04 Thread C Smith
I had always assumed that append() was more efficient, but some recent discussions seem to point at that it is the same as append(). Which is preferable and why? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https:

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

2014-05-04 Thread Steven D'Aprano
On Sun, May 04, 2014 at 10:00:08AM +0100, Alan Gauld wrote: > For the specific case of sort you can always use > the sorted() function which does return a reference > (not a copy!) to the sorted item. sorted() does make a copy of the list: py> a = [2, 5, 3, 4, 1] py> sorted(a), a ([1, 2, 3, 4,

Re: [Tutor] Advice needed by a new to Python but abit experience software dev

2014-05-04 Thread Chris “Kwpolska” Warrick
On Sat, May 3, 2014 at 1:51 AM, Muhammed Salman wrote: > Hi, > > I have to develop a simple web app. In which i have to create, update, read > and delete people. I also should be able to make people friends and best > friends with each other. Now, (obviously) I do not want you guys to do this > pr

Re: [Tutor] Advice needed by a new to Python but abit experience software dev

2014-05-04 Thread Alan Gauld
On 03/05/14 00:51, Muhammed Salman wrote: I have to develop a simple web app. ... I do not want you guys to do this project for me ;). But what I want is that maybe you guys can give me some hints about where to start and make my journey easy by giving me some good pointers on what to look for a

Re: [Tutor] Help With Code

2014-05-04 Thread Alan Gauld
On 01/05/14 01:18, jordan smallwood wrote: Hey there, I have this code below (in to cm conversion) and I want to have the user try again if they enter in a non integer. What am I missing: A loop. There is a common pattern or idiom in Pytthon: while True: get input if input ok:

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

2014-05-04 Thread Alan Gauld
On 28/04/14 19:45, taserian wrote: I can't claim to be new to programming, but I've dabbled in Python over and over again to get small problems and puzzles resolved. One thing that I find I can't keep straight are the methods that change a list in place, vs. those that return a copy (sometimes tr

Re: [Tutor] New to Python

2014-05-04 Thread Alan Gauld
On 28/04/14 13:56, Jordan Smallwood wrote: I never got a response. Should I check my spam? Probably, although Dave and I both basically said the same as the current batch of answers. Namely the exercise is pretty clear: write a module with 2 functions. Now, what part of that specifically do

Re: [Tutor] Using import

2014-05-04 Thread Peter Otten
Felipe Melo wrote: [Felipe, please post plain text, your code examples are unreadable] > Hello, > I'm starting with Python and I'm trying to work with "import" but I'm > having a problem. I have the file c.py (that works when executed) with a > function performing a multiplication: > def mult(a,x

[Tutor] Advice needed by a new to Python but abit experience software dev

2014-05-04 Thread Muhammed Salman
Hi, I have to develop a simple web app. In which i have to create, update, read and delete people. I also should be able to make people friends and best friends with each other. Now, (obviously) I do not want you guys to do this project for me ;). But what I want is that maybe you guys can give me

[Tutor] Help With Code

2014-05-04 Thread jordan smallwood
Hey there, I have this code below (in to cm conversion) and I want to have the user try again if they enter in a non integer. What am I missing: ConversionConstant = 2.54 def CalculateCentimeters(inches):     return ConversionConstant * inches def CalculateInches(centimeters):     return centi

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

2014-05-04 Thread Cameron Simpson
On 28Apr2014 14:45, taserian wrote: I can't claim to be new to programming, but I've dabbled in Python over and over again to get small problems and puzzles resolved. One thing that I find I can't keep straight are the methods that change a list in place, vs. those that return a copy (sometimes

Re: [Tutor] Remove last newline only in print / open / read function

2014-05-04 Thread Chris
On 04/25/2014 12:14 PM, Dave Angel wrote: > print adds a newline. Use write () instead. > sys.stdout.write (open (name).read ()) The comma at the end of the line didn't change anything, but the write method worked! Thank you! -- Chris ___ Tu

[Tutor] Using import

2014-05-04 Thread Felipe Melo
Hello, I'm starting with Python and I'm trying to work with "import" but I'm having a problem. I have the file c.py (that works when executed) with a function performing a multiplication: def mult(a,x): resul=a*xreturn(resul)print 'test print'ent1=2ent3=3dedo=mult(ent1,ent3)print 'resu

Re: [Tutor] Remove last newline only in print / open / read function

2014-05-04 Thread Chris
Dear Dave, On 04/25/2014 12:14 PM, Dave Angel wrote: > But what is your context? Your Python version (apparently 2.x, > since you're using print as a statement, rather than a function)? > What os, and what is stdout pointing to, since you're pretending > that you can write binary data to it?

Re: [Tutor] Final review

2014-05-04 Thread Matt Harris
> The ouput for below is 2 when it seems like there should be 3 lists located > inside x. Is it [10,20] that is not consider inside of x?Any tips on how > to tell how to spot them more clearly? > > x = ['a', [2.0, 5, [10, 20]]] > print len(x) Hey Scott Here, it looks like x is a list cont

Re: [Tutor] Remove last newline only in print / open / read function

2014-05-04 Thread Chris
On 04/25/2014 10:36 AM, Alan Gauld wrote: > Can I first ask what makes you think there is an extra > linefeed at the end? Is it because of the print output? > You do remember that print adds a newline? I opened the zip file with an editor. My zip program said the file was invalid, until I removed

Re: [Tutor] Stephen Mik-Almost Brand New to Python 3.4.0-"Guess My Number" program is syntactically correct but will not run as expected

2014-05-04 Thread Philip Dexter
On Mon, 28 Apr 2014, C Smith wrote: I should probably clarify that this list is mainly for python2.7, correct me if I am wrong. I don't think that is true. On Mon, Apr 28, 2014 at 1:49 PM, C Smith wrote: The reason this is happening here is you need to import sys. I don't know why

Re: [Tutor] New to Python

2014-05-04 Thread Jordan Smallwood
I never got a response. Should I check my spam? Sent from my iPhone > On Apr 28, 2014, at 1:57 AM, Mark Lawrence wrote: > >> On 26/04/2014 23:53, jordan smallwood wrote: >> Hello, >> >> I am new to Python. I mean completely new and we're working on this >> problem set in class where they give

Re: [Tutor] Question about O(N**2)

2014-05-04 Thread Devin Jeanpierre
On Sat, May 3, 2014 at 9:13 PM, Steven D'Aprano wrote: > > On Sat, May 03, 2014 at 03:59:40PM -0700, Danny Yoo wrote: > > Following up on this. Let's make sure that we're talking about the same > > thing. > > > > > > The assertion is that the following: > > > > fullPath += [...] > > > > wher