[Tutor] removing file from zip archive.

2006-03-28 Thread Keo Sophon
Hi all, How can we remove one file inside of a zip archive? I'm using this method: import zipfile ziparchive = zipfile.ZipFile('test.odt', 'r') xmldata = ziparchive.read('content.xml') ziparchive.close Thanks in advance, Sophon _

Re: [Tutor] ASCII

2006-03-28 Thread Pujo Aji
Hi Kaushal,Please clarify the problem more specific.Or you can tell us that you have a problem and want to use python to solve it?Sincerely Yours,pujoOn 3/29/06, Kaushal Shriyan <[EMAIL PROTECTED]> wrote: Hi AllHow do i use this ASCII values in my day to day activities, I am going throughlearning

Re: [Tutor] get a character of an ascii-value

2006-03-28 Thread Keo Sophon
On Wednesday 29 March 2006 13:54, Keo Sophon wrote: > Hi all, > > I wonder how to get a character of an Ascii-value. For example, i have r = > 37. So i wanna print the character of 37. Is there any function? > > Thanks, > Sophon I just got the answer from Pujo. How about r is bigger than 127. How

[Tutor] ASCII

2006-03-28 Thread Kaushal Shriyan
Hi All How do i use this ASCII values in my day to day activities, I am going through learning python, Please illustrate with examples Thanks in Advance Regards Kaushal ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/t

Re: [Tutor] get a character of an ascii-value

2006-03-28 Thread Hugo González Monteverde
Keo Sophon wrote: > Hi all, > > I wonder how to get a character of an Ascii-value. For example, i have r = > 37. So i wanna print the character of 37. Is there any function? > Hi ..yeah, it's called chr(), and its opposite is ord() >>> ord('r') 114 >>> chr(114) 'r' >>> Hugo ___

Re: [Tutor] get a character of an ascii-value

2006-03-28 Thread Pujo Aji
Hello use this function:    print ord('a')    print chr(97)Cheers,pujoOn 3/29/06, Keo Sophon < [EMAIL PROTECTED]> wrote:Hi all,I wonder how to get a character of an Ascii-value.  For example, i have r = 37. So i wanna print the character of 37. Is there any function?Thanks,Sophon___

[Tutor] get a character of an ascii-value

2006-03-28 Thread Keo Sophon
Hi all, I wonder how to get a character of an Ascii-value. For example, i have r = 37. So i wanna print the character of 37. Is there any function? Thanks, Sophon ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Alternating patterns

2006-03-28 Thread Pujo Aji
Hi,you can also use simple way of iterating using modus:    L = [1,2]    for i in range(6):    print L[i%len(L)]121212Cheers,pujo On 3/29/06, kevin parks <[EMAIL PROTECTED]> wrote: -->> Message: 10> Date: Tue, 28 Mar 2006 22:43:38 -0500> From: Kent Johnson <[EMA

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread John Fouhy
On 29/03/06, Hoffmann <[EMAIL PROTECTED]> wrote: > Hi John, > > (1) vehicle[index] is: 'c' > (2) If index = index = 1, so vehicle[index] becomes: > 'a' What I'm getting at here is that, by changing index, we can change which letter we are looking at. And index is a number, which means it's easier

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread Hoffmann
--- John Fouhy <[EMAIL PROTECTED]> wrote: > On 29/03/06, Hoffmann <[EMAIL PROTECTED]> wrote: > > >>> vehicle='car' > > >>> index = 0 > > >>> lenght =len(vehicle) > > >>> last = vehicle[lenght -1] > > >>> while last >= vehicle[0]: > > ... letter = vehicle[index] > > ... print letter > > .

Re: [Tutor] Alternating patterns

2006-03-28 Thread kevin parks
> > > > -- > > Message: 10 > Date: Tue, 28 Mar 2006 22:43:38 -0500 > From: Kent Johnson <[EMAIL PROTECTED]> > Subject: Re: [Tutor] Alternating patterns > Cc: tutor@python.org > Message-ID: <[EMAIL PROTECTED]> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread John Fouhy
On 29/03/06, Hoffmann <[EMAIL PROTECTED]> wrote: > >>> vehicle='car' > >>> index = 0 > >>> lenght =len(vehicle) > >>> last = vehicle[lenght -1] > >>> while last >= vehicle[0]: > ... letter = vehicle[index] > ... print letter > ... last -= 1 > ... What is vehicle[index] ? What if I

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread Hoffmann
--- John Fouhy <[EMAIL PROTECTED]> wrote: > On 29/03/06, Hoffmann <[EMAIL PROTECTED]> wrote: > > vehicle='car' > > index = vehicle[-1] #the last letter > > index_zero = vehicle[0] #the first letter > > > > while index >= index_zero: > >letter=vehicle[index] > >print letter > >i

Re: [Tutor] Bigrams and nested dictionaries

2006-03-28 Thread Michael Broe
Aha! John wrote: "Are you sure you haven't mistakenly assigned something other than a dict to D or D['d'] ?" Thanks for the tip! Yup that was it (and apologies for not reporting the problem more precisely). I hadn't initialized the nested dictionary before trying to assign to it. (I think P

Re: [Tutor] Python help

2006-03-28 Thread Hugo González Monteverde
Why not post where you are stuck or what you are trying to understand? and we'll give you help and direction. What we cannot do is solve your homework for you. Hugo Natasha Menon wrote: > hi, > > i need help on a terrible homework assignment. do ul offer hw help? > ___

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread Kent Johnson
Hoffmann wrote: > --- Kent Johnson <[EMAIL PROTECTED]> wrote: > >>You are confusing the index of a letter - the number >>which represents >>its position in the word - with the letter itself. >>In your code, index >>and index_zero are actually letters, not indices. >>Try to rewrite the >>code so

Re: [Tutor] Alternating patterns

2006-03-28 Thread Kent Johnson
kevin parks wrote: > I have a set that i iterate over... but each time through it i would > like to alternate between the original set and a variation of the set > that has one of the members of the set altered (by + or - 1) > > So if my original set is: > > [0, 2, 4, 5, 7, 9, 11] > > I would

Re: [Tutor] Bigrams and nested dictionaries

2006-03-28 Thread Kent Johnson
Michael Broe wrote: > I'm playing with the whole idea of creating bigram (digram?) > frequencies for text analysis and cryptographic and entropy analysis > etc (this is as much an exercise in learning Python and programming > as anything else, I realise everything has already been done > so

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread Hoffmann
--- Kent Johnson <[EMAIL PROTECTED]> wrote: > Hoffmann wrote: > > Hello: > > > > I am trying to write a code (this is an exercose > from > > a book). The goal is to write a program that takes > a > > string and outputs the letters backward, ine per > > line. > > Ok. I did a test first, by writin

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread Kent Johnson
Hoffmann wrote: > Hello: > > I am trying to write a code (this is an exercose from > a book). The goal is to write a program that takes a > string and outputs the letters backward, ine per > line. > Ok. I did a test first, by writing a code with > numbers: > > a=0; b=10 > while a<=b: >print

[Tutor] Alternating patterns

2006-03-28 Thread kevin parks
I have a set that i iterate over... but each time through it i would like to alternate between the original set and a variation of the set that has one of the members of the set altered (by + or - 1) So if my original set is: [0, 2, 4, 5, 7, 9, 11] I would use that the first pass but on the se

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread Hoffmann
--- John Fouhy <[EMAIL PROTECTED]> wrote: > On 29/03/06, Hoffmann <[EMAIL PROTECTED]> wrote: > > vehicle='car' > > index = vehicle[-1] #the last letter > > index_zero = vehicle[0] #the first letter > > > > while index >= index_zero: > >letter=vehicle[index] > >print letter > >i

Re: [Tutor] Bigrams and nested dictionaries

2006-03-28 Thread John Fouhy
On 29/03/06, Michael Broe <[EMAIL PROTECTED]> wrote: > Well I ran into an interesting glitch already. For a dictionary D, I > can pull out a nested value using this syntax: > > >>> D['b']['a'] > 23 > > and I can assign to this dictionary using > > >>> D['d'] = {'a':7, 'b':0'} > > but I can't assi

Re: [Tutor] Bigrams and nested dictionaries

2006-03-28 Thread Michael Broe
Well I ran into an interesting glitch already. For a dictionary D, I can pull out a nested value using this syntax: >>> D['b']['a'] 23 and I can assign to this dictionary using >>> D['d'] = {'a':7, 'b':0'} but I can't assign like this: >>> D['d']['c'] = 1 TypeError: object does not suppor

[Tutor] Program for outputing the letter backward

2006-03-28 Thread Johnston Jiaa
Hoffman,I am a newbie at python and programming in general so excuse me if I'm wrong.  In your example, you hadwhile index >= index_zero:which I believe to not be what you intended as you are essentially saying:while "last letter of vehicle" >= "first letter of vehicle""e" is respectively "less tha

[Tutor] Bigrams and nested dictionaries

2006-03-28 Thread Michael Broe
I'm playing with the whole idea of creating bigram (digram?) frequencies for text analysis and cryptographic and entropy analysis etc (this is as much an exercise in learning Python and programming as anything else, I realise everything has already been done somewhere somehow :) Though I *a

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread Hugo González Monteverde
Hoffmann wrote: > while index >= index_zero: >letter=vehicle[index] >print letter >index -= 1 > > The problem is that I get no output here. Could I hear > from you? Hi, remember that the condition for the while has to be true. When does index >= index_zero stop being true??? Hope th

Re: [Tutor] Program for outputing the letter backward

2006-03-28 Thread John Fouhy
On 29/03/06, Hoffmann <[EMAIL PROTECTED]> wrote: > vehicle='car' > index = vehicle[-1] #the last letter > index_zero = vehicle[0] #the first letter > > while index >= index_zero: >letter=vehicle[index] >print letter >index -= 1 > > The problem is that I get no output here. Could

[Tutor] Program for outputing the letter backward

2006-03-28 Thread Hoffmann
Hello: I am trying to write a code (this is an exercose from a book). The goal is to write a program that takes a string and outputs the letters backward, ine per line. Ok. I did a test first, by writing a code with numbers: a=0; b=10 while a<=b: print b b -= 1 Here the output is: 10 9 8

Re: [Tutor] Guessing a number with limited no. of tries game gone wrong.

2006-03-28 Thread Victor Bouffier
Hi Ros, Look what happens when the user tried for more than 5 times: if tries > 5: break This just takes you out of the loop, but it does not handle the issue that the user did not guess correctly. The next statement will be to print the congratulations message. You should instead t

Re: [Tutor] Python tutor

2006-03-28 Thread Anna Ravenscroft
On 3/27/06, Noufal Ibrahim <[EMAIL PROTECTED] > wrote: Greetings all,   Are there any programs for python that offer an "interactive" tutorial?Something on the lines of the builtin emacs tutorial (which isbasically just a buffer that tells you to try this and try that with itself) or the Inkscape t

[Tutor] Object Oriented Programmin

2006-03-28 Thread Mike Hansen
> Subject: > [Tutor] Object Oriented Programmin > From: > "Kaushal Shriyan" <[EMAIL PROTECTED]> > Date: > Tue, 28 Mar 2006 12:57:58 +0530 > To: > tutor@python.org > > To: > tutor@python.org > > > Hi ALL > > I have gone through the object oriented programming in Python, I am > not able to unders

Re: [Tutor] Data Type with Dictionary and List Behavior

2006-03-28 Thread Orri Ganel
Carroll, Barry wrote: >Greetings: > >I have a function that computes the checksum of an integer, including or >excluding digits in the computation based on the content of a mask string. >For example, > >cksum(123456789, '***...***') > >will do its computation on 123789, masking out the thr

Re: [Tutor] Python help

2006-03-28 Thread Danny Yoo
On Tue, 28 Mar 2006, Natasha Menon wrote: > i need help on a terrible homework assignment. do ul offer hw help? Not directly. Your homework is really your own to do. Please try to avoid the temptation of just posting a homework question here and hoping that someone will do the work for you.

[Tutor] Python help

2006-03-28 Thread Natasha Menon
hi,i need help on a terrible homework assignment. do ul offer hw help?natasha Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] Python tutor

2006-03-28 Thread John Lesko
This actually sounds like very good idea. I have not heard of it before, but I think it would be a very good way to learn. Let me know if you find anything.JohnOn 3/28/06, Noufal Ibrahim <[EMAIL PROTECTED]> wrote: Greetings all,   Are there any programs for python that offer an "interactive" tutor

[Tutor] Guessing a number with limited no. of tries game gone wrong.

2006-03-28 Thread Ros Daniel
I am a newbie at Python. Just bought Python Programming 2nd ed. by Michael Dawson. While I understand the concepts as the book is going through the code, and I am able get the same results, when it comes to applying what I've learned to the exercises at the end of each chapter, I seem to be stu

Re: [Tutor] Tutor Digest, Vol 25, Issue 70

2006-03-28 Thread Carroll, Barry
John: Well, I haven't made a custom container class before. This looks like a good time to start. And the sample code you provided looks like a good starting place. Thanks for your help. Regards, Barry [EMAIL PROTECTED] 541-302-1107 We who cut mere stones must alwa

Re: [Tutor] setdefault method

2006-03-28 Thread Carroll, Barry
Terry and Kent: Thanks for your timely replies. I agree: its creator could have chosen a more intuitive name for setdefault. Regards, Barry [EMAIL PROTECTED] 541-302-1107 We who cut mere stones must always be envisioning cathedrals. -Quarry worker's creed _

Re: [Tutor] Learning Python

2006-03-28 Thread Hoffmann
I do recommend three books: (1) "How to Think Like a Computer Scientist: Learning with Python", by Allen Downey, Jeffrey Elkner, and Chris Meyers. There exist a free online version, too: http://www.ibiblio.org/obp/thinkCSpy/ (2) "Learning Python", by Mark Lutz and David Ascher. (3) "Beginning Py

Re: [Tutor] Learning Python

2006-03-28 Thread stv
If you're a bookish type, I found Magnus Lie Hetland's "Beginning Python" excellent. It's really more than a beginners books. I came to Python with a scripting background--mostly lightweight OS stuff (Applescript, DOS) as well as a lot of lightweight application programming (Filemaker, SQL, VBA for

Re: [Tutor] BeautifulSoup - deleting tags

2006-03-28 Thread jonasmg
Kent Johnson writes: > [EMAIL PROTECTED] wrote: >> Is possible deleting all tags from a text and how? >> >> i.e.: >> >> s='foo bar; >> foo2 > title="...">bar2' >> >> so, I would get only: foo bar, foo2, bar2 > > How about this? > > In [1]: import BeautifulSoup > > In [2]: s=Beautifu

Re: [Tutor] Object Oriented Programmin

2006-03-28 Thread Kaushal Shriyan
On 3/28/06, Kent Johnson <[EMAIL PROTECTED]> wrote: > Kaushal Shriyan wrote: > > Hi ALL > > > > I have gone through the object oriented programming in Python, I am > > not able to understand OOP concept in python, > > Both Alan Gauld's tutorial and A Byte of Python have beginner's > introductions t

Re: [Tutor] BeautifulSoup - deleting tags

2006-03-28 Thread Kent Johnson
[EMAIL PROTECTED] wrote: > Is possible deleting all tags from a text and how? > > i.e.: > > qwe='foo bar; > foo2 bar2' > > so, I would get only: foo bar, foo2, bar2 How about this? In [1]: import BeautifulSoup In [2]: s=BeautifulSoup.BeautifulSoup('''foo bar; ...: foo2 bar2''') In [4

Re: [Tutor] Object Oriented Programmin

2006-03-28 Thread Kent Johnson
Kaushal Shriyan wrote: > Hi ALL > > I have gone through the object oriented programming in Python, I am > not able to understand OOP concept in python, Both Alan Gauld's tutorial and A Byte of Python have beginner's introductions to OOP: http://www.freenetpages.co.uk/hp/alan.gauld/ http://www.by

[Tutor] BeautifulSoup - deleting tags

2006-03-28 Thread jonasmg
Is possible deleting all tags from a text and how? i.e.: qwe='foo bar; foo2 bar2' so, I would get only: foo bar, foo2, bar2 Thanks in advance! ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] using BeautifulSoup

2006-03-28 Thread jonasmg
Kent Johnson writes: > [EMAIL PROTECTED] wrote: >> anchor.findNext('code') fails: >> >> anchor = soup.fetch('a', {'href': '/wiki/List_of_country_calling_codes'}) >> print anchor >> >> [Calling code] >> >> anchor.findNext('code') >> [] > > are you sure that's what you got? Looks like a

Re: [Tutor] Object Oriented Programmin

2006-03-28 Thread Pujo Aji
Object is object, means like ordinary object we know.Let's say good things about objecs paradigm.First you can create object of course. object can contain property and action.You can put your object as part as other object. It makes sense since for example object hand is part of object body in huma