[Tutor] Help please

2013-10-17 Thread Pinedo, Ruben A
I was given this code and I need to modify it so that it will: #1. Error handling for the files to ensure reading only .txt file #2. Print a range of top words... ex: print top 10-20 words #3. Print only the words with 3 characters #4. Modify the printing function to print top 1 or 2 or 3

Re: [Tutor] Help please

2013-10-17 Thread Todd Matsumoto
Hello Ruben, You might already know this, but the Python documentation will get you pretty far: http://www.python.org/doc/ Here are some things to lookup that may help you solve the problems. On 10/16/2013 08:49 PM, Pinedo, Ruben A wrote: I was given this code and I need to modify it so

Re: [Tutor] Help please

2013-10-17 Thread Alan Gauld
On 16/10/13 19:49, Pinedo, Ruben A wrote: I was given this code and I need to modify it so that it will: #1. Error handling for the files to ensure reading only .txt file I'm not sure what is meant here since your code only ever opens 'emma.txt', so it is presumably a text file... Or are you

Re: [Tutor] Help please

2013-10-17 Thread Peter Otten
Alan Gauld wrote: [Ruben Pinedo] def process_file(filename): hist = dict() fp = open(filename) for line in fp: process_line(line, hist) return hist def process_line(line, hist): line = line.replace('-', ' ') for word in line.split(): word =

Re: [Tutor] Help please

2013-10-17 Thread Dominik George
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Todd Matsumoto c.t.matsum...@gmail.com schrieb: #1. Error handling for the files to ensure reading only .txt file Look up exceptions. Find out what the string method endswith() does. One should note that the OP probably meant files of the type

Re: [Tutor] Help please

2013-10-17 Thread Kengesbayev, Askar
Ruben, #1 you can try something like this try: with open('my_file.txt') as file: pass except IOError as e: print Unable to open file #Does not exist or you do not have read permission #2. I would try to use regular expression push words to array and then you

Re: [Tutor] keyboard interrupt

2013-10-17 Thread Bill
I know, way late to the party... Did you try Ctrl-Break? In Windows that is usually how you interrupt a program... ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] keyboard interrupt

2013-10-17 Thread Tim Golden
On 17/10/2013 16:36, Bill wrote: I know, way late to the party... Did you try Ctrl-Break? In Windows that is usually how you interrupt a program... Take consolation from the fact that your five-month delay in replying isn't even close to the longest delay I've seen on a Python list.

Re: [Tutor] Help please

2013-10-17 Thread Alan Gauld
On 17/10/13 14:37, Peter Otten wrote: Alan Gauld wrote: [Ruben Pinedo] def process_file(filename): hist = dict() fp = open(filename) for line in fp: process_line(line, hist) return hist or somebody is just sloppy. But neither work as expected right now. (Hint:

[Tutor] Parse text with python

2013-10-17 Thread Danilo Chilene
Hello, I have the text below: CSMP0097I 14.42.12 CPU-B SS-BSS SSU-AA IS-02 -LAL USER CONTROL FILE- MAXIMUM DEFINABLE USERS- 14999 MAXIMUM CONFIGURABLE USERS - 11790 CURRENT NUMBER USERS - 09692 USER FLUSH CRET TIME VALUE -5 -LAL USER FILE- NAME UORD T/O O OXIT RXIT

Re: [Tutor] Parse text with python

2013-10-17 Thread Albert-Jan Roskam
On Thursday, October 17, 2013 9:54 PM, Danilo Chilene bicof...@gmail.com wrote: Hello, I have the text below: CSMP0097I 14.42.12 CPU-B SS-BSS  SSU-AA   IS-02   -LAL USER CONTROL FILE- MAXIMUM DEFINABLE USERS    - 14999 MAXIMUM CONFIGURABLE USERS - 11790 CURRENT NUMBER USERS -   09692  

Re: [Tutor] Parse text with python

2013-10-17 Thread Mark Lawrence
On 17/10/2013 20:54, Danilo Chilene wrote: Hello, I have the text below: CSMP0097I 14.42.12 CPU-B SS-BSS SSU-AA IS-02 -LAL USER CONTROL FILE- MAXIMUM DEFINABLE USERS- 14999 MAXIMUM CONFIGURABLE USERS - 11790 CURRENT NUMBER USERS - 09692 USER FLUSH CRET TIME VALUE -5 -LAL

Re: [Tutor] Parse text with python

2013-10-17 Thread Danny Yoo
Do you have other domain-specific information about this text? Concretely: if you have another similar report, what parts will have to stay the same, and what parts might change? You want to make sure whatever you're using to anchor and search is based on something stable. Otherwise, your

Re: [Tutor] Parse text with python

2013-10-17 Thread Danilo Chilene
Hi, The part that always change is the , it can be 1 digit or 4 digits. Example: 1. The part that never changes is the 1700. On Thu, Oct 17, 2013 at 5:37 PM, Danny Yoo d...@hashcollision.org wrote: Do you have other domain-specific information about this text? Concretely: if you have

Re: [Tutor] Parse text with python

2013-10-17 Thread Danny Yoo
The part that always change is the , it can be 1 digit or 4 digits. Example: 1. The part that never changes is the 1700. You most likely need to be more specific with your pattern matching. Why should we expect no other numbers to be 1700? I see several fields in the form that look

Re: [Tutor] Parse text with python

2013-10-17 Thread David Rock
* Danilo Chilene bicof...@gmail.com [2013-10-17 17:55]: Hi, The part that always change is the , it can be 1 digit or 4 digits. Example: 1. The part that never changes is the 1700. I think the point is we have a hard time believing that 1700 will never change. What do you plan to do

Re: [Tutor] Parse text with python

2013-10-17 Thread Danny Yoo
Yes. Concretely, I'm trying to see if it's appropriate to look at this: ### -LAL USER FILE- NAME UORD T/O O OXIT RXIT SMAX INUSE PCT --- - - - - --- J4IB

Re: [Tutor] Tutor Digest, Vol 116, Issue 37

2013-10-17 Thread Siva Cn
-- next part -- An HTML attachment was scrubbed... URL: http://mail.python.org/pipermail/tutor/attachments/20131017/ea525e7b/attachment.html -- Subject: Digest Footer ___ Tutor maillist - Tutor

[Tutor] Weird Python Error

2013-10-17 Thread Zaid Saeed
First and foremost, here is the code: Player Car import pygame, random pygame.init() screen = pygame.display.set_mode((640, 480)) class RedCar(pygame.sprite.Sprite): def __init__(self): pygame.sprite.Sprite.__init__(self) self.image =

Re: [Tutor] Weird Python Error

2013-10-17 Thread Danny Yoo
Hi Zaid, Your YellowCar will have one once its reset() has been called. However, I don't see it in __init__(), so there might be a period of time where it won't have one. I haven't traced through possible code paths where this happens, but I suspect one of them may. One example may be: c