Re: [Tutor] Does IPython have a "restart"?

2008-07-17 Thread Dick Moores
At 07:55 AM 7/16/2008, Dick Moores wrote: I mean something equivalent to what you get when you do a Ctrl+F6 in IDLE: >>> import math >>> math.log(3) 1.0986122886681098 >>> === RESTART === >>> math.log(3) T

Re: [Tutor] Unittest

2008-07-17 Thread Mark Tolonen
You get the "D" characters when decoding Russian encoded in UTF-8 using Latin-1 instead. # coding: utf-8 x=u'Зарегистрироваться' print x.encode('utf-8').decode('latin-1') Зарегистрироваться Check that your html encoding is declared correctly. -- Mark "Oleg Oltar" <[EMAIL P

Re: [Tutor] Any way of monitoring a python program's memory utilization?

2008-07-17 Thread Monika Jisswel
> > I'm iterating through a vey large tarfile (uncompressed, it would be about > 2.4G, with about 2.5 million files in it) and I can see from some external > monitors that its virtual storage usage just grows and grows, until my > whole system finally grinds to a halt after about 1.2 million member

Re: [Tutor] Any way of monitoring a python program's memory utilization?

2008-07-17 Thread Terry Carroll
On Thu, 17 Jul 2008, Monika Jisswel wrote: > Well, you can check whether your system has reached its limits or not, but > what for ? So I can debug the problem. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

[Tutor] IPython problem: Difficulty in setting editor to TextPad

2008-07-17 Thread Dick Moores
Win XP, Python 2.51, IPython 0.84 In my ipy_user_conf.py I have put this line: ipy_editors.install_editor("C:\Program Files\TextPad 5\TextPad.exe") I use IPython -debug to start IPython, and this is what it tells me: 'editor': '"C:\\Program Files\\TextPad 5\\textpad.exe"', but In [3]: ed versi

Re: [Tutor] Unittest

2008-07-17 Thread Oleg Oltar
beryl:~ oleg$ env MANPATH=/usr/share/man:/usr/local/share/man:/usr/X11/man TERM_PROGRAM=Apple_Terminal TERM=xterm-color SHELL=/bin/bash TMPDIR=/var/folders/PC/PCtFE4gQGiqpQymiAScfnk+++TM/-Tmp-/ Apple_PubSub_Socket_Render=/tmp/launch-UNXiC6/Render TERM_PROGRAM_VERSION=237 USER=oleg COMMAND_MODE=unix

Re: [Tutor] Unittest

2008-07-17 Thread Oleg Oltar
And also: Getting this in console when trying to generate report via HTMLTestRunner (it displayed text correctly when tried simple unittest.main) pass output_list['pt1.1'] = '!!! True\nÐ"омен \'foobar\' занят. Рекомендованные свободные домены: ffoobar foobar.

Re: [Tutor] Any way of monitoring a python program's memory utilization?

2008-07-17 Thread Monika Jisswel
I see no problem, if you open very BIG files then your memory will get filled up & your system will halt, can you buy more food than your fridge can handle , and write to a list asking to invistigate the problem ? 2008/7/17 Terry Carroll <[EMAIL PROTECTED]>: > On Thu, 17 Jul 2008, Monika Jisswel

[Tutor] How to populate a dictionary

2008-07-17 Thread josetjr
Hello, I am taking python this summer, and have run into a problem. The assignment is to create a dictionary from a text file: "12/07/0526 = St Felix IV begins his reign as Catholic Pope" "12/07/1109 = Crusaders capture Syria's harbor city of Tripoli" "12/07/1191 = Richard Coeur de Lion and Crusa

[Tutor] Recursive function

2008-07-17 Thread vanam
hi all, i am new to programming, i just started writing scripts in python about functions.There is a program by name hangman where in i take input three characters and then concatenate the resultant output is compared to a three letter string, if it is similar it will display the word as correct if

Re: [Tutor] How to populate a dictionary

2008-07-17 Thread Michiel Overtoom
josetjr wrote... >Hello, I am taking python this summer, and have run into a problem. Let me suggest some improvements. You can process all the lines in a textfile like this: for line in open("dates.txt").readlines(): print line Furthermore, if you have a string in the form of

Re: [Tutor] How to populate a dictionary

2008-07-17 Thread FT
Dates = {} def read_Dates (Dates): if os.path.exists(FILE_NAME): store = open(FILE_NAME,'r') for line in store: name = line.rstrip() entry = store.next().rstrip() Dates[name] = entry store.close() def save_Dates (Dates): store =

Re: [Tutor] How to populate a dictionary

2008-07-17 Thread bob gailer
Several reactions: --- As I understood it the list policy is: 1) not solve homework problems. 2) request students to tell us exactly what problems they were running into e.g. expected output, actual output, exceptions, ... 3) then give

Re: [Tutor] Any way of monitoring a python program's memoryutilization?

2008-07-17 Thread Alan Gauld
"Monika Jisswel" <[EMAIL PROTECTED]> wrote... I see no problem, if you open very BIG files then your memory will get filled up & your system will halt, Only if you were to foolishly read the whole file into memory at once. Early computers only had memories of a few kilobytes but could process

Re: [Tutor] How to populate a dictionary

2008-07-17 Thread Alan Gauld
<[EMAIL PROTECTED]> wrote The assignment is to create a dictionary from a text file: ok, since it's 'homework' I won't give the whole answer but will try to point you in the right direction. Your program should start by creating an empty dictionary called dates. Then your program will get

Re: [Tutor] How to populate a dictionary

2008-07-17 Thread Alan Gauld
"Michiel Overtoom" <[EMAIL PROTECTED]> wrote Let me suggest some improvements. You can process all the lines in a textfile like this: for line in open("dates.txt").readlines(): print line Or just for line in open("dates.txt"): print line.rstrip() So, your little homework prog

Re: [Tutor] How to populate a dictionary

2008-07-17 Thread Alan Gauld
"bob gailer" <[EMAIL PROTECTED]> wrote As I understood it the list policy is: 1) not solve homework problems. 2) request students to tell us exactly what problems they were running into e.g. expected output, actual output, exceptions, ... 3) then give specific suggestions We seem to hav

Re: [Tutor] IPython problem: Difficulty in setting editor to TextPad

2008-07-17 Thread Alan Gauld
"Dick Moores" <[EMAIL PROTECTED]> wrote In my ipy_user_conf.py I have put this line: ipy_editors.install_editor("C:\Program Files\TextPad 5\TextPad.exe") escape the spaces and backslashes(raw string might work as well) ipy_editors.install_editor("C:\\Program\ Files\\TextPad 5\\TextPad.exe")

Re: [Tutor] IPython problem: Difficulty in setting editor to TextPad

2008-07-17 Thread Dick Moores
At 08:13 AM 7/17/2008, Alan Gauld wrote: "Dick Moores" <[EMAIL PROTECTED]> wrote In my ipy_user_conf.py I have put this line: ipy_editors.install_editor("C:\Program Files\TextPad 5\TextPad.exe") escape the spaces and backslashes(raw string might work as well) Yeah, I tried that (except for t

Re: [Tutor] Recursive function

2008-07-17 Thread Alan Gauld
"vanam" <[EMAIL PROTECTED]> wrote i am new to programming, i just started writing scripts in python about functions. You need to check the section of your tutorial/book that discusses loops. That will make your solution much easier. characters as input. The problem is i am not getting a runt

[Tutor] continuouse loop

2008-07-17 Thread Monika Jisswel
Would a program using a continuouse loop such as in this code take up resources on the system if left for long period ? import sys > > while 1: > self.data = sys.stdin.readline() > self.function_1(data) > What are my other options is I want to have a running program & other programs commu

Re: [Tutor] continuouse loop

2008-07-17 Thread Alan Gauld
"Monika Jisswel" <[EMAIL PROTECTED]> wrote Would a program using a continuouse loop such as in this code take up resources on the system if left for long period ? Any running program takes up some resources but whether this one would increase its resource usage over time, which I assume is w

Re: [Tutor] Any way of monitoring a python program's memory utilization?

2008-07-17 Thread Terry Carroll
On Thu, 17 Jul 2008, Monika Jisswel wrote: > I see no problem, if you open very BIG files then your memory will get > filled up & your system will halt, I'm going to disagree with you on this one. First, in general, it is not the case that opening a very large file will cause memory to be fille

Re: [Tutor] Any way of monitoring a python program's memory utilization?

2008-07-17 Thread Monika Jisswel
I m really sorry if no one of you liked/agreed with the fridge analogy but that's what my brain could come up with at the time, I have to say it's not a very scientific argument. but I only meant to say that if you are piping data into memory & this data is larger than that memory then there is no

[Tutor] Question on how to do something.

2008-07-17 Thread Mitchell Nguyen
Hello. I'm new to Python and I was wondering how to read all the files in a folder. I used this program or command for single files. import pprint pprint.pprint(open(r'c:\text\somefile.txt').readlines()) And if possible, is there a way to make it so that it waits at the end of each file for a

Re: [Tutor] continuouse loop

2008-07-17 Thread Martin Walsh
Monika Jisswel wrote: > Would a program using a continuouse loop such as in this code take up > resources on the system if left for long period ? > > import sys > > while 1: > self.data = sys.stdin.readline() > self.function_1(data) Not much, I would think, until somethin

[Tutor] creating pop method for stack class

2008-07-17 Thread Christopher Spears
I am almost done with a stack class that I wrote: #!/usr/bin/python class Stack(list): def isempty(self): length = len(self) if length == 0: return True else: return False def peek(self): length = len(self) if le

Re: [Tutor] creating pop method for stack class

2008-07-17 Thread John Fouhy
On 18/07/2008, Christopher Spears <[EMAIL PROTECTED]> wrote: > How come the stack doesn't shrink when I pop off the last value? I tested > the code in the interpreter: > > >>> lista = [1,2,3,4] > >>> lista[:len(lista)-1] > [1, 2, 3] > >>> lista = lista[:len(lista)-1] > >>> lista > [1, 2, 3

Re: [Tutor] parsing sendmail logs

2008-07-17 Thread nibudh
2008/7/15 Martin Walsh <[EMAIL PROTECTED]>: > > Any pragmatic advice on building or working with a framework to get > > to the point where i can do analysis on my logs would be cool. > > > > > As an exercise, I think it would be a reasonable approach to write > python derivatives of the s

Re: [Tutor] parsing sendmail logs

2008-07-17 Thread nibudh
2008/7/16 Jeff Younker <[EMAIL PROTECTED]>: > Parsers as referenced in your link are intended for heavy-duty lifting > such as parsing programming languages. > > Sendmail logs are very simple, so those parsers are vast overkill. Split > on whitespace combined with regular expressions should be u

[Tutor] Guidance on jump-starting to learn Python

2008-07-17 Thread Steve Poe
I have the challenge / opportunity to learn Python quickly. I am technically-minded, but I am not a programmer. When I have tried / used Python before (I've written 5-6 python programs/utilities), it has been solving a particular issue but not learning the proper structure/procedures to learn Pytho

Re: [Tutor] creating pop method for stack class

2008-07-17 Thread Christopher Spears
> > First, a tip: > > Instead of lista[:len(lista)-1], you can (and should) just > write lista[:-1]. > > Now, what if we wrap that in a function: > > >>> def shorten(lst): > ... lst = lst[:-1] # identical to: lst = > lst[:len(lst)-1] > ... > > Then test it: > > >>> lista = [1, 2, 3, 4] >

Re: [Tutor] Question on how to do something.

2008-07-17 Thread Alan Gauld
"Mitchell Nguyen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hello. I'm new to Python and I was wondering how to read all the files in a folder. Take a look at the fileinput module, I think it will do what you want. Alan G ___

Re: [Tutor] creating pop method for stack class

2008-07-17 Thread Alan Gauld
"Christopher Spears" <[EMAIL PROTECTED]> wrote I am almost done with a stack class that I wrote: Some comments... class Stack(list): def isempty(self): length = len(self) if length == 0: return True else: return False This can just be return bool(len(self)