[Tutor] 'help' remove me from you list immediately.

AJGables at cs.com AJGables at cs.com
Wed Mar 24 21:27:18 EST 2004




help unsubscribe me immediately.  I do not wish to receive any further communication from you.  aj








>To subscribe or unsubscribe via the World Wide Web, visit
>    http://mail.python.org/mailman/listinfo/tutor
>or, via email, send a message with subject or body 'help' to
>    tutor-request at python.org
>
>You can reach the person managing the list at
>    tutor-owner at python.org
>
>When replying, please edit your Subject line so it is more specific
>than "Re: Contents of Tutor digest..."
>
>
>Today's Topics:
>
>   1. Re: python virgin (Andrei)
>   2. Re: How do I slice up a list of strings? (G Kiran)
>   3. RE: usenet server quest (John Purser)
>   4. Re: How do I slice up a list of strings? (John Matthews) (G Kiran)
>   5. Re: write a file (Andrei)
>   6. pickle broken for strings in 2.3? (R. Alan Monroe)
>   7. Re: Tutor Digest, Vol 1, Issue 2678 (Tony Cappellini)
>   8. RE: pickle broken for strings in 2.3? (John Purser)
>   9. Once again....HTTP Digest Authentication (Allen Schmidt)
>  10. RE: Once again....HTTP Digest Authentication (John Purser)
>  11. Re: write a file (APQ LE)
>  12. RE: Re: write a file (APQ LE)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Wed, 24 Mar 2004 21:15:02 +0100
>From: Andrei <project5 at redrival.net>
>Subject: [Tutor] Re: python virgin
>To: tutor at python.org
>Message-ID: <tleld02brbsx.15ewc1uz1pzt8.dlg at 40tude.net>
>Content-Type: text/plain; charset="us-ascii"
>
>Doug Gentry wrote on Wed, 24 Mar 2004 10:29:15 -0800:
>
>> Heck, I'm a programming virgin too. I was browsing the net the other day and
>> ran across a site about active  state python. I had the "old Python loaded
>> on here so I removed it and installed the new version on my XP computer.
>
>I too prefer the ActiveState distro over the default Python one. The docs
>are much better for one thing and it includes PythonWin which is better
>than IDLE IMO.
>
>> i.e.; click on file and then new window? Mine has File/new and then a choice
>> of script or grep. I kind of figured that script is the same thing as what
>> they wanted in the new window. 
>
>Not sure if you're talking about IDLE, PythonWin or...
>
>>  Also when I opened notepad and did the little exercise of hello world and
>> saved as hello.py  I went back and ran it. I get a real quick flash of a cmd
>> box running but that's it.
>
>Except for that raw_input method that Tim Wilson mentioned, you could also
>open the program in PythonWin (as opposed to Notepad) and then run it from
>there. The output will be (and will remain) visible inside PythonWin
>itself.
>
>> So I guess my question should be. Does anyone know of a good website to go
>> to learn this?
>
>Alan Gauld's tutorial is nice (as linked by John Purser), How To Think Like
>A Computer Scientist in Python is nice too. Don't be fooled, by the name,
>it's a beginner-level tutorial: http://www.ibiblio.org/obp/thinkCSpy/
>
>There are many more (I particularly liked
>http://www.hetland.org/python/instant-hacking.php, but it's down ATM of
>this writing), but which one is the best for you, depends on your style of
>learning.
>
>-- 
>Yours,
>
>Andrei
>
>=====
>Real contact info (decode with rot13):
>cebwrpg5 at jnanqbb.ay. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
>gur yvfg, fb gurer'f ab arrq gb PP.
>
>
>
>
>------------------------------
>
>Message: 2
>Date: Thu, 25 Mar 2004 01:46:37 +0530
>From: "G Kiran" <goki75 at vsnl.net>
>Subject: [Tutor] Re: How do I slice up a list of strings?
>To: <tutor at python.org>
>Message-ID: <001301c411dc$eeabcb90$4d2ee2dc at VULCAN>
>Content-Type: text/plain;   charset="iso-8859-1"
>
>>>> l=['Tue 03/23/2004 13:11:07.49 user1 \n', 'Tue 03/23/2004 13:45:07.34
>user2 \n','Tue 03/23/2004 13:46:13.53 user2 \n', 'Tue 03/23/2004 14:22:08.45
>user3 \n', 'Tue 03/23/2004 15:17:58.38 user4 \n']
>>>> l
>['Tue 03/23/2004 13:11:07.49 user1 \n', 'Tue 03/23/2004 13:45:07.34 user2
>\n', 'Tue 03/23/2004 13:46:13.53 user2 \n', 'Tue 03/23/2004 14:22:08.45
>user3 \n', 'Tue 03/23/2004 15:17:58.38 user4 \n']
>>>> a=[s[27:-2] for s in l]
>>>> a
>['user1', 'user2', 'user2', 'user3', 'user4']
>
>
>or
>
>>>> a=[s.strip().split()[-1] for s in l]
>>>> a
>['user1', 'user2', 'user2', 'user3', 'user4']
>>>>
>
>
>
>Beware of the lollipop of mediocrity: lick it once and you suck forever
>www.mhowlinux.org- Helping Linux users in Mhow
>
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.624 / Virus Database: 401 - Release Date: 3/15/2004
>
>
>
>
>------------------------------
>
>Message: 3
>Date: Wed, 24 Mar 2004 13:18:34 -0700
>From: "John Purser" <johnp at HomeLumber.com>
>Subject: RE: [Tutor] usenet server quest
>To: <tutor at python.org>
>Message-ID:
>    <D0DD3F40FC3F714A88D0DB43BAE362565F0512 at 01-hl-prime.denver.homelmbr.com>
>    
>Content-Type: text/plain;   charset="iso-8859-1"
>
>Google = "nntp server", Python
>
>http://freshmeat.net/projects/papercut/
>
>You might want to contribute to this existing project.
>
>John Purser
>
>-----Original Message-----
>From: Kirk Bailey [mailto:idiot1 at netzero.net]
>Sent: Wednesday, March 24, 2004 1:13 PM
>To: tutor at python.org
>Subject: [Tutor] usenet server quest
>
>
>OK, I want a usenet server. There is nothing in the library to 
>facilitate this, so it might turn into an entire nre module.
>
>To start with, it can be a single group. It should not be a hairpull to 
>install. And of course, written in python.
>
>Any discussion?
>
>-- 
>
>
>Respectfully,
>              Kirk D Bailey
>              Pinellas county Florida USA
>
>   think   http://www.tinylist.org/ - $FREE$ software for liberty
>+-------+ http://www.pinellasintergroupsociety.org/ - In Her Service
>|  BOX  | http://www.listville.net/ - $FREE$ list hosting services
>+-------+ http://www.howlermonkey.net/ - $FREE$ email service
>   kniht   http://www.sacredelectron.org/ - My personal SCREED pit
>
>          (C)2004 Kirk D Bailey, all rights reserved- but ask!
>
>
>
>
>
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>
>------------------------------
>
>Message: 4
>Date: Thu, 25 Mar 2004 01:48:13 +0530
>From: "G Kiran" <goki75 at vsnl.net>
>Subject: [Tutor] Re: How do I slice up a list of strings? (John
>    Matthews)
>To: <tutor at python.org>
>Message-ID: <001e01c411dd$271bbb70$4d2ee2dc at VULCAN>
>Content-Type: text/plain;   charset="iso-8859-1"
>
>
>>>> l=['Tue 03/23/2004 13:11:07.49 user1 \n', 'Tue 03/23/2004 13:45:07.34
>user2 \n','Tue 03/23/2004 13:46:13.53 user2 \n', 'Tue 03/23/2004 14:22:08.45
>user3 \n', 'Tue 03/23/2004 15:17:58.38 user4 \n']
>>>> l
>['Tue 03/23/2004 13:11:07.49 user1 \n', 'Tue 03/23/2004 13:45:07.34 user2
>\n', 'Tue 03/23/2004 13:46:13.53 user2 \n', 'Tue 03/23/2004 14:22:08.45
>user3 \n', 'Tue 03/23/2004 15:17:58.38 user4 \n']
>>>> a=[s[27:-2] for s in l]
>>>> a
>['user1', 'user2', 'user2', 'user3', 'user4']
>
>
>or
>
>>>> a=[s.strip().split()[-1] for s in l]
>>>> a
>['user1', 'user2', 'user2', 'user3', 'user4']
>>>>
>
>
>
>Beware of the lollipop of mediocrity: lick it once and you suck forever
>www.mhowlinux.org- Helping Linux users in Mhow
>
>
>
>
>
>---
>Outgoing mail is certified Virus Free.
>Checked by AVG anti-virus system (http://www.grisoft.com).
>Version: 6.0.624 / Virus Database: 401 - Release Date: 3/15/2004
>
>
>
>
>------------------------------
>
>Message: 5
>Date: Wed, 24 Mar 2004 21:25:56 +0100
>From: Andrei <project5 at redrival.net>
>Subject: [Tutor] Re: write a file
>To: tutor at python.org
>Message-ID: <b4a67ddg3mz0$.1gpjh4rtzrv7g.dlg at 40tude.net>
>Content-Type: text/plain; charset="iso-8859-1"
>
>Karl Pflästerer wrote on Wed, 24 Mar 2004 20:52:38 +0100:
>
>>> I'm trying to open a file, read its content and write its content to a
>>> new file.  Pretty much like copying a file.  Here is what I have
>> 
>>> ========
>>> in = open ("a.txt", "r")
>>> out = open ("b.txt", "w")
>>> for line in in.readlines()
>>>    out.write(line)
>> 
>>> in.close()
>>> out.close()
>
>That code works?? Never gives stuff names that are already used by Python.
>'in' is a kewyword used in e.g. 'for something in whatever', so you
>shouldn't be able to name a file 'in'. It's also a bad idea to override
>built-ins, like range, file or open - even though you don't do that in that
>particular piece of code :).
>
>>> ==========
>>> However, the output isn't as expected.  There is additional empty line
>>> comes after every existing line.  So, the output file is bigger than
>>> the original file.
>
>That might happen especially on Windows where lines end in '\r\n'. Let's
>see if I get this right... '\n' gets expanded to '\r\n' as well and '\n'
>means on its own that a new line is required, so you end up with an extra
>empty line. The line ends are very pesky, because different platforms use
>different line endings (on Linux lines end in \n, on Mac I believe in \r
>and on Windows in both).
>
>I think that if you open the file with "rU" instead of "r" you might get
>better results. (not available in Pythons older than 2.3)
>
>-- 
>Yours,
>
>Andrei
>
>=====
>Real contact info (decode with rot13):
>cebwrpg5 at jnanqbb.ay. Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V ernq
>gur yvfg, fb gurer'f ab arrq gb PP.
>
>
>
>
>------------------------------
>
>Message: 6
>Date: Wed, 24 Mar 2004 16:02:30 -0500
>From: "R. Alan Monroe" <amonroe at columbus.rr.com>
>Subject: [Tutor] pickle broken for strings in 2.3?
>To: tutor at python.org
>Message-ID: <181163728348.20040324160230 at columbus.rr.com>
>Content-Type: text/plain; charset=us-ascii
>
>
>
>
>Python 2.3.2 (#49, Oct  2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on win32
>Type "help", "copyright", "credits" or "license" for more information.
>>>> x={1:2, 'a':'b'}
>>>> import pickle
>>>> pickle.dump(x, 'test.pik')
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>  File "c:\python23\lib\pickle.py", line 1382, in dump
>    Pickler(file, protocol, bin).dump(obj)
>  File "c:\python23\lib\pickle.py", line 210, in __init__
>    self.write = file.write
>AttributeError: 'str' object has no attribute 'write'
>
>
>
>
>------------------------------
>
>Message: 7
>Date: Wed, 24 Mar 2004 13:01:45 -0800 (PST)
>From: Tony Cappellini <tony at tcapp.com>
>Subject: [Tutor] Re: Tutor Digest, Vol 1, Issue 2678
>To: <Doug.Gentry at comcast.net>
>Cc: tutor at python.org
>Message-ID: <20040324125738.M71236-100000 at yamato.yamato.com>
>Content-Type: TEXT/PLAIN; charset=US-ASCII
>
>
>Doug
>
>One good place to start is at many of the Python Tutorials (google will
>help you find them). Another good starting point for non-programmers is
>http://www.python.org/topics/learn/non-prog.html
>
>A very good Online book (free) is Dive Into Python
>(assumes some programming knowledge, but still a great place to learn
>Python)
>http://diveintopython.org/
>
>
>Of course- this list is an excellent resource too. It has been a big
>help to me.
>
>
>
>Tony
>
>
>
>
>
>
>
>------------------------------
>
>Message: 8
>Date: Wed, 24 Mar 2004 14:06:20 -0700
>From: "John Purser" <johnp at HomeLumber.com>
>Subject: RE: [Tutor] pickle broken for strings in 2.3?
>To: <tutor at python.org>
>Message-ID:
>    <D0DD3F40FC3F714A88D0DB43BAE3625686D226 at 01-hl-prime.denver.homelmbr.com>
>    
>Content-Type: text/plain;   charset="iso-8859-1"
>
>You passed a file name to pickle, not an opened file object.  So when pickle tried to "test.pik.write(x)" it couldn't do it because the string test.pik has no write method.
>try:
>f = file("test.pik", "w")
>pickle.dump(x, f)
>
>and see if that works better.
>
>John Purser
>
>-----Original Message-----
>From: R. Alan Monroe [mailto:amonroe at columbus.rr.com]
>Sent: Wednesday, March 24, 2004 2:03 PM
>To: tutor at python.org
>Subject: [Tutor] pickle broken for strings in 2.3?
>
>
>
>
>
>Python 2.3.2 (#49, Oct  2 2003, 20:02:00) [MSC v.1200 32 bit (Intel)] on win32
>Type "help", "copyright", "credits" or "license" for more information.
>>>> x={1:2, 'a':'b'}
>>>> import pickle
>>>> pickle.dump(x, 'test.pik')
>Traceback (most recent call last):
>  File "<stdin>", line 1, in ?
>  File "c:\python23\lib\pickle.py", line 1382, in dump
>    Pickler(file, protocol, bin).dump(obj)
>  File "c:\python23\lib\pickle.py", line 210, in __init__
>    self.write = file.write
>AttributeError: 'str' object has no attribute 'write'
>
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>
>------------------------------
>
>Message: 9
>Date: Wed, 24 Mar 2004 16:09:46 -0500
>From: Allen Schmidt <aschmidt at fredericksburg.com>
>Subject: [Tutor] Once again....HTTP Digest Authentication
>To: tutor at python.org
>Message-ID: <4061F91A.3020206 at fredericksburg.com>
>Content-Type: text/plain; charset=us-ascii; format=flowed
>
>Howdy folks,
>
>I did another google search on what I needed and danged if my original question months ago was what popped up.
>
>Back at it again and I need to know (examples, etc) how to call a URL that requires a userid and password using digest authentication to proceed with the request.
>
>I just need a tutor-simplisitic approach as to how to get started.
>
>How do I pass a URL so that I get 'asked' for the userid and pwd? Or how do I pass it all at once? I am just lost as to how to proceed.
>
>If someone might be able to help  but feels this outside of tutor type answers, I am willing to PayPal you for your time. Just let me know.
>
>Thanks!!!
>
>Allen
>
>
>
>
>------------------------------
>
>Message: 10
>Date: Wed, 24 Mar 2004 14:20:31 -0700
>From: "John Purser" <johnp at HomeLumber.com>
>Subject: RE: [Tutor] Once again....HTTP Digest Authentication
>To: <tutor at python.org>
>Message-ID:
>    <D0DD3F40FC3F714A88D0DB43BAE3625686D227 at 01-hl-prime.denver.homelmbr.com>
>    
>Content-Type: text/plain;   charset="iso-8859-1"
>
>Alan,
>
>Take a look at:
>http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/267197
>There seems to be an example there that passes a username and password to a URL.
>
>I found it by Goggling = http, Python, username, password.  Lots of other links listed as well.
>
>Good Luck,
>
>John Purser
>
>-----Original Message-----
>From: Allen Schmidt [mailto:aschmidt at fredericksburg.com]
>Sent: Wednesday, March 24, 2004 2:10 PM
>To: tutor at python.org
>Subject: [Tutor] Once again....HTTP Digest Authentication
>
>
>Howdy folks,
>
>I did another google search on what I needed and danged if my original question months ago was what popped up.
>
>Back at it again and I need to know (examples, etc) how to call a URL that requires a userid and password using digest authentication to proceed with the request.
>
>I just need a tutor-simplisitic approach as to how to get started.
>
>How do I pass a URL so that I get 'asked' for the userid and pwd? Or how do I pass it all at once? I am just lost as to how to proceed.
>
>If someone might be able to help  but feels this outside of tutor type answers, I am willing to PayPal you for your time. Just let me know.
>
>Thanks!!!
>
>Allen
>
>
>_______________________________________________
>Tutor maillist  -  Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>
>------------------------------
>
>Message: 11
>Date: Wed, 24 Mar 2004 15:45:34 -0600
>From: "APQ LE" <apqle75 at hotmail.com>
>Subject: Re: [Tutor] write a file
>To: tutor at python.org
>Message-ID: <BAY16-F79NMjiGwYt7y00014a47 at hotmail.com>
>Content-Type: text/plain; format=flowed
>
>Thanks for all the responses.  Here is what I have.
>
>OS: Win 2k
>File: French context (French strings)
>Encoding: Unicode
>
>-----
>The output file that I got contains a bunch of question marks after every 
>strings that I have.  For example, the original string is
>
>Le fichier local n'a pas pu être créé.
>
>output:
>Le fichier local n'a pas pu être créé.
>????????????????????????????????
>
>~Megan
>
>>From: sigurd at 12move.de (Karl Pflästerer)
>>To: tutor at python.org
>>Subject: Re: [Tutor] write a file
>>Date: Wed, 24 Mar 2004 20:52:38 +0100
>>
>>On 24 Mar 2004, APQ LE <- apqle75 at hotmail.com wrote:
>>
>> > I'm trying to open a file, read its content and write its content to a
>> > new file.  Pretty much like copying a file.  Here is what I have
>>
>> > ========
>> > in = open ("a.txt", "r")
>> > out = open ("b.txt", "w")
>> > for line in in.readlines()
>> >    out.write(line)
>>
>> > in.close()
>> > out.close()
>>
>> > ==========
>> > However, the output isn't as expected.  There is additional empty line
>> > comes after every existing line.  So, the output file is bigger than
>> > the original file.
>>
>>What OS are you working on?
>>
>>Furthermore the above code is overcomplicated; I assume you use a recent
>>version of Python.  Then you could write:
>>
>>inf = file('a.txt')
>>out = file('b.txt', 'w')
>>out.writelines(inf)
>>out.close()
>>inf.close()
>>
>>writelines() takes an iterator as argument: here the open file object.
>>
>>
>>
>>
>>    Karl
>>--
>>Please do *not* send copies of replies to me.
>>I read the list
>>
>>
>>_______________________________________________
>>Tutor maillist  -  Tutor at python.org
>>http://mail.python.org/mailman/listinfo/tutor
>
>_________________________________________________________________
>MSN Toolbar provides one-click access to Hotmail from any Web page – FREE 
>download! http://toolbar.msn.com/go/onm00200413ave/direct/01/
>
>
>
>
>------------------------------
>
>Message: 12
>Date: Wed, 24 Mar 2004 15:51:47 -0600
>From: "APQ LE" <apqle75 at hotmail.com>
>Subject: RE: [Tutor] Re: write a file
>To: tutor at python.org
>Message-ID: <BAY16-F35LtosJ3Ih7j0001514b at hotmail.com>
>Content-Type: text/plain; format=flowed
>
>'rU' works better, but not completely.  Now, I get two trailing question 
>marks at the end of every line rather than an additional line with only 
>question marks.
>
>what is 'U'?
>
>thanks.
>
>
>>From: Andrei <project5 at redrival.net>
>>To: tutor at python.org
>>Subject: [Tutor] Re: write a file
>>Date: Wed, 24 Mar 2004 21:25:56 +0100
>>
>>Karl Pflästerer wrote on Wed, 24 Mar 2004 20:52:38 +0100:
>>
>> >> I'm trying to open a file, read its content and write its content to a
>> >> new file.  Pretty much like copying a file.  Here is what I have
>> >
>> >> ========
>> >> in = open ("a.txt", "r")
>> >> out = open ("b.txt", "w")
>> >> for line in in.readlines()
>> >>    out.write(line)
>> >
>> >> in.close()
>> >> out.close()
>>
>>That code works?? Never gives stuff names that are already used by Python.
>>'in' is a kewyword used in e.g. 'for something in whatever', so you
>>shouldn't be able to name a file 'in'. It's also a bad idea to override
>>built-ins, like range, file or open - even though you don't do that in that
>>particular piece of code :).
>



More information about the Tutor mailing list