From kauphlyn@speakeasy.org  Sat Sep  1 00:53:13 2001
From: kauphlyn@speakeasy.org (Daniel Coughlin)
Date: Fri, 31 Aug 2001 16:53:13 -0700 (PDT)
Subject: [Tutor] help with web programming
Message-ID: <Pine.LNX.4.33L2.0108311650070.7294-100000@grace.speakeasy.net>

Hello Pythoneers,

I am writing a script which grabs a webpage and then returns a list of a
certain type of link. The each link is then appended to my main url to collect
the associated pages.
It works fine for the first 10 or so links and then it breaks. (The list
of valid links has about 85 items in it.)

Here is the script:


import urllib
import re


sUrl = 'http://mydomain.com/'
sCmd = 'cmd'
sUrlcmd = sUrl+sCmd
lCmds = []


tupU = urllib.urlretrieve(sUrlcmd) 	#get main page
fTmp = open(tupU[0]) 			#open source file for main page
sTmp = fTmp.read()
lTmpHrefs = re.findall(r'href="(.*?)"', sTmp) #filter source for hrefs

for item in lTmpHrefs:
    if item[0:3] == sCmd: lCmds.append(item) #make list of special hrefs


for cmd in lCmds:
    tupTmp = urllib.urlretrieve(sUrl+cmd) #retrieve source of special links
    print tupTmp[0]                       #print location of source files

-----------------------------------------------------
Here is the result:

C:\DOCUME~1\DANIEL~1.SEA\LOCALS~1\Temp\~1204-21
C:\DOCUME~1\DANIEL~1.SEA\LOCALS~1\Temp\~1204-22
C:\DOCUME~1\DANIEL~1.SEA\LOCALS~1\Temp\~1204-24
C:\DOCUME~1\DANIEL~1.SEA\LOCALS~1\Temp\~1204-25
C:\DOCUME~1\DANIEL~1.SEA\LOCALS~1\Temp\~1204-26
C:\DOCUME~1\DANIEL~1.SEA\LOCALS~1\Temp\~1204-27
C:\DOCUME~1\DANIEL~1.SEA\LOCALS~1\Temp\~1204-28
C:\DOCUME~1\DANIEL~1.SEA\LOCALS~1\Temp\~1204-29
C:\DOCUME~1\DANIEL~1.SEA\LOCALS~1\Temp\~1204-30
C:\DOCUME~1\DANIEL~1.SEA\LOCALS~1\Temp\~1204-31
C:\DOCUME~1\DANIEL~1.SEA\LOCALS~1\Temp\~1204-32
C:\DOCUME~1\DANIEL~1.SEA\LOCALS~1\Temp\~1204-33
Traceback (most recent call last):
  File "C:\Python21\Pythonwin\pywin\framework\scriptutils.py", line 301,
in RunScript
    exec codeObject in __main__.__dict__
  File "C:\daniel\test.py", line 28, in ?
  File "C:\Python21\lib\urllib.py", line 78, in urlretrieve
    return _urlopener.retrieve(url, filename, reporthook, data)
  File "C:\Python21\lib\urllib.py", line 208, in retrieve
    fp = self.open(url, data)
  File "C:\Python21\lib\urllib.py", line 176, in open
    return getattr(self, name)(url)
  File "C:\Python21\lib\urllib.py", line 290, in open_http
    errcode, errmsg, headers = h.getreply()
  File "C:\Python21\lib\httplib.py", line 705, in getreply
    response = self._conn.getresponse()
  File "C:\Python21\lib\httplib.py", line 559, in getresponse
    response.begin()
  File "C:\Python21\lib\httplib.py", line 117, in begin
    line = self.fp.readline()
  File "C:\Python21\lib\socket.py", line 233, in readline
    new = self._sock.recv(self._rbufsize)
IOError: [Errno socket error] (10054, 'Connection reset by peer')
------
Can anyone out there help me interprit this error? Any help at all will
be appreciated!

Thanks,

Daniel



From ignacio@openservices.net  Sat Sep  1 00:57:37 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Fri, 31 Aug 2001 19:57:37 -0400 (EDT)
Subject: [Tutor] help with web programming
In-Reply-To: <Pine.LNX.4.33L2.0108311650070.7294-100000@grace.speakeasy.net>
Message-ID: <Pine.LNX.4.33.0108311956490.4004-100000@terbidium.openservices.net>

On Fri, 31 Aug 2001, Daniel Coughlin wrote:

> IOError: [Errno socket error] (10054, 'Connection reset by peer')

That means that the other side cut you off. Reconnect and try again from where
you were.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From kauphlyn@speakeasy.org  Sat Sep  1 01:11:06 2001
From: kauphlyn@speakeasy.org (Daniel Coughlin)
Date: Fri, 31 Aug 2001 17:11:06 -0700 (PDT)
Subject: [Tutor] help with web programming
In-Reply-To: <Pine.LNX.4.33.0108311956490.4004-100000@terbidium.openservices.net>
Message-ID: <Pine.LNX.4.33L2.0108311707410.7294-100000@grace.speakeasy.net>

I changed the code include a function with
a try-except IOError, and which also removes the already done commands from the
list and
it appears to do the trick!

Thank You,
Daniel

On Fri, 31 Aug 2001, Ignacio Vazquez-Abrams wrote:

> On Fri, 31 Aug 2001, Daniel Coughlin wrote:
>
> > IOError: [Errno socket error] (10054, 'Connection reset by peer')
>
> That means that the other side cut you off. Reconnect and try again from where
> you were.
>
> --
> Ignacio Vazquez-Abrams  <ignacio@openservices.net>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From ignacio@openservices.net  Sat Sep  1 01:18:54 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Fri, 31 Aug 2001 20:18:54 -0400 (EDT)
Subject: [Tutor] help with web programming
In-Reply-To: <Pine.LNX.4.33L2.0108311707410.7294-100000@grace.speakeasy.net>
Message-ID: <Pine.LNX.4.33.0108312017420.4004-100000@terbidium.openservices.net>

On Fri, 31 Aug 2001, Daniel Coughlin wrote:

> I changed the code include a function with
> a try-except IOError, and which also removes the already done commands from the
> list and
> it appears to do the trick!
>
> Thank You,
> Daniel

Maybe so, but I would narrow down the except to the specific error (10054,
'Connection reset by peer'). IOError is fairly common, and you wouldn't want
to try to reconnect if the connection is rejected in the first place.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From kauphlyn@speakeasy.org  Sat Sep  1 05:07:31 2001
From: kauphlyn@speakeasy.org (Daniel Coughlin)
Date: Fri, 31 Aug 2001 21:07:31 -0700 (PDT)
Subject: [Tutor] help with web programming
In-Reply-To: <Pine.LNX.4.33.0108312017420.4004-100000@terbidium.openservices.net>
Message-ID: <Pine.LNX.4.33L2.0108312059310.17735-100000@grace.speakeasy.net>

Hmmmm, it might be somekind of security setting, I suppose. I am using this
script for web testing on a private network, but I will consult with my
System Admistrator (knowing him it probably is a security setting) to find out
more. Thanks for the tip.

Daniel


On Fri, 31 Aug 2001, Ignacio Vazquez-Abrams wrote:
>
> Maybe so, but I would narrow down the except to the specific error (10054,
> 'Connection reset by peer'). IOError is fairly common, and you wouldn't want
> to try to reconnect if the connection is rejected in the first place.
>
> --
> Ignacio Vazquez-Abrams  <ignacio@openservices.net>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From ignacio@openservices.net  Sat Sep  1 05:19:18 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Sat, 1 Sep 2001 00:19:18 -0400 (EDT)
Subject: [Tutor] help with web programming
In-Reply-To: <Pine.LNX.4.33L2.0108312059310.17735-100000@grace.speakeasy.net>
Message-ID: <Pine.LNX.4.33.0109010009550.4535-100000@terbidium.openservices.net>

On Fri, 31 Aug 2001, Daniel Coughlin wrote:

> Hmmmm, it might be somekind of security setting, I suppose. I am using this
> script for web testing on a private network, but I will consult with my
> System Admistrator (knowing him it probably is a security setting) to find out
> more. Thanks for the tip.
>
> Daniel

You misunderstood what I said (don't worry, you're about the fifth today...).

What I meant was to tune your exception to catch IOError #10054 exclusively:

---
try:
   ...
except IOError:
  if sys.exc_info()[1].errno!=10054:
    raise
   ...
---

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>






From smt@pacific.net.hk  Sat Sep  1 05:45:47 2001
From: smt@pacific.net.hk (Kenneth Tsang)
Date: Sat, 1 Sep 2001 12:45:47 +0800
Subject: [Tutor] wxPython GUI builder
Message-ID: <006001c132a0$f8408a60$a800a8c0@orange>

This is a multi-part message in MIME format.

------=_NextPart_000_005D_01C132E4.05FEEE10
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi, I am looking for a tools for quick prototype building, and I am into =
Python 2-3 weeks ago, which I found it totally amazing. I am now trying =
to build a applications for multiple GUI platforms, speciafically =
Solaris, Linux and Windows, which I found that wxPython is quite a good =
choice. But one thing I would like to know is that if there is any GUI =
builder out there that can speed up the development of UI? rather than =
just using layout constraints and boxer? Please advice, thanks.

cheers, Kenneth
--
Kenneth Tsang
email: smt@pacific.net.hk tel: +852 9468 4772

------=_NextPart_000_005D_01C132E4.05FEEE10
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2479.6" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi, I am looking for a tools for quick =
prototype=20
building, and I am into Python 2-3 weeks ago, which I found it totally =
amazing.=20
I am now trying to build a applications for multiple GUI platforms,=20
speciafically Solaris, Linux and Windows, which I found that wxPython is =
quite a=20
good choice. But one thing I would like to know is that if there is any =
GUI=20
builder out there that can speed up the development of UI? rather than =
just=20
using layout constraints and boxer? Please advice, thanks.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>cheers, Kenneth<BR>--<BR>Kenneth =
Tsang<BR>email: <A=20
href=3D"mailto:smt@pacific.net.hk">smt@pacific.net.hk</A> tel: +852 9468 =

4772</FONT></DIV></BODY></HTML>

------=_NextPart_000_005D_01C132E4.05FEEE10--



From sheila@thinkspot.net  Sat Sep  1 05:52:15 2001
From: sheila@thinkspot.net (Sheila King)
Date: Fri, 31 Aug 2001 21:52:15 -0700
Subject: [Tutor] wxPython GUI builder
In-Reply-To: <006001c132a0$f8408a60$a800a8c0@orange>
References: <006001c132a0$f8408a60$a800a8c0@orange>
Message-ID: <7C5CB43530@kserver.org>

On Sat, 1 Sep 2001 12:45:47 +0800, "Kenneth Tsang" <smt@pacific.net.hk>
wrote about [Tutor] wxPython GUI builder:

:Hi, I am looking for a tools for quick prototype building, and I am into Python 2-3 weeks ago, which I found it totally amazing. I am now trying to build a applications for multiple GUI platforms, speciafically Solaris, Linux and Windows, which I found 
that wxPython is quite a good choice. But one thing I would like to know is that if there is any GUI builder out there that can speed up the development of UI? rather than just using layout constraints and boxer? Please advice, thanks.
:
:cheers, Kenneth

You might try searching for Boa Constructor at SourceForge.net.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/



From kauphlyn@speakeasy.org  Sat Sep  1 06:00:11 2001
From: kauphlyn@speakeasy.org (Daniel Coughlin)
Date: Fri, 31 Aug 2001 22:00:11 -0700 (PDT)
Subject: [Tutor] help with web programming
In-Reply-To: <Pine.LNX.4.33.0109010009550.4535-100000@terbidium.openservices.net>
Message-ID: <Pine.LNX.4.33L2.0108312149310.17735-100000@grace.speakeasy.net>

Ha ha. I understand now!
By the way, thanks for the code to fine tune the exception
handling. Before now, I knew nothing about the sys module.
Usually I am about as discriminating as

except StandardError:
	yadda yadda

On Sat, 1 Sep 2001, Ignacio Vazquez-Abrams wrote:

>
> You misunderstood what I said (don't worry, you're about the fifth today...).
>
> What I meant was to tune your exception to catch IOError #10054 exclusively:
>
> ---
> try:
>    ...
> except IOError:
>   if sys.exc_info()[1].errno!=10054:
>     raise
>    ...
> ---
>
> --
> Ignacio Vazquez-Abrams  <ignacio@openservices.net>
>
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From wmperry@swbell.net  Sat Sep  1 06:32:47 2001
From: wmperry@swbell.net (William Perry)
Date: Sat, 01 Sep 2001 00:32:47 -0500
Subject: [Tutor] what am I missing?
Message-ID: <200109010032470650.1835B8D1@mail.swbell.net>

--Boundary_(ID_P8sBd2dCsRzUVW8uFdJHiw)
Content-type: text/plain; charset=ISO-8859-1
Content-transfer-encoding: 7BIT

More Newby ignorance:

3 weeks and ?? different permutations of this and I just can't seem to get the widgets and the functions to play nice and share.
I've been following the stdout capture thread and that may be another way to go with this but I'm thinking that understanding WHY I can't make this work might be more useful in understanding Python/Tkinter/programming for future projects.

This is a stripped down trial version, search (if it worked) would take a user supplied search term and apply it to a .txt file and send the results to the display. I've got it running in a command line version but can't seem to wrap it in Tkinter. Actually, if I open the search entry widget at run time it works, I'd like to call the search from a button on the frame.

I left most of the most recent failures in commented out



from Tkinter import *
from ScrolledText import *

def doSearch(event):
    sTerm=StringVar()
    #print 'HERE'
    box=Toplevel()

    label=Label(box, text='Enter term').pack()
    entry=Entry(box)
    Button(box, text='Look For', command=search).pack()
    entry.pack()
    entry.focus()
    display=ScrolledText(box, width=40, height=20, bg='white').pack(expand=YES, fill=BOTH)



    #sTerm=entry.get
    #search(sTerm)
    #print sTerm

def quit():
    root.quit()

def search():
    sTerm=StringVar()
    sTerm=box.entry.get()  #produces attribute error as below
    print sTerm
    #root.insert(END, sTerm)   ##############
    #lbox.insert(END, sTerm)   # doesn't work
    #fr.lbox.insert(END, sTerm) ################
    display.insert(sTerm)
    #pass





root=Tk()
fr=Frame(root)
button=Button(fr)
button['text']= 'Search'
button.bind('<Button-1>', doSearch)
button.pack()

lbox=ScrolledText(fr, height=20, width=40, bg='white').pack(expand=YES, fill=BOTH)
#root.insert(END, 'Word') # doesn't work
Button(fr, text='QUIT', command=quit).pack()
fr.pack()

root.mainloop()


Error produced when the ' Look For ' button is pressed

Exception in Tkinter callback
Traceback (most recent call last):
  File "c:\python21\lib\lib-tk\Tkinter.py", line 1285, in __call__
    return apply(self.func, args)
  File "C:\WINDOWS\Desktop\Programing\getdata.py", line 31, in search
    sTerm=box.entry.get()
NameError: global name 'box' is not defined


Thanks..
Bill Perry


--Boundary_(ID_P8sBd2dCsRzUVW8uFdJHiw)
Content-type: text/html; charset=us-ascii
Content-transfer-encoding: 7BIT

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 5.50.4611.1300" name=GENERATOR></HEAD>
<BODY style="FONT-FAMILY: Arial" text=#000000 bgColor=#ffffff>
<DIV>More Newby ignorance:</DIV>
<DIV>&nbsp;</DIV>
<DIV>3 weeks and ?? different permutations of this and I just can't seem to get 
the widgets and the functions to play nice and&nbsp;share.</DIV>
<DIV>I've been following the stdout capture thread and that may be another way 
to go with this but I'm thinking that understanding WHY I can't make this work 
might be more useful in understanding Python/Tkinter/programming for future 
projects.</DIV>
<DIV>&nbsp;</DIV>
<DIV>This is a stripped down trial version, search (if it worked) would take a 
user supplied search term and apply it to a .txt file and send the results to 
the display. I've got it running in a command line version but can't seem to 
wrap it in Tkinter. Actually, if I open the search entry widget at run time 
it&nbsp;works, I'd like to call the search from&nbsp;a button on the 
frame.&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>I left most of the most recent failures in commented out</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>from Tkinter import *<BR>from ScrolledText import *</DIV>
<DIV>&nbsp;</DIV>
<DIV>def doSearch(event):<BR>&nbsp;&nbsp;&nbsp; 
sTerm=StringVar()<BR>&nbsp;&nbsp;&nbsp; #print 'HERE'<BR>&nbsp;&nbsp;&nbsp; 
box=Toplevel()<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; label=Label(box, 
text='Enter term').pack()<BR>&nbsp;&nbsp;&nbsp; 
entry=Entry(box)<BR>&nbsp;&nbsp;&nbsp; Button(box, text='Look For', 
command=search).pack()<BR>&nbsp;&nbsp;&nbsp; entry.pack()<BR>&nbsp;&nbsp;&nbsp; 
entry.focus()<BR>&nbsp;&nbsp;&nbsp; display=ScrolledText(box, width=40, 
height=20, bg='white').pack(expand=YES, fill=BOTH)<BR>&nbsp;&nbsp;&nbsp; 
<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; 
#sTerm=entry.get<BR>&nbsp;&nbsp;&nbsp; #search(sTerm)<BR>&nbsp;&nbsp;&nbsp; 
#print sTerm</DIV>
<DIV>&nbsp;</DIV>
<DIV>def quit():<BR>&nbsp;&nbsp;&nbsp; root.quit()</DIV>
<DIV>&nbsp;</DIV>
<DIV>def search():<BR>&nbsp;&nbsp;&nbsp; sTerm=StringVar()<BR>&nbsp;&nbsp;&nbsp; 
sTerm=box.entry.get()&nbsp; #produces attribute error as 
below<BR>&nbsp;&nbsp;&nbsp; print sTerm<BR>&nbsp;&nbsp;&nbsp; #root.insert(END, 
sTerm)&nbsp;&nbsp; ##############<BR>&nbsp;&nbsp;&nbsp; #lbox.insert(END, 
sTerm)&nbsp;&nbsp; # doesn't work<BR>&nbsp;&nbsp;&nbsp; #fr.lbox.insert(END, 
sTerm) ################<BR>&nbsp;&nbsp;&nbsp; 
display.insert(sTerm)<BR>&nbsp;&nbsp;&nbsp; 
#pass&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; </DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR>root=Tk()<BR>fr=Frame(root)<BR>button=Button(fr)<BR>button['text']= 
'Search'<BR>button.bind('&lt;Button-1&gt;', doSearch)<BR>button.pack()</DIV>
<DIV>&nbsp;</DIV>
<DIV>lbox=ScrolledText(fr, height=20, width=40, bg='white').pack(expand=YES, 
fill=BOTH)<BR>#root.insert(END, 'Word') # doesn't work<BR>Button(fr, 
text='QUIT', command=quit).pack()<BR>fr.pack()</DIV>
<DIV>&nbsp;</DIV>
<DIV>root.mainloop()</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=#ff0000>Error produced when the '&nbsp;Look For ' button is 
pressed</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>Exception in Tkinter callback<BR>Traceback (most recent call 
last):<BR>&nbsp; File "c:\python21\lib\lib-tk\Tkinter.py", line 1285, in 
__call__<BR>&nbsp;&nbsp;&nbsp; return apply(self.func, args)<BR>&nbsp; File 
"C:\WINDOWS\Desktop\Programing\getdata.py", line 31, in 
search<BR>&nbsp;&nbsp;&nbsp; sTerm=box.entry.get()<BR>NameError: global name 
'box' is not defined<BR></DIV>
<DIV><BR>Thanks..</DIV>
<DIV>Bill Perry</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV></BODY></HTML>


--Boundary_(ID_P8sBd2dCsRzUVW8uFdJHiw)--


From ignacio@openservices.net  Sat Sep  1 07:07:00 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Sat, 1 Sep 2001 02:07:00 -0400 (EDT)
Subject: [Tutor] what am I missing?
In-Reply-To: <200109010032470650.1835B8D1@mail.swbell.net>
Message-ID: <Pine.LNX.4.33.0109010205360.4535-100000@terbidium.openservices.net>

On Sat, 1 Sep 2001, William Perry wrote:

Whoops.

> from Tkinter import *
> from ScrolledText import *

box=None

> def doSearch(event):

    global box

>     sTerm=StringVar()
>     #print 'HERE'
>     box=Toplevel()
>
>     label=Label(box, text='Enter term').pack()
>     entry=Entry(box)
>     Button(box, text='Look For', command=search).pack()
>     entry.pack()
>     entry.focus()
>     display=ScrolledText(box, width=40, height=20, bg='white').pack(expand=YES, fill=BOTH)
>
>
>
>     #sTerm=entry.get
>     #search(sTerm)
>     #print sTerm
>
> def quit():
>     root.quit()
>
> def search():

    global box

>     sTerm=StringVar()
>     sTerm=box.entry.get()  #produces attribute error as below
>     print sTerm
>     #root.insert(END, sTerm)   ##############
>     #lbox.insert(END, sTerm)   # doesn't work
>     #fr.lbox.insert(END, sTerm) ################
>     display.insert(sTerm)
>     #pass
>
>
>
>
>
> root=Tk()
> fr=Frame(root)
> button=Button(fr)
> button['text']= 'Search'
> button.bind('<Button-1>', doSearch)
> button.pack()
>
> lbox=ScrolledText(fr, height=20, width=40, bg='white').pack(expand=YES, fill=BOTH)
> #root.insert(END, 'Word') # doesn't work
> Button(fr, text='QUIT', command=quit).pack()
> fr.pack()
>
> root.mainloop()
>
>
> Error produced when the ' Look For ' button is pressed
>
> Exception in Tkinter callback
> Traceback (most recent call last):
>   File "c:\python21\lib\lib-tk\Tkinter.py", line 1285, in __call__
>     return apply(self.func, args)
>   File "C:\WINDOWS\Desktop\Programing\getdata.py", line 31, in search
>     sTerm=box.entry.get()
> NameError: global name 'box' is not defined
>
>
> Thanks..
> Bill Perry
>
>

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From sheila@thinkspot.net  Sat Sep  1 07:27:16 2001
From: sheila@thinkspot.net (Sheila King)
Date: Fri, 31 Aug 2001 23:27:16 -0700
Subject: [Tutor] what am I missing?
In-Reply-To: <Pine.LNX.4.33.0109010205360.4535-100000@terbidium.openservices.net>
References: <200109010032470650.1835B8D1@mail.swbell.net> <Pine.LNX.4.33.0109010205360.4535-100000@terbidium.openservices.net>
Message-ID: <D37F6D7812@kserver.org>

I really don't know as I care for just throwing in a "global"
everywhere, to solve this scoping problem. Sometimes you can't do it any
other way, but this one could be solved in other ways (it seems to me).

To William:
The problem you were having with the error message about the "global
box", was that your code first mentions this statement:

box = Toplevel() 

inside the doSearch function. Because you mention it inside that
function, then (barring use of the "global" keyword), the other parts of
your code can't see it. They can't see inside of the other functions to
see what they are doing. So when your search() function tries to do
something to the "box", it gets confused, because it doesn't know where
it came from. Putting the phrase "global box" in there, tells the
function to look outside itself, to a "box" object that all parts of the
program are allowed to access.

Ignacio has shown you one possible solution. By declaring the identifier
"box" to be a global, this means ALL parts of your code have access to
it and can see it.

Other possibilities:
Declare the box inside your main code, but create it hidden, and pass it
as a parameter to the functions.

OR:
Write a class, that is a box object, that subclasses a Toplevel, and
give it its own "search" method functions. The book Programming Python
shows a lot about how to effectively use classes with Tkinter objects
and subclass them. I've found it to be a really neat approach to the
problem.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/



On Sat, 1 Sep 2001 02:07:00 -0400 (EDT), Ignacio Vazquez-Abrams
<ignacio@openservices.net>  wrote about Re: [Tutor] what am I missing?:

:On Sat, 1 Sep 2001, William Perry wrote:
:
:Whoops.
:
:> from Tkinter import *
:> from ScrolledText import *
:
:box=None
:
:> def doSearch(event):
:
:    global box
:
:>     sTerm=StringVar()
:>     #print 'HERE'
:>     box=Toplevel()
:>
:>     label=Label(box, text='Enter term').pack()
:>     entry=Entry(box)
:>     Button(box, text='Look For', command=search).pack()
:>     entry.pack()
:>     entry.focus()
:>     display=ScrolledText(box, width=40, height=20, bg='white').pack(expand=YES, fill=BOTH)
:>
:>
:>
:>     #sTerm=entry.get
:>     #search(sTerm)
:>     #print sTerm
:>
:> def quit():
:>     root.quit()
:>
:> def search():
:
:    global box
:
:>     sTerm=StringVar()
:>     sTerm=box.entry.get()  #produces attribute error as below
:>     print sTerm
:>     #root.insert(END, sTerm)   ##############
:>     #lbox.insert(END, sTerm)   # doesn't work
:>     #fr.lbox.insert(END, sTerm) ################
:>     display.insert(sTerm)
:>     #pass
:>
:>
:>
:>
:>
:> root=Tk()
:> fr=Frame(root)
:> button=Button(fr)
:> button['text']= 'Search'
:> button.bind('<Button-1>', doSearch)
:> button.pack()
:>
:> lbox=ScrolledText(fr, height=20, width=40, bg='white').pack(expand=YES, fill=BOTH)
:> #root.insert(END, 'Word') # doesn't work
:> Button(fr, text='QUIT', command=quit).pack()
:> fr.pack()
:>
:> root.mainloop()
:>
:>
:> Error produced when the ' Look For ' button is pressed
:>
:> Exception in Tkinter callback
:> Traceback (most recent call last):
:>   File "c:\python21\lib\lib-tk\Tkinter.py", line 1285, in __call__
:>     return apply(self.func, args)
:>   File "C:\WINDOWS\Desktop\Programing\getdata.py", line 31, in search
:>     sTerm=box.entry.get()
:> NameError: global name 'box' is not defined
:>
:>
:> Thanks..
:> Bill Perry
:>
:>



From dyoo@hkn.eecs.berkeley.edu  Sat Sep  1 10:24:19 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sat, 1 Sep 2001 02:24:19 -0700 (PDT)
Subject: [Tutor] Re: Pythonica (symbolic algebra)
In-Reply-To: <a04330104b7b440541a37@[24.30.141.233]>
Message-ID: <Pine.LNX.4.21.0109010220230.6976-100000@hkn.eecs.berkeley.edu>

On Thu, 30 Aug 2001, Joseph J. Strout wrote:

> At 1:42 PM -0500 8/30/01, Christopher Smith wrote:
> 
> >It looks like you had made some significant progress
> >on Python and provided some useful tools (I am using
> >the patched editor, for example).  Thank you.
> 
> Quite happy to have contributed; Python is great (as is the community).
> 
> >Do you have a list of errors that have been reported for Pythonica?
> 
> Sorry, I don't.
> 
> >I passed along your comments to the tutor and mac lists.


Hello!  Have you had a chance to look at:

   http://hkn.eecs.berkeley.edu/~dyoo/python/pythonica/

I've been playing around with the Pythonica code, mostly to learn how to
use the Spark parser generator tools.  I think the parser bug with
"2*3+2^2/3" is fixed, although I'm sure I've introduced new bugs 
everywhere... *grin*  I'd like to get your input on the changes I've
made; do they look ok?



From dsh8290@rit.edu  Sat Sep  1 14:15:57 2001
From: dsh8290@rit.edu (dman)
Date: Sat, 1 Sep 2001 09:15:57 -0400
Subject: [Tutor] wxPython GUI builder
In-Reply-To: <006001c132a0$f8408a60$a800a8c0@orange>; from smt@pacific.net.hk on Sat, Sep 01, 2001 at 12:45:47PM +0800
References: <006001c132a0$f8408a60$a800a8c0@orange>
Message-ID: <20010901091557.G13154@harmony.cs.rit.edu>

On Sat, Sep 01, 2001 at 12:45:47PM +0800, Kenneth Tsang wrote:

[ want RAD GUI builder for cross-platform deployment ]

For wxPython ther is Boa Constructor (free) or wxDesigner (demo is
free, small fee for registered version).

For GTK+ (PyGTK) there is glade, and the accompanying 'libglade'
library.

wxPython looks pretty good and will give you close to native LnF in
the end result.  I really like PyGTK and find it easy to get things to
look right.  The neat thing about using a glade/libglade combo is you
don't actually generate any code -- the GUI is built dynamically at
runtime from the glade project file.  You can even change the
arrangement of stuff without rebuilding the code (more significant
with compiled languages like C or C++).  (BTW gtk, pygtk, glade, and
libglade have all been ported to windows.)

HTH,
-D



From alan.gauld@bt.com  Sat Sep  1 14:59:17 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sat, 1 Sep 2001 14:59:17 +0100
Subject: [OT] BASIC Factoid (was Re: [Tutor] Functions !)
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BEFE@mbtlipnt02.btlabs.bt.co.uk>

> > From:	Bruce Sass [SMTP:bsass@freenet.edmonton.ab.ca]
> > 2K on the ZX81, unless you bought one of the RAM expanders 
> (16, 32 and 64k sizes).  
>  
> It was *definitely* only 1K on mine. I ended up getting a 16K 
> Ram pack, but if I typed too hard, it would wobble, 
> and the ZX81 would crash.

I believe the export version(Timex) did have 2K RAM but the 
original only had 1K. The RAM packs became available about  
6 months- 1 year later (Jan 1982?) in 4K and 16K versions. 
I've never heard of 32K or 64K versions but it wouldn't 
surprise me.

By 1984 I had moved to an AMSTRAD PCW8256 running CP/M Plus 
- ah the joys of MASM, DR Pascal and Logo, real computing at 
last! ;-)

Alan G


From alan.gauld@bt.com  Sat Sep  1 15:05:31 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sat, 1 Sep 2001 15:05:31 +0100
Subject: [Tutor] Did someone ask me a question?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BEFF@mbtlipnt02.btlabs.bt.co.uk>

Someone sent me mail last week from my web tutor asking 
for some help with a project. Unfortunaely it got deleted by 
mistake in the middle of a mail storm. All I recall 
is it involved reading passwords.

If you are out there please resend the mail, I did mean 
to reply honest...

Alan Gauld
BT computing partners
Tel : 0141 220 8795
Fax : 0141 248 1284 


From alan.gauld@bt.com  Sat Sep  1 15:30:45 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sat, 1 Sep 2001 15:30:45 +0100
Subject: [Tutor] Why I'm learning Python (OT and long)
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF00@mbtlipnt02.btlabs.bt.co.uk>

> wondered how do people learn all this stuff about how the operating
> systems work, and file locking and sockets and servers and ...

Gradually ;-)

Seriously you learn it as you need it.
Although my Elect Eng degree included intro programming
which included file handling and dynamic data structures
and some program design and validation. I also did a course
on Assembler programming which included stuff on serial 
comms and I/O details. Then my final year project required 
some networking stuff and also included a course on OS design
- so threading, scheduling, and yes, file locking.

Then I left college and my first project was a multi 
processor PBX using a real time OS and designed using state 
machines. My next project had a big database under it so I 
had to learn SQL. I moved onto a billing project and came 
across COBOL and the joys of batch processing.

You get the idea? Its taken a long combination of school 
and many projects. And still I feel like a "Jack of all 
trades but a master of none"!

And things like crypto and hard core graphics programming 
are still on my "must take time to learn" list...

One of the great things about the IT industry is you never 
really "know it all" and even when you think you might be 
getting close along comes something like the Web to add 
a whole new dimension!

Accept that you'll never know it all and just enjoy the 
learning experience. It makes for an easier life!

Alan G


From alan.gauld@bt.com  Sat Sep  1 15:58:04 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sat, 1 Sep 2001 15:58:04 +0100
Subject: [Tutor] Why I'm learning Python (OT and long)
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF02@mbtlipnt02.btlabs.bt.co.uk>

> > Here's some code I was looking at today that I COMPLETELY DON'T GET:
> 
> Don't worry too much about it --- neither does the author.
> 
> """ There are actually two versions of crypt() out there. The 
> older one uses DES encryption, and the newer one uses an MD5 

I once spent a short project building a hardware encryption board
to go in a PC. The chip implemented an alternative to DES (which 
can't be used in the UK except for Finance or Defense) and I was 
privvy to the code and the DES algorithms(which are public). 
It was some f the most convoluted, self referential, highly 
recursive code I've ever seen. It put me of crypto stuff for years!
Its only in the last 2 years when I've gotten dragged into 
IT Security issues at work that I've dared to start considering 
looking at that stuff again!

For now I use the libraries that other folks write and just 
trust them to get it right...

Alan g



From alan.gauld@bt.com  Sat Sep  1 17:02:24 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sat, 1 Sep 2001 17:02:24 +0100
Subject: [Tutor] Re: How to change Windows Environment Variable
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF03@mbtlipnt02.btlabs.bt.co.uk>

> > How to change environment variable on Windows NT or 2000 by python?
> > Private Declare Function SetEnvironmentVariable Lib "kernel32" _
> >     Alias "SetEnvironmentVariableA" (ByVal lpName As String, _
> >     ByVal lpValue As String) As Long

The SetEnvronmentVariable function only changes the value 
*in the current process*. Thus is a fairly pointless function.
You might as well just set a global variable!

This is true in most OSs in that the program gets a copy of 
the environment which it holds in memory, thus changing the 
value only affects the local program. Howeever on Windows 
some of the API functions use env var settings so it does 
make sense(very occasionally)  to change the local copy.

Maybe because its usually a bad idea Python doesn't offer a 
function to do it. But just maybe, the return value of the get
versuion is a pointer to the actual memory space instead of a 
copy - in which case you can try modifying it -  but beware of
overwriting an adjacent value...

In short, be very sure you need to do this. If so then 
proceed with caution. If you really do want it then as 
Ignacio says writing your own as part of win32api might 
be the best route.

Alan G.




From alan.gauld@bt.com  Sat Sep  1 17:55:49 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sat, 1 Sep 2001 17:55:49 +0100
Subject: [Tutor] what am I missing?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF04@mbtlipnt02.btlabs.bt.co.uk>

------_=_NextPart_001_01C13306.F3731370
Content-type: text/plain; charset="ISO-8859-1"

from Tkinter import *
from ScrolledText import *
 

def doSearch(event):
    sTerm=StringVar() 
This is never used , might as well delete it!

    box=Toplevel()
     
You define box here, inside doSearch, so its not visible 
anywhere else in the program. IMHO you are better to 
create your GUI el;ements either as members of a class or, 
if your not happy with OO yet as global variables 
- ie outside of any function.
 
    label=Label(box, text='Enter term').pack()
    entry=Entry(box)
    Button(box, text='Look For', command=search).pack() 
    entry.pack()
    entry.focus()
    display=ScrolledText(box, width=40, height=20,
bg='white').pack(expand=YES, fill=BOTH)
    
def quit():
    root.quit()

def search():
    sTerm=StringVar() 

Not sure why you are using StrinGVar() here, you don't 
seem to use the 'magical' properties of StringVar, 
so a normal string would suffice...

    sTerm=box.entry.get()  #produces attribute error as below 
 
especially since you now replace the StringVar with a string
- or you would if your function could see box.
 
    display.insert(sTerm)

Similarly this won't work coz display is a name only known 
to the doSearch function. 
 
Your problems are not really to do with Tlinter but with your understanding
of Pythons naming rules. Try looking at my chapter on namespaces to see if
that helps:
 
http://www.crosswinds.net/~agauld <http://www.crosswinds.net/~agauld>
/tutname.htm
 

 root=Tk()
fr=Frame(root)
button=Button(fr)
button['text']= 'Search'
button.bind('<Button-1>', doSearch)
button.pack()
 

Why not just:
 
Button(fr, text='Search', command=doSearch).pack()
 
As you do below...?

 
lbox=ScrolledText(fr, height=20, width=40, bg='white').pack(expand=YES,
fill=BOTH)
#root.insert(END, 'Word') # doesn't work
Button(fr, text='QUIT', command=quit).pack()
fr.pack()
 
root.mainloop()
 

So what the program does is create a window with 2 buttons and 
a text area. When you press the Sarch button it creates a dialog
with a label, entry, text area and button.
 
When you hit the dialog button it calls search which has no 
knowledge of the dialog you created only the original 
window(which is global in scope. But Search tries to 
read the value in the dialog. You either need to pass the 
entry and display widgets to the search fnction or make 
them globally available.
 
HTH,
 
Alan G

------_=_NextPart_001_01C13306.F3731370
Content-type: text/html; charset="ISO-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">


<META content="MSHTML 5.00.3013.2600" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff style="FONT-FAMILY: Arial" text=#000000>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
  <DIV>from Tkinter import *<BR>from ScrolledText import *</DIV>
  <DIV>&nbsp;</DIV></BLOCKQUOTE>
<DIV style="MARGIN-RIGHT: 0px">def doSearch(event):<BR>&nbsp;&nbsp;&nbsp; 
sTerm=StringVar()<SPAN class=910503716-01092001><FONT color=#0000ff 
face="Courier New" size=2>&nbsp;</FONT></SPAN></DIV>
<DIV style="MARGIN-RIGHT: 0px"><SPAN class=910503716-01092001><FONT 
color=#0000ff face="Courier New" size=2>This is never used</FONT>&nbsp;<FONT 
color=#0000ff face="Courier New" size=2>, might as well delete 
it!</FONT></SPAN></DIV>
<DIV style="MARGIN-RIGHT: 0px"><SPAN 
class=910503716-01092001></SPAN><BR>&nbsp;&nbsp;&nbsp; 
box=Toplevel()<BR>&nbsp;&nbsp;&nbsp;<SPAN class=910503716-01092001>&nbsp;<FONT 
color=#0000ff face="Courier New" size=2>&nbsp;</FONT></SPAN></DIV>
<DIV style="MARGIN-RIGHT: 0px"><SPAN class=910503716-01092001></SPAN><FONT 
size=2><FONT color=#0000ff><FONT face="Courier New"><SPAN 
class=910503716-01092001>You define box here, inside doSearch, so its not 
visible </SPAN></FONT></FONT></FONT></DIV>
<DIV style="MARGIN-RIGHT: 0px"><FONT size=2><FONT color=#0000ff><FONT 
face="Courier New"><SPAN class=910503716-01092001>anywhere else&nbsp;in the 
program. IMHO you are better to </SPAN></FONT></FONT></FONT></DIV>
<DIV style="MARGIN-RIGHT: 0px"><FONT size=2><FONT color=#0000ff><FONT 
face="Courier New"><SPAN class=910503716-01092001>create your GUI el;ements 
either as members of a class or, </SPAN></FONT></FONT></FONT></DIV>
<DIV style="MARGIN-RIGHT: 0px"><FONT size=2><FONT color=#0000ff><FONT 
face="Courier New"><SPAN class=910503716-01092001>if your not happy with OO yet 
as global variables </SPAN></FONT></FONT></FONT></DIV>
<DIV style="MARGIN-RIGHT: 0px"><FONT size=2><FONT color=#0000ff><FONT 
face="Courier New"><SPAN class=910503716-01092001>- ie outside of any 
function.</SPAN></FONT></FONT></FONT></DIV>
<DIV style="MARGIN-RIGHT: 0px"><FONT size=2><FONT color=#0000ff><FONT 
face="Courier New"><SPAN 
class=910503716-01092001></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV style="MARGIN-RIGHT: 0px">&nbsp;&nbsp;&nbsp; label=Label(box, text='Enter 
term').pack()<BR>&nbsp;&nbsp;&nbsp; entry=Entry(box)<BR>&nbsp;&nbsp;&nbsp; 
Button(box, text='Look For', command=search).pack()<SPAN 
class=910503716-01092001><FONT color=#0000ff face="Courier New" 
size=2>&nbsp;</FONT></SPAN></DIV>
<DIV style="MARGIN-RIGHT: 0px">&nbsp;&nbsp;&nbsp; 
entry.pack()<BR>&nbsp;&nbsp;&nbsp; entry.focus()<BR>&nbsp;&nbsp;&nbsp; 
display=ScrolledText(box, width=40, height=20, bg='white').pack(expand=YES, 
fill=BOTH)<BR>&nbsp;&nbsp;&nbsp; <BR>def quit():<BR>&nbsp;&nbsp;&nbsp; 
root.quit()</DIV>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
  <DIV>def search():<BR>&nbsp;&nbsp;&nbsp; sTerm=StringVar()<SPAN 
  class=910503716-01092001><FONT color=#0000ff face="Courier New" 
  size=2>&nbsp;</FONT></SPAN></DIV></BLOCKQUOTE>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>Not sure why you are using StrinGVar() here, you don't 
</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001></SPAN></FONT><FONT color=#0000ff face="Courier New" 
size=2><SPAN class=910503716-01092001>seem to use the 'magical' properties of 
StringVar, </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001></SPAN></FONT><FONT color=#0000ff face="Courier New" 
size=2><SPAN class=910503716-01092001>so a normal string would 
suffice...</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001></SPAN></FONT><BR>&nbsp;&nbsp;&nbsp; 
sTerm=box.entry.get()&nbsp; #produces attribute error as below<SPAN 
class=910503716-01092001><FONT color=#0000ff face="Courier New" 
size=2>&nbsp;</FONT></SPAN></DIV>
<DIV><SPAN class=910503716-01092001></SPAN>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>especially since you now replace the StringVar with a 
string</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>- or you would if your function could see 
box.</SPAN></FONT></DIV>
<DIV><SPAN class=910503716-01092001>&nbsp;</SPAN><BR>&nbsp;&nbsp;&nbsp; 
display.insert(sTerm)<BR><SPAN class=910503716-01092001><FONT color=#0000ff 
face="Courier New" size=2></FONT></SPAN></DIV>
<DIV><SPAN class=910503716-01092001><FONT color=#0000ff face="Courier New" 
size=2>Similarly this won't work coz display is a name only known 
</FONT></SPAN></DIV>
<DIV><SPAN class=910503716-01092001><FONT color=#0000ff face="Courier New" 
size=2>to the doSearch function.</FONT>&nbsp;</SPAN></DIV>
<DIV><SPAN class=910503716-01092001></SPAN>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>Your problems are not really to do with Tlinter but 
with your understanding of Pythons naming rules. Try looking at my chapter on 
namespaces to see if that helps:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001><A 
href="http://www.crosswinds.net/~agauld">http://www.crosswinds.net/~agauld</A>/tutname.htm</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001></SPAN></FONT>&nbsp;</DIV>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
  <DIV><SPAN 
  class=910503716-01092001>&nbsp;</SPAN>root=Tk()<BR>fr=Frame(root)<BR>button=Button(fr)<BR>button['text']= 
  'Search'<BR>button.bind('&lt;Button-1&gt;', doSearch)<BR>button.pack()</DIV>
  <DIV>&nbsp;</DIV></BLOCKQUOTE>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>Why not just:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>Button(fr, text='Search', 
command=doSearch).pack()</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>As you do below...?</SPAN></FONT></DIV>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
  <DIV>&nbsp;</DIV>
  <DIV>lbox=ScrolledText(fr, height=20, width=40, bg='white').pack(expand=YES, 
  fill=BOTH)<BR>#root.insert(END, 'Word') # doesn't work<BR>Button(fr, 
  text='QUIT', command=quit).pack()<BR>fr.pack()</DIV>
  <DIV>&nbsp;</DIV>
  <DIV>root.mainloop()</DIV>
  <DIV>&nbsp;</DIV></BLOCKQUOTE>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>So what the program does is create a window with 2 
buttons and </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>a text area. When you press the Sarch button it creates 
a dialog</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>with a label, entry, text area and 
button.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>When you hit the dialog button it calls search which 
has no </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>knowledge </SPAN></FONT><FONT color=#0000ff 
face="Courier New" size=2><SPAN class=910503716-01092001>of the dialog you 
created only the original </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>window(which is </SPAN></FONT><FONT color=#0000ff 
face="Courier New" size=2><SPAN class=910503716-01092001>global in scope. But 
Search tries to </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>read the value in the </SPAN></FONT><FONT color=#0000ff 
face="Courier New" size=2><SPAN class=910503716-01092001>dialog. You either need 
to pass the </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>entry and display widgets </SPAN></FONT><FONT 
color=#0000ff face="Courier New" size=2><SPAN class=910503716-01092001>to the 
search fnction or make </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>them globally available.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>HTH,</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=910503716-01092001>Alan G</SPAN></FONT></DIV></BODY></HTML>

------_=_NextPart_001_01C13306.F3731370--


From dsh8290@rit.edu  Sat Sep  1 21:26:33 2001
From: dsh8290@rit.edu (dman)
Date: Sat, 1 Sep 2001 16:26:33 -0400
Subject: [Tutor] Re: How to change Windows Environment Variable
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF03@mbtlipnt02.btlabs.bt.co.uk>; from alan.gauld@bt.com on Sat, Sep 01, 2001 at 05:02:24PM +0100
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF03@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <20010901162633.D13398@harmony.cs.rit.edu>

On Sat, Sep 01, 2001 at 05:02:24PM +0100, alan.gauld@bt.com wrote:
| > > How to change environment variable on Windows NT or 2000 by python?
| > > Private Declare Function SetEnvironmentVariable Lib "kernel32" _
| > >     Alias "SetEnvironmentVariableA" (ByVal lpName As String, _
| > >     ByVal lpValue As String) As Long
| 
| The SetEnvronmentVariable function only changes the value 
| *in the current process*. Thus is a fairly pointless function.
| You might as well just set a global variable!

True, unless for some reason you need to tweak the environment.  Maybe
you are embedding a 3rd party app/lib that checks the environment for
config stuff.

| Maybe because its usually a bad idea Python doesn't offer a 
| function to do it. But just maybe, the return value of the get

See os.putenv().

| versuion is a pointer to the actual memory space instead of a 
| copy - in which case you can try modifying it -  but beware of
| overwriting an adjacent value...

Python strings are immutable and the os.environment dictionary is just
a python view of the environment.  Changing may or may not (probably
not) have the desired effect.

HTH,
-D



From wmperry@swbell.net  Sat Sep  1 23:31:58 2001
From: wmperry@swbell.net (William Perry)
Date: Sat, 01 Sep 2001 17:31:58 -0500
Subject: [Tutor] what am I missing?
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF04@mbtlipnt02.btlabs.bt.co.uk>
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF04@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <200109011731580230.018977E3@mail.swbell.net>

--Boundary_(ID_Yr8NzmNZIMaKfOzSFSgd/g)
Content-type: text/plain; charset=us-ascii
Content-transfer-encoding: 7BIT

I was treating StringVar() as if it were a global. over the couse of repeated attempts to get this working i stuck it several places in an effort to see if/how it worked. The problem as  i understood it was a namespace issue preventing the thing from working. I have the search as a class as well. (weak OOP but i'm trying) so I'm sucessful on calling the class method from the root button now. I need to send or capture the output to the display. it's printing to the stdout window

I'm just one of those folks that has to USE it to understand it (I did BTW work your tutorial early on and it was quite helpful. Maybe a re-read is in order?)



*********** REPLY SEPARATOR ***********

On 9/1/01 at 5:55 PM alan.gauld@bt.com wrote:
from Tkinter import *
from ScrolledText import *

def doSearch(event):
    sTerm=StringVar() This is never used , might as well delete it!

    box=Toplevel()

You define box here, inside doSearch, so its not visible
anywhere else in the program. IMHO you are better to
create your GUI el;ements either as members of a class or,
if your not happy with OO yet as global variables
- ie outside of any function.

    label=Label(box, text='Enter term').pack()
    entry=Entry(box)
    Button(box, text='Look For', command=search).pack()
    entry.pack()
    entry.focus()
    display=ScrolledText(box, width=40, height=20, bg='white').pack(expand=YES, fill=BOTH)

def quit():
    root.quit()
def search():
    sTerm=StringVar()
Not sure why you are using StrinGVar() here, you don't
seem to use the 'magical' properties of StringVar,
so a normal string would suffice...

    sTerm=box.entry.get()  #produces attribute error as below

especially since you now replace the StringVar with a string
- or you would if your function could see box.

    display.insert(sTerm)

Similarly this won't work coz display is a name only known
to the doSearch function.

Your problems are not really to do with Tlinter but with your understanding of Pythons naming rules. Try looking at my chapter on namespaces to see if that helps:

http://www.crosswinds.net/~agauld/tutname.htm  I'll look at it, all help is apprecated

 root=Tk()
fr=Frame(root)
button=Button(fr)
button['text']= 'Search'
button.bind('<Button-1>', doSearch)
button.pack()

Why not just:

Button(fr, text='Search', command=doSearch).pack()

As you do below...?

Teach Yourself Python 24 uses the above method, Programming Python the below. I tried several books to get an understanding. Depending on where I was looking it's inconsistant. I plan to clean it up when it works.

lbox=ScrolledText(fr, height=20, width=40, bg='white').pack(expand=YES, fill=BOTH)
#root.insert(END, 'Word') # doesn't work
Button(fr, text='QUIT', command=quit).pack()
fr.pack()

root.mainloop()

So what the program does is create a window with 2 buttons and
a text area. When you press the Sarch button it creates a dialog
with a label, entry, text area and button.

When you hit the dialog button it calls search which has no
knowledge of the dialog you created only the original
window(which is global in scope. But Search tries to
read the value in the dialog. You either need to pass the
entry and display widgets to the search fnction or make
them globally available.

HTH,

Alan G


--Boundary_(ID_Yr8NzmNZIMaKfOzSFSgd/g)
Content-type: text/html; charset=us-ascii
Content-transfer-encoding: 7BIT

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<META content="MSHTML 5.50.4611.1300" name=GENERATOR></HEAD>
<BODY style="FONT-FAMILY: Arial" text=#000000 bgColor=#ffffff>
<DIV>I was treating StringVar() as if it were a global. over the couse of 
repeated attempts to get this working i stuck it several places in an effort to 
see if/how it worked. The problem as&nbsp; i understood it was a namespace issue 
preventing the thing from working. I have the search as a class as well. (weak 
OOP but i'm trying) so I'm&nbsp;sucessful on calling the class method from the 
root button now. I need to&nbsp;send or capture the output to the display. it's 
printing to the stdout window&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>I'm just one of those folks that has to USE it to understand it (I did BTW 
work your tutorial early on and it was quite helpful. Maybe a re-read is in 
order?)</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><BR><FONT face=Arial size=2>*********** REPLY SEPARATOR 
***********<BR><BR>On 9/1/01 at 5:55 PM alan.gauld@bt.com wrote:</FONT></DIV>
<BLOCKQUOTE 
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid">
  <BLOCKQUOTE 
  style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
    <DIV>from Tkinter import *<BR>from ScrolledText import *</DIV>
    <DIV>&nbsp;</DIV></BLOCKQUOTE>
  <DIV style="MARGIN-RIGHT: 0px">def doSearch(event):<BR>&nbsp;&nbsp;&nbsp; 
  sTerm=StringVar()<SPAN class=910503716-01092001><FONT face="Courier New" 
  color=#0000ff size=2>&nbsp;</FONT></SPAN><SPAN class=910503716-01092001><FONT 
  face="Courier New" color=#0000ff size=2>This is never used</FONT>&nbsp;<FONT 
  face="Courier New" color=#0000ff size=2>, might as well delete 
  it!</FONT></SPAN></DIV>
  <DIV style="MARGIN-RIGHT: 0px"><SPAN 
  class=910503716-01092001></SPAN><BR>&nbsp;&nbsp;&nbsp; 
  box=Toplevel()<BR>&nbsp;&nbsp;&nbsp;<SPAN class=910503716-01092001>&nbsp;<FONT 
  face="Courier New" color=#0000ff size=2>&nbsp;</FONT></SPAN></DIV>
  <DIV style="MARGIN-RIGHT: 0px"><SPAN class=910503716-01092001></SPAN><FONT 
  size=2><FONT color=#0000ff><FONT face="Courier New"><SPAN 
  class=910503716-01092001>You define box here, inside doSearch, so its not 
  visible </SPAN></FONT></FONT></FONT></DIV>
  <DIV style="MARGIN-RIGHT: 0px"><FONT size=2><FONT color=#0000ff><FONT 
  face="Courier New"><SPAN class=910503716-01092001>anywhere else&nbsp;in the 
  program. IMHO you are better to </SPAN></FONT></FONT></FONT></DIV>
  <DIV style="MARGIN-RIGHT: 0px"><FONT size=2><FONT color=#0000ff><FONT 
  face="Courier New"><SPAN class=910503716-01092001>create your GUI el;ements 
  either as members of a class or, </SPAN></FONT></FONT></FONT></DIV>
  <DIV style="MARGIN-RIGHT: 0px"><FONT size=2><FONT color=#0000ff><FONT 
  face="Courier New"><SPAN class=910503716-01092001>if your not happy with OO 
  yet as global variables </SPAN></FONT></FONT></FONT></DIV>
  <DIV style="MARGIN-RIGHT: 0px"><FONT size=2><FONT color=#0000ff><FONT 
  face="Courier New"><SPAN class=910503716-01092001>- ie outside of any 
  function.</SPAN></FONT></FONT></FONT></DIV>
  <DIV style="MARGIN-RIGHT: 0px"><FONT size=2><FONT color=#0000ff><FONT 
  face="Courier New"><SPAN 
  class=910503716-01092001></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
  <DIV style="MARGIN-RIGHT: 0px">&nbsp;&nbsp;&nbsp; label=Label(box, text='Enter 
  term').pack()<BR>&nbsp;&nbsp;&nbsp; entry=Entry(box)<BR>&nbsp;&nbsp;&nbsp; 
  Button(box, text='Look For', command=search).pack()<SPAN 
  class=910503716-01092001><FONT face="Courier New" color=#0000ff 
  size=2>&nbsp;</FONT></SPAN></DIV>
  <DIV style="MARGIN-RIGHT: 0px">&nbsp;&nbsp;&nbsp; 
  entry.pack()<BR>&nbsp;&nbsp;&nbsp; entry.focus()<BR>&nbsp;&nbsp;&nbsp; 
  display=ScrolledText(box, width=40, height=20, bg='white').pack(expand=YES, 
  fill=BOTH)<BR>&nbsp;&nbsp;&nbsp; <BR>def quit():<BR>&nbsp;&nbsp;&nbsp; 
  root.quit()</DIV>
  <BLOCKQUOTE 
  style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
    <DIV>def search():<BR>&nbsp;&nbsp;&nbsp; sTerm=StringVar()<SPAN 
    class=910503716-01092001><FONT face="Courier New" color=#0000ff 
    size=2>&nbsp;</FONT></SPAN></DIV></BLOCKQUOTE>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>Not sure why you are using StrinGVar() here, you 
  don't </SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001></SPAN></FONT><FONT face="Courier New" color=#0000ff 
  size=2><SPAN class=910503716-01092001>seem to use the 'magical' properties of 
  StringVar, </SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001></SPAN></FONT><FONT face="Courier New" color=#0000ff 
  size=2><SPAN class=910503716-01092001>so a normal string would 
  suffice...</SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001></SPAN></FONT><BR>&nbsp;&nbsp;&nbsp; 
  sTerm=box.entry.get()&nbsp; #produces attribute error as below<SPAN 
  class=910503716-01092001><FONT face="Courier New" color=#0000ff 
  size=2>&nbsp;</FONT></SPAN></DIV>
  <DIV><SPAN class=910503716-01092001></SPAN>&nbsp;</DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>especially since you now replace the StringVar with a 
  string</SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>- or you would if your function could see 
  box.</SPAN></FONT></DIV>
  <DIV><SPAN class=910503716-01092001></SPAN><BR>&nbsp;&nbsp;&nbsp; 
  display.insert(sTerm)<BR><SPAN class=910503716-01092001><FONT 
  face="Courier New" color=#0000ff size=2></FONT></SPAN></DIV>
  <DIV><SPAN class=910503716-01092001><FONT face="Courier New" color=#0000ff 
  size=2>Similarly this won't work coz display is a name only known 
  </FONT></SPAN></DIV>
  <DIV><SPAN class=910503716-01092001><FONT face="Courier New" color=#0000ff 
  size=2>to the doSearch function.</FONT>&nbsp;</SPAN></DIV>
  <DIV><SPAN class=910503716-01092001></SPAN>&nbsp;</DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>Your problems are not really to do with Tlinter but 
  with your understanding of Pythons naming rules. Try looking at my chapter on 
  namespaces to see if that helps:</SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001><A 
  href="http://www.crosswinds.net/~agauld/tutname.htm">http://www.crosswinds.net/~agauld/tutname.htm</A>&nbsp; 
  <FONT color=#ff0000>I'll look at it, all help is 
  apprecated</FONT></SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001></SPAN></FONT>&nbsp;</DIV>
  <BLOCKQUOTE 
  style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
    <DIV><SPAN 
    class=910503716-01092001>&nbsp;</SPAN>root=Tk()<BR>fr=Frame(root)<BR>button=Button(fr)<BR>button['text']= 
    'Search'<BR>button.bind('&lt;Button-1&gt;', doSearch)<BR>button.pack()</DIV>
    <DIV>&nbsp;</DIV></BLOCKQUOTE>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>Why not just:</SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>Button(fr, text='Search', 
  command=doSearch).pack()</SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>As you do below...?</SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face="Courier New" color=#ff0000 size=2><SPAN 
  class=910503716-01092001>Teach Yourself Python 24 uses the above method, 
  Programming Python the below. I tried several books to get an understanding. 
  Depending on where I was looking it's inconsistant. I plan to clean it up when 
  it works.</SPAN></FONT></DIV>
  <BLOCKQUOTE 
  style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
    <DIV>&nbsp;</DIV>
    <DIV>lbox=ScrolledText(fr, height=20, width=40, bg='white').pack(expand=YES, 
    fill=BOTH)<BR>#root.insert(END, 'Word') # doesn't work<BR>Button(fr, 
    text='QUIT', command=quit).pack()<BR>fr.pack()</DIV>
    <DIV>&nbsp;</DIV>
    <DIV>root.mainloop()</DIV>
    <DIV>&nbsp;</DIV></BLOCKQUOTE>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>So what the program does is create a window with 2 
  buttons and </SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>a text area. When you press the Sarch button it 
  creates a dialog</SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>with a label, entry, text area and 
  button.</SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>When you hit the dialog button it calls search which 
  has no </SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>knowledge </SPAN></FONT><FONT face="Courier New" 
  color=#0000ff size=2><SPAN class=910503716-01092001>of the dialog you created 
  only the original </SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>window(which is </SPAN></FONT><FONT 
  face="Courier New" color=#0000ff size=2><SPAN class=910503716-01092001>global 
  in scope. But Search tries to </SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>read the value in the </SPAN></FONT><FONT 
  face="Courier New" color=#0000ff size=2><SPAN class=910503716-01092001>dialog. 
  You either need to pass the </SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>entry and display widgets </SPAN></FONT><FONT 
  face="Courier New" color=#0000ff size=2><SPAN class=910503716-01092001>to the 
  search fnction or make </SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>them globally available.</SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>HTH,</SPAN></FONT></DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001></SPAN></FONT>&nbsp;</DIV>
  <DIV><FONT face="Courier New" color=#0000ff size=2><SPAN 
  class=910503716-01092001>Alan G</SPAN></FONT></DIV><FONT size=2 
Arial></BLOCKQUOTE></FONT></BODY></HTML>


--Boundary_(ID_Yr8NzmNZIMaKfOzSFSgd/g)--


From dyoo@hkn.eecs.berkeley.edu  Sun Sep  2 07:24:33 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sat, 1 Sep 2001 23:24:33 -0700 (PDT)
Subject: [Tutor] Why I'm learning Python (OT and long)
In-Reply-To: <20010831120115.H10562@harmony.cs.rit.edu>
Message-ID: <Pine.LNX.4.21.0109012246440.20083-100000@hkn.eecs.berkeley.edu>

On Fri, 31 Aug 2001, dman wrote:

> On Thu, Aug 30, 2001 at 10:27:42AM -0400, Bill Tolbert wrote:
> | I spent some time reading Useless Python last night and went to bed
> | totally depressed. I feel that even Useless is above my skill level. So,
> | what follows is the story of why I'm trying to learn Python. Perhaps some
> | will understand; some may be in a similar situation; some may want to send
> | me money. Maybe it can become an installment for the soapbox on Useless.
> [...]
> 
> As Javier said, you learn it little by little.  You read docs, you
> experiement, and practice and you end up knowing the stuff that is
> interesting to you.  None of us know everything.  In fact, computers
> and software are so complex nowadays that nobody can ever know
> everything about any given system, and certainly not everything about
> all (or even several) systems.


Also, source code can be somewhat deceptive: it's like a distillation of
hours of research, hapless experimentation, wrong turns, and uninformed
misdirection, all into a dense, syrupy concoction.  What we end up is
something short and sweet, but it can mask the roundabout way we cooked
it.  And if swallowed too quickly, we can gag!

This same sort of dilation happens with math proofs, books, emails, or
anything else written down.  I guess I'm trying to say: don't worry if you
read something that doesn't make sense initially: take it slow, one sip at
a time.  It takes some time to sample new things.


Now if only I could properly use a Bodum plunger coffee machine, I'll be
very happy.  *grin*



From kev@sat.net  Sun Sep  2 12:58:18 2001
From: kev@sat.net (Kevin McCormick)
Date: Sun, 02 Sep 2001 06:58:18 -0500
Subject: [Tutor] wxPython GUI builder
References: <006001c132a0$f8408a60$a800a8c0@orange> <20010901091557.G13154@harmony.cs.rit.edu>
Message-ID: <3B921EDA.95AE81@sat.net>

dman wrote:
> 
> On Sat, Sep 01, 2001 at 12:45:47PM +0800, Kenneth Tsang wrote:
> 
> [ want RAD GUI builder for cross-platform deployment ]
> 
> For wxPython ther is Boa Constructor (free) or wxDesigner (demo is
> free, small fee for registered version).
> 
> For GTK+ (PyGTK) there is glade, and the accompanying 'libglade'
> library.
> 
> wxPython looks pretty good and will give you close to native LnF in
> the end result.  I really like PyGTK and find it easy to get things to
> look right.  The neat thing about using a glade/libglade combo is you
> don't actually generate any code -- the GUI is built dynamically at
> runtime from the glade project file.  You can even change the
> arrangement of stuff without rebuilding the code (more significant
> with compiled languages like C or C++).  (BTW gtk, pygtk, glade, and
> libglade have all been ported to windows.)
> 
> HTH,
> -D
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

On the subject of PyGTK and Glade, I am a complete newbie.  I have been
trying some things with Tkinter, but GTK apps are definitely more slick
looking and I would like to get started with that.  However, I have
always had trouble getting things like that set up (I have BlackAdder
beta, but have never taken the time to figure it out).  I really don't
know where to begin or even how to load the component libraries.  I use
Linux Mandrake 7.2 (waiting for 8.1) with Python 2.0.

Would some users of PyGTK talk about their setup and sources of help for
beginners?


From ajaya@ncoretech.com  Sun Sep  2 15:32:15 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Sun, 2 Sep 2001 20:02:15 +0530
Subject: [Tutor] How to install Pmw for python Tkinter programming
Message-ID: <000101c133bc$10add320$6501a8c0@ncoretech.com>

Hi,

I am just learning Tkinter programming. I came across some book wich is
using Pmw. But when I try to import Pmw python is giving exception like this

Traceback (innermost last):
  File "<pyshell#0>", line 1, in ?
    import Pmw
ImportError: No module named Pmw


I've downloaded python2.0 version from www.python.org. I am using in windows
NT system. Please give me some idea what need to install to get Pmw module.

another question is book is telling me that there is extensive
documentation. From where I could get this.

Thanks and Regards,
Ajaya



From ski100mph@hotmail.com  Sun Sep  2 15:33:51 2001
From: ski100mph@hotmail.com (David de-Beger)
Date: Sun, 2 Sep 2001 15:33:51 +0100
Subject: [Tutor] (no subject)
Message-ID: <DAV17Cj2fBUA51HLvsq00000ad9@hotmail.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0017_01C133C4.AB30E740
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable



------=_NextPart_000_0017_01C133C4.AB30E740
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4522.1800" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0017_01C133C4.AB30E740--


From sheila@thinkspot.net  Sun Sep  2 17:01:15 2001
From: sheila@thinkspot.net (Sheila King)
Date: Sun, 02 Sep 2001 09:01:15 -0700
Subject: [Tutor] How to install Pmw for python Tkinter programming
In-Reply-To: <000101c133bc$10add320$6501a8c0@ncoretech.com>
References: <000101c133bc$10add320$6501a8c0@ncoretech.com>
Message-ID: <806720D286D@kserver.org>

On Sun, 2 Sep 2001 20:02:15 +0530, "Ajaya Babu" <ajaya@ncoretech.com>
wrote about [Tutor] How to install Pmw for python Tkinter programming:

: Please give me some idea what need to install to get Pmw module.
:
:another question is book is telling me that there is extensive
:documentation. From where I could get this.

go here:
http://pmw.sourceforge.net/

download the files and follow the directions in the distribution for
installation.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/




From urnerk@qwest.net  Sun Sep  2 14:04:08 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Sun, 2 Sep 2001 09:04:08 -0400
Subject: [Tutor] How to install Pmw for python Tkinter programming
In-Reply-To: <000101c133bc$10add320$6501a8c0@ncoretech.com>
References: <000101c133bc$10add320$6501a8c0@ncoretech.com>
Message-ID: <01090209040801.04129@ktu>

> I've downloaded python2.0 version from www.python.org. I am using in
> windows NT system. Please give me some idea what need to install to get Pmw
> module.
>

http://pmw.sourceforge.net/

Both module and docs.

Kirby



From dyoo@hkn.eecs.berkeley.edu  Sun Sep  2 20:38:01 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sun, 2 Sep 2001 12:38:01 -0700 (PDT)
Subject: [Tutor] How to install Pmw for python Tkinter programming
In-Reply-To: <000101c133bc$10add320$6501a8c0@ncoretech.com>
Message-ID: <Pine.LNX.4.21.0109021231460.31927-100000@hkn.eecs.berkeley.edu>

On Sun, 2 Sep 2001, Ajaya Babu wrote:

> I am just learning Tkinter programming. I came across some book wich
> is using Pmw. But when I try to import Pmw python is giving exception

Ah, are you talking about "Python and Tkinter Programming", by John
Grayson?  If so, be aware that that book does go a bit fast, so please
feel free to ask us questions if the going goes rough.


> Traceback (innermost last):
>   File "<pyshell#0>", line 1, in ?
>     import Pmw
> ImportError: No module named Pmw

Python Megawidgets (Pmw) is an addon to Tkinter --- it provides more
widgets to play with, and Grayson uses them a lot in his book.  You can
download Pmw from the Pmw website here:

    http://pmw.sourceforge.net

You should be able to use Winzip to unzip the files into

    C:\Program Files\Python\Pmw

and that should do it.


> another question is book is telling me that there is extensive
> documentation. From where I could get this.

Do you mean documentation on Pmw, or documentation overall about Python?


Good luck to you!



From dyoo@hkn.eecs.berkeley.edu  Sun Sep  2 23:50:59 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sun, 2 Sep 2001 15:50:59 -0700 (PDT)
Subject: [Tutor] wxPython GUI builder
In-Reply-To: <3B921EDA.95AE81@sat.net>
Message-ID: <Pine.LNX.4.21.0109021238160.31927-100000@hkn.eecs.berkeley.edu>

On Sun, 2 Sep 2001, Kevin McCormick wrote:

> On the subject of PyGTK and Glade, I am a complete newbie.  I have
> been trying some things with Tkinter, but GTK apps are definitely more
> slick looking and I would like to get started with that.  However, I
> have always had trouble getting things like that set up (I have
> BlackAdder beta, but have never taken the time to figure it out).  I
> really don't know where to begin or even how to load the component
> libraries.  I use Linux Mandrake 7.2 (waiting for 8.1) with Python
> 2.0.
> 
> Would some users of PyGTK talk about their setup and sources of help
> for beginners?

Deirdre wrote a "Ten Minutes Total Idiots Guide to Using Gnome/Gtk+ &
Glade with Python."

    http://www.baypiggies.org/10mintig.html

(As of this writing, I wasn't able to connect to baypiggies.org though...
*sob*)  Not quite sure about the title, but the content is very good.


Here are links to other introductions:

    http://linuxfocus.org/English/July2000/article160.shtml
    http://laguna.fmedic.unam.mx/~daniel/pygtutorial/pygtutorial/


I'm very excited to hear that they've ported PyGtk and Glade to Windows.  
Can anyone point out where to look for this?  Is it fairly stable?




From sullivan@fotoasia.com  Sun Sep  2 15:11:43 2001
From: sullivan@fotoasia.com (FotoAsia)
Date: Sun, 02 Sep 2001 14:11:43 GMT
Subject: [Tutor] Something to brighten your day!
Message-ID: <99943890803@202.157.153.2>

<HTML>
<HEAD>
<TITLE>FotoAsia Newsletter 2001 September</TITLE>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html;=
 charset=3Diso-8859-1">
<script language=3D"JavaScript">
<!--
function MM_swapImgRestore() { //v3=2E0
  var i,x,a=3Ddocument=2EMM_sr;=
 for(i=3D0;a&&i<a=2Elength&&(x=3Da[i])&&x=2EoSrc;i++) x=2Esrc=3Dx=2EoSrc;
}

function MM_preloadImages() { //v3=2E0
  var d=3Ddocument; if(d=2Eimages){ if(!d=2EMM_p) d=2EMM_p=3Dnew Array();
    var i,j=3Dd=2EMM_p=2Elength,a=3DMM_preloadImages=2Earguments; for(i=3D0;=
 i<a=2Elength; i++)
    if (a[i]=2EindexOf("#")!=3D0){ d=2EMM_p[j]=3Dnew Image;=
 d=2EMM_p[j++]=2Esrc=3Da[i];}}
}

function MM_findObj(n, d) { //v3=2E0
  var p,i,x;  if(!d) d=3Ddocument;=
 if((p=3Dn=2EindexOf("?"))>0&&parent=2Eframes=2Elength) {
    d=3Dparent=2Eframes[n=2Esubstring(p+1)]=2Edocument;=
 n=3Dn=2Esubstring(0,p);}
  if(!(x=3Dd[n])&&d=2Eall) x=3Dd=2Eall[n]; for=
 (i=3D0;!x&&i<d=2Eforms=2Elength;i++) x=3Dd=2Eforms[i][n];
  for(i=3D0;!x&&d=2Elayers&&i<d=2Elayers=2Elength;i++)=
 x=3DMM_findObj(n,d=2Elayers[i]=2Edocument); return x;
}

function MM_swapImage() { //v3=2E0
  var i,j=3D0,x,a=3DMM_swapImage=2Earguments; document=2EMM_sr=3Dnew Array;=
 for(i=3D0;i<(a=2Elength-2);i+=3D3)
   if ((x=3DMM_findObj(a[i]))!=3Dnull){document=2EMM_sr[j++]=3Dx;=
 if(!x=2EoSrc) x=2EoSrc=3Dx=2Esrc; x=2Esrc=3Da[i+2];}
}
function JS_CheckEMailSubscribe()
{
=09document=2Eemail_subscribe=2Esubmit();
}

function JS_CheckPosterVote()
{
=09document=2Eposter_vote=2Esubmit();
}
//-->
</script>

</HEAD>
<BODY BGCOLOR=3D#FFFFFF=
 onLoad=3D"MM_preloadImages('http://www=2Efotoasia=2Ecom/email/HTML/ima=
ges/e1_01_over=2Egif','http://www=2Efotoasia=2Ecom/email/HTML/images/e1=
_03_over=2Egif','http://www=2Efotoasia=2Ecom/email/HTML/images/e1_10_ov=
er=2Egif','http://www=2Efotoasia=2Ecom/email/HTML/images/ButGO2=2Egif','h=
ttp://www=2Efotoasia=2Ecom/email/HTML/images/e1_15_over=2Egif','http://=
www=2Efotoasia=2Ecom/email/HTML/images/ButSub-02=2Egif')">
<div align=3D"center">
  <font face=3D"Arial, Helvetica, sans-serif" size=3D"1"=
 color=3D"#000000">
=09This is a HTML document=2E If you are unable to view this page,=
 copy this link <a=
 href=3D"http://www=2Efotoasia=2Ecom/email/HTML/newsletter/newsletter_2=
00109=2Ehtml"=
 target=3D"http://www=2Efotoasia=2Ecom/email/HTML/newsletter/newsletter=
_200109=2Ehtml"><font=
 color=3D"#FF0000">http://www=2Efotoasia=2Ecom/email/HTML/newsletter/ne=
wsletter_200109=2Ehtml</font></a><br>
=09into your web browser to view our complete range of=
 Inspirational Posters=2E</font>
</div>
<TABLE WIDTH=3D740 BORDER=3D0 CELLPADDING=3D0 CELLSPACING=3D0=
 align=3D"center">
  <TR>
=09=09<TD>
=09=09=09<IMG=
 SRC=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/spacer=2Egif"=
 WIDTH=3D178 HEIGHT=3D1></TD>
=09=09<TD>
=09=09=09<IMG=
 SRC=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/spacer=2Egif"=
 WIDTH=3D74 HEIGHT=3D1></TD>
=09=09<TD>
=09=09=09<IMG=
 SRC=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/spacer=2Egif"=
 WIDTH=3D339 HEIGHT=3D1></TD>
=09=09<TD>
=09=09=09<IMG=
 SRC=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/spacer=2Egif"=
 WIDTH=3D149 HEIGHT=3D1></TD>
=09</TR>
=09<TR>
=09=09
    <TD> <a href=3D"http://www=2Elogos=2Ecom=2Esg"=
 target=3D"http://www=2Elogos=2Ecom=2Esg"=
 onMouseOut=3D"MM_swapImgRestore()"=
 onMouseOver=3D"MM_swapImage('Image19','','http://www=2Efotoasia=2Ecom/=
email/HTML/images/e1_01_over=2Egif',1)"><img name=3D"Image19"=
 border=3D"0"=
 src=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/e1_01=2Egif"=
 width=3D"178" height=3D"49"></a></TD>
=09=09
    <TD COLSPAN=3D2 ROWSPAN=3D2> <IMG=
 SRC=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/e1_02=2Egif"=
 WIDTH=3D413 HEIGHT=3D68></TD>
=09=09
    <TD> <a href=3D"http://www=2Efotoasia=2Ecom"=
 target=3D"http://www=2Efotoasia=2Ecom"=
 onMouseOut=3D"MM_swapImgRestore()"=
 onMouseOver=3D"MM_swapImage('Image20','','http://www=2Efotoasia=2Ecom/=
email/HTML/images/e1_03_over=2Egif',1)"><img name=3D"Image20"=
 border=3D"0"=
 src=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/e1_03=2Egif"=
 width=3D"149" height=3D"49"></a></TD>
=09</TR>
=09<TR>
=09=09
    <TD ROWSPAN=3D5> <IMG=
 SRC=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/e1_04=2Egif"=
 WIDTH=3D178 HEIGHT=3D355></TD>
=09=09
    <TD> <IMG=
 SRC=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/e1_05=2Egif"=
 WIDTH=3D149 HEIGHT=3D19></TD>
=09</TR>
=09<TR>
=09=09
    <TD COLSPAN=3D2 ROWSPAN=3D3> <img=
 src=3D"http://www=2Efotoasia=2Ecom/email/HTML/posters/iP-25=2Ejpg"=
 width=3D"413" height=3D"286"></TD>
    <TD> <IMG=
 SRC=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/e1_07=2Egif"=
 WIDTH=3D149 HEIGHT=3D213 usemap=3D"#Map" border=3D"0"><map=
 name=3D"Map"><area shape=3D"rect" coords=3D"8,118,37,131"=
 href=3D"http://www=2Efotoasia=2Ecom/email_unsubscribe=2Easp"=
 target=3D"http://www=2Efotoasia=2Ecom/email_unsubscribe=2Easp"><area=
 shape=3D"rect" coords=3D"7,67,97,79" href=3D"http://www=2Efotoasia=2Ecom"=
 target=3D"http://www=2Efotoasia=2Ecom"></map></TD>
=09</TR>
=09<!--Subscribe-->
    <form name=3D"email_subscribe" method=3D"post"=
 action=3D"http://www=2Efotoasia=2Ecom/email_subscribe=2Easp">
=09<input type=3D"hidden" name=3D"entrypoint" value=3D"2">    
=09<TR>
    <TD bgcolor=3D"#000000" height=3D"38" align=3D"left"> 
      &nbsp;<input type=3D"text" name=3D"txtEMailSubscribe" size=3D"11"=
 value=3D"your e-mail" maxlength=3D"50">
=09  <input name=3D"Image15" type=3D"image" border=3D"0"=
 src=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/ButGO1=2Egif"=
 width=3D"31" height=3D"15" onClick=3D"JS_CheckEMailSubscribe()"=
 onMouseOut=3D"MM_swapImgRestore()"=
 onMouseOver=3D"MM_swapImage('Image15','','http://www=2Efotoasia=2Ecom/=
email/HTML/images/ButGO2=2Egif',1)">
    </TD>
=09</TR>
=09</form>
=09<TR>
=09=09
    <TD> <IMG=
 SRC=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/e1_09=2Egif"=
 WIDTH=3D149 HEIGHT=3D35></TD>
=09</TR>
=09<TR>
=09=09
    <TD> <a=
 href=3D"http://www=2Efotoasia=2Ecom/email_broadcastuserform=2Easp"=
 target=3D"http://www=2Efotoasia=2Ecom/email_broadcastuserform=2Easp"=
 onMouseOut=3D"MM_swapImgRestore()"=
 onMouseOver=3D"MM_swapImage('Image21','','http://www=2Efotoasia=2Ecom/=
email/HTML/images/e1_10_over=2Egif',1)"><img name=3D"Image21"=
 border=3D"0"=
 src=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/e1_10=2Egif"=
 width=3D"74" height=3D"50"></a></TD>
=09=09
    <TD COLSPAN=3D2 ROWSPAN=3D4> <IMG=
 SRC=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/e1_11=2Egif"=
 WIDTH=3D488 HEIGHT=3D146 usemap=3D"#Map2" border=3D"0"><map=
 name=3D"Map2"><area shape=3D"rect" coords=3D"211,15,322,28"=
 href=3D"http://www=2Efotoasia=2Ecom"=
 target=3D"http://www=2Efotoasia=2Ecom"></map></TD>
=09</TR>
=09<form method=3D"post" name=3D"poster_vote"=
 action=3D"http://www=2Efotoasia=2Ecom/poster_vote=2Easp">
    <input type=3D"hidden" name=3D"month" value=3D"200109">
    <input type=3D"hidden" name=3D"entrypoint" value=3D"2">
=09<TR>
    <TD bgcolor=3D"#99CCFF" height=3D"25"> <font size=3D"1"=
 face=3D"Arial, Helvetica, sans-serif"> 
      &nbsp; 
      <select name=3D"vote">
      <option value=3D"6" selected>Wow!</option>
      <option value=3D"5">Great!</option>
      <option value=3D"4">Good</option>
      <option value=3D"3">Average</option>
      <option value=3D"2">Poor</option>
      <option value=3D"1">It sucks!</option>
      </select>
    <input name=3D"Image17" type=3D"image" border=3D"0"=
 src=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/ButSub-01=2Egif"=
 width=3D"71" height=3D"14" onClick=3D"JS_CheckPosterVote()"=
 onMouseOut=3D"MM_swapImgRestore()"=
 onMouseOver=3D"MM_swapImage('Image17','','http://www=2Efotoasia=2Ecom/=
email/HTML/images/ButSub-02=2Egif',1)">
    <TD ROWSPAN=3D3> <IMG=
 SRC=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/e1_13=2Egif"=
 WIDTH=3D74 HEIGHT=3D96></TD>
=09</font></TR>
=09</form>
=09<TR>
=09=09
    <TD> <IMG=
 SRC=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/e1_14=2Egif"=
 WIDTH=3D178 HEIGHT=3D35></TD>
=09</TR>
=09<TR>
=09=09
    <TD> <a href=3D"http://www=2Efotoasia=2Ecom/poster_index=2Easp"=
 target=3D"http://www=2Efotoasia=2Ecom/poster_index=2Easp"=
 onMouseOut=3D"MM_swapImgRestore()"=
 onMouseOver=3D"MM_swapImage('Image22','','http://www=2Efotoasia=2Ecom/=
email/HTML/images/e1_15_over=2Egif',1)"><img name=3D"Image22"=
 border=3D"0"=
 src=3D"http://www=2Efotoasia=2Ecom/email/HTML/images/e1_15=2Egif"=
 width=3D"178" height=3D"36"></a></TD>
=09</TR>
</TABLE>
</BODY>
</HTML>



From dsh8290@rit.edu  Mon Sep  3 03:23:53 2001
From: dsh8290@rit.edu (dman)
Date: Sun, 2 Sep 2001 22:23:53 -0400
Subject: [Tutor] wxPython GUI builder
In-Reply-To: <3B921EDA.95AE81@sat.net>; from kev@sat.net on Sun, Sep 02, 2001 at 06:58:18AM -0500
References: <006001c132a0$f8408a60$a800a8c0@orange> <20010901091557.G13154@harmony.cs.rit.edu> <3B921EDA.95AE81@sat.net>
Message-ID: <20010902222353.A14093@harmony.cs.rit.edu>

On Sun, Sep 02, 2001 at 06:58:18AM -0500, Kevin McCormick wrote:
| dman wrote:
[..]
| > For GTK+ (PyGTK) there is glade, and the accompanying 'libglade'
| > library.

| On the subject of PyGTK and Glade, I am a complete newbie.  I have been
| trying some things with Tkinter, but GTK apps are definitely more slick
| looking and I would like to get started with that.  However, I have
| always had trouble getting things like that set up (I have BlackAdder
| beta, but have never taken the time to figure it out).  I really don't
| know where to begin or even how to load the component libraries.  I use
| Linux Mandrake 7.2 (waiting for 8.1) with Python 2.0.

Oh, good, I was afraid you were about to say you were using windows.
I haven't actually used pygtk on windows, but I know that binaries
exist.  Frequently setting up stuff on windows is much harder than
unices.

| Would some users of PyGTK talk about their setup and sources of help for
| beginners?

When I was using RH I simply installed the RPMs.  Now that I am using
Debian I simply use apt-get to download and install the necessary
DEBs.

Could you give an example of what you are trying to do and why it
doesn't work?

If I get some spare time soon, then I could refresh myself on the GTK+
API and give you a "hello world" program that should work.  On my
system I can 'import gtk' and 'window = gtk.GtkWindow() ;
window.show()"  (but I don't remember how to make it actually visible
-- I probably need to put something in it and make it bigger than 0x0)

-D



From dsh8290@rit.edu  Mon Sep  3 03:25:43 2001
From: dsh8290@rit.edu (dman)
Date: Sun, 2 Sep 2001 22:25:43 -0400
Subject: [Tutor] wxPython GUI builder
In-Reply-To: <Pine.LNX.4.21.0109021238160.31927-100000@hkn.eecs.berkeley.edu>; from dyoo@hkn.eecs.berkeley.edu on Sun, Sep 02, 2001 at 03:50:59PM -0700
References: <3B921EDA.95AE81@sat.net> <Pine.LNX.4.21.0109021238160.31927-100000@hkn.eecs.berkeley.edu>
Message-ID: <20010902222542.B14093@harmony.cs.rit.edu>

On Sun, Sep 02, 2001 at 03:50:59PM -0700, Danny Yoo wrote:
 
| I'm very excited to hear that they've ported PyGtk and Glade to Windows.  
| Can anyone point out where to look for this?  Is it fairly stable?

It's stable enough to run the GIMP with.  The GIMP crashes sometimes,
but really works very well (unless you have a certain version of MS's
mouse driver on an NT system -- then no plugins (or script-fu) will
work).

For Glib/GTK+ for windows see the GimpWin page

    http://www.gimp.org/~tml/gimp/win32/

for PyGTK and Glade and related stuff see

    http://hans.breuer.org/ports/default.htm

Enjoy :-).
-D


From ajaya@ncoretech.com  Mon Sep  3 06:52:38 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Mon, 3 Sep 2001 11:22:38 +0530
Subject: [Tutor] How to install Pmw for python Tkinter programming
In-Reply-To: <Pine.LNX.4.21.0109021231460.31927-100000@hkn.eecs.berkeley.edu>
Message-ID: <000001c1343c$a4373c50$6501a8c0@ncoretech.com>

Thanks for all your help,

:Ah, are you talking about "Python and Tkinter Programming", by John
:Grayson?  If so, be aware that that book does go a bit fast, so please
:feel free to ask us questions if the going goes rough.

exactly..., Ya this book is fast..

:Python Megawidgets (Pmw) is an addon to Tkinter --- it provides more
:widgets to play with, and Grayson uses them a lot in his book.  You can
:download Pmw from the Pmw website here:

:    http://pmw.sourceforge.net

:You should be able to use Winzip to unzip the files into

:    C:\Program Files\Python\Pmw

:and that should do it.


Thanks allot I am able to fix this problem. Now I am able to use Pmw.


:Do you mean documentation on Pmw, or documentation overall about Python?

I've python documentation. I was asking Pmw documentation. I got in the link
that you specified.




Good luck to you!


Thanks and Regards,
Ajaya Babu



From lonetwin@yahoo.com  Mon Sep  3 08:28:15 2001
From: lonetwin@yahoo.com (lonetwin)
Date: Mon, 3 Sep 2001 00:28:15 -0700 (PDT)
Subject: [Tutor] mail server stress
Message-ID: <20010903072815.9798.qmail@web20704.mail.yahoo.com>

Hi all you good people,
 One quick question, does anyone know about a mail
server stress/load test application/module written in
python ?? This seems like just the thing that is
likely to be written in python, well if there isn't
any helpful tips/comments on what I should be thinking
if I decide to write something of my own ???

Peace
Steve

__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com


From ajaya@ncoretech.com  Mon Sep  3 08:26:48 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Mon, 3 Sep 2001 12:56:48 +0530
Subject: [Tutor] What **something means in Python!
Message-ID: <000601c13449$cc04ad00$6501a8c0@ncoretech.com>

Hi All,

I am sutdying Python and Tkinter programming by Grayson. I came across this
fraction of code

class Key(Button):
    def __init__(self, master, font=('arial', 8, 'bold'),
                 fg='white',width=5, borderwidth=5, **kw):
        kw['font'] = font
        kw['fg'] = fg
        kw['width'] = width
        kw['borderwidth'] = borderwidth
        apply(Button.__init__, (self, master), kw)
        self.pack(side=LEFT, expand=NO, fill=NONE)


Here I understand Key in inherited the properties of the Button. But I've
doubt on the argument **k I really not able to understand this. What that **
represent.

Secondly I understand he is passing that kw as a dictionary to the apply
function. But I confused with **. can any one give comments on this.

Thanks and Regards,
Ajaya Babu



From hnowak@cuci.nl  Mon Sep  3 09:20:15 2001
From: hnowak@cuci.nl (Hans Nowak)
Date: Mon, 3 Sep 2001 10:20:15 +0200
Subject: [Tutor] What **something means in Python!
Message-ID: <3B95971F@twigger.nl>

>===== Original Message From "Ajaya Babu" <ajaya@ncoretech.com> =====
>Hi All,
>
>I am sutdying Python and Tkinter programming by Grayson. I came across this
>fraction of code
>
>class Key(Button):
>    def __init__(self, master, font=('arial', 8, 'bold'),
>                 fg='white',width=5, borderwidth=5, **kw):
>        kw['font'] = font
>        kw['fg'] = fg
>        kw['width'] = width
>        kw['borderwidth'] = borderwidth
>        apply(Button.__init__, (self, master), kw)
>        self.pack(side=LEFT, expand=NO, fill=NONE)
>
>Here I understand Key in inherited the properties of the Button. But I've
>doubt on the argument **k I really not able to understand this. What that **
>represent.

It's a so-called keyword argument. Here's an example of their usage.

>>> def snarl(**kw):
	print kw

Now snarl can be called with arbitrary arguments of the form key=value:

>>> snarl(animal="penguin", age=28, food="pizza")
{'animal': 'penguin', 'age': 28, 'food': 'pizza'}

Since kw is a dictionary inside the function body, you can inspect it and use 
it like any other dictionary.

>Secondly I understand he is passing that kw as a dictionary to the apply
>function. But I confused with **. can any one give comments on this.

He is passing the dict with keyword arguments to the Button.__init__ 
constructor, using apply. In more recent versions of Python (starting with 
2.1, or 2.0, I'm not sure) you can pass the arguments with a different syntax:

>>> class Foo:
	def __init__(self, a, **kw):
		print "foo:", a, kw

>>> class Bar(Foo):
	def __init__(self, a, b, **kw):
		self.b = b
		Foo.__init__(self, a, **kw)  # !!!
		# equivalent of apply(Foo.__init__, (self, a), kw)

>>> f = Foo(3, name="Eric")
foo: 3 {'name': 'Eric'}
>>> b = Bar(42, 10, sport="golf")
foo: 42 {'sport': 'golf'}

HTH,

--Hans Nowak



From alan.gauld@bt.com  Mon Sep  3 11:36:03 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 3 Sep 2001 11:36:03 +0100
Subject: [Tutor] How to install Pmw for python Tkinter programming
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF08@mbtlipnt02.btlabs.bt.co.uk>

> I am just learning Tkinter programming. I came across some 
> book wich is using Pmw. 

PMW is an add on to Tkinter that you can download and install.
See the Tkinter section of the Python web site for links.

> another question is book is telling me that there is extensive
> documentation. From where I could get this.

Well, assuming its Graysons book that pretty extensive in 
its own right! However the Tkinter section of the web site 
has lots of other links. Fred Lundh's tutor and reference 
are both pretty good - he keeps threatening to bring them 
out as a book but it hasn't happened yet....

Also, once you get the hang of the conversion there are 
several books on native Tk which translate easily to Tkinter
(eg. I use Tcl/Tk in a nutshell from O'Reilly as my main 
resource for Tkinter programming)

However saying that Tkinter is well documented is only 
relative to other Python GUI toolkits - pyGTK, Qt, wxPython
etc. If somebody wrote a really good book on either wxPython
(even wxWindows!) or pyGTK I might consider moving to those. 

But Tkinter does most of what I need in Python GUI programming
so I'll stick with it for now.

Alan G


From abhiramkushwah@rediffmail.com  Mon Sep  3 12:02:07 2001
From: abhiramkushwah@rediffmail.com (Abhiram Singh Kushwah)
Date: 3 Sep 2001 11:02:07 -0000
Subject: [Tutor] Can I tell me anyone about [x.lower() for x in lst]
Message-ID: <20010903110207.2986.qmail@mailweb26.rediffmail.com>

Hi All,

Can I tell me anyone about the following code:

>>> import string
>>> lst =3D3D ['ONE', 'TWO', 'THREE']
>>> newlst =3D3D [x.lower() for x in lst]
  File "<stdin>", line 1
    newlst =3D3D [x.lower() for x in lst]

I am using python1.5 on Red Hat Linux 7.1.
Does  the facility "[x.lower() for x in lst]" not =

available in python1.5 ?

Thanks in advance!

Abhiram


 =






From scarblac@pino.selwerd.nl  Mon Sep  3 11:59:35 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Mon, 3 Sep 2001 12:59:35 +0200
Subject: [Tutor] Can I tell me anyone about [x.lower() for x in lst]
In-Reply-To: <20010903110207.2986.qmail@mailweb26.rediffmail.com>; from abhiramkushwah@rediffmail.com on Mon, Sep 03, 2001 at 11:02:07AM -0000
References: <20010903110207.2986.qmail@mailweb26.rediffmail.com>
Message-ID: <20010903125935.A26015@pino.selwerd.nl>

On  0, Abhiram Singh Kushwah <abhiramkushwah@rediffmail.com> wrote:
> Hi All,
> 
> Can I tell me anyone about the following code:
> 
> >>> import string
> >>> lst = ['ONE', 'TWO', 'THREE']
> >>> newlst = [x.lower() for x in lst]
>   File "<stdin>", line 1
>     newlst = [x.lower() for x in lst]
> 
> I am using python1.5 on Red Hat Linux 7.1.
> Does  the facility "[x.lower() for x in lst]" not 
> available in python1.5 ?

No, these are list comprehensions, they were new in 2.0, which is almost a
year old now.

-- 
Remco Gerlich


From abhiramkushwah@rediffmail.com  Mon Sep  3 12:38:28 2001
From: abhiramkushwah@rediffmail.com (Abhiram Singh Kushwah)
Date: 3 Sep 2001 11:38:28 -0000
Subject: [Tutor] Can anyone tell me where is being used python in India?
Message-ID: <20010903113828.30091.qmail@mailweb25.rediffmail.com>

Hi All,

I am indian and am learning python But I am afraid for =

job in India.I can't go to abroad because I'm poor in =

english.

So, can anyone tell me where is being used python =

programming in India and in which company? =




Thanks in advance!
Abhiram


 =






From alan.gauld@bt.com  Mon Sep  3 12:34:25 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 3 Sep 2001 12:34:25 +0100
Subject: [Tutor] Can I tell me anyone about [x.lower() for x in lst]
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF0B@mbtlipnt02.btlabs.bt.co.uk>

> >>> lst =3D ['ONE', 'TWO', 'THREE']
> >>> newlst =3D [x.lower() for x in lst]
>   File "<stdin>", line 1
>     newlst =3D [x.lower() for x in lst]
> 
> I am using python1.5 on Red Hat Linux 7.1.
> Does  the facility "[x.lower() for x in lst]" not 
> available in python1.5 ?

Correct. List comprehensions were introduced in version 2.0.

The equivalent code for 1.5 is:

lst = ['ONE', 'TWO', 'THREE']
newlst = map(string.lower, lst)

OR without a functional approach:

lst = ['ONE', 'TWO', 'THREE']
newlst = []
for x in lst: 
	newlst.append(string.lower(x))

Alan g


From GADGILP@INFOTECH.ICICI.com  Mon Sep  3 13:03:48 2001
From: GADGILP@INFOTECH.ICICI.com (GADGIL PRASAD /INFRA/INFOTECH)
Date: Mon, 3 Sep 2001 17:33:48 +0530
Subject: [Tutor] Can anyone tell me where is being used python in Indi
 a?
Message-ID: <E1B786DCFA6ED511A0390008C7289E476350D6@ICICIBACK3>

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C13470.7D7A67C0
Content-Type: text/plain;
	charset="iso-8859-1"

hi,

The only mention I saw was in, TOI ascent by tata infotech,
arround 1 1/2 years back. I havnt been checking recruitment ads
much lately, so don't know the latest...

/prasad.

> -----Original Message-----
> From: Abhiram Singh Kushwah [mailto:abhiramkushwah@rediffmail.com]
> Sent: Monday, September 03, 2001 5:08 PM
> To: tutor@python.org
> Subject: [Tutor] Can anyone tell me where is being used 
> python in India?
> 
> 
> Hi All,
> 
> I am indian and am learning python But I am afraid for 
> job in India.I can't go to abroad because I'm poor in 
> english.
> 
> So, can anyone tell me where is being used python 
> programming in India and in which company? 
> 
> 
> 
> Thanks in advance!
> Abhiram
> 
> 
>  
> 
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


. 

-- 


"This e-mail message may contain confidential, proprietary or legally 
privileged information. It should not be used by anyone who is not the 
original intended recipient. If you have erroneously received this message, 
please delete it immediately and notify the sender. The recipient acknowledges 
that ICICI or its subsidiaries and associated companies (including ICICI Bank)
"ICICI Group", are unable to exercise control or ensure or guarantee the 
integrity of/over the contents of the information contained in e-mail 
transmissions and further acknowledges that any views expressed in this 
message are those of the individual sender and no binding nature of the 
message shall be implied or assumed unless the sender does so expressly with 
due authority of ICICI Group. Before opening any attachments please check them 
for viruses and defects." 


------_=_NextPart_001_01C13470.7D7A67C0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3Diso-8859-=
1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [Tutor] Can anyone tell me where is being used python in India?<=
/TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>hi,</FONT>
</P>

<P><FONT SIZE=3D2>The only mention I saw was in, TOI ascent by tata infotec=
h,</FONT>
<BR><FONT SIZE=3D2>arround 1 1/2 years back. I havnt been checking recruitm=
ent ads</FONT>
<BR><FONT SIZE=3D2>much lately, so don't know the latest...</FONT>
</P>

<P><FONT SIZE=3D2>/prasad.</FONT>
</P>

<P><FONT SIZE=3D2>&gt; -----Original Message-----</FONT>
<BR><FONT SIZE=3D2>&gt; From: Abhiram Singh Kushwah [<A HREF=3D"mailto:abhi=
ramkushwah@rediffmail.com">mailto:abhiramkushwah@rediffmail.com</A>]</FONT>
<BR><FONT SIZE=3D2>&gt; Sent: Monday, September 03, 2001 5:08 PM</FONT>
<BR><FONT SIZE=3D2>&gt; To: tutor@python.org</FONT>
<BR><FONT SIZE=3D2>&gt; Subject: [Tutor] Can anyone tell me where is being =
used </FONT>
<BR><FONT SIZE=3D2>&gt; python in India?</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; Hi All,</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; I am indian and am learning python But I am afraid =
for </FONT>
<BR><FONT SIZE=3D2>&gt; job in India.I can't go to abroad because I'm poor =
in </FONT>
<BR><FONT SIZE=3D2>&gt; english.</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; So, can anyone tell me where is being used python <=
/FONT>
<BR><FONT SIZE=3D2>&gt; programming in India and in which company? </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; Thanks in advance!</FONT>
<BR><FONT SIZE=3D2>&gt; Abhiram</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt;&nbsp; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; _______________________________________________</FO=
NT>
<BR><FONT SIZE=3D2>&gt; Tutor maillist&nbsp; -&nbsp; Tutor@python.org</FONT>
<BR><FONT SIZE=3D2>&gt; <A HREF=3D"http://mail.python.org/mailman/listinfo/=
tutor" TARGET=3D"_blank">http://mail.python.org/mailman/listinfo/tutor</A><=
/FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
</P>
<BR>

<P><B><FONT SIZE=3D2>.. </FONT></B>
</P>

<P>
<FONT FACE=3D"Zurich BT" SIZE=3D1 COLOR=3D"#0000ff"><P>"This e-mail message=
 may contain confidential, proprietary or legally privileged information. I=
t should not be used by anyone who is not the original intended recipient. =
If you have erroneously received this message, please delete it immediately=
 and notify the sender. The recipient acknowledges that ICICI or its subsid=
iaries and associated companies (including ICICI Bank) "ICICI Group", are u=
nable to exercise control or ensure or guarantee the integrity of/over the =
contents of the information contained in e-mail transmissions and further a=
cknowledges that any views expressed in this message are those of the indiv=
idual sender and no binding nature of the message shall be implied or assum=
ed unless the sender does so expressly with due authority of ICICI Group. B=
efore opening any attachments please check them for viruses and defects."</=
P>
</FONT>

</BODY>
</HTML>
------_=_NextPart_001_01C13470.7D7A67C0--


From m_konermann@gmx.de  Mon Sep  3 13:45:28 2001
From: m_konermann@gmx.de (Marcus Konermann)
Date: Mon, 03 Sep 2001 14:45:28 +0200
Subject: [Tutor] I Need Help on Extension Python with C
Message-ID: <3B937B68.6090606@gmx.de>

Hello !

I search for I-Net pages or literature on help for Extension of Python 
with a C program. I`ve got different  .cc files and .h Files and i 
develop a GUI with python´s Tkinter and now i search for a solution on 
binding the c progam into the Tkinter GUI.
I already looked on python.org or different other links like parnassus, 
but i did´nt find a good solution for my problem.

So, thanks a lot for any help
Marcus



From kev@sat.net  Mon Sep  3 14:26:47 2001
From: kev@sat.net (Kevin McCormick)
Date: Mon, 03 Sep 2001 08:26:47 -0500
Subject: [Tutor] wxPython GUI builder
References: <006001c132a0$f8408a60$a800a8c0@orange> <20010901091557.G13154@harmony.cs.rit.edu> <3B921EDA.95AE81@sat.net> <20010902222353.A14093@harmony.cs.rit.edu>
Message-ID: <3B938517.7DECFD11@sat.net>

dman wrote:
> 
> On Sun, Sep 02, 2001 at 06:58:18AM -0500, Kevin McCormick wrote:
> | dman wrote:
> [..]
> | > For GTK+ (PyGTK) there is glade, and the accompanying 'libglade'
> | > library.
> 
> | On the subject of PyGTK and Glade, I am a complete newbie.  I have been
> | trying some things with Tkinter, but GTK apps are definitely more slick
> | looking and I would like to get started with that.  However, I have
> | always had trouble getting things like that set up (I have BlackAdder
> | beta, but have never taken the time to figure it out).  I really don't
> | know where to begin or even how to load the component libraries.  I use
> | Linux Mandrake 7.2 (waiting for 8.1) with Python 2.0.
> 
> Oh, good, I was afraid you were about to say you were using windows.
> I haven't actually used pygtk on windows, but I know that binaries
> exist.  Frequently setting up stuff on windows is much harder than
> unices.
> 
> | Would some users of PyGTK talk about their setup and sources of help for
> | beginners?
> 
> When I was using RH I simply installed the RPMs.  Now that I am using
> Debian I simply use apt-get to download and install the necessary
> DEBs.
> 
> Could you give an example of what you are trying to do and why it
> doesn't work?
> 
> If I get some spare time soon, then I could refresh myself on the GTK+
> API and give you a "hello world" program that should work.  On my
> system I can 'import gtk' and 'window = gtk.GtkWindow() ;
> window.show()"  (but I don't remember how to make it actually visible
> -- I probably need to put something in it and make it bigger than 0x0)
> 
> -D
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

Thanks for your response.

The links that were provided by Danny Yoo look like pretty nice
introductions, so I don't need to impose.

An example of what I am doing:  I am working on a program that displays
charts of stock market daily price data.  I have a subscription for
update service from msodata (www.msodata.com), but they have no Linux
utility stuff.  At the time I thought they would have some or I could
use my windows, but now I have deleted windows and they don't.  However,
they seem friendly enough and would probably (I haven't asked) use a
Linux utility (download updates) if they had one.  Anyway, it has been
fairly interesting and easy to code it this far, but the Tkinter GUI
stuff has me stopped.  I can display a nice PMW scrolled canvas, but I
do not see how to incorporate that into a larger program, which would
have a menu, download utility, database queries, and the chart.  What
excites me about this is that Python offers an easy way to experiment
with functions so that over time one could develop some really good (or
really bad) analysis tools. [which commercial programs do after you
waste $$ and months learning their arcane syntax, only to be screwed by
some change in the data/version/connection]  Also, Python would allow
for easy collaboration if this project attracted any interest.  I would
like to get this to a point of being functional, with a good
architecture, and then see what happens.  (At least it would be useful
to me.)  The long and short of pyGTK is that, while I would prefer
Tkinter for its universality, perhaps pyGTK is more amenable to my
project, and probably just as universal.


From dyoo@hkn.eecs.berkeley.edu  Mon Sep  3 20:23:20 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 3 Sep 2001 12:23:20 -0700 (PDT)
Subject: [Tutor] Can I tell me anyone about [x.lower() for x in lst]
In-Reply-To: <20010903125935.A26015@pino.selwerd.nl>
Message-ID: <Pine.LNX.4.21.0109031218460.14433-100000@hkn.eecs.berkeley.edu>

On Mon, 3 Sep 2001, Remco Gerlich wrote:

> On  0, Abhiram Singh Kushwah <abhiramkushwah@rediffmail.com> wrote:
> > Hi All,
> > 
> > Can I tell me anyone about the following code:
> > 
> > >>> import string
> > >>> lst = ['ONE', 'TWO', 'THREE']
> > >>> newlst = [x.lower() for x in lst]
> >   File "<stdin>", line 1
> >     newlst = [x.lower() for x in lst]
> > 
> > I am using python1.5 on Red Hat Linux 7.1.
> > Does  the facility "[x.lower() for x in lst]" not 
> > available in python1.5 ?
> 
> No, these are list comprehensions, they were new in 2.0, which is
> almost a year old now.


Hi Abhiram, welcome!  If you can't upgrade to the newest 2.1.1 at:

    http://python.org/2.1.1/

you can still do a similar thing to your list by using the map() function:

###
>>> import string
>>> lst = ['ONE', 'TWO', 'THREE']
>>> newlst = map(string.lower, lst)
>>> newlst
['one', 'two', 'three']
###

Still, we recommend upgrading your Python if you can, because there's been
quite a few bugfixes and improvements made to the language.  List
comprehensions and string methods are very fun to work with, and I'd hate
to think that you'd miss them!

If you have more questions, please feel free to ask!



From lonetwin@yahoo.com  Tue Sep  4 04:29:29 2001
From: lonetwin@yahoo.com (lonetwin)
Date: Mon, 3 Sep 2001 20:29:29 -0700 (PDT)
Subject: [Tutor] Can anyone tell me where is being used python in India?
In-Reply-To: <20010903113828.30091.qmail@mailweb25.rediffmail.com>
Message-ID: <20010904032929.22440.qmail@web20703.mail.yahoo.com>

Hey there,
    Don't be too  worried Abhi, there are plenty of
places in India that use python, I was working for one
such place in Pune called CyberQuest Systems,
Indiatimes.com I believe also uses python. You would
almost certainly find python being used wherever Linux
is being used in India.....an' believe me Linux *is*
being used at *plenty* of places (Banglore has many of
such places).
     I'm working at b'bay now, and I'm mainly
scripting in python. Hope that's enough to make happy
:)

Peace
Steve
--- Abhiram Singh Kushwah
<abhiramkushwah@rediffmail.com> wrote:
> Hi All,
> 
> I am indian and am learning python But I am afraid
> for 
> job in India.I can't go to abroad because I'm poor
> in 
> english.
> 
> So, can anyone tell me where is being used python 
> programming in India and in which company? 
> 
> 
> 
> Thanks in advance!
> Abhiram
> 
> 
>  
> 
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com


From lonetwin@yahoo.com  Tue Sep  4 08:24:15 2001
From: lonetwin@yahoo.com (lonetwin)
Date: Tue, 4 Sep 2001 00:24:15 -0700 (PDT)
Subject: [Tutor] Re: from prompt to file in windows
In-Reply-To: <20010904052959.19491.qmail@mailFA9.rediffmail.com>
Message-ID: <20010904072415.82111.qmail@web20701.mail.yahoo.com>

Hi all,
    Maybe someone could help kumud ....

--- kumud  joseph <kumudjk@rediffmail.com> wrote:
>   hi steve,
>      its me kumud again . i've done few things in
> python such as basic programming , little bit of
> visual python,tkinter , and some of the numpy...but
> my basic problem is that i m not able to save any of
> my programmes through the python prompt used in
> windows .. so do help me ...
>  ---kumud

Hi kumud,
    Well, I can't really answer your question, b'cos
my experience with python is limited to linux. Though,
if you uses the IDLE interface, you can simply save to
a file (methinks!! I use a simple mark & paste in vi
[many thanks for that feature in gpm]), so I'm
forwarding this mail to the tutor list too....I still
don't know if you are on the list, are you ?? if you
aren't, you might want to join it, it's pretty helpful
like I said in my last mail.

Peace
Steve 


__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com


From alan.gauld@bt.com  Tue Sep  4 11:55:04 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 4 Sep 2001 11:55:04 +0100
Subject: [Tutor] Can anyone tell me where is being used python in Indi a?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF13@mbtlipnt02.btlabs.bt.co.uk>

> I am indian and am learning python But I am afraid for 
> job in India.I can't go to abroad because I'm poor in 
> english.

Hi, I don't know of specific examples but given that India 
is the second biggest software development area in the world, 
I'm sure somebody is using it! I know we use a lot of Indian 
contractors and they nearly all have either Perl or Tcl skills, 
I wouldn't be surprised if they knew Python too - we just 
don't ask them for that...

Alan G.


From alan.gauld@bt.com  Tue Sep  4 12:01:46 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 4 Sep 2001 12:01:46 +0100
Subject: [Tutor] I Need Help on Extension Python with C
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF14@mbtlipnt02.btlabs.bt.co.uk>

> I search for I-Net pages or literature on help for Extension=20
> of Python with a C program.=20

There are several ways to do this depending on what=20
exactly you want to achieve:=20
1) You could embed a Python interpreter in your C application.=20
2) You could turn your C application into Python modules.
3) You could make your C application into a server
   (using sockets or maybe XML-RPC)
Others???

It depends how complete the C app is, what kind of interface etc.

> develop a GUI with python=B4s Tkinter and now i search for a=20
> solution on binding the c progam into the Tkinter GUI.

If you go the client server route you can just call the server=20
functions and format up the data you receive back for=20
presentation in Tkinter.

If you embed Python you can get the C program to call your=20
Tkinter script with parameters. Umm, what then? Not sure=20
I haven't done any embedding! But I think you can communicate=20
with the Tk objects from the C using pyXXXX type C calls.
Ask somebody else on that one :-)

Alan g


From abhiramkushwah@rediffmail.com  Tue Sep  4 12:23:54 2001
From: abhiramkushwah@rediffmail.com (Abhiram Singh Kushwah)
Date: 4 Sep 2001 11:23:54 -0000
Subject: [Tutor] Can anyone tell me where is being used python in Indi a?
Message-ID: <20010904112354.10627.qmail@mailweb13.rediffmail.com>

Hi,

Thanks for your rsponse.I've found that Python is being =

used in many companies in India as CISCO,TATAINFOTECH,
IIPL etc. I'm very glad to know this.

With Regards,
Abhiram


On Tue, 04 Sep 2001 alan.gauld@bt.com wrote :
>> I am indian and am learning python But I am afraid =

>for =

>> job in India.I can't go to abroad because I'm poor =

in =

>> english.
>
>Hi, I don't know of specific examples but given that =

>India =

>is the second biggest software development area in the =

>world, =

>I'm sure somebody is using it! I know we use a lot of =

>Indian =

>contractors and they nearly all have either Perl or =

Tcl =

>skills, =

>I wouldn't be surprised if they knew Python too - we =

>just =

>don't ask them for that...
>
>Alan G.


 =






From ajaya@ncoretech.com  Tue Sep  4 13:08:51 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Tue, 4 Sep 2001 17:38:51 +0530
Subject: [Tutor] How to disable Resizing in Tkinter.
Message-ID: <000e01c1353a$61833a90$6501a8c0@ncoretech.com>

Dear All,

I have one problem. I am developing GUI using Tkinter. I've this problem

I've a fixed layout. If i try to maximize and resize it is looking ugly. So
I would like to disable the resizing option.

can any one kindly suggest some thig to fix this problem.

Thanks ana Regards,
Ajaya babu



From pythonpython@hotmail.com  Tue Sep  4 14:04:40 2001
From: pythonpython@hotmail.com (HY)
Date: Tue, 4 Sep 2001 22:04:40 +0900
Subject: [Tutor] How to use Python's Regular Expression to process Japanese or Chinese characters?
Message-ID: <OE27cZi71mrvoGdKO8F0000786e@hotmail.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0025_01C1358D.986C9BC0
Content-Type: text/plain;
	charset="gb2312"
Content-Transfer-Encoding: quoted-printable

Hi there,

Does anyone know how to use Regular Expression to process Japanese or =
Chinese characters?
Is there a tutorial/book on this?

For example, how can I represent a Japanese or Chinese character? I =
don't think "/w" works.

Thanks a lot.

Hy

------=_NextPart_000_0025_01C1358D.986C9BC0
Content-Type: text/html;
	charset="gb2312"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb2312">
<META content=3D"MSHTML 5.50.4134.100" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial>Hi there,</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>Does anyone know how to use Regular Expression =
to process=20
Japanese or Chinese characters?</FONT></DIV>
<DIV><FONT face=3DArial>Is there a tutorial/book on this?</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>For example, how can I represent a Japanese or =
Chinese=20
character? I don't think "/w" works.</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>Thanks a lot.</FONT></DIV>
<DIV><FONT face=3DArial></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial>Hy</FONT></DIV></BODY></HTML>

------=_NextPart_000_0025_01C1358D.986C9BC0--


From bill_tolbert@bigfoot.com  Tue Sep  4 14:53:29 2001
From: bill_tolbert@bigfoot.com (Bill Tolbert)
Date: Tue, 4 Sep 2001 09:53:29 -0400 (EDT)
Subject: [Tutor] Why I'm learning Python (OT and long)
In-Reply-To: <5.1.0.14.0.20010830185646.029d2bc0@mail>
Message-ID: <Pine.GSO.4.21L1.0109040946090.4800-100000@sunny>

Thanks to all for the encouragement. You guys are great. I guess I've
only been at this about 5 years now. If I stick with it I may know
something by the time I retire....

Bill




From urnerk@qwest.net  Tue Sep  4 13:37:00 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Tue, 4 Sep 2001 08:37:00 -0400
Subject: [Tutor] Re: from prompt to file in windows
In-Reply-To: <20010904072415.82111.qmail@web20701.mail.yahoo.com>
References: <20010904072415.82111.qmail@web20701.mail.yahoo.com>
Message-ID: <01090408370001.03466@ktu>

Yes Kumud, on Windows the best shell for Python straight out
of the download is IDLE, a graphical shell.  You go File | New Window
and write your Python code there.  Then Save.  Then, back at 
the shell window, go 'import mynewmodule' (no quotes) and 
your new code will either (a) be imported or (b) give you some 
error messages.  Or you can Save and go Ctrl-F5 and have 
your program execute right there and then.

When writing for import (i.e. internal use), vs. exporting a script, 
you'll develop a slightly different psychology.  You'll invoke 
individual classes and functions that you've written as tools, 
maybe gluing them together in short ad hoc functions you actually 
write in the IDLE shell window (easily done).  These ad hoc 
functions, if used often, might eventually be worth migrating to
the module itself (just cut and paste).

IDLE has limitations in that Tkinter programs, when quit, often
make the whole of IDLE quit, because it's a Tkinter program 
and doesn't run your stuff as a separate process.  The VPython
modifications to IDLE seem to get around this, and the IDLE fork
project might eventually get around this problem as well.  You
can still write Tk programs in IDLE, but boot/test them in a 
DOS Python shell open in another window.

In any case, for non-Tkinter programming, I highly recommend
IDLE over using any DOS box shell.  Your program is automatically
color coded and so forth.  You can get other editors that do this, 
but IDLE is more than an editor, it's a shell, so you can execute 
an expression directly, as you would in the DOS shell.

Note:  all of the above applies to Linux as well.  You have the
option of installing IDLE from /Tools after you compile a new version,
simply by copying it to the apppropriate subdirectory (e.g. to 
/usr/lib/python2.0/site-packages/idle/idle.py or maybe to
/usr/local/lib/python2.2/site-packages/idle/idle.py).  

Chances are, if you're a long-time *nixer, you've picked up 
Vi or Emacs or something (Windows versions of these also available), 
and you might frown on IDLE's program editor (you might not though
-- not everyone is that fanatical about their text editor).  On other 
hand, if you're new to both Python *and* Linux, then using IDLE, 
over trying to master a new editor (and/or typing everything in 
some Xterm window running Python in shell mode) will probably
give you more immediate satisfaction.

Kirby

On Tuesday 04 September 2001 03:24, lonetwin wrote:
> Hi all,
>     Maybe someone could help kumud ....
>
> --- kumud  joseph <kumudjk@rediffmail.com> wrote:
> >   hi steve,
> >      its me kumud again . i've done few things in
> > python such as basic programming , little bit of
> > visual python,tkinter , and some of the numpy...but
> > my basic problem is that i m not able to save any of
> > my programmes through the python prompt used in
> > windows .. so do help me ...
> >  ---kumud


From alan.gauld@bt.com  Tue Sep  4 17:16:47 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 4 Sep 2001 17:16:47 +0100
Subject: [Tutor] How to disable Resizing in Tkinter.
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF1A@mbtlipnt02.btlabs.bt.co.uk>

> I've a fixed layout. If i try to maximize and resize it is 
> looking ugly. 

This is a common problem with GuUIs but Tkinter usually handles 
it better than most. It depenfds to some extent which layout 
manager you use - grid often causes problems IME.

> I would like to disable the resizing option.
> can any one kindly suggest some thig to fix this problem.

I guess that there's probablty Window Manager messages that 
you can trap. Check the docs for the WM_XXX messages.

Alan G


From alan.gauld@bt.com  Tue Sep  4 17:18:17 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 4 Sep 2001 17:18:17 +0100
Subject: [Tutor] Why I'm learning Python (OT and long)
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF1B@mbtlipnt02.btlabs.bt.co.uk>

> only been at this about 5 years now. If I stick with it I may know
> something by the time I retire....

I've been at it for over 25 years, I figure the same thing ;-)

Alan G


From lkvam@venix.com  Tue Sep  4 17:25:30 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Tue, 04 Sep 2001 12:25:30 -0400
Subject: [Tutor] Re: from prompt to file in windows
References: <20010904072415.82111.qmail@web20701.mail.yahoo.com>
Message-ID: <3B95007A.3F76869B@venix.com>

I've been reasonably happy using pythonwin.  Active State provides a Python release with bundled Windows support (COM, etc.).
http://aspn.activestate.com/ASPN/Downloads/ActivePython/

Your python directory will contain a pythonwin directory.  This, in turn, contains pythonwin.exe.

The pythonwin program provides a script editor and an interactive Python window.  It is covered in the Mark Hammond & Andy Robinson book "Python Programming on Win32".


IDLE is certainly preferred as a cross-platform choice.  Pythonwin is only available in windows.

lonetwin wrote:
> 
> Hi all,
>     Maybe someone could help kumud ....
> 
> --- kumud  joseph <kumudjk@rediffmail.com> wrote:
> >   hi steve,
> >      its me kumud again . i've done few things in
> > python such as basic programming , little bit of
> > visual python,tkinter , and some of the numpy...but
> > my basic problem is that i m not able to save any of
> > my programmes through the python prompt used in
> > windows .. so do help me ...
> >  ---kumud
> 
> Hi kumud,
>     Well, I can't really answer your question, b'cos
> my experience with python is limited to linux. Though,
> if you uses the IDLE interface, you can simply save to
> a file (methinks!! I use a simple mark & paste in vi
> [many thanks for that feature in gpm]), so I'm
> forwarding this mail to the tutor list too....I still
> don't know if you are on the list, are you ?? if you
> aren't, you might want to join it, it's pretty helpful
> like I said in my last mail.
> 
> Peace
> Steve
> 
> __________________________________________________
> Do You Yahoo!?
> Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
> http://im.yahoo.com
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582


From alan.gauld@bt.com  Tue Sep  4 17:28:25 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 4 Sep 2001 17:28:25 +0100
Subject: [Tutor] Re: from prompt to file in windows
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF1C@mbtlipnt02.btlabs.bt.co.uk>

> Yes Kumud, on Windows the best shell for Python straight out
> of the download is IDLE, a graphical shell.  

Depends. If you got the ActiveState Python you might 
prefer Pythonwin - but it's for Windows only. The folding 
editor features of Pythonwin are a powerful inducement :-)
(You also get Pythonwin if you install the winall package)

> You go File | New Window and write your Python code there.  

This is the important bit for IDLE or Pythonwin.
Don't try to save the session from the Python >>> prompt
(you can but then need to edit out all the '>>>' bits 
and the responses. I sometimes do this if prototyping 
at the prompt... its faster than retyping it all!

> IDLE has limitations in that Tkinter programs

Pythonwin does strange things with Tkinter too.
Which is really weird since its not a Tk app!

> IDLE over using any DOS box shell.  Your program is automatically
> color coded and so forth.  You can get other editors that do this, 
> but IDLE is more than an editor, it's a shell, so you can execute 
> an expression directly, as you would in the DOS shell.

The advantage of the editor/DOS box approach is that you 
can be sure that the running program does exactly what it 
will when you run it for real. In IDLE etc you can never 
be quite certain it'll be the same.

(Incidentally the Pythonwin editor is available as a 
 standalone app - Scite I recommend it as an alternative 
 to vim for Windows users.)

Alan G
(Who likes IDLE too but felt the opposition deserved a plug :-)


From ajaya@ncoretech.com  Tue Sep  4 17:40:25 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Tue, 4 Sep 2001 22:10:25 +0530
Subject: [Tutor] Intresting problem with GUI and Threads,
Message-ID: <000001c13560$4cfc9a00$6501a8c0@ncoretech.com>


Hi All,

I am using Python2.0

I've some intresting problem with python Tkinter programming. I've  GUI
class with which I can create the GUI then I've a pipe callass with which I
will be receiving commnads from remote system. Now any Event that takes
place at GUI should go the remote system using same pipe. so I've designed
like this


class GUI(Frame):
  --GUI Suite

class Processor
   self.gui = GUI()
   self.pipe = TcpIpPipe()

   start WorkerThread

   def WorkerThread()
         EventQ = a.GetEventQ()
         self.pipe.SendEventQToRemoteSystem(EventQ)


in this implementation I've a problem when I close the GUI. Python is
hanging some times...may be because it try to call a.GetEvent() wich is
actually deleted...,

How to solve this problem.

Any comments on implemention or any suggestion to improve the implementation
welcome.

Thanks and Regards,
Ajaya



From srichter@cbu.edu  Tue Sep  4 18:12:02 2001
From: srichter@cbu.edu (Stephan Richter)
Date: Tue, 04 Sep 2001 12:12:02 -0500
Subject: [Tutor] Python Tool for converting TeX to GIF
Message-ID: <5.1.0.14.2.20010904120831.0349fd60@mail.cbu.edu>

Hello everyone,

does anyone know about a tool in Python that will convert TeX to GIFs? I 
mean, it could use some other Unix commands too.

I need it for a Web Site, where someone, can type a math expression using 
TEX and it is then converted, so it can be displayed.

I could really use any hint, since I was out of luck searching through the Web.

Regards,
Stephan

--
Stephan Richter
CBU - Physics and Chemistry Student
Web2k - Web Design/Development & Technical Project Management



From rbl@hal.cwru.edu  Tue Sep  4 18:15:52 2001
From: rbl@hal.cwru.edu (Robin B. Lake)
Date: Tue, 4 Sep 2001 13:15:52 -0400 (EDT)
Subject: [Tutor] Matrix Read-in and Inversion
Message-ID: <200109041715.NAA00203@hal.cwru.edu>

I have a 100 x 150 matrix which I want to invert using the Generalized
Inverse capability of MathPy.

How might I read this dataset in from either a comma-separated file or
an Excel spreadsheet.  I'm on a Mac G3, OS 8.6.

Thanks,
Robin Lake
lake@cwru.edu


From Blake.Garretson@dana.com  Tue Sep  4 18:28:23 2001
From: Blake.Garretson@dana.com (Blake.Garretson@dana.com)
Date: Tue, 4 Sep 2001 13:28:23 -0400
Subject: [Tutor] How to disable Resizing in Tkinter.
Message-ID: <OF8DB8B642.56CC55E0-ON85256ABD.005F7C45@dana.com>

If you created your window with the command:
root = Tk()
then the following line will disable resizing:
root.resizable(0,0)

This tells the window that it it can't be resized in the x or y direction.

-Blake Garretson

>From: "Ajaya Babu" <ajaya@ncoretech.com>:
>Dear All,
>
>I have one problem. I am developing GUI using Tkinter. I've this problem
>
>I've a fixed layout. If i try to maximize and resize it is looking ugly.
So
>I would like to disable the resizing option.
>
>can any one kindly suggest some thig to fix this problem.
>
>Thanks ana Regards,
>Ajaya babu



From ignacio@openservices.net  Tue Sep  4 18:48:51 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Tue, 4 Sep 2001 13:48:51 -0400 (EDT)
Subject: [Tutor] Python Tool for converting TeX to GIF
In-Reply-To: <5.1.0.14.2.20010904120831.0349fd60@mail.cbu.edu>
Message-ID: <Pine.LNX.4.33.0109041344550.726-100000@terbidium.openservices.net>

On Tue, 4 Sep 2001, Stephan Richter wrote:

> Hello everyone,
>
> does anyone know about a tool in Python that will convert TeX to GIFs? I
> mean, it could use some other Unix commands too.
>
> I need it for a Web Site, where someone, can type a math expression using
> TEX and it is then converted, so it can be displayed.
>
> I could really use any hint, since I was out of luck searching through the Web.
>
> Regards,
> Stephan
>
> --
> Stephan Richter
> CBU - Physics and Chemistry Student
> Web2k - Web Design/Development & Technical Project Management

There's textogif:

  http://www.fourmilab.ch/webtools/textogif/textogif.html

but it has a lot of requirements. I couldn't find anything else for TeX ->
GIF.

You can also have a look at MathML. There are only a couple of browsers that
support it, but there are some MathML -> GIF converters out there.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From dsh8290@rit.edu  Tue Sep  4 19:17:14 2001
From: dsh8290@rit.edu (dman)
Date: Tue, 4 Sep 2001 14:17:14 -0400
Subject: [Tutor] wxPython GUI builder
In-Reply-To: <3B938517.7DECFD11@sat.net>; from kev@sat.net on Mon, Sep 03, 2001 at 08:26:47AM -0500
References: <006001c132a0$f8408a60$a800a8c0@orange> <20010901091557.G13154@harmony.cs.rit.edu> <3B921EDA.95AE81@sat.net> <20010902222353.A14093@harmony.cs.rit.edu> <3B938517.7DECFD11@sat.net>
Message-ID: <20010904141714.G17060@harmony.cs.rit.edu>

On Mon, Sep 03, 2001 at 08:26:47AM -0500, Kevin McCormick wrote:
| dman wrote:
...
| > Could you give an example of what you are trying to do and why it
| > doesn't work?
...
| An example of what I am doing:  
[long story :-)]

By "example of what you are trying to do" I meant, could you post some
code and the console output when you try and run it.  Seeing the error
messages you get would help to figure out what your problem is and how
to solve it :-).

Have you gotten it to work over the weekend?

-D



From dsh8290@rit.edu  Tue Sep  4 19:19:33 2001
From: dsh8290@rit.edu (dman)
Date: Tue, 4 Sep 2001 14:19:33 -0400
Subject: [Tutor] mail server stress
In-Reply-To: <20010903072815.9798.qmail@web20704.mail.yahoo.com>; from lonetwin@yahoo.com on Mon, Sep 03, 2001 at 12:28:15AM -0700
References: <20010903072815.9798.qmail@web20704.mail.yahoo.com>
Message-ID: <20010904141933.H17060@harmony.cs.rit.edu>

On Mon, Sep 03, 2001 at 12:28:15AM -0700, lonetwin wrote:
| Hi all you good people,
|  One quick question, does anyone know about a mail
| server stress/load test application/module written in

I don't know of any (written in any language).

| python ?? This seems like just the thing that is
| likely to be written in python, well if there isn't
| any helpful tips/comments on what I should be thinking
| if I decide to write something of my own ???

I think you should get several machines and have each of them try
sending mail messages as fast as they can at the same time.  Also vary
the messages from being proper to being incorrect in various ways.
Also try messing up the SMTP communication to see how the server
handles it if something went wrong during a real-world transfer.

-D



From cwebster@unlv.edu  Tue Sep  4 20:47:13 2001
From: cwebster@unlv.edu (Corran Webster)
Date: Tue, 4 Sep 2001 12:47:13 -0700
Subject: [Tutor] Matrix Read-in and Inversion
In-Reply-To: <200109041715.NAA00203@hal.cwru.edu>
References: <200109041715.NAA00203@hal.cwru.edu>
Message-ID: <f05100e0eb7badd6e45ab@[192.168.0.4]>

At 1:15 PM -0400 4/9/01, Robin B. Lake wrote:
>I have a 100 x 150 matrix which I want to invert using the Generalized
>Inverse capability of MathPy.
>
>How might I read this dataset in from either a comma-separated file or
>an Excel spreadsheet.  I'm on a Mac G3, OS 8.6.

Something like the following should work for comma-separated, 
assuming each matrix row is on a line by itself and the numbers are 
floats (warning, untested code):

import Numeric

# open the file
f = open("filename")

# read data into a list of lists
data = []
for line in f.readlines():
      linedata = []
      # split the line at each comma
      for value in line.split(","):
           linedata.append(float(value))
      data.append(linedata)
f.close()

# convert to numpy array
a = Numeric.array(data)

In a python version with list comprehensions (2.0 or better), this 
can be compressed considerably:

import Numeric

f = open("filename")
a = Numeric.array([[float(value) for value in line.split(",")] for 
line in f.readlines()])
f.close()

Regards,
Corran


From shalehperry@home.com  Tue Sep  4 20:49:43 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Tue, 04 Sep 2001 12:49:43 -0700 (PDT)
Subject: [Tutor] Matrix Read-in and Inversion
In-Reply-To: <200109041715.NAA00203@hal.cwru.edu>
Message-ID: <XFMail.20010904124943.shalehperry@home.com>

On 04-Sep-2001 Robin B. Lake wrote:
> I have a 100 x 150 matrix which I want to invert using the Generalized
> Inverse capability of MathPy.
> 
> How might I read this dataset in from either a comma-separated file or
> an Excel spreadsheet.  I'm on a Mac G3, OS 8.6.
> 

csv's are easy, just use string.split.


From scott@zenplex.com  Tue Sep  4 21:36:54 2001
From: scott@zenplex.com (Scott Comboni)
Date: 04 Sep 2001 16:36:54 -0400
Subject: [Tutor] Database connectivity tools for MS-SQL
Message-ID: <999635814.1408.20.camel@scoot>

Hello All,
Is anyone in the group aware of a package that allows python to connect
to a MS-SQL server?  Remote Client running Linux/Python2.1 
Thanks Scott





From rick@niof.net  Tue Sep  4 21:53:26 2001
From: rick@niof.net (Rick Pasotto)
Date: Tue, 4 Sep 2001 16:53:26 -0400
Subject: [Tutor] Matrix Read-in and Inversion
In-Reply-To: <XFMail.20010904124943.shalehperry@home.com>
References: <200109041715.NAA00203@hal.cwru.edu> <XFMail.20010904124943.shalehperry@home.com>
Message-ID: <20010904165325.A844@tc.niof.net>

On Tue, Sep 04, 2001 at 12:49:43PM -0700, Sean 'Shaleh' Perry wrote:
> 
> On 04-Sep-2001 Robin B. Lake wrote:
> > I have a 100 x 150 matrix which I want to invert using the
> > Generalized Inverse capability of MathPy.
> > 
> > How might I read this dataset in from either a comma-separated file
> > or an Excel spreadsheet.  I'm on a Mac G3, OS 8.6.
> 
> csv's are easy, just use string.split.

Not if a quote delimited field has a comma within it. 

-- 
The demands of the socialists raise another question, which I have
often addressed to them, and to which, as far as I know, they have
never replied. Since the natural inclinations of mankind are so
evil that its liberty must be taken away, how is it that the
inclinations of the socialists are good? Are not the legislators
and their agents part of the human race? Do they believe
themselves moulded from another clay than the rest of mankind?
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net


From brian@dorseys.org  Tue Sep  4 22:12:58 2001
From: brian@dorseys.org (Brian Dorsey)
Date: Tue, 4 Sep 2001 14:12:58 -0700
Subject: [Tutor] Reading CSVs  Was:Matrix Read-in and Inversion
In-Reply-To: <20010904165325.A844@tc.niof.net>; from rick@niof.net on Tue, Sep 04, 2001 at 04:53:26PM -0400
References: <200109041715.NAA00203@hal.cwru.edu> <XFMail.20010904124943.shalehperry@home.com> <20010904165325.A844@tc.niof.net>
Message-ID: <20010904141258.B594@dorseys.org>

On Tue, Sep 04, 2001 at 04:53:26PM -0400, Rick Pasotto wrote:
> On Tue, Sep 04, 2001 at 12:49:43PM -0700, Sean 'Shaleh' Perry wrote:
> > 
> > On 04-Sep-2001 Robin B. Lake wrote:
> > > I have a 100 x 150 matrix which I want to invert using the
> > > Generalized Inverse capability of MathPy.
> > > 
> > > How might I read this dataset in from either a comma-separated file
> > > or an Excel spreadsheet.  I'm on a Mac G3, OS 8.6.
> > 
> > csv's are easy, just use string.split.
> 
> Not if a quote delimited field has a comma within it. 
> 
I've found the CSV module at the following address quite useful for dealing withoccasionally quoted CSV files (especially from Excell). 

http://object-craft.com.au/projects/csv/

Take care,
-Brian



From brian@dorseys.org  Tue Sep  4 22:16:26 2001
From: brian@dorseys.org (Brian Dorsey)
Date: Tue, 4 Sep 2001 14:16:26 -0700
Subject: [Tutor] Database connectivity tools for MS-SQL
In-Reply-To: <999635814.1408.20.camel@scoot>; from scott@zenplex.com on Tue, Sep 04, 2001 at 04:36:54PM -0400
References: <999635814.1408.20.camel@scoot>
Message-ID: <20010904141626.C594@dorseys.org>

On Tue, Sep 04, 2001 at 04:36:54PM -0400, Scott Comboni wrote:
> Hello All,
> Is anyone in the group aware of a package that allows python to connect
> to a MS-SQL server?  Remote Client running Linux/Python2.1 
> Thanks Scott
> 
Looks like it's time for my second Object-Craft plug for the day. They have a SQL-Server python module at:

http://www.object-craft.com.au/projects/mssql/

I've used it successfully with a windows client and the page claims it works from Linux with Sybase libraries. I also found the author of the module to be quite responsive and helpful.

Take care,
-Brian



From jerryl@europa.com  Tue Sep  4 22:24:15 2001
From: jerryl@europa.com (Jerry Lake)
Date: Tue, 4 Sep 2001 14:24:15 -0700
Subject: [Tutor] date function
In-Reply-To: <20010904141258.B594@dorseys.org>
Message-ID: <000201c13587$f39a0920$0103670a@europa.com>

Does python have a date function ?
I didn't stumble across it in the 
docs. if so, where can I read about it.

Regards,

Jerry Lake 
Interface Engineering Technician


From mbc2@netdoor.com  Tue Sep  4 22:37:26 2001
From: mbc2@netdoor.com (Brad Chandler)
Date: Tue, 4 Sep 2001 16:37:26 -0500
Subject: [Tutor] Database connectivity tools for MS-SQL
References: <999635814.1408.20.camel@scoot>
Message-ID: <003d01c13589$cae0b400$111c0d0a@spb.state.ms.us>

There is an ODBC module included in the Python distribution.  I've used it
to connect to MS-SQL Server from Windows95.  I'm not sure how that would
work from Linux.  Here's how I use it:

import dbi, odbc

mydb=odbc.odbc("ODBCdatasource/username/password")
cursor = mydb.cursor()
cursor.execute("select * from table1")
result = cursor.fetchall()
for x in result:
    print x

cursor.close()
mydb.close()
cursor = None
mydb = None



----- Original Message -----
From: "Scott Comboni" <scott@zenplex.com>
To: <tutor@python.org>
Sent: Tuesday, September 04, 2001 3:36 PM
Subject: [Tutor] Database connectivity tools for MS-SQL


> Hello All,
> Is anyone in the group aware of a package that allows python to connect
> to a MS-SQL server?  Remote Client running Linux/Python2.1
> Thanks Scott
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor



From rob@jam.rr.com  Tue Sep  4 22:32:03 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Tue, 04 Sep 2001 16:32:03 -0500
Subject: [Tutor] date function
References: <000201c13587$f39a0920$0103670a@europa.com>
Message-ID: <3B954853.8323614B@jam.rr.com>

Jerry Lake wrote:
> 
> Does python have a date function ?
> I didn't stumble across it in the
> docs. if so, where can I read about it.
> 
> Regards,
> 
> Jerry Lake
> Interface Engineering Technician
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

There's a "batteries included" time module:

http://www.python.org/doc/current/lib/module-time.html

Rob
-- 
A {} is a terrible thing to waste.
Useless Python!
http://www.lowerstandard.com/python


From ak@silmarill.org  Tue Sep  4 22:31:31 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Tue, 04 Sep 2001 17:31:31 -0400
Subject: [Tutor] date function
In-Reply-To: <000201c13587$f39a0920$0103670a@europa.com>
References: <20010904141258.B594@dorseys.org>
 <000201c13587$f39a0920$0103670a@europa.com>
Message-ID: <20010904173131.A18868@sill.silmarill.org>

On Tue, Sep 04, 2001 at 02:24:15PM -0700, Jerry Lake wrote:
> Does python have a date function ?
> I didn't stumble across it in the 
> docs. if so, where can I read about it.

Certainly - it's in time module, since time and date are kind of related.
It'd probably be useful to have a date module too that would be another
name for time.. There's also MxDateTime that should have more goods for
date manipulations.

Here's an example of usage of time module:

>>> import time
>>> time.localtime()
(2001, 9, 4, 17, 29, 48, 1, 247, 1)
>>> time.ctime(time.time())
'Tue Sep  4 17:30:03 2001'

Plain time.ctime() does the same in later versions but not in 1.5 iirc.

[snip]

- Andrei 

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From urnerk@qwest.net  Tue Sep  4 20:05:46 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Tue, 4 Sep 2001 15:05:46 -0400
Subject: [Tutor] Database connectivity tools for MS-SQL
In-Reply-To: <999635814.1408.20.camel@scoot>
References: <999635814.1408.20.camel@scoot>
Message-ID: <01090415054604.03466@ktu>

On Tuesday 04 September 2001 04:36, Scott Comboni wrote:
> Hello All,
> Is anyone in the group aware of a package that allows python to connect
> to a MS-SQL server?  Remote Client running Linux/Python2.1
> Thanks Scott
>

MS-SQL is ODBC-compliant, and there are ODBC modules for
Python, so, yes, you can make your Python app a client of 
MS-SQL.

I think the ODBC stuff is stashed with the win32all package.  Is
that over at the ActivePython site?

Kirby


From srichter@cbu.edu  Tue Sep  4 23:06:44 2001
From: srichter@cbu.edu (Stephan Richter)
Date: Tue, 04 Sep 2001 17:06:44 -0500
Subject: [Tutor] date function
In-Reply-To: <000201c13587$f39a0920$0103670a@europa.com>
References: <20010904141258.B594@dorseys.org>
Message-ID: <5.1.0.14.2.20010904170618.037c4680@mail.cbu.edu>

At 02:24 PM 9/4/2001 -0700, Jerry Lake wrote:
>Does python have a date function ?
>I didn't stumble across it in the
>docs. if so, where can I read about it.

Look also at mxDateTime. It is very nice.

Regards,
Stephan

--
Stephan Richter
CBU - Physics and Chemistry Student
Web2k - Web Design/Development & Technical Project Management



From urnerk@qwest.net  Tue Sep  4 20:12:20 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Tue, 4 Sep 2001 15:12:20 -0400
Subject: [Tutor] Python Tool for converting TeX to GIF
In-Reply-To: <5.1.0.14.2.20010904120831.0349fd60@mail.cbu.edu>
References: <5.1.0.14.2.20010904120831.0349fd60@mail.cbu.edu>
Message-ID: <01090415122005.03466@ktu>

On Tuesday 04 September 2001 01:12, Stephan Richter wrote:
> Hello everyone,
>
> does anyone know about a tool in Python that will convert TeX to GIFs? I
> mean, it could use some other Unix commands too.
>
> I need it for a Web Site, where someone, can type a math expression using
> TEX and it is then converted, so it can be displayed.
>
> I could really use any hint, since I was out of luck searching through the
> Web.
>
> Regards,
> Stephan
>

Off-hand, I wouldn't think there'd be such a thing as a Python module,
but ya never know.  

The best way I know is to display the TeX in any quality reader, and 
use a screen grabber to get the GIF content.

The web is moving the MathML, an XML, for displaying math stuff.  The 
Amaya browser is starting to build that in.  There might be a TeX-to-ML 
conversion package out there, or in the works.  But you want GIFs....

(In Windows, MathCad used to save screen-based math to lots of 
little JPEGs.  Now it has a "Save as MathML option" -- just thought I'd
mention a best-seller as indicative of current trends).

Kirby


From urnerk@qwest.net  Tue Sep  4 20:14:12 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Tue, 4 Sep 2001 15:14:12 -0400
Subject: [Tutor] Python Tool for converting TeX to GIF
In-Reply-To: <Pine.LNX.4.33.0109041344550.726-100000@terbidium.openservices.net>
References: <Pine.LNX.4.33.0109041344550.726-100000@terbidium.openservices.net>
Message-ID: <01090415141206.03466@ktu>

On Tuesday 04 September 2001 01:48, Ignacio Vazquez-Abrams wrote:

> There's textogif:
>
>   http://www.fourmilab.ch/webtools/textogif/textogif.html
>
> but it has a lot of requirements. I couldn't find anything else for TeX ->
> GIF.

Ah!  You've broadened my mind.  Once again, live and learn...
(doesn't mean there's a Python version, but at least someone has done
it in Perl -- why not go with that, hey?).

Kirby


From urnerk@qwest.net  Tue Sep  4 20:27:22 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Tue, 4 Sep 2001 15:27:22 -0400
Subject: [Tutor] Re: from prompt to file in windows
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF1C@mbtlipnt02.btlabs.bt.co.uk>
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF1C@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <01090415272207.03466@ktu>

On Tuesday 04 September 2001 12:28, alan.gauld@bt.com wrote:

> The advantage of the editor/DOS box approach is that you
> can be sure that the running program does exactly what it
> will when you run it for real. In IDLE etc you can never
> be quite certain it'll be the same.
>

True.  But in my own case, much of what I do "for real" in Python
I do from within IDLE, i.e. IDLE is where my programs were written
and from whence they're most comfortably run.  IDLE is as real as 
it needs to get, a lot of the time.  IDLE can be the command window
of choice, similar to the command window I'm accustomed to from 
Visual FoxPro (historically my bread and butter language).

> (Incidentally the Pythonwin editor is available as a
>  standalone app - Scite I recommend it as an alternative
>  to vim for Windows users.)

Yes, I've used this too.  But I like having a shell that I can also 
write code in.  In IDLE (and I presume Pythonwin, which I've used 
in the past), I can arrow up to a previously written function (in the 
shell, not in a file), hit enter, and the whole thing transfers to the 
current command line, where I can re-edit it (not practical for super 
long programs, but nifty when I just want 10 lines of code to do 
something -- often the case).

> Alan G
> (Who likes IDLE too but felt the opposition deserved a plug :-)
>

Sure.  I was mostly pointing to IDLE because it's included in the 
native distros coming directly from python.org, and it's not Windows-
specific (I recommend it to Linux users too -- maybe with bigger 
fonts than you get natively).  

I also always recommend that newcomers to Python download the 
most up-to-date versions if possible, as that's one of the benefits 
of not having invested a ton in some pet project that will break if 
you migrate to 2.x (e.g. Zope).  When you're still just getting your 
feet wet is a great time to play with the latest alpha.  Sometimes 
the ActivePython stuff lags behind a bit, no? (I had to teach VI 
about the new "yield" key word, and still haven't bothered to teach
Emacs how to color-code properly).

Kirby


From lonetwin@yahoo.com  Wed Sep  5 04:59:37 2001
From: lonetwin@yahoo.com (lonetwin)
Date: Tue, 4 Sep 2001 20:59:37 -0700 (PDT)
Subject: [Tutor] mail server stress
In-Reply-To: <20010904141933.H17060@harmony.cs.rit.edu>
Message-ID: <20010905035937.33871.qmail@web20701.mail.yahoo.com>

Hey dman

--- dman <dsh8290@rit.edu> wrote:
> On Mon, Sep 03, 2001 at 12:28:15AM -0700, lonetwin
> wrote:
> | Hi all you good people,
> |  One quick question, does anyone know about a mail
> | server stress/load test application/module written
> | in
> 
> I don't know of any (written in any language).

  Well there are quite a few such applications, but
most of them are commercial, written in c/c++. of
these a number of them are windows applications. A
quick search at freshmeat [keyword 'stress'] served up
smpop, which looks pretty good, maybe I'll write
something like that up in python (smpop's written in
C) also a google search led me to Netscape's Mailstone
and the mozzila equivalent mstone, but those were for
stressing the Netscape Messaging server. I have yet to
look at those....today 'also' is gonna be a nice long
day :)

> | python ?? This seems like just the thing that is
> | likely to be written in python, well if there
> | isn't
> | any helpful tips/comments on what I should be
> | thinking
> | if I decide to write something of my own ???
> 
> I think you should get several machines and have
> each of them try
> sending mail messages as fast as they can at the
> same time.  Also vary
> the messages from being proper to being incorrect in
> various ways.
> Also try messing up the SMTP communication to see
> how the server
> handles it if something went wrong during a
> real-world transfer.
> 
> -D

Hey thanx try that too ....

Peace
Steve

__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com


From chikitychina@home.com  Wed Sep  5 05:21:34 2001
From: chikitychina@home.com (Pablo Manzanera)
Date: Wed, 05 Sep 2001 00:21:34 -0400
Subject: [Tutor] Running python scripts without installing python
Message-ID: <3B95A84E.672BE63E@home.com>

Hey all,

Just a quick question for all you Windows Pythoners...

What is the best way to run python scripts on Windows machines that do
not have Python installed? 



Thanks in advance

Pablo Manzanera


From wheelege@tsn.cc  Wed Sep  5 05:33:15 2001
From: wheelege@tsn.cc (wheelege)
Date: Wed, 5 Sep 2001 14:33:15 +1000
Subject: [Tutor] Running python scripts without installing python
References: <3B95A84E.672BE63E@home.com>
Message-ID: <018e01c135c3$e2041de0$61a616ca@ACE>

  Hey Pablo,

  Your looking at using something that makes and exe, no?  I think you
should look into py2exe - I've had quite a bit of experience with it and it
works with alot of things (tkinter, for example).
  The url for that is http://starship.python.net/crew/theller/py2exe/.
  Another one I hear people mentioning is Gordon Macmillian's Installer - I
don't have a URL for that.  Although I'm sure google would.

  Good luck,
  Glen.


> Hey all,
>
> Just a quick question for all you Windows Pythoners...
>
> What is the best way to run python scripts on Windows machines that do
> not have Python installed?
>
>
>
> Thanks in advance
>
> Pablo Manzanera



From srichter@cbu.edu  Wed Sep  5 06:21:41 2001
From: srichter@cbu.edu (Stephan Richter)
Date: Wed, 05 Sep 2001 00:21:41 -0500
Subject: [Tutor] Python Tool for converting TeX to GIF
In-Reply-To: <Pine.LNX.4.33.0109041344550.726-100000@terbidium.openservi
 ces.net>
References: <5.1.0.14.2.20010904120831.0349fd60@mail.cbu.edu>
Message-ID: <5.1.0.14.2.20010904155655.037c0228@mail.cbu.edu>

>There's textogif:
>
>   http://www.fourmilab.ch/webtools/textogif/textogif.html
>
>but it has a lot of requirements. I couldn't find anything else for TeX ->
>GIF.

Yeah, I had seen this one before. But I figured out that the script can be 
written quickly (see code below) in Python. I really do not like it. The 
code is ugly and some features are not working, but it is a proof of 
concept which I will turn into a class now... ;-)

>You can also have a look at MathML. There are only a couple of browsers that
>support it, but there are some MathML -> GIF converters out there.

I am just not one of the XML fans and the professors using this tool know 
Latex already.

Regards,
Stephan

Code for tex2gif.py

import sys, getopt, string

usage = '''
Usage:
$COMNAME [options...] file.tex

Description:
$COMNAME converts a *.tex file into one GIF image file.
Current Version is ${VERSION_MAJOR}.${VERSION_MINOR}

Options :
-p --detail_ratio          [default = ${DETAIL_DEFAULT}]
-d --dpi pix_per_inch      [default = ${DPI_DEFAULT}]
-m --margin margin_width   [default = ${MARGIN_DEFAULT}]
-r --rotate angle          [default = ${ROTATE_DEFAULT} (counterclockwise 
in deg)]
-t --transparent colorname [default no transparent color set]

--usage | --help : show this message
'''

command = '''
latex %(file)s.tex;
dvips  -q -f %(file)s.dvi > %(file)s.ps
gs -sDEVICE=ppmraw \
    -sOutputFile=- \
    -g%(xSize)sx%(ySize)s \
    -r%(workDPI)s \
    -q -dNOPAUSE %(file)s.ps < /dev/null  | \
pnmscale %(reductionRatio)s | \
pnmcrop -white  | \
pnmmargin -white %(margin)s | \
ppmquant 256 | \
ppmtogif -interlace %(transparentOption)s - \
 > %(file)s.gif

rm -f %(file)s.log %(file)s.aux %(file)s.dvi %(file)s.ps
'''


detailRatio = 3.0
dpi         = 78
margin      = 1
rotate      = 0
transparent = 2
xSizeInch   = 12
ySizeInch   = 12
file        = ''

opts, args = getopt.getopt(sys.argv[1:],
                            'p:d:m:r:t:h:u',
                            ['detail_ratio=', 'dpi=', 'margin=', 'rotate=', 
'transparent=', 'usage', 'help'])

file = string.split(args[0], '.')[0]

for opt, arg in opts:
     if opt in ('-h', '--help', '-u', '--usage'):
         print usage
         sys.exit()
     if opt in ("-p", "--detail_ratio"):
         detailRatio = float(arg)
     if opt in ("-d", "--dpi"):
         dpi = float(arg)
     if opt in ("-m", "--margin"):
         margin = float(arg)
     if opt in ("-r", "--rotate"):
         rotate = int(arg)
     if opt in ("-t", "--transparent"):
         transparent = int(arg)


def tex2gif():

     fillIn = globals()
     fillIn['workDPI'] = detailRatio*dpi
     fillIn['reductionRatio'] = 1.0/detailRatio
     fillIn['xSize'] = int(fillIn['workDPI'] * xSizeInch)
     fillIn['ySize'] = int(fillIn['workDPI'] * ySizeInch)
     fillIn['transparentOption'] = ''

     import popen2
     print popen2.popen2(command %fillIn)[0].read()


tex2gif()



--
Stephan Richter
CBU - Physics and Chemistry Student
Web2k - Web Design/Development & Technical Project Management



From urnerk@qwest.net  Wed Sep  5 07:04:08 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Tue, 04 Sep 2001 23:04:08 -0700
Subject: [Tutor] Python Tool for converting TeX to GIF
In-Reply-To: <5.1.0.14.2.20010904155655.037c0228@mail.cbu.edu>
References: <Pine.LNX.4.33.0109041344550.726-100000@terbidium.openservi ces.net>
 <5.1.0.14.2.20010904120831.0349fd60@mail.cbu.edu>
Message-ID: <4.2.0.58.20010904230002.00bd1e20@pop3.norton.antivirus>

"Stephan Richter" <srichter@cbu.edu> posted:

>tex2gif()


OK, I get it.  Somehow I was thinking Python would be
doing the TeX-to-GIF processing, i.e. using PIL or
something like that, but the necessary tools are
already provided in this case with gs, dvi etc. and
Python's job is really just to build the requisite
command lines and pass 'em out to the Unix shell.

It's acting trully as a scripting language here -- in
its element (and in competition with Perl).

Thanks for posting your code.  Interesting to read.

Kirby



From dyoo@hkn.eecs.berkeley.edu  Wed Sep  5 08:22:04 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Wed, 5 Sep 2001 00:22:04 -0700 (PDT)
Subject: [Tutor] [Python-Help] FW: new page for Newbies (fwd)
Message-ID: <Pine.LNX.4.21.0109050021470.15965-100000@hkn.eecs.berkeley.edu>


---------- Forwarded message ----------
Date: Wed, 5 Sep 2001 00:35:31 -0400
From: Tim Peters <tim.one@home.com>
To: PythonHelp <python-help@python.org>
Subject: [Python-Help] FW: new page for Newbies

FYI, in case you missed it elsewhere.

-----Original Message-----
From: python-list-admin@python.org
[mailto:python-list-admin@python.org]On Behalf Of Guido van Rossum
Sent: Tuesday, September 04, 2001 11:35 PM
To: python-announce@python.org; python-list@python.org;
python-dev@python.org
Subject: new page for Newbies


I finally broke down and created a new page collecting the most
important resources for newbies (people who are new at programming):

    http://www.python.org/doc/Newbies.html

We get several emails per day from people asking how to get started,
so I figured this definitely serves a need.

Please help us making this a better resource -- send your ideas for
making the page more effective to webmaster@python.org.  (Note: more
effective could mean removing information as well as adding!)

Please add this URL to other collections of links about Python.

--Guido van Rossum (home page: http://www.python.org/~guido/)

-- 
http://mail.python.org/mailman/listinfo/python-list

_______________________________________________
Python-Help maillist  -  Python-Help@python.org
http://mail.python.org/mailman/listinfo/python-help



From tzuming@sanbi.ac.za  Wed Sep  5 11:37:50 2001
From: tzuming@sanbi.ac.za (Tzu-Ming Chern)
Date: Wed, 5 Sep 2001 12:37:50 +0200 (SAST)
Subject: [Tutor] Sorting ranges
Message-ID: <Pine.BSF.4.21.0109051235230.47492-100000@fling.sanbi.ac.za>

Hi,

does anyone know how to sort ranges in ascending order? Eg. 

780=>1014  range 1
771=>1014  range 2
29=>214    range 3
226=>426   range 4

I would like my output to look like this:

29=>214
226=>426
771=>1014
780=>1014


With thanks,

tzuming










******************************************************************************
Tzu-Ming Chern 
South African National Bioinformatics Institute
University of Western Cape
PO box X17
Bellville
Cape Town
South Africa
Tel#:27-21-959-3908/3645
Fax:27-21-959-2512
Email:tzuming@fling.sanbi.ac.za

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++






From GADGILP@INFOTECH.ICICI.com  Wed Sep  5 12:49:10 2001
From: GADGILP@INFOTECH.ICICI.com (GADGIL PRASAD /INFRA/INFOTECH)
Date: Wed, 5 Sep 2001 17:19:10 +0530
Subject: [Tutor] [OT] what every programmer should know ? - a DDJ article related.
 ..
Message-ID: <E1B786DCFA6ED511A0390008C7289E476352E0@ICICIBACK3>

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C13600.C67EE770
Content-Type: text/plain;
	charset="iso-8859-1"

hello,

A recent post abt being lost in programming world, reminded me of an
article my friend had forwarded to me earlier. It was something 
published in Dr Dobbs Journal. It did help me quite a bit. So I thaught 
I should post it here. Pl. excuse me for OT post.

I guess copyright etc will prevent me from mailing the article. Fortunately 
I could find the article on net.

Check out the link,

http://www.developercareers.com/ddj/articles/1997/9719/9719l/9719l.htm

/prasad


. 

-- 


"This e-mail message may contain confidential, proprietary or legally 
privileged information. It should not be used by anyone who is not the 
original intended recipient. If you have erroneously received this message, 
please delete it immediately and notify the sender. The recipient acknowledges 
that ICICI or its subsidiaries and associated companies (including ICICI Bank)
"ICICI Group", are unable to exercise control or ensure or guarantee the 
integrity of/over the contents of the information contained in e-mail 
transmissions and further acknowledges that any views expressed in this 
message are those of the individual sender and no binding nature of the 
message shall be implied or assumed unless the sender does so expressly with 
due authority of ICICI Group. Before opening any attachments please check them 
for viruses and defects." 


------_=_NextPart_001_01C13600.C67EE770
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3Diso-8859-=
1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version 5.5.2653.12">
<TITLE>[OT] what every programmer should know ? - a DDJ article related...<=
/TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>hello,</FONT>
</P>

<P><FONT SIZE=3D2>A recent post abt being lost in programming world, remind=
ed me of an</FONT>
<BR><FONT SIZE=3D2>article my friend had forwarded to me earlier. It was so=
mething </FONT>
<BR><FONT SIZE=3D2>published in Dr Dobbs Journal. It did help me quite a bi=
t. So I thaught </FONT>
<BR><FONT SIZE=3D2>I should post it here. Pl. excuse me for OT post.</FONT>
</P>

<P><FONT SIZE=3D2>I guess copyright etc will prevent me from mailing the ar=
ticle. Fortunately </FONT>
<BR><FONT SIZE=3D2>I could find the article on net.</FONT>
</P>

<P><FONT SIZE=3D2>Check out the link,</FONT>
</P>

<P><FONT SIZE=3D2><A HREF=3D"http://www.developercareers.com/ddj/articles/1=
997/9719/9719l/9719l.htm" TARGET=3D"_blank">http://www.developercareers.com=
/ddj/articles/1997/9719/9719l/9719l.htm</A></FONT>
</P>

<P><FONT SIZE=3D2>/prasad</FONT>
</P>
<BR>

<P><B><FONT SIZE=3D2>.. </FONT></B>
</P>

<P>
<FONT FACE=3D"Zurich BT" SIZE=3D1 COLOR=3D"#0000ff"><P>"This e-mail message=
 may contain confidential, proprietary or legally privileged information. I=
t should not be used by anyone who is not the original intended recipient. =
If you have erroneously received this message, please delete it immediately=
 and notify the sender. The recipient acknowledges that ICICI or its subsid=
iaries and associated companies (including ICICI Bank) "ICICI Group", are u=
nable to exercise control or ensure or guarantee the integrity of/over the =
contents of the information contained in e-mail transmissions and further a=
cknowledges that any views expressed in this message are those of the indiv=
idual sender and no binding nature of the message shall be implied or assum=
ed unless the sender does so expressly with due authority of ICICI Group. B=
efore opening any attachments please check them for viruses and defects."</=
P>
</FONT>

</BODY>
</HTML>
------_=_NextPart_001_01C13600.C67EE770--


From csmith@blakeschool.org  Wed Sep  5 13:04:50 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Wed, 05 Sep 2001 07:04:50 -0500
Subject: [Tutor] Re: Sorting ranges
In-Reply-To: <E15ebEs-0005U5-00@mail.python.org>
References: <E15ebEs-0005U5-00@mail.python.org>
Message-ID: <fc.004c4b6b007a08973b9aca00f1d021f0.7a089b@blakeschool.org>

tzuming wrote:
>
>does anyone know how to sort ranges in ascending order? Eg. 
>
>780=>1014  range 1
>771=>1014  range 2
>29=>214    range 3
>226=>426   range 4
>
>I would like my output to look like this:
>
>29=>214
>226=>426
>771=>1014
>780=>1014
>
Just create a list of these ranges and sort them:

>>> r1=range(780,1015)
>>> r2=range(771,1015)
>>> r3=range(29,215)
>>> r4=range(226,427)
>>> all=[r1,r2,r3,r4]  #here is the list of ranges
>>> all.sort()         #here we sort them
>>> for a in all:
...  print a[0:2],'...'
... 
[29, 30] ...
[226, 227] ...
[771, 772] ...
[780, 781] ...
>>>


/c



From srichter@cbu.edu  Wed Sep  5 13:33:51 2001
From: srichter@cbu.edu (Stephan Richter)
Date: Wed, 05 Sep 2001 07:33:51 -0500
Subject: [Tutor] Python Tool for converting TeX to GIF
In-Reply-To: <4.2.0.58.20010904230002.00bd1e20@pop3.norton.antivirus>
References: <5.1.0.14.2.20010904155655.037c0228@mail.cbu.edu>
 <Pine.LNX.4.33.0109041344550.726-100000@terbidium.openservi ces.net>
 <5.1.0.14.2.20010904120831.0349fd60@mail.cbu.edu>
Message-ID: <5.1.0.14.2.20010905072822.037d5670@mail.cbu.edu>

>It's acting trully as a scripting language here -- in
>its element (and in competition with Perl).

In fact this is almost the same idea of the Perl tex2gif version. Most of 
the code (the commands) I got from a shell script called ps2gif. Do it is 
really a mix of a lot of things. :-) In the beginning I wanted to let PIL 
handle the PS2GIF conversion, but there was no anti-aliasing support, so I 
went with the GS solution.

BTW, I was able abstract it all a little and make a class. I incorporated 
it all into Zope and I can now generate on the fly GIFs on any Web Site. 
This is truly nice for science.

Regards,
Stephan

--
Stephan Richter
CBU - Physics and Chemistry Student
Web2k - Web Design/Development & Technical Project Management



From kev@sat.net  Wed Sep  5 13:49:23 2001
From: kev@sat.net (Kevin McCormick)
Date: Wed, 05 Sep 2001 07:49:23 -0500
Subject: [Tutor] wxPython GUI builder
References: <006001c132a0$f8408a60$a800a8c0@orange> <20010901091557.G13154@harmony.cs.rit.edu> <3B921EDA.95AE81@sat.net> <20010902222353.A14093@harmony.cs.rit.edu> <3B938517.7DECFD11@sat.net> <20010904141714.G17060@harmony.cs.rit.edu>
Message-ID: <3B961F53.FAE4B43B@sat.net>

dman wrote:
> 
> On Mon, Sep 03, 2001 at 08:26:47AM -0500, Kevin McCormick wrote:
> | dman wrote:
> ...
> | > Could you give an example of what you are trying to do and why it
> | > doesn't work?
> ...
> | An example of what I am doing:
> [long story :-)]
> 
> By "example of what you are trying to do" I meant, could you post some
> code and the console output when you try and run it.  Seeing the error
> messages you get would help to figure out what your problem is and how
> to solve it :-).
> 
> Have you gotten it to work over the weekend?
> 
> -D
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

Thanks for the response.  It works and I don't have output errors.  So
my problem is in knowing how to structure Tk widget classes into a
program.  I was thinking that I should make a menu class which imports
all the widget classes, so that the menu functions would have "import
dialogwidget" as their first line.  I'll try that.


From dsh8290@rit.edu  Wed Sep  5 15:51:59 2001
From: dsh8290@rit.edu (dman)
Date: Wed, 5 Sep 2001 10:51:59 -0400
Subject: [Tutor] Running python scripts without installing python
In-Reply-To: <3B95A84E.672BE63E@home.com>; from chikitychina@home.com on Wed, Sep 05, 2001 at 12:21:34AM -0400
References: <3B95A84E.672BE63E@home.com>
Message-ID: <20010905105159.D17823@harmony.cs.rit.edu>

On Wed, Sep 05, 2001 at 12:21:34AM -0400, Pablo Manzanera wrote:
| Hey all,
| 
| Just a quick question for all you Windows Pythoners...
| 
| What is the best way to run python scripts on Windows machines that do
| not have Python installed? 

Install python.  *grin*

There are some tools ('py2exe' and Gordon MacMillan's 'installer')
that will take your python source and pack it up with the interpreter
to try and make it easier for your end users to install python *and*
your program, but the long and short of it is you need a python
interpreter to interpret python code.

HTH,
-D



From alan.gauld@bt.com  Wed Sep  5 15:59:03 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 5 Sep 2001 15:59:03 +0100
Subject: [Tutor] Matrix Read-in and Inversion
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF22@mbtlipnt02.btlabs.bt.co.uk>

> csv's are easy, just use string.split.

Careful, that won't work for string fields containing embedded commas.
You need to split out quoted foelds first then split the remaining 
fields by commas...

There are a few other niceties that can trip you up with CSV too 
but quoted fields are the worst and most common nasty.

Alan G


From jeff@ccvcorp.com  Wed Sep  5 17:24:25 2001
From: jeff@ccvcorp.com (Jeff Shannon)
Date: Wed, 05 Sep 2001 09:24:25 -0700
Subject: [Tutor] Sorting ranges
References: <E15ebEt-0005UH-00@mail.python.org>
Message-ID: <3B9651B9.D8C15541@ccvcorp.com>

> does anyone know how to sort ranges in ascending order? Eg.

....

How are you storing your ranges, and how do you want them sorted?  If you're storing
them as a tuple of (start,end), or as a list of either [start,end] or full range
(i.e., the result of range(start,end) ), then you should be able to put all of them in
a list sort that--list.sort() will sort by the value of the first item.  In other
words,

>>> myranges = [ (780,1014), (771,1014), (29,214), (226,426) ]
>>> myranges.sort()
>>> print myranges
[(29, 214), (226, 426), (771, 1014), (780, 1014)]
>>> myranges = [ range(780,1014), range(771,1014), range(29,214), range(226,426) ]
>>> myranges.sort()
>>> for r in myranges: print r[0], r[-1]
...
29 213
226 425
771 1013
780 1013
>>>

Jeff Shannon
Technician/Programmer
Credit International




From Charlie@begeistert.org  Wed Sep  5 18:40:23 2001
From: Charlie@begeistert.org (Charlie Clark)
Date: Wed, 05 Sep 2001 19:40:23 +0200
Subject: [Tutor] Help with cookies
Message-ID: <999711623_PM_BeOS.Charlie@begeistert.org>

Dear Python gurus and those who want to become such,

I need to be able to pass a cookie in a url request. I know what the 
cookie should contain and inspection of the cookie module and 
documentation indicates that handling cookies should be straightforward 
but the example does not include sending one in an url request. Has 
anyone experience of this and ideas on how this might be done.

Many thanx

Charlie (bashing his head on a brick wall again)




From python.tutorial@jarava.org  Wed Sep  5 18:55:02 2001
From: python.tutorial@jarava.org (Javier JJ)
Date: Wed, 5 Sep 2001 19:55:02 +0200
Subject: [Tutor] Why I'm learning Python (OT and long)
References: <Pine.GSO.4.21L1.0109040946090.4800-100000@sunny>
Message-ID: <010a01c13633$e6171930$0124a8c0@uno>

----- Mensaje original -----
De: "Bill Tolbert" <bill_tolbert@bigfoot.com>
Para: <tutor@python.org>
Enviado: martes, 04 de septiembre de 2001 15:53
Asunto: Re: [Tutor] Why I'm learning Python (OT and long)


> Thanks to all for the encouragement. You guys are great. I guess I've
> only been at this about 5 years now. If I stick with it I may know
> something by the time I retire....
>
> Bill
>

Hey!! With a bit of luck, at the speed that things change in the computing
world, what you learn may get to be obsolete by the time you retire <sigh>
(looking at the DR-DOS box and MS-DOS manuals sitting on a corner, together
with the CP/M disks :-))

    Javier

----

He who laughs last is S-L-O-W.





From deliberatus@my995internet.com  Wed Sep  5 19:36:01 2001
From: deliberatus@my995internet.com (Kirk Bailey)
Date: Wed, 05 Sep 2001 14:36:01 -0400
Subject: [Tutor] subscribe
Message-ID: <3B967091.AF251B7D@my995internet.com>

subscribe

-- 

                  -Kirk D Bailey

end

                   _  __ _        _      ____      ____          _  _
                  | |/ /(_) _ __ | | __ |  _ \    | __ )   __ _ (_)| | 
___  _   _
                  | ' / | || '__|| |/ / | | | |   |  _ \  / _` || || | /
_ \| | | |
                  | . \ | || |   |   <  | |_| |_  | |_) || (_| || || || 
__/| |_| |
                  |_|\_\|_||_|   |_|\_\ |____/(_) |____/  \__,_||_||_|
\___| \__, |
                                                                            
|___/

                    http://www.howlermonkey.net   
http://www.tampabaydevival.org
                        ____                           _  _    _
                       / ___| ___   _ __   ___  _   _ | || |_ (_) _
__    __ _
                      | |    / _ \ | '_ \ / __|| | | || || __|| || '_ \ 
/ _` |
                      | |___| (_) || | | |\__ \| |_| || || |_ | || | |
|| (_| |
                       \____|\___/ |_| |_||___/ \__,_||_| \__||_||_| |_|
\__, |
                                                                        
|___/

         mailto:deliberatus@howlermonkey.net          
mailto:deliberatus@my995internet.com
      _____  _                           _      _   
____                     _
     |_   _|| |__    ___   _   _   __ _ | |__  | |_ | __ )   ___   _ __
___  | |__    ___  _ __
       | |  | '_ \  / _ \ | | | | / _` || '_ \ | __||  _ \  / _ \ | '_ `
_ \ | '_ \  / _ \| '__|
       | |  | | | || (_) || |_| || (_| || | | || |_ | |_) || (_) || | |
| | || |_) ||  __/| |
       |_|  |_| |_| \___/  \__,_| \__, ||_| |_| \__||____/  \___/ |_|
|_| |_||_.__/  \___||_|
                                  |___/


From dyoo@hkn.eecs.berkeley.edu  Wed Sep  5 19:40:38 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Wed, 5 Sep 2001 11:40:38 -0700 (PDT)
Subject: [Tutor] Help with cookies
In-Reply-To: <999711623_PM_BeOS.Charlie@begeistert.org>
Message-ID: <Pine.LNX.4.21.0109051132170.24366-100000@hkn.eecs.berkeley.edu>

On Wed, 5 Sep 2001, Charlie Clark wrote:

> I need to be able to pass a cookie in a url request. I know what the
> cookie should contain and inspection of the cookie module and
> documentation indicates that handling cookies should be
> straightforward but the example does not include sending one in an url
> request. Has anyone experience of this and ideas on how this might be
> done.

I have a silly example of one here:

    http://hkn.eecs.berkeley.edu/~dyoo/python/cookiecounter.py

The important thing is that we send off the cookie before any of the other
headers: otherwise, the browser will ignore the cookie.  I think that the
RFC says something to this effect here:

    http://home.netscape.com/newsref/std/cookie_spec.html



There should be some other examples of cookies on Useless Python.

    http://www.lowerstandard.com/python/pythonsource.html

Hmmm... it might be nice if we had a small searching facility for Useless
Python --- it's getting big!  *grin*



From jerryl@europa.com  Wed Sep  5 19:53:32 2001
From: jerryl@europa.com (Jerry Lake)
Date: Wed, 5 Sep 2001 11:53:32 -0700
Subject: [Tutor] OverFlowError
In-Reply-To: <Pine.LNX.4.21.0109051132170.24366-100000@hkn.eecs.berkeley.edu>
Message-ID: <000001c1363c$10993be0$0103670a@europa.com>

in my python2.1 install on win98
I'm having a problem generating numbers
past approx. 500,000,000,000
I keep getting an OverFlowError, what if 
anything can I do to increase this value
just in case I need to raise 9 to the 11th power ;)

Regards,

Jerry Lake 
Interface Engineering Technician


From dyoo@hkn.eecs.berkeley.edu  Wed Sep  5 19:52:51 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Wed, 5 Sep 2001 11:52:51 -0700 (PDT)
Subject: [Tutor] Sorting ranges
In-Reply-To: <Pine.BSF.4.21.0109051235230.47492-100000@fling.sanbi.ac.za>
Message-ID: <Pine.LNX.4.21.0109051144510.24366-100000@hkn.eecs.berkeley.edu>

On Wed, 5 Sep 2001, Tzu-Ming Chern wrote:

> does anyone know how to sort ranges in ascending order? Eg. 
> 
> 780=>1014  range 1
> 771=>1014  range 2
> 29=>214    range 3
> 226=>426   range 4
> 
> I would like my output to look like this:
> 
> 29=>214
> 226=>426
> 771=>1014
> 780=>1014


Hello!  I'm guessing that:

###
29=>214
226=>426
771=>1014
780=>1014
###

is a sample of what a user can type into your program, since '=>' is not
part of Python syntax.

Can you explain a little more what you mean by "range"?  The reason I'm
asking is because Python uses the word "range" to mean a sequence of
numbers:

###
>>> range(0, 10)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
###

so that might be causing some language confusion --- what we think of
"ranges" might be different from what you're thinking of.


Do you mean "pairs of numbers" instead?  That is, are you trying to sort:

###
[(780, 1014),
 (771, 1014),
 (29, 214),
 (226, 426)]
###

Just want to make sure we understand the problem better.



From ak@silmarill.org  Wed Sep  5 20:01:53 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Wed, 05 Sep 2001 15:01:53 -0400
Subject: [Tutor] OverFlowError
In-Reply-To: <000001c1363c$10993be0$0103670a@europa.com>
References: <Pine.LNX.4.21.0109051132170.24366-100000@hkn.eecs.berkeley.edu>
 <000001c1363c$10993be0$0103670a@europa.com>
Message-ID: <20010905150153.A23360@sill.silmarill.org>

On Wed, Sep 05, 2001 at 11:53:32AM -0700, Jerry Lake wrote:
> in my python2.1 install on win98
> I'm having a problem generating numbers
> past approx. 500,000,000,000
> I keep getting an OverFlowError, what if 
> anything can I do to increase this value
> just in case I need to raise 9 to the 11th power ;)
> 
> Regards,
> 
> Jerry Lake 
> Interface Engineering Technician

I haven't used it myself, but I think NumPy can do that
(you can google for it).

> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From ignacio@openservices.net  Wed Sep  5 20:07:24 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Wed, 5 Sep 2001 15:07:24 -0400 (EDT)
Subject: [Tutor] OverFlowError
In-Reply-To: <000001c1363c$10993be0$0103670a@europa.com>
Message-ID: <Pine.LNX.4.33.0109051505460.726-100000@terbidium.openservices.net>

On Wed, 5 Sep 2001, Jerry Lake wrote:

> in my python2.1 install on win98
> I'm having a problem generating numbers
> past approx. 500,000,000,000
> I keep getting an OverFlowError, what if
> anything can I do to increase this value
> just in case I need to raise 9 to the 11th power ;)
>
> Regards,
>
> Jerry Lake
> Interface Engineering Technician

Use long integers like 2L or 516L or 28364543610936237528791274591817364136L.
I'd tell you what their maximum value is, but your hard drive would fill up,
your computer would melt, and your brain would explode ;)

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From fallen@leveltwo.com  Thu Sep  6 00:10:55 2001
From: fallen@leveltwo.com (Fred Allen)
Date: Wed, 5 Sep 2001 16:10:55 -0700
Subject: [Tutor] Browser-based Python Interpreter
Message-ID: <4BB02C541824D311921600902765DB7B44583B@LTISERVER>

I would like to find a Python interpreter that is adapted to operate
independently via a browser, e.g. IE5.0.  To be clearer, I mean a Python
facility akin to the “Java Runtime Environment.”  It seems I've
encountered references to such facilities several times, but, now,
cannot find them.  With thanks in advance for any's efforts, I am,

Respectfully,

Fred Allen



From dsh8290@rit.edu  Thu Sep  6 01:26:41 2001
From: dsh8290@rit.edu (dman)
Date: Wed, 5 Sep 2001 20:26:41 -0400
Subject: [Tutor] Browser-based Python Interpreter
In-Reply-To: <4BB02C541824D311921600902765DB7B44583B@LTISERVER>; from fallen@leveltwo.com on Wed, Sep 05, 2001 at 04:10:55PM -0700
References: <4BB02C541824D311921600902765DB7B44583B@LTISERVER>
Message-ID: <20010905202641.D18539@harmony.cs.rit.edu>

On Wed, Sep 05, 2001 at 04:10:55PM -0700, Fred Allen wrote:
| I would like to find a Python interpreter that is adapted to operate
| independently via a browser, e.g. IE5.0.  To be clearer, I mean a Python
| facility akin to the Java Runtime Environment.  It seems I've
| encountered references to such facilities several times, but, now,
| cannot find them.  With thanks in advance for any's efforts, I am,

I'm not sure exactly what you mean by that -- the "Java Runtime
Environment" is a fancy way of saying "Java interpreter".  It is no
different than the python interpreter, except that it interprets java
bytcodes, not python source and bytecodes.

If you are looking for a way to write "java applets" in Python then
that is a little different.  The only special thing about Java is that
IE, Netscape, etc, have Java interpreters built in to them and the
<applet> tag is specified.  You could do the same thing with python,
but first you would need to convince web browser developers to include
a python interpreter and you would need to convince end-users to
upgrade.  Instead of that you can use Jython.  Jython is a python
interpreter that is written in Java so it runs in a JVM.  It is a
little bit more restrictive -- you can't use any C extension modules,
but it provides immediate access to all Java libraries.  You can write
(in python) a subclass of java.applet.Applet and compile the source to
java bytecode which your users can download and run in the JVM already
bundled with their web browser.

-D



From pythonpython@hotmail.com  Thu Sep  6 07:38:43 2001
From: pythonpython@hotmail.com (HY)
Date: Thu, 6 Sep 2001 15:38:43 +0900
Subject: [Tutor] What is the best way to count the number of lines in a huge file?
Message-ID: <OE40E2q4x1s0h6F1nub00009dc9@hotmail.com>

What is the best way to count the number of lines in a huge file?
Say, I have a file which is 15MB in size.
I used:

file=open("data.txt","r")
n=0
for line in file.xreadlines():
    n+=0
print n

Is there a better/simpler way to do it?

Thanks a lot.

Hy


From ignacio@openservices.net  Thu Sep  6 07:50:04 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Thu, 6 Sep 2001 02:50:04 -0400 (EDT)
Subject: [Tutor] What is the best way to count the number of lines in a
 huge file?
In-Reply-To: <OE40E2q4x1s0h6F1nub00009dc9@hotmail.com>
Message-ID: <Pine.LNX.4.33.0109060247030.27144-100000@terbidium.openservices.net>

On Thu, 6 Sep 2001, HY wrote:

> What is the best way to count the number of lines in a huge file?
> Say, I have a file which is 15MB in size.
> I used:
>
> file=open("data.txt","r")
> n=0
> for line in file.xreadlines():
>     n+=0
> print n
>
> Is there a better/simpler way to do it?
>
> Thanks a lot.
>
> Hy

a=None
n=0
while not a=='':
  a=file.read(262144) # season to taste
  n+=a.count('\n')

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From ppathiyi@cisco.com  Thu Sep  6 08:06:38 2001
From: ppathiyi@cisco.com (Praveen Pathiyil)
Date: Thu, 6 Sep 2001 12:36:38 +0530
Subject: [Tutor] What is the best way to count the number of lines in a huge file?
References: <OE40E2q4x1s0h6F1nub00009dc9@hotmail.com>
Message-ID: <068001c136a2$793c95a0$37ef87c0@ppathiyipc>

Hi,

May be you can execute the Unix "wc -l" command using the popen2 command.

stdout, stdin = popen2.popen2("wc -l <filename>")
print stdout.read()

-Praveen.

----- Original Message -----
From: "HY" <pythonpython@hotmail.com>
To: <Tutor@python.org>
Sent: Thursday, September 06, 2001 12:08 PM
Subject: [Tutor] What is the best way to count the number of lines in a huge
file?


> What is the best way to count the number of lines in a huge file?
> Say, I have a file which is 15MB in size.
> I used:
>
> file=open("data.txt","r")
> n=0
> for line in file.xreadlines():
>     n+=0
> print n
>
> Is there a better/simpler way to do it?
>
> Thanks a lot.
>
> Hy
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From pythonpython@hotmail.com  Thu Sep  6 08:28:42 2001
From: pythonpython@hotmail.com (HY)
Date: Thu, 6 Sep 2001 16:28:42 +0900
Subject: [Tutor] What is the best way to count the number of lines in a huge file?
References: <OE40E2q4x1s0h6F1nub00009dc9@hotmail.com> <068001c136a2$793c95a0$37ef87c0@ppathiyipc>
Message-ID: <OE26m9t0CI76rOJhKPc000064e2@hotmail.com>

Thanks for your respond. Great idea!

What if I want to use it on both Unix and Windows?
Is there a platform independent way to do it?

Hy

----- Original Message -----
From: "Praveen Pathiyil" <ppathiyi@cisco.com>
To: "HY" <pythonpython@hotmail.com>; <Tutor@python.org>
Sent: Thursday, September 06, 2001 4:06 PM
Subject: Re: [Tutor] What is the best way to count the number of lines in a
huge file?


> Hi,
>
> May be you can execute the Unix "wc -l" command using the popen2 command.
>
> stdout, stdin = popen2.popen2("wc -l <filename>")
> print stdout.read()
>
> -Praveen.
>
> ----- Original Message -----
> From: "HY" <pythonpython@hotmail.com>
> To: <Tutor@python.org>
> Sent: Thursday, September 06, 2001 12:08 PM
> Subject: [Tutor] What is the best way to count the number of lines in a
huge
> file?
>
>
> > What is the best way to count the number of lines in a huge file?
> > Say, I have a file which is 15MB in size.
> > I used:
> >
> > file=open("data.txt","r")
> > n=0
> > for line in file.xreadlines():
> >     n+=0
> > print n
> >
> > Is there a better/simpler way to do it?
> >
> > Thanks a lot.
> >
> > Hy
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>


From scarblac@pino.selwerd.nl  Thu Sep  6 09:25:17 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 6 Sep 2001 10:25:17 +0200
Subject: [Tutor] What is the best way to count the number of lines in a huge file?
In-Reply-To: <OE40E2q4x1s0h6F1nub00009dc9@hotmail.com>; from pythonpython@hotmail.com on Thu, Sep 06, 2001 at 03:38:43PM +0900
References: <OE40E2q4x1s0h6F1nub00009dc9@hotmail.com>
Message-ID: <20010906102516.A30764@pino.selwerd.nl>

On  0, HY <pythonpython@hotmail.com> wrote:
> What is the best way to count the number of lines in a huge file?
> Say, I have a file which is 15MB in size.

That's not huge :)

On new PCs I'd just read it all in and count the \n's, but I'll assume here
that we can't do that.

> I used:
> 
> file=open("data.txt","r")
> n=0
> for line in file.xreadlines():
>     n+=0
> print n
> 
> Is there a better/simpler way to do it?
  
Well, this one works and is quite simple. Look no further unless its
performance is unacceptable.

I like Ignacio's solution best: read the file in chunks of acceptable size,
and count the '\n' characters. Don't see how it can be more efficient than
that.

-- 
Remco Gerlich


From dsh8290@rit.edu  Thu Sep  6 14:00:56 2001
From: dsh8290@rit.edu (dman)
Date: Thu, 6 Sep 2001 09:00:56 -0400
Subject: [Tutor] What is the best way to count the number of lines in a huge file?
In-Reply-To: <Pine.LNX.4.33.0109060247030.27144-100000@terbidium.openservices.net>; from ignacio@openservices.net on Thu, Sep 06, 2001 at 02:50:04AM -0400
References: <OE40E2q4x1s0h6F1nub00009dc9@hotmail.com> <Pine.LNX.4.33.0109060247030.27144-100000@terbidium.openservices.net>
Message-ID: <20010906090056.A20827@harmony.cs.rit.edu>

On Thu, Sep 06, 2001 at 02:50:04AM -0400, Ignacio Vazquez-Abrams wrote:
| On Thu, 6 Sep 2001, HY wrote:
| 
| > What is the best way to count the number of lines in a huge file?
| > Say, I have a file which is 15MB in size.
| > I used:
| >
| > file=open("data.txt","r")
| > n=0
| > for line in file.xreadlines():
| >     n+=0
| > print n
| >
| > Is there a better/simpler way to do it?
| >
| > Thanks a lot.
| >
| > Hy
| 
| a=None
| n=0
| while not a=='':
|   a=file.read(262144) # season to taste
|   n+=a.count('\n')

Just beware of Mac's.  You won't find a single \n in a Mac text file
because they use \r instead.  FYI in case you have to deal with a text
file that came from a Mac.

-D



From ignacio@openservices.net  Thu Sep  6 14:07:08 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Thu, 6 Sep 2001 09:07:08 -0400 (EDT)
Subject: [Tutor] What is the best way to count the number of lines in a
 huge file?
In-Reply-To: <20010906090056.A20827@harmony.cs.rit.edu>
Message-ID: <Pine.LNX.4.33.0109060905590.17605-100000@terbidium.openservices.net>

On Thu, 6 Sep 2001, dman wrote:

> On Thu, Sep 06, 2001 at 02:50:04AM -0400, Ignacio Vazquez-Abrams wrote:
> | On Thu, 6 Sep 2001, HY wrote:
> |
> | > What is the best way to count the number of lines in a huge file?
> | > Say, I have a file which is 15MB in size.
> | > I used:
> | >
> | > file=open("data.txt","r")
> | > n=0
> | > for line in file.xreadlines():
> | >     n+=0
> | > print n
> | >
> | > Is there a better/simpler way to do it?
> | >
> | > Thanks a lot.
> | >
> | > Hy
> |
> | a=None
> | n=0
> | while not a=='':
> |   a=file.read(262144) # season to taste
> |   n+=a.count('\n')
>
> Just beware of Mac's.  You won't find a single \n in a Mac text file
> because they use \r instead.  FYI in case you have to deal with a text
> file that came from a Mac.
>
> -D

Fair enough:

---
a=None
n=0
while not a='':
  a=file.read(262144)
  n+=a.count(os.linesep)
---

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From alan.gauld@bt.com  Thu Sep  6 14:48:25 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 6 Sep 2001 14:48:25 +0100
Subject: [Tutor] Sorting ranges
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20F6E69F0@mbtlipnt02.btlabs.bt.co.uk>

> does anyone know how to sort ranges in ascending order? 

Nope, not even without Python.

What happens if the ranges overlap? What if one range is 
a subset of another?

Eg. 
> 780=>1014  range 1
> 771=>1014  range 2
> I would like my output to look like this:
> 771=>1014
> 780=>1014

OK, This implies you want the size of the first element
to be the determining factor in which case you could 
define your own comparison function (__cmp__() I guess?)
and just compare range1[0] with range2[0]...

You can then pass that as an extra parameter to the standard 
cmp function if I recall correctly. Theres definitely a way 
of doing that once you know how to write the __cmp__ bit.

Alan g


From alan.gauld@bt.com  Thu Sep  6 15:10:20 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 6 Sep 2001 15:10:20 +0100
Subject: [Tutor] Browser-based Python Interpreter
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF25@mbtlipnt02.btlabs.bt.co.uk>

> facility akin to the "Java Runtime Environment."  

There are only two options that I know of:

1) Grail, an unmaintained web browser written entirely(?) 
in Python with an embedded interpreter.

2) Use Jython and compile to classes. This produced standard 
java applets that you can reference and run pretty much as 
any other Java applet. But you write them in Python.

THe 3rd option is not quite the same which is (on Windows 
at least) to install the Active Scripting support for 
Python and this then allows you to embed Python in a 
web page in the same way as Javascript.

Personally I'd go the Jython route, not least because 
there's a bigger support community!

Alan g


From alan.gauld@bt.com  Thu Sep  6 15:13:47 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 6 Sep 2001 15:13:47 +0100
Subject: [Tutor] What is the best way to count the number of lines in a
 huge file?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF26@mbtlipnt02.btlabs.bt.co.uk>

> What is the best way to count the number of lines in a huge file?

If on *nix try:

import os
print os.popen("wc -l bigfile.txt")

> file=open("data.txt","r")
> n=0
> for line in file.xreadlines():
>     n+=0

assuming you mean n+=1 thats about the best I can think of.

Alan G


From scarblac@pino.selwerd.nl  Thu Sep  6 15:22:22 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 6 Sep 2001 16:22:22 +0200
Subject: [Tutor] What is the best way to count the number of lines in a huge file?
In-Reply-To: <20010906090056.A20827@harmony.cs.rit.edu>; from dsh8290@rit.edu on Thu, Sep 06, 2001 at 09:00:56AM -0400
References: <OE40E2q4x1s0h6F1nub00009dc9@hotmail.com> <Pine.LNX.4.33.0109060247030.27144-100000@terbidium.openservices.net> <20010906090056.A20827@harmony.cs.rit.edu>
Message-ID: <20010906162222.A31346@pino.selwerd.nl>

On  0, dman <dsh8290@rit.edu> wrote:
> On Thu, Sep 06, 2001 at 02:50:04AM -0400, Ignacio Vazquez-Abrams wrote:
> | On Thu, 6 Sep 2001, HY wrote:
> | 
> | > What is the best way to count the number of lines in a huge file?
> | > Say, I have a file which is 15MB in size.
> | > I used:
> | >
> | > file=open("data.txt","r")
> | > n=0
> | > for line in file.xreadlines():
> | >     n+=0
> | > print n
> | >
> | > Is there a better/simpler way to do it?
> | >
> | > Thanks a lot.
> | >
> | > Hy
> | 
> | a=None
> | n=0
> | while not a=='':
> |   a=file.read(262144) # season to taste
> |   n+=a.count('\n')
> 
> Just beware of Mac's.  You won't find a single \n in a Mac text file
> because they use \r instead.  FYI in case you have to deal with a text
> file that came from a Mac.

If the file is opened in text mode, then that is Python's problem (actually
the C library's), not yours. From the Python side it all looks like \n,
whatever the system.

-- 
Remco Gerlich


From xiaowp@chinaren.com  Thu Sep  6 15:27:54 2001
From: xiaowp@chinaren.com (xiaowp)
Date: Thu, 6 Sep 2001 22:27:54 +0800 (CST)
Subject: [Tutor] How to use Chinese in pygtk.
Message-ID: <5586162.999786474998.JavaMail.qmailuser@mlapp1.chinaren.com>

Hello all, 
	I'm writing a test tool in python and I select pygtk to buil the UI.
Now, I have a question about internationalization: how can I display 
Chinese on pygtk's label?
	Thanks ahead!


Best Regards,
Gary

=======================
xiaowp@chinaren.com
2001-09-06
========================
_________________________________________________________
搜狐闪电邮件,咱们不要钱!
http://mail.sohu.com




From sheila@thinkspot.net  Thu Sep  6 15:39:05 2001
From: sheila@thinkspot.net (Sheila King)
Date: Thu, 06 Sep 2001 07:39:05 -0700
Subject: [Tutor] How to use Chinese in pygtk.
In-Reply-To: <5586162.999786474998.JavaMail.qmailuser@mlapp1.chinaren.com>
References: <5586162.999786474998.JavaMail.qmailuser@mlapp1.chinaren.com>
Message-ID: <27EDFE95A75@kserver.org>

On Thu, 6 Sep 2001 22:27:54 +0800 (CST), xiaowp <xiaowp@chinaren.com>
wrote about [Tutor] How to use Chinese in pygtk.:

:Hello all, 
:	I'm writing a test tool in python and I select pygtk to buil the UI.
:Now, I have a question about internationalization: how can I display 
:Chinese on pygtk's label?
:	Thanks ahead!

I recently was trying to do the same thing with some French letters.
Are you planning to use Unicode?
I found, here:
http://www.unicode.org/charts/
That the latin-1 shows, for example, Ç with a code of 00C7

In Python, I can do this:
>>> print '\xC7'
Ç
>>> 

To get the character displayed.

So, find the Unicode codings for the characters you want, and print them
like above??

I haven't worked with the Chinese charset, only a few simple French
letters, so I'm not sure this is 100% applicable for your case. But
maybe it will get you started in the right direction?

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/



From rob@jam.rr.com  Thu Sep  6 15:48:34 2001
From: rob@jam.rr.com (Rob)
Date: Thu, 06 Sep 2001 09:48:34 -0500
Subject: [Tutor] Browser-based Python Interpreter
References: <4BB02C541824D311921600902765DB7B44583B@LTISERVER> <20010905202641.D18539@harmony.cs.rit.edu>
Message-ID: <3B978CC2.3020802@jam.rr.com>

dman wrote:

 > On Wed, Sep 05, 2001 at 04:10:55PM -0700, Fred Allen wrote: | I
 > would like to find a Python interpreter that is adapted to operate |
 >  independently via a browser, e.g. IE5.0.  To be clearer, I mean a
 > Python | facility akin to the Java Runtime Environment.  It seems
 > I've | encountered references to such facilities several times,
 > but, now, | cannot find them.  With thanks in advance for any's
 > efforts, I am,
 >
 > I'm not sure exactly what you mean by that -- the "Java Runtime 
Environment"
 >  is a fancy way of saying "Java interpreter".  It is no different
 > than the python interpreter, except that it interprets java bytcodes,
 >  not python source and bytecodes.
 >
 > If you are looking for a way to write "java applets" in Python then that
 >  is a little different.  The only special thing about Java is that IE,
 >  Netscape, etc, have Java interpreters built in to them and the <applet>
 >  tag is specified.  You could do the same thing with python, but
 > first you would need to convince web browser developers to include a
 >  python interpreter and you would need to convince end-users to upgrade.
 >   Instead of that you can use Jython.  Jython is a python interpreter
 >  that is written in Java so it runs in a JVM.  It is a little bit
 > more restrictive -- you can't use any C extension modules, but it
 > provides immediate access to all Java libraries.  You can write (in
 >  python) a subclass of java.applet.Applet and compile the source to java
 >  bytecode which your users can download and run in the JVM already 
bundled
 >  with their web browser.
 >
 > -D
 >
 >


Although it's probably not even close to what you have in mind, I've 
seen that at least one of the projects known as Python Server Pages even 
allows you to make an interactive Python interpreter available via browser.

With a clever bit of security, this could be a mighty handy thing to 
have around.

Uselessly,
Rob
-- 
Aw, c'mon.... You indent ANYWAY!
Useless Python!
http://www.lowerstandard.com/python



From jeff@ccvcorp.com  Thu Sep  6 17:31:58 2001
From: jeff@ccvcorp.com (Jeff Shannon)
Date: Thu, 06 Sep 2001 09:31:58 -0700
Subject: [Tutor] Browser-based Python Interpreter
References: <E15f1ae-0000JA-00@mail.python.org>
Message-ID: <3B97A4FE.A97729C8@ccvcorp.com>

> > facility akin to the "Java Runtime Environment."

...

> THe 3rd option is not quite the same which is (on Windows
> at least) to install the Active Scripting support for
> Python and this then allows you to embed Python in a
> web page in the same way as Javascript.

Note that ActiveScript support is not only specific to Windows, it's specific to MSIE--Netscape
does not (afaik) use the ActiveScripting engine.  This also requires that every *client* have a
Python interpreter installed, and set up to support ActiveScripting.  This *should* be done
automatically when installing ActiveState's ActivePython distribution, *or* when installing the
win32all package on top of some other python distribution.  It's actually pretty nice, but it
doesn't work so well for WWW purposes, since it's so platform/browser specific.  It can be
great if you're on a small intranet where you *know* what your clients are, however.  I've used
it to write a "hypertext application" to automatically interact with a vendor's web scripts,
using python as my scripting language (it's *so* much nicer than trying to do it all in VB!
<wink>)

Jeff Shannon
Technician/Programmer
Credit International




From sheila@thinkspot.net  Thu Sep  6 20:25:21 2001
From: sheila@thinkspot.net (Sheila King)
Date: Thu, 06 Sep 2001 12:25:21 -0700
Subject: [Tutor] Unpickleable object error
Message-ID: <384C2C017D0@kserver.org>

OK, so I'm happy as a clam, shelving away my objects into a database
hash file.

I have this type of object:

class user:
    def __init__(self, id, passwd, email, mssgList, lastmssg, caller = None):
        self.lockfile = MutexFile.MutexFile('userdb.lck')
        self.myfilename = 'users'
        self.id = id
        self.passwd = passwd
        self.email = email
        self.mssgList = mssgList
        self.lasmssg = lastmssg

And another class, called mssgBoard, has this method:

    def addUser(self, user):
        user.lockfile.flock('LOCK_EX')
        userdb = shelve.open(user.myfilename, 'c')
        if not userdb.has_key(user.id):
            userdb[user.id] = user
            userdb.close()
            user.lockfile.flock('LOCK_UN')

And I'm running my script, and debugging it, and (it's a cgi script) I get
the typical 500 Internal Server error, and when I check my log files, this
is the error message:

Premature end of script headers: e:/apache/cgi-bin/pibby/init.py
Traceback (most recent call last):
  File "e:\apache\cgi-bin\pibby\init.py", line 20, in ?
    mainBoard.addUser(admin)
  File "e:\apache\cgi-bin\pibby\pbbclass.py", line 34, in addUser
    userdb[user.id] = user
  File "E:\PYTHON\PYTHON21\lib\shelve.py", line 76, in __setitem__
    p.dump(value)
cPickle.UnpickleableError: Cannot pickle <type 'PyHANDLE'> objects

So, I'm thinking either I can't pickle/shelve this data class, as I have defined
it, or else I really don't know what the problem is.

Does anyone have any suggestions on how to proceed?

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/




From ignacio@openservices.net  Thu Sep  6 20:44:19 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Thu, 6 Sep 2001 15:44:19 -0400 (EDT)
Subject: [Tutor] Unpickleable object error
In-Reply-To: <384C2C017D0@kserver.org>
Message-ID: <Pine.LNX.4.33.0109061541570.25741-100000@terbidium.openservices.net>

On Thu, 6 Sep 2001, Sheila King wrote:

> class user:
>     def __init__(self, id, passwd, email, mssgList, lastmssg, caller = None):
>         self.lockfile = MutexFile.MutexFile('userdb.lck')
>         self.myfilename = 'users'
>         self.id = id
>         self.passwd = passwd
>         self.email = email
>         self.mssgList = mssgList
>         self.lasmssg = lastmssg
>
>  [snip]
>
> So, I'm thinking either I can't pickle/shelve this data class, as I have defined
> it, or else I really don't know what the problem is.
>
> Does anyone have any suggestions on how to proceed?

I don't think that it likes that MutexFile.MutexFile object in user. Try
pulling it out of there and putting it somewhere else in the code.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From sheila@thinkspot.net  Thu Sep  6 21:00:22 2001
From: sheila@thinkspot.net (Sheila King)
Date: Thu, 06 Sep 2001 13:00:22 -0700
Subject: [Tutor] Unpickleable object error
In-Reply-To: <Pine.LNX.4.33.0109061541570.25741-100000@terbidium.openservices.net>
References: <384C2C017D0@kserver.org> <Pine.LNX.4.33.0109061541570.25741-100000@terbidium.openservices.net>
Message-ID: <3A4DDDB66F7@kserver.org>

On Thu, 6 Sep 2001 15:44:19 -0400 (EDT), Ignacio Vazquez-Abrams
<ignacio@openservices.net>  wrote about Re: [Tutor] Unpickleable object
error:

:I don't think that it likes that MutexFile.MutexFile object in user. Try
:pulling it out of there and putting it somewhere else in the code.

I don't think that is the problem, because before I introduced the user
class, I was running this code without any problem (this is only a
snippet of the code, of course):

class mssgBoard:
    def __init__(self, dict=None, caller=None):
        self.lockfile = MutexFile.MutexFile('main.lck')
        self.myfilename = 'mainboard'
        if caller == 'init':
            try:
                self.lockfile.flock('LOCK_EX')
                db = shelve.open(self.myfilename, 'n')
                db['title'] = dict['title'].value
                db['adminID'] = dict['adminID'].value
                db['smtpserver'] = dict['smtpserver'].value
                db['exitURL'] = dict['exitURL'].value
                db['adminEmail'] = dict['email'].value
                db['threads'] = []
                db.close()
                self.lockfile.flock('LOCK_UN')
            except KeyError, e:
                print header('Error in Message Board Init')
                print body('missing keys')

Notice that it also has a MutexFile object, and it caused no problems in
shelving that object.

Code runs fine when I comment out the addUser function and the call to
it.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/




From sheila@thinkspot.net  Thu Sep  6 21:09:00 2001
From: sheila@thinkspot.net (Sheila King)
Date: Thu, 06 Sep 2001 13:09:00 -0700
Subject: [Tutor] Unpickleable object error
In-Reply-To: <384C2C017D0@kserver.org>
References: <384C2C017D0@kserver.org>
Message-ID: <3ACC07A6D45@kserver.org>

On Thu, 06 Sep 2001 12:25:21 -0700, Sheila King <sheila@thinkspot.net>
wrote about [Tutor] Unpickleable object error:

:So, I'm thinking either I can't pickle/shelve this data class, as I have defined
:it, or else I really don't know what the problem is.
:
:Does anyone have any suggestions on how to proceed?

You know what...I just went back, removed the comments on the addUser
function, and I caught a small spelling error in the user.__init__
function. Namely:

        self.lasmssg = lastmssg

should have been
        self.lastmssg = lastmssg
                ^ (missing "t")

And I can't see why that would have made any difference (as I never
refer to it anywhere in the code, yet...)

Anyhow, the code just ran without error, and just created the users
database for me. 

I don't know why it worked now and not before. Go figure.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/




From vdbroekw@wxs.nl  Thu Sep  6 22:21:21 2001
From: vdbroekw@wxs.nl (Walter van den Broek)
Date: Thu, 06 Sep 2001 23:21:21 +0200
Subject: [Tutor] input problem ?
Message-ID: <3B97E8D1.4E5BD86E@wxs.nl>

Hi, 
Complete newbie here.
>From a lot of patients we get data to obtain a diagnosis.
To make it easier and more accurate i planned to put the obtained scores
in a program to verify the diagnoses.
>From the first two questions at least one has to have a score>4.
If that is the case from the other 7 questions at least 4 have to score
higher than four to become diagnosed as being severely depressed.
I tried the following code to accomplish it, but became slightly
"depressed"
At first with the first two questions it worked well, appending the
other questions delivered error messages
Traceback (innermost last):
  File "<string>", line 1, in ?
SyntaxError: can't assign to operator (dsm4.py, line 10)
And this is the code:
import string
vraag_234 = input ( "Wat is de score bij vraag 234? ")
vraag_326 = input ("Wat is de score bij vraag 326? ")
vraag_317-321 = input ("Wat is de score bij vraag 317-321?")
vraag_272-315 = input ("Wat is de score bij vraag 272-315?")
vraag_334-343 = input ("Wat is de score bij vraag 334-343?")
vraag_315 = input ("Wat is de score bij vraag 315?")
vraag_240-242 = input ("Wat is de score bij vraag 240-242?")
vraag_325 = input ("Wat is de score bij vraag 325?")
vraag_246-250 = input ("Wat is de score bij vraag 246-250?")

if (vraag_234 > 4) or (vraag_326 > 4):
    print "Er kan sprake zijn van een depressie volgens DSM IV criteria"

else:
    print "Er kan geen sprake zijn van een depressie volgens DSM IV
criteria"



List = []
if (vraag_317-321 > 4):
    List.append
if (vraag_272-315 > 4):
    List.append
if  (vraag_334-343 > 4):
    List.append
if (vraag_315 > 4 ):
    List.append
if (vraag_240-242 > 4):
    List.append
if (vraag_325 > 4):
    List.append
if (vraag_246-250 > 4):
    List.append
len(List)
if len(List) > 4:
    print "Er is sprake van de depressieve stoornis volgens DSM IV
criteria"

else:
    print "Er is geen sprake van een depressieve stoornis volgens DSM IV
criteria"

    Is there to much input?, should i make functions?
>From the last 7 questions i decided to create a list of scores, append
was usede if the score was higher than 4, so if i have more then 4
positive results (scores higher than 4) the diagnoses is confirmed
Maybe  a difficult try out but to me it is very usefull if it works
Thanks, willing to learn
Walter
-- 
W.W. van den Broek	vandenbroek@psyd.azr.nl
URL: http://home.planet.nl/~vdbroekw
Private email: vdbroekw@wxs.nl


From sheila@thinkspot.net  Thu Sep  6 21:12:26 2001
From: sheila@thinkspot.net (Sheila King)
Date: Thu, 06 Sep 2001 13:12:26 -0700
Subject: [Tutor] Unpickleable object error
Message-ID: <3AFE6A015F2@kserver.org>

On Thu, 06 Sep 2001 13:09:00 -0700, Sheila King <sheila@thinkspot.net>
wrote about Re: [Tutor] Unpickleable object error:

:Anyhow, the code just ran without error, and just created the users
:database for me. 
:
:I don't know why it worked now and not before. Go figure.

Argh! I take it back. Sorry, it's not working.
(I had some indentation problem when I ran it this last time, and made
it appear to work, when in fact it did not.)

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/



From koen@behindthesofa.dhs.org  Thu Sep  6 21:22:21 2001
From: koen@behindthesofa.dhs.org (Koen Bossers)
Date: Thu, 06 Sep 2001 22:22:21 +0200
Subject: [Tutor] input problem ?
References: <3B97E8D1.4E5BD86E@wxs.nl>
Message-ID: <3B97DAFD.90901@behindthesofa.dhs.org>

Walter van den Broek wrote:

>Hi, 
>Complete newbie here.
>>From a lot of patients we get data to obtain a diagnosis.
>To make it easier and more accurate i planned to put the obtained scores
>in a program to verify the diagnoses.
>>From the first two questions at least one has to have a score>4.
>If that is the case from the other 7 questions at least 4 have to score
>higher than four to become diagnosed as being severely depressed.
>I tried the following code to accomplish it, but became slightly
>"depressed"
>At first with the first two questions it worked well, appending the
>other questions delivered error messages
>Traceback (innermost last):
>  File "<string>", line 1, in ?
>SyntaxError: can't assign to operator (dsm4.py, line 10)
>And this is the code:
>import string
>vraag_234 = input ( "Wat is de score bij vraag 234? ")
>vraag_326 = input ("Wat is de score bij vraag 326? ")
>vraag_317-321 = input ("Wat is de score bij vraag 317-321?")
>vraag_272-315 = input ("Wat is de score bij vraag 272-315?")
>vraag_334-343 = input ("Wat is de score bij vraag 334-343?")
>vraag_315 = input ("Wat is de score bij vraag 315?")
>
Change vraag_number-number to vraag_number_number (minus symbol cannot 
be used in keywords!)

Cheers, Koen




From ignacio@openservices.net  Thu Sep  6 21:31:19 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Thu, 6 Sep 2001 16:31:19 -0400 (EDT)
Subject: [Tutor] Unpickleable object error
In-Reply-To: <3A4DDDB66F7@kserver.org>
Message-ID: <Pine.LNX.4.33.0109061629010.25741-100000@terbidium.openservices.net>

On Thu, 6 Sep 2001, Sheila King wrote:

> class mssgBoard:
>     def __init__(self, dict=None, caller=None):
>         self.lockfile = MutexFile.MutexFile('main.lck')
>         self.myfilename = 'mainboard'
>         if caller == 'init':
>             try:
>                 self.lockfile.flock('LOCK_EX')
>                 db = shelve.open(self.myfilename, 'n')
>                 db['title'] = dict['title'].value
>                 db['adminID'] = dict['adminID'].value
>                 db['smtpserver'] = dict['smtpserver'].value
>                 db['exitURL'] = dict['exitURL'].value
>                 db['adminEmail'] = dict['email'].value
>                 db['threads'] = []
>                 db.close()
>                 self.lockfile.flock('LOCK_UN')
>             except KeyError, e:
>                 print header('Error in Message Board Init')
>                 print body('missing keys')
>
> Notice that it also has a MutexFile object, and it caused no problems in
> shelving that object.

Right, but in this case it is not trying to shelve the MutexFile, whereas in
the previous snippet it is.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>




From sheila@thinkspot.net  Thu Sep  6 21:56:04 2001
From: sheila@thinkspot.net (Sheila King)
Date: Thu, 06 Sep 2001 13:56:04 -0700
Subject: [Tutor] Unpickleable object error
In-Reply-To: <Pine.LNX.4.33.0109061629010.25741-100000@terbidium.openservices.net>
References: <3A4DDDB66F7@kserver.org> <Pine.LNX.4.33.0109061629010.25741-100000@terbidium.openservices.net>
Message-ID: <3D7BD1843AE@kserver.org>

On Thu, 6 Sep 2001 16:31:19 -0400 (EDT), Ignacio Vazquez-Abrams
<ignacio@openservices.net>  wrote about Re: [Tutor] Unpickleable object
error:

:Right, but in this case it is not trying to shelve the MutexFile, whereas in
:the previous snippet it is.

OK, good point. I removed the MutexFile from the object's data
attributes, and you are correct: Now I can shelve it.

I have a work around. I made it an attribute of the class, and not of an
instance of the class.

Thanks,

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/



From dyoo@hkn.eecs.berkeley.edu  Thu Sep  6 22:06:54 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 6 Sep 2001 14:06:54 -0700 (PDT)
Subject: [Tutor] Unpickleable object error
In-Reply-To: <384C2C017D0@kserver.org>
Message-ID: <Pine.LNX.4.21.0109061358180.19043-100000@hkn.eecs.berkeley.edu>

On Thu, 6 Sep 2001, Sheila King wrote:

>     def __init__(self, id, passwd, email, mssgList, lastmssg, caller = None):
>         self.lockfile = MutexFile.MutexFile('userdb.lck')
>         self.myfilename = 'users'
>         self.id = id
>         self.passwd = passwd
>         self.email = email
>         self.mssgList = mssgList
>         self.lasmssg = lastmssg

[some text cut]

> Traceback (most recent call last):
>   File "e:\apache\cgi-bin\pibby\init.py", line 20, in ?
>     mainBoard.addUser(admin)
>   File "e:\apache\cgi-bin\pibby\pbbclass.py", line 34, in addUser
>     userdb[user.id] = user
>   File "E:\PYTHON\PYTHON21\lib\shelve.py", line 76, in __setitem__
>     p.dump(value)
> cPickle.UnpickleableError: Cannot pickle <type 'PyHANDLE'> objects


I suspect it might have to do with the MutexFile object --- the error
about a PyHANDLE sounds really specific to a Win32 thing:

 http://aspn.activestate.com/ASPN/Python/Reference/Products
       /ActivePython/PythonWin32Extensions/PyHANDLE.html

and since you mentioned earlier that MutexFile tries to do things
uniformly on Windows and Unix, that implies that MutexFile could be the
source of the pickle bug.

How are you implementing MutexFile?  Can you check to see if you can
pickle a MutexFile?  If not, you may need to tell pickle not to touch your
self.lockfile --- that is, you might need to give pickle some specific
instructions when pickling/unpickling a MutexFile.

Take a look at:

    http://www.python.org/doc/lib/module-pickle.html

In particular, you might need to define __getstate__() and __setstate__()
methods in either MutexFile or your userfile class to take this into
account.


Hope this helps!



From dyoo@hkn.eecs.berkeley.edu  Thu Sep  6 22:10:31 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 6 Sep 2001 14:10:31 -0700 (PDT)
Subject: [Tutor] How to use Chinese in pygtk.
In-Reply-To: <5586162.999786474998.JavaMail.qmailuser@mlapp1.chinaren.com>
Message-ID: <Pine.LNX.4.21.0109061407440.19043-100000@hkn.eecs.berkeley.edu>

On Thu, 6 Sep 2001, xiaowp wrote:

> Hello all, 
> 	I'm writing a test tool in python and I select pygtk to buil the UI.
> Now, I have a question about internationalization: how can I display 
> Chinese on pygtk's label?

According to the pygtk mailing list:

    http://www.daa.com.au/pipermail/pygtk/2000-November/000523.html

Pygtk might not support Unicode yet; you may need to double check with the
pygtk folks to see if this has been amended yet.  You can ask them at:

    http://www.daa.com.au/mailman/listinfo/pygtk

If you find out that you can get Chinese working in PyGtk, please tell us.  
Good luck to you!



From dsh8290@rit.edu  Thu Sep  6 22:11:23 2001
From: dsh8290@rit.edu (dman)
Date: Thu, 6 Sep 2001 17:11:23 -0400
Subject: [Tutor] What is the best way to count the number of lines in a huge file?
In-Reply-To: <Pine.LNX.4.33.0109060905590.17605-100000@terbidium.openservices.net>; from ignacio@openservices.net on Thu, Sep 06, 2001 at 09:07:08AM -0400
References: <20010906090056.A20827@harmony.cs.rit.edu> <Pine.LNX.4.33.0109060905590.17605-100000@terbidium.openservices.net>
Message-ID: <20010906171123.C22153@harmony.cs.rit.edu>

On Thu, Sep 06, 2001 at 09:07:08AM -0400, Ignacio Vazquez-Abrams wrote:
| On Thu, 6 Sep 2001, dman wrote:
| > On Thu, Sep 06, 2001 at 02:50:04AM -0400, Ignacio Vazquez-Abrams wrote:
| > | On Thu, 6 Sep 2001, HY wrote:
<major snipage>
| > | a=None
| > | n=0
| > | while not a=='':
| > |   a=file.read(262144) # season to taste
| > |   n+=a.count('\n')
| >
| > Just beware of Mac's.  You won't find a single \n in a Mac text file
| > because they use \r instead.  FYI in case you have to deal with a text
| > file that came from a Mac.
| 
| Fair enough:
| 
| ---
| a=None
| n=0
| while not a='':
|   a=file.read(262144)
|   n+=a.count(os.linesep)
| ---

The only problem with this is it only (truly properly) counts the
lines of files that were created with the same OS as the one
counting.

You'd probably want to use a regex to search for "\r\n|\r|\n", but it
all depends on the source(s) of the files you want to count.

Make your script "good enough", not "perfect according to some misty
definition".  :-).

-D



From tjenkins@devis.com  Thu Sep  6 22:14:34 2001
From: tjenkins@devis.com (Tom Jenkins)
Date: Thu, 06 Sep 2001 17:14:34 -0400
Subject: [Tutor] input problem ?
References: <3B97E8D1.4E5BD86E@wxs.nl>
Message-ID: <3B97E73A.3040306@devis.com>

Hi Walter,
Couple of problems here which are easily fixable...

Walter van den Broek wrote:
> Hi, 
> Complete newbie here.
> From a lot of patients we get data to obtain a diagnosis.
> To make it easier and more accurate i planned to put the obtained scores
> in a program to verify the diagnoses.
> From the first two questions at least one has to have a score>4.
> If that is the case from the other 7 questions at least 4 have to score
> higher than four to become diagnosed as being severely depressed.
> I tried the following code to accomplish it, but became slightly
> "depressed"
> At first with the first two questions it worked well, appending the
> other questions delivered error messages
> Traceback (innermost last):
>   File "<string>", line 1, in ?
> SyntaxError: can't assign to operator (dsm4.py, line 10)
> And this is the code:
> import string
> vraag_234 = input ( "Wat is de score bij vraag 234? ")
> vraag_326 = input ("Wat is de score bij vraag 326? ")
> vraag_317-321 = input ("Wat is de score bij vraag 317-321?")
> vraag_272-315 = input ("Wat is de score bij vraag 272-315?")
> vraag_334-343 = input ("Wat is de score bij vraag 334-343?")
> vraag_315 = input ("Wat is de score bij vraag 315?")
> vraag_240-242 = input ("Wat is de score bij vraag 240-242?")
> vraag_325 = input ("Wat is de score bij vraag 325?")
> vraag_246-250 = input ("Wat is de score bij vraag 246-250?")
> 

change the '-' to '_' in these variables...


> if (vraag_234 > 4) or (vraag_326 > 4):
>     print "Er kan sprake zijn van een depressie volgens DSM IV criteria"
> 
> else:
>     print "Er kan geen sprake zijn van een depressie volgens DSM IV
> criteria"
> 
> 
> 
> List = []
> if (vraag_317-321 > 4):
>     List.append
> if (vraag_272-315 > 4):
>     List.append
> if  (vraag_334-343 > 4):
>     List.append
> if (vraag_315 > 4 ):
>     List.append
> if (vraag_240-242 > 4):
>     List.append
> if (vraag_325 > 4):
>     List.append
> if (vraag_246-250 > 4):
>     List.append
> len(List)
> if len(List) > 4:
>     print "Er is sprake van de depressieve stoornis volgens DSM IV
> criteria"
> 
> else:
>     print "Er is geen sprake van een depressieve stoornis volgens DSM IV
> criteria"
> 

Here you really don't need a list; you are counting the number of 
answers that are "positive results" (ie > 4).  so lets just keep a 
running count...

  count = 0
  if (vraag_317_321 > 4):
      count = count + 1
  if (vraag_272_315 > 4):
      count = count + 1
  if  (vraag_334_343 > 4):
      count = count + 1
  if (vraag_315 > 4 ):
      count = count + 1
  if (vraag_240_242 > 4):
      count = count + 1
  if (vraag_325 > 4):
      count = count + 1
  if (vraag_246_250 > 4):
      count = count + 1

  if count > 4:
      print "Er is sprake van de depressieve stoornis volgens DSM IV 
criteria"
  else:
      print "Er is geen sprake van een depressieve stoornis volgens DSM 
IV criteria"



-- 
Tom Jenkins
devIS - Development Infostructure
http://www.devis.com



From dsh8290@rit.edu  Thu Sep  6 22:15:17 2001
From: dsh8290@rit.edu (dman)
Date: Thu, 6 Sep 2001 17:15:17 -0400
Subject: [Tutor] What is the best way to count the number of lines in a huge file?
In-Reply-To: <20010906162222.A31346@pino.selwerd.nl>; from scarblac@pino.selwerd.nl on Thu, Sep 06, 2001 at 04:22:22PM +0200
References: <OE40E2q4x1s0h6F1nub00009dc9@hotmail.com> <Pine.LNX.4.33.0109060247030.27144-100000@terbidium.openservices.net> <20010906090056.A20827@harmony.cs.rit.edu> <"from dsh8290"@rit.edu> <20010906162222.A31346@pino.selwerd.nl>
Message-ID: <20010906171517.D22153@harmony.cs.rit.edu>

On Thu, Sep 06, 2001 at 04:22:22PM +0200, Remco Gerlich wrote:
| On  0, dman <dsh8290@rit.edu> wrote:
| > On Thu, Sep 06, 2001 at 02:50:04AM -0400, Ignacio Vazquez-Abrams wrote:
| > | On Thu, 6 Sep 2001, HY wrote:
<major snippage>
| > | a=None
| > | n=0
| > | while not a=='':
| > |   a=file.read(262144) # season to taste
| > |   n+=a.count('\n')
| > 
| > Just beware of Mac's.  You won't find a single \n in a Mac text file
| > because they use \r instead.  FYI in case you have to deal with a text
| > file that came from a Mac.
| 
| If the file is opened in text mode, then that is Python's problem (actually
| the C library's), not yours. From the Python side it all looks like \n,
| whatever the system.

That's cool -- lines always end properly in python :-).  Although I
don't think that will work on a unix box -- "text" mode is no
different from "binary" mode.  I don't think this theory works on a
windows box either, when opening a mac file.  My reasoning is that I
had to tweak an HTML file recently.  I opened the file (first on the
FreeBS web host) using vim -- it reported "noeol" and everything was
on one huge line.  I got the same effect when I copied it to my win2k
workstation and opened it with vim.  I used a little bit of
substitution (I was going to use python which is why I copied the file
to my windows box, but then I learned how to use vim's subsitute
strings properly) to replace all \r with \n and make the file a
"proper" (unix) text file.

-D



From bill_tolbert@bigfoot.com  Thu Sep  6 22:20:56 2001
From: bill_tolbert@bigfoot.com (Bill Tolbert)
Date: Thu, 6 Sep 2001 17:20:56 -0400 (EDT)
Subject: [Tutor] sending stdout to a text box
Message-ID: <Pine.GSO.4.21L1.0109061711520.10065-100000@sunny>

Well, a week has gone by and I've got to give this thing another try.

I have a script which works well; it sends messages to the console when
run from a prompt. How can I catch this and route it to a text box in
tkinter?

I've read about the textvariable and StringVar() option but I can't get it
to work. Text boxes don't support textvariable and I can't get the stdout
to redirect to anything useful.

Can someone help?

Here's the code:

#Adapted from TKTextDemo.py by Martin Stevens, budgester@budgester.com
#Shamelessly lifted from Useless Python (www.lowerstandard.com/python)


from Tkinter import *

class App:

##  Create GUI 

    def __init__(self, master):

        frame = Frame(master)
        frame.pack()
        self.t = StringVar()
	# this line doesn't work
        #self.text_box = Text(frame, textvariable=self.t)
        self.text_box = Text(frame)
        self.text_box.pack()
        
	# this call to dobackup works but no redirect of stdout
        self.dobackup = Button(frame, text="Do Backup",
				command=self.backup)

        self.dobackup.pack(side=TOP)

    def backup(self):
        import ICAREBackup
        #self.t = sys.stdout
        #sys.stdout = self.t
        self.text_box.insert(END, sys.stdout)
        ICAREBackup.ICAREBackup()

root = Tk()

app = App(root)

root.mainloop()



=-=-=-=-=-=-=-=-=
Bill Tolbert



From ignacio@openservices.net  Thu Sep  6 22:26:00 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Thu, 6 Sep 2001 17:26:00 -0400 (EDT)
Subject: [Tutor] What is the best way to count the number of lines in a
 huge file?
In-Reply-To: <20010906171123.C22153@harmony.cs.rit.edu>
Message-ID: <Pine.LNX.4.33.0109061723440.25741-100000@terbidium.openservices.net>

On Thu, 6 Sep 2001, dman wrote:

> On Thu, Sep 06, 2001 at 09:07:08AM -0400, Ignacio Vazquez-Abrams wrote:
> | Fair enough:
> |
> | ---
> | a=None
> | n=0
> | while not a='':
> |   a=file.read(262144)
> |   n+=a.count(os.linesep)
> | ---
>
> The only problem with this is it only (truly properly) counts the
> lines of files that were created with the same OS as the one
> counting.
>
> You'd probably want to use a regex to search for "\r\n|\r|\n", but it
> all depends on the source(s) of the files you want to count.
>
> Make your script "good enough", not "perfect according to some misty
> definition".  :-).
>
> -D

Even using that RE (and in fact, of using the given code on Windows) is that
the \r\n may straddle a 256k boundary, losing one line in the code, and
gaining one with the RE.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From dsh8290@rit.edu  Thu Sep  6 22:33:18 2001
From: dsh8290@rit.edu (dman)
Date: Thu, 6 Sep 2001 17:33:18 -0400
Subject: [Tutor] What is the best way to count the number of lines in a huge file?
In-Reply-To: <Pine.LNX.4.33.0109061723440.25741-100000@terbidium.openservices.net>; from ignacio@openservices.net on Thu, Sep 06, 2001 at 05:26:00PM -0400
References: <20010906171123.C22153@harmony.cs.rit.edu> <Pine.LNX.4.33.0109061723440.25741-100000@terbidium.openservices.net>
Message-ID: <20010906173318.F22153@harmony.cs.rit.edu>

On Thu, Sep 06, 2001 at 05:26:00PM -0400, Ignacio Vazquez-Abrams wrote:
| On Thu, 6 Sep 2001, dman wrote:
| > On Thu, Sep 06, 2001 at 09:07:08AM -0400, Ignacio Vazquez-Abrams wrote:
| > | Fair enough:
| > |
| > | ---
| > | a=None
| > | n=0
| > | while not a='':
| > |   a=file.read(262144)
| > |   n+=a.count(os.linesep)
| > | ---
| >
| > The only problem with this is it only (truly properly) counts the
| > lines of files that were created with the same OS as the one
| > counting.
| >
| > You'd probably want to use a regex to search for "\r\n|\r|\n", but it
| > all depends on the source(s) of the files you want to count.
| >
| > Make your script "good enough", not "perfect according to some misty
| > definition".  :-).
| 
| Even using that RE (and in fact, of using the given code on Windows) is that
| the \r\n may straddle a 256k boundary, losing one line in the code, and
| gaining one with the RE.

Heh.  I didn't even know windows had a 256k boundary.  I always though
that putting an extra character in the file was a bad idea ... (it
also breaks ftell() and fseek()).  Ken Thompson and Dennis Ritchie had
more foresight than most ;-).

A more robust technique would be to scout the file's contents first
and determine whether it is *nix, 'doze or mac format and then search
only for that particular line terminator.  My regex would allow for a
combination of line separators in a single file, which isn't a good
idea.

-D



From ignacio@openservices.net  Thu Sep  6 22:39:44 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Thu, 6 Sep 2001 17:39:44 -0400 (EDT)
Subject: [Tutor] What is the best way to count the number of lines in a
 huge file?
In-Reply-To: <20010906173318.F22153@harmony.cs.rit.edu>
Message-ID: <Pine.LNX.4.33.0109061738230.25741-100000@terbidium.openservices.net>

On Thu, 6 Sep 2001, dman wrote:
> Heh.  I didn't even know windows had a 256k boundary.  I always though

?

I meant the parameter passed to file.read() in my code (262144B=256KiB).

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>





From alan.gauld@bt.com  Thu Sep  6 22:37:35 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 6 Sep 2001 22:37:35 +0100
Subject: [Tutor] Browser-based Python Interpreter
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF2E@mbtlipnt02.btlabs.bt.co.uk>

AG> > THe 3rd option is not quite the same which is (on Windows
AG> > at least) to install the Active Scripting support for
> 
JS> requires that every *client* have a
JS> Python interpreter installed, and set up to support 
JS> ActiveScripting.  

Good catch. I actually meant to explain that in my message 
but somewhere between thought and email it got lost. The option
is fine on an intranet where the environment is controlled, 
on the internet you really do need to go with Jython.

Alan G


From alan.gauld@bt.com  Thu Sep  6 23:12:02 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 6 Sep 2001 23:12:02 +0100
Subject: [Tutor] input problem ?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF2F@mbtlipnt02.btlabs.bt.co.uk>

Walter,

Others have dealt with the errors you got, here are a 
couple of other things to consider.

> vraag_234 = input ( "Wat is de score bij vraag 234? ")

Use raw_input() rather than input() - it's safer should 
you get a knowledgable and rogue user. You need to convert 
the raw_input to an int thus:

vraag_317-321 = int(raw_input ("Wat is de score bij vraag 317-321?"))

Also to save code and make the program easier to extend you could
store the questions and responses in a dictionary:

vraag = {'317-321':["Wat is de score bij vraag 317-321?", 4, None],
         '234':["Wat is de score bij vraag 234? ", 4, None],
         etc...
}

Here we use the question number as a key and store the question,
the compared value(weight) and a place marker(None) for the 
input result. 
Thus to access the question we can do:
vraag['234'][0]
To access the weighting value:
vraag['234'][1]
and to store a value:
vraag['234'][2] =  42

To ask the questions you can then just loop over the keys:

for q in vraag.keys():
    # vraag[q] is the dictionary item, 
    # 2 is the value field and 0 the question text
    vraag[q][2] = int(raw_input(vraag[q][0]))

The advantage here is that you can add new questions to the 
dictionary or change the weighting values without changing the
actual code structure.

Combining that with the earlier tip about using a count value 
you can then later do:

for q in vraag.keys():
    # compare value and weighting
    if vraag[q][2] > vraag[q][1]:
       count = count + 1

> if (vraag_234 > 4) or (vraag_326 > 4):

This doesn't change much:

if (vraag['234'][2] > vraag['234'][1]) 
    or (vraag['326'][2] > vraag['326'][1]):
>     print "Er kan sprake zijn van een depressie ..."

>     Is there to much input?, should i make functions?

You could do it in functions too but if you use a dictionary 
the code shrinks to the point where its not so important.
Structuring the data to suit the problem can often save 
an awful lot of repetitive coding.
 
OTOH you might find the complexity of using indexes too 
difficult to track, in which case a function might be better.

Finally, in your original code you used something like this:

List = []
if (vraag_317-321 > 4):
    List.append

That won't do anything to the list since List.append is 
not being executed - its simply the name of a function. 
You need to add parentheses - and put something inside them!

eg. List.append(1)

> Maybe  a difficult try out but to me it is very usefull if it works

For a first attempt its very good, my first programs 
in a new language are usually much less ambitious! :-)

Alan G


From dsh8290@rit.edu  Thu Sep  6 23:15:14 2001
From: dsh8290@rit.edu (dman)
Date: Thu, 6 Sep 2001 18:15:14 -0400
Subject: [Tutor] What is the best way to count the number of lines in a huge file?
In-Reply-To: <Pine.LNX.4.33.0109061738230.25741-100000@terbidium.openservices.net>; from ignacio@openservices.net on Thu, Sep 06, 2001 at 05:39:44PM -0400
References: <20010906173318.F22153@harmony.cs.rit.edu> <Pine.LNX.4.33.0109061738230.25741-100000@terbidium.openservices.net>
Message-ID: <20010906181514.A22356@harmony.cs.rit.edu>

On Thu, Sep 06, 2001 at 05:39:44PM -0400, Ignacio Vazquez-Abrams wrote:
| On Thu, 6 Sep 2001, dman wrote:
| > Heh.  I didn't even know windows had a 256k boundary.  I always though
| 
| ?
| 
| I meant the parameter passed to file.read() in my code (262144B=256KiB).

Oh, right.  Searching for a sequence of characters in an stream of
bytes is problematic unless you have some sort of structure within
which to work (IOW that boundary thing).

-D



From GADGILP@INFOTECH.ICICI.com  Fri Sep  7 06:45:48 2001
From: GADGILP@INFOTECH.ICICI.com (GADGIL PRASAD /INFRA/INFOTECH)
Date: Fri, 7 Sep 2001 11:15:48 +0530
Subject: [Tutor] Browser-based Python Interpreter
Message-ID: <E1B786DCFA6ED511A0390008C7289E47635411@ICICIBACK3>

This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.

------_=_NextPart_001_01C13760.58908960
Content-Type: text/plain;
	charset="iso-8859-1"

hello,

there was a mail abt NT related automation and somebody mentioned WSH.
I have installed it. Alan mentions about "Active Scripting support for 
Python". Is there another component that I need to install after WSH
so that I can proceed ?

I need to be able to start and stop server daemons using a script on NT
and havn't coded on win/COM env earlier.

/prasad

> -----Original Message-----
> From: alan.gauld@bt.com [mailto:alan.gauld@bt.com]
> Sent: Friday, September 07, 2001 3:08 AM
> To: jeff@ccvcorp.com; tutor@python.org
> Subject: RE: [Tutor] Browser-based Python Interpreter
> 
> 
> AG> > THe 3rd option is not quite the same which is (on Windows
> AG> > at least) to install the Active Scripting support for
> > 
> JS> requires that every *client* have a
> JS> Python interpreter installed, and set up to support 
> JS> ActiveScripting.  
> 
> Good catch. I actually meant to explain that in my message 
> but somewhere between thought and email it got lost. The option
> is fine on an intranet where the environment is controlled, 
> on the internet you really do need to go with Jython.
> 
> Alan G
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


. 

-- 


"This e-mail message may contain confidential, proprietary or legally 
privileged information. It should not be used by anyone who is not the 
original intended recipient. If you have erroneously received this message, 
please delete it immediately and notify the sender. The recipient acknowledges 
that ICICI or its subsidiaries and associated companies (including ICICI Bank)
"ICICI Group", are unable to exercise control or ensure or guarantee the 
integrity of/over the contents of the information contained in e-mail 
transmissions and further acknowledges that any views expressed in this 
message are those of the individual sender and no binding nature of the 
message shall be implied or assumed unless the sender does so expressly with 
due authority of ICICI Group. Before opening any attachments please check them 
for viruses and defects." 


------_=_NextPart_001_01C13760.58908960
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; charset=3Diso-8859-=
1">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version 5.5.2653.12">
<TITLE>RE: [Tutor] Browser-based Python Interpreter</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=3D2>hello,</FONT>
</P>

<P><FONT SIZE=3D2>there was a mail abt NT related automation and somebody m=
entioned WSH.</FONT>
<BR><FONT SIZE=3D2>I have installed it. Alan mentions about &quot;Active Sc=
ripting support for </FONT>
<BR><FONT SIZE=3D2>Python&quot;. Is there another component that I need to =
install after WSH</FONT>
<BR><FONT SIZE=3D2>so that I can proceed ?</FONT>
</P>

<P><FONT SIZE=3D2>I need to be able to start and stop server daemons using =
a script on NT</FONT>
<BR><FONT SIZE=3D2>and havn't coded on win/COM env earlier.</FONT>
</P>

<P><FONT SIZE=3D2>/prasad</FONT>
</P>

<P><FONT SIZE=3D2>&gt; -----Original Message-----</FONT>
<BR><FONT SIZE=3D2>&gt; From: alan.gauld@bt.com [<A HREF=3D"mailto:alan.gau=
ld@bt.com">mailto:alan.gauld@bt.com</A>]</FONT>
<BR><FONT SIZE=3D2>&gt; Sent: Friday, September 07, 2001 3:08 AM</FONT>
<BR><FONT SIZE=3D2>&gt; To: jeff@ccvcorp.com; tutor@python.org</FONT>
<BR><FONT SIZE=3D2>&gt; Subject: RE: [Tutor] Browser-based Python Interpret=
er</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; AG&gt; &gt; THe 3rd option is not quite the same wh=
ich is (on Windows</FONT>
<BR><FONT SIZE=3D2>&gt; AG&gt; &gt; at least) to install the Active Scripti=
ng support for</FONT>
<BR><FONT SIZE=3D2>&gt; &gt; </FONT>
<BR><FONT SIZE=3D2>&gt; JS&gt; requires that every *client* have a</FONT>
<BR><FONT SIZE=3D2>&gt; JS&gt; Python interpreter installed, and set up to =
support </FONT>
<BR><FONT SIZE=3D2>&gt; JS&gt; ActiveScripting.&nbsp; </FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; Good catch. I actually meant to explain that in my =
message </FONT>
<BR><FONT SIZE=3D2>&gt; but somewhere between thought and email it got lost=
. The option</FONT>
<BR><FONT SIZE=3D2>&gt; is fine on an intranet where the environment is con=
trolled, </FONT>
<BR><FONT SIZE=3D2>&gt; on the internet you really do need to go with Jytho=
n.</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; Alan G</FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
<BR><FONT SIZE=3D2>&gt; _______________________________________________</FO=
NT>
<BR><FONT SIZE=3D2>&gt; Tutor maillist&nbsp; -&nbsp; Tutor@python.org</FONT>
<BR><FONT SIZE=3D2>&gt; <A HREF=3D"http://mail.python.org/mailman/listinfo/=
tutor" TARGET=3D"_blank">http://mail.python.org/mailman/listinfo/tutor</A><=
/FONT>
<BR><FONT SIZE=3D2>&gt; </FONT>
</P>
<BR>

<P><B><FONT SIZE=3D2>.. </FONT></B>
</P>

<P>
<FONT FACE=3D"Zurich BT" SIZE=3D1 COLOR=3D"#0000ff"><P>"This e-mail message=
 may contain confidential, proprietary or legally privileged information. I=
t should not be used by anyone who is not the original intended recipient. =
If you have erroneously received this message, please delete it immediately=
 and notify the sender. The recipient acknowledges that ICICI or its subsid=
iaries and associated companies (including ICICI Bank) "ICICI Group", are u=
nable to exercise control or ensure or guarantee the integrity of/over the =
contents of the information contained in e-mail transmissions and further a=
cknowledges that any views expressed in this message are those of the indiv=
idual sender and no binding nature of the message shall be implied or assum=
ed unless the sender does so expressly with due authority of ICICI Group. B=
efore opening any attachments please check them for viruses and defects."</=
P>
</FONT>

</BODY>
</HTML>
------_=_NextPart_001_01C13760.58908960--


From ajaya@ncoretech.com  Fri Sep  7 08:18:29 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Fri, 7 Sep 2001 12:48:29 +0530
Subject: [Tutor] Running Python GUI on Windows and Linux...problems encountered in Windows.
Message-ID: <000201c1376d$4c3f14d0$6501a8c0@ncoretech.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0003_01C1379B.65F750D0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit


Hi,

I've a problem specific to windows. I've developed a simple GUI using
python. My amin is to test with both linux and windows. I've two threads for
it. One for GUI and another for processing. But when I tested with windows
it started hanging...can any one give comments on implementation.

I am jsut attaching my file here with:


from Tkinter import *
import string
import Pmw
from time import sleep
import thread
import sys

class Key(Button):
    def __init__(self, master, font=('arial', 8, 'bold'),
                 fg='white', width=3, bd=3, **kw):
        kw['font'] = font
        kw['fg'] = fg
        kw['width'] = width
        kw['bd'] = bd
        apply(Button.__init__, (self, master), kw)
        self.pack(side=LEFT, expand=YES, fill=BOTH)


class MenuBar(Frame):
    def __init__(self, master, Menus, relief=RAISED, **kw):
        kw['relief'] = relief
        apply(Frame.__init__, (self, master), kw)
        self.pack(side=TOP, expand=YES, fill=BOTH)

        for x in Menus:
            cmdbutn, cmdlist = x
            CommandButton(self, cmdlist, text=cmdbutn)


class CommandButton(Menubutton):
    def __init__(self, MenuBar, commandlist, **kw):
        apply(Menubutton.__init__, (self, MenuBar), kw)
        self.pack(side=LEFT, padx="2m")
        self.menu = Menu(self)
        for x in commandlist:
            L, C, S = x
            self.menu.add_command(label=L, command=C, state=S)

        self['menu'] = self.menu


class PhoneLabel(Frame):
    def __init__(self, master, text):
        Frame.__init__(self, master, bg='gray40')
        self.pack(side=LEFT, expand=YES, fill=BOTH)
        Label(self, text=text, fg='steelblue1', font=("arail", 10, "bold"),
              width=5, bg='gray40').pack(side=LEFT, expand=YES, fill=BOTH)


class VirtualHandSet(Frame):
    def __init__(self, parent=None):
        Frame.__init__(self, bg='gray40')
        self.pack(expand=YES, fill=BOTH)
        self.master.title('Virtual Hand Set')
        self.master.iconname('VHS')
        self.EventQ = []
        self.current = ''
        self.BuildVirtualHandSet()


    def EvalAction(self, action):
        self.EventQ.append(action)




    def EvalKey(self, key):
        self.display.insert(END, key)
        self.current = self.current + key



    def GetEventQ(self):
        return self.EventQ

    def GetDigitMap(self):
        return self.current


    def ConfigMenu(self):
        print 'This is not implemented yet'

    def __del__(self):
        sys.exit(0)


    def BuildVirtualHandSet(self):
        FUN = 1
        KEY = 0
        KC1 = 'gray30'      #Dark Keys
        KC2 = 'gray50'      #Light Keys
        KC3 = 'steelblue1'  #Light Blue Keys
        KC4 = 'steelblue'   #Dark Blue Keys
        OnOffBD = 10
        FunBD = 3
        KeyBD = 3
        Keys = [
                [('ON/OFF', '', FUN, 'OnOff', OnOffBD),
                ],


                  ('Flash', '', FUN, 'Flash', FunBD),
                  ('Mute', '', FUN, 'Mute', FunBD),
                  ('R', '', FUN, 'Redial', FunBD)
                ],
                [ ('1', 'abc', KEY, '1', KeyBD),
                  ('2', 'def', KEY, '2', KeyBD),
                  ('3', 'ghi', KEY, '3', KeyBD),

                ],
                [ ('4', 'jkl', KEY, '4', KeyBD),
                  ('5', 'mno', KEY, '5', KeyBD),
                  ('6', 'pqr', KEY, '6', KeyBD)
                ],
                [
                  ('7', 'stu', KEY, '7', KeyBD),
                  ('8', 'vwx', KEY, '8', KeyBD),
                  ('9', 'yz', KEY, '9', KeyBD)
                ],
                [
                  ('*', '', KEY, '*', KeyBD),
                  ('0', '', KEY, '0', KeyBD),
                  ('#', '', KEY, '#', KeyBD)

                ]
               ]

        MenuItems = [ ('Config', [('IP Parameters', self.ConfigMenu,
DISABLED),
                                  ('Layout', self.ConfigMenu, DISABLED)
                                 ]

                      )


                    ]


        MenuBar(self, MenuItems,relief=RAISED, bd=1)

        self.display = Pmw.ScrolledText(self, hscrollmode='dynamic',
                                  vscrollmode='dynamic',
                                  hull_relief='sunken',
                                  hull_background='gray40',
                                  hull_borderwidth=3,
                                  text_background='honeydew4',
                                  text_width=20,
                                  text_foreground='black',
                                  text_height=3,
                                  text_padx=10, text_pady=10,
                                  text_relief='groove',
                                  text_font=('arial', 12, 'bold'))
        self.display.pack(side=TOP, expand=YES, fill=BOTH)

        for row in Keys:
            rowa = Frame(self, bg='gray40')
            rowb = Frame(self, bg='gray40')
            for p1, p2, ktype, func, bd in row:
                PhoneLabel(rowa, text=p2)
                if ktype == FUN:
                    a = lambda s=self, a=func: s.EvalAction(a)
                    Key(rowb, text=p1, bg=KC4, bd=bd, command=a)
                else:
                    a = lambda s=self, k=func: s.EvalKey(k)
                    Key(rowb, text=p1, bg=KC1, bd=bd, command=a)

            rowa.pack(side=TOP, expand=YES, fill=BOTH)
            rowb.pack(side=TOP, expand=YES, fill=BOTH)









class VirtualHandSetProcessor:
    def __init__(self):
        self.handset = VirtualHandSet()
#        self.Pipe = TcpIpPipe()
        thread.start_new_thread(self.WorkerThread, ())

    def WorkerThread(self):
        while(1):
            print 'Hello'
            print self.handset.GetEventQ()
            sleep(1)



if __name__ == '__main__':
    print "Hello"
    a = VirtualHandSetProcessor()
    print "Hello"

------=_NextPart_000_0003_01C1379B.65F750D0
Content-Type: text/plain;
	name="utils.py"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="utils.py"

from Tkinter import *
import string
import Pmw
from time import sleep
import thread
import sys

class Key(Button):
    def __init__(self, master, font=3D('arial', 8, 'bold'),
                 fg=3D'white', width=3D3, bd=3D3, **kw):
        kw['font'] =3D font
        kw['fg'] =3D fg
        kw['width'] =3D width
        kw['bd'] =3D bd
        apply(Button.__init__, (self, master), kw)
        self.pack(side=3DLEFT, expand=3DYES, fill=3DBOTH)


class MenuBar(Frame):
    def __init__(self, master, Menus, relief=3DRAISED, **kw):
        kw['relief'] =3D relief
        apply(Frame.__init__, (self, master), kw)
        self.pack(side=3DTOP, expand=3DYES, fill=3DBOTH)

        for x in Menus:
            cmdbutn, cmdlist =3D x
            CommandButton(self, cmdlist, text=3Dcmdbutn)
           =20
           =20
class CommandButton(Menubutton):
    def __init__(self, MenuBar, commandlist, **kw):
        apply(Menubutton.__init__, (self, MenuBar), kw)
        self.pack(side=3DLEFT, padx=3D"2m")
        self.menu =3D Menu(self)
        for x in commandlist:
            L, C, S =3D x
            self.menu.add_command(label=3DL, command=3DC, state=3DS)

        self['menu'] =3D self.menu
           =20

class PhoneLabel(Frame):
    def __init__(self, master, text):
        Frame.__init__(self, master, bg=3D'gray40')
        self.pack(side=3DLEFT, expand=3DYES, fill=3DBOTH)
        Label(self, text=3Dtext, fg=3D'steelblue1', font=3D("arail", 10, =
"bold"),
              width=3D5, bg=3D'gray40').pack(side=3DLEFT, expand=3DYES, =
fill=3DBOTH)


class VirtualHandSet(Frame):
    def __init__(self, parent=3DNone):
        Frame.__init__(self, bg=3D'gray40')
        self.pack(expand=3DYES, fill=3DBOTH)
        self.master.title('Virtual Hand Set')
        self.master.iconname('VHS')
        self.EventQ =3D []
        self.current =3D ''
        self.BuildVirtualHandSet()
       =20

    def EvalAction(self, action):
        self.EventQ.append(action)

       =20
       =20
   =20
    def EvalKey(self, key):
        self.display.insert(END, key)
        self.current =3D self.current + key
      =20
       =20

    def GetEventQ(self):
        return self.EventQ

    def GetDigitMap(self):
        return self.current


    def ConfigMenu(self):
        print 'This is not implemented yet'

    def __del__(self):
        sys.exit(0)
    =20

    def BuildVirtualHandSet(self):
        FUN =3D 1
        KEY =3D 0
        KC1 =3D 'gray30'      #Dark Keys
        KC2 =3D 'gray50'      #Light Keys
        KC3 =3D 'steelblue1'  #Light Blue Keys
        KC4 =3D 'steelblue'   #Dark Blue Keys
        OnOffBD =3D 10
        FunBD =3D 3
        KeyBD =3D 3
        Keys =3D [
                [('ON/OFF', '', FUN, 'OnOff', OnOffBD),
                ],
                [=20
                  ('Flash', '', FUN, 'Flash', FunBD),
                  ('Mute', '', FUN, 'Mute', FunBD),
                  ('R', '', FUN, 'Redial', FunBD)
                ],
                [ ('1', 'abc', KEY, '1', KeyBD),
                  ('2', 'def', KEY, '2', KeyBD),
                  ('3', 'ghi', KEY, '3', KeyBD),
                 =20
                ],
                [ ('4', 'jkl', KEY, '4', KeyBD), =20
                  ('5', 'mno', KEY, '5', KeyBD),
                  ('6', 'pqr', KEY, '6', KeyBD)
                ],
                [
                  ('7', 'stu', KEY, '7', KeyBD),
                  ('8', 'vwx', KEY, '8', KeyBD),
                  ('9', 'yz', KEY, '9', KeyBD)
                ],
                [
                  ('*', '', KEY, '*', KeyBD),
                  ('0', '', KEY, '0', KeyBD),
                  ('#', '', KEY, '#', KeyBD)

                ]
               ]

        MenuItems =3D [ ('Config', [('IP Parameters', self.ConfigMenu, =
DISABLED),
                                  ('Layout', self.ConfigMenu, DISABLED)  =

                                 ]
       =20
                      )
                   =20

                    ]

       =20
        MenuBar(self, MenuItems,relief=3DRAISED, bd=3D1)
               =20
        self.display =3D Pmw.ScrolledText(self, hscrollmode=3D'dynamic',
                                  vscrollmode=3D'dynamic',
                                  hull_relief=3D'sunken',
                                  hull_background=3D'gray40',
                                  hull_borderwidth=3D3,
                                  text_background=3D'honeydew4',
                                  text_width=3D20,
                                  text_foreground=3D'black',
                                  text_height=3D3,
                                  text_padx=3D10, text_pady=3D10,
                                  text_relief=3D'groove',
                                  text_font=3D('arial', 12, 'bold'))
        self.display.pack(side=3DTOP, expand=3DYES, fill=3DBOTH)

        for row in Keys:
            rowa =3D Frame(self, bg=3D'gray40')
            rowb =3D Frame(self, bg=3D'gray40')
            for p1, p2, ktype, func, bd in row:
                PhoneLabel(rowa, text=3Dp2)
                if ktype =3D=3D FUN:
                    a =3D lambda s=3Dself, a=3Dfunc: s.EvalAction(a)
                    Key(rowb, text=3Dp1, bg=3DKC4, bd=3Dbd, command=3Da)
                else:
                    a =3D lambda s=3Dself, k=3Dfunc: s.EvalKey(k)
                    Key(rowb, text=3Dp1, bg=3DKC1, bd=3Dbd, command=3Da)
                   =20
            rowa.pack(side=3DTOP, expand=3DYES, fill=3DBOTH)
            rowb.pack(side=3DTOP, expand=3DYES, fill=3DBOTH)

   =20
       =20
   =20





class VirtualHandSetProcessor:
    def __init__(self):
        self.handset =3D VirtualHandSet()
#        self.Pipe =3D TcpIpPipe()
        thread.start_new_thread(self.WorkerThread, ())

    def WorkerThread(self):
        while(1):
            print 'Hello'
            print self.handset.GetEventQ()
            sleep(1)



if __name__ =3D=3D '__main__':
    print "Hello"
    a =3D VirtualHandSetProcessor()
    print "Hello"
   =20

   =20


       =20
       =20
   =20
   =20


       =20
       =20
       =20
       =20
       =20
   =20

       =20

------=_NextPart_000_0003_01C1379B.65F750D0--



From wheelege@tsn.cc  Fri Sep  7 09:40:56 2001
From: wheelege@tsn.cc (wheelege)
Date: Fri, 7 Sep 2001 18:40:56 +1000
Subject: [Tutor] Running Python GUI on Windows and Linux...problems encountered in Windows.
References: <000201c1376d$4c3f14d0$6501a8c0@ncoretech.com>
Message-ID: <006301c13778$d03f5820$b9a616ca@ACE>

  Hi,

  I had similar problems with a tkinter game I developed for the place I
work for (pong+arkanoid, networked scores, network multiplayer...etc) and I
had hell with this exact error.
  The way to fix it is to do >zero< GUI calls in any thread other than the
main one.  This is a little trickier than it sounds, but very possible.

> <...>
>
>
> class VirtualHandSetProcessor:
>     def __init__(self):
>         self.handset = VirtualHandSet()
> #        self.Pipe = TcpIpPipe()
>         thread.start_new_thread(self.WorkerThread, ())
>
>     def WorkerThread(self):
>         while(1):
>             print 'Hello'
>             print self.handset.GetEventQ()
>             sleep(1)

  I didn't use this exact architecture but I think here is where your
problem may lie.
  You have the same instance of a class with two threads - one which is
heavy GUI and one which looks like it has only processing.  However, with
the line 'print self.handset.GetEventQ()' you are accessing a function from
an object which is in use by the other main GUI thread, for GUI type calls.
This is what I think you need to fix.
  Perhaps use a dummy object with some attributes (no GUI stuff) and get the
while 1 loop to check it's attributes for changes instead of polling the
handset object (of the VirtualHandSet class).  This would mean that whenever
an event occured you would have to append it to the dummy object instead of
itself, but this should be only a minor code change.
  I'll just append this discaimer here - I did not use this exact object
structure so I may well be wrong :)

>
>
>
> if __name__ == '__main__':
>     print "Hello"
>     a = VirtualHandSetProcessor()
>     print "Hello"
>



From Charlie@begeistert.org  Fri Sep  7 10:17:37 2001
From: Charlie@begeistert.org (Charlie Clark)
Date: Fri, 07 Sep 2001 11:17:37 +0200
Subject: [Tutor] Problem with IDLE in Windows
Message-ID: <999854257_PM_BeOS.Charlie@begeistert.org>

Dear list,

can anyone tell me why this line causes problems when I try to edit the 
file in IDLE under windows? It seems that the ´ is a unicode symbol 
that causes IDLE to throw a unicode -> ascii error and delete the file. 
Does this count as a bug?

content = "some text"
content = content.replace( "'":"´")

Any suggestions for an alternative? I need to replace simple apostrophes 
with something else as they get inserted into an SQL statement which 
subsequently doesn't work if they are kept.

Thanx

Charlie




From ajaya@ncoretech.com  Fri Sep  7 10:17:24 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Fri, 7 Sep 2001 14:47:24 +0530
Subject: [Tutor] Running Python GUI on Windows and Linux...problems encountered in Windows.
In-Reply-To: <006301c13778$d03f5820$b9a616ca@ACE>
Message-ID: <000801c1377d$e8a63190$6501a8c0@ncoretech.com>

Hi Wheelege,

Thanks allot for your help, Yes! what exactly you told is the problem.

Perhaps...it is not because of the call the the object wich is alredy used
in GUI...(may cause problems...yet to test
throughly)..self.handset.GetEventQ()

But for the movement the print state ment associated with this...


> <...>
>

 class VirtualHandSetProcessor:
     def __init__(self):
         self.handset = VirtualHandSet()
#        self.Pipe = TcpIpPipe()
         thread.start_new_thread(self.WorkerThread, ())

     def WorkerThread(self):
         while(1):
------>      #print 'Hello'
------>      #print self.handset.GetEventQ()
             sleep(1)

I've tested by commenting this prints and calling
		a = self.handset.GetEventQ() in the while(1) loop..., now this is working
fine..,
but as you said there may be problems that I will face later...

One more two requests I've...,

First thing is I am a C++ programmer...can you suggest some good site or
meterial...which gives
good information about the python oriented design...,

Second one is in the above code I want to disable the maximizing option....,
For that I was jut thinking using protocol to register my class methods
...for WM_ messages...but I've very few documents available on it...could
you please suggest some reference to document..


Thanks allot for your great help

with regards,
Ajaya



-----Original Message-----
From: wheelege [mailto:wheelege@tsn.cc]
Sent: Friday, September 07, 2001 2:11 PM
To: Ajaya Babu; PythonTutorlist (E-mail)
Subject: Re: [Tutor] Running Python GUI on Windows and Linux...problems
encountered in Windows.



  Hi,

  I had similar problems with a tkinter game I developed for the place I
work for (pong+arkanoid, networked scores, network multiplayer...etc) and I
had hell with this exact error.
  The way to fix it is to do >zero< GUI calls in any thread other than the
main one.  This is a little trickier than it sounds, but very possible.

> <...>
>
>
> class VirtualHandSetProcessor:
>     def __init__(self):
>         self.handset = VirtualHandSet()
> #        self.Pipe = TcpIpPipe()
>         thread.start_new_thread(self.WorkerThread, ())
>
>     def WorkerThread(self):
>         while(1):
>             print 'Hello'
>             print self.handset.GetEventQ()
>             sleep(1)

  I didn't use this exact architecture but I think here is where your
problem may lie.
  You have the same instance of a class with two threads - one which is
heavy GUI and one which looks like it has only processing.  However, with
the line 'print self.handset.GetEventQ()' you are accessing a function from
an object which is in use by the other main GUI thread, for GUI type calls.
This is what I think you need to fix.
  Perhaps use a dummy object with some attributes (no GUI stuff) and get the
while 1 loop to check it's attributes for changes instead of polling the
handset object (of the VirtualHandSet class).  This would mean that whenever
an event occured you would have to append it to the dummy object instead of
itself, but this should be only a minor code change.
  I'll just append this discaimer here - I did not use this exact object
structure so I may well be wrong :)

>
>
>
> if __name__ == '__main__':
>     print "Hello"
>     a = VirtualHandSetProcessor()
>     print "Hello"
>



From ajaya@ncoretech.com  Fri Sep  7 11:22:18 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Fri, 7 Sep 2001 15:52:18 +0530
Subject: [Tutor] is there any way to read key configuration..!
Message-ID: <000001c13786$f9f9fd60$6501a8c0@ncoretech.com>

Hi,

Tkinter programming guys..., is there any method to call get Key
configureation to read. I want it becasue it gives the flexibility to change
relief artribute from RAISED to SUNKEN and vice versa

Thanks and Regards,
Ajaya



From koen@behindthesofa.dhs.org  Fri Sep  7 11:36:45 2001
From: koen@behindthesofa.dhs.org (Koen Bossers)
Date: Fri, 07 Sep 2001 12:36:45 +0200
Subject: [Tutor] is there any way to read key configuration..!
References: <000001c13786$f9f9fd60$6501a8c0@ncoretech.com>
Message-ID: <3B98A33D.4070707@behindthesofa.dhs.org>

 >>> from Tkinter import *
 >>> root =Tk()
 >>> label = Label(root, text="Hi there")
 >>> label.pack()
 >>> label.cget('relief')
'flat'
 >>> label.config(relief=SUNKEN)
 >>> label.cget('relief')
'sunken'

Take a good look at 
http://www.pythonware.com/library/tkinter/introduction/index.htm, Basic 
Widget Methods.

Cheers, Koen

Ajaya Babu wrote:

>Hi,
>
>Tkinter programming guys..., is there any method to call get Key
>configureation to read. I want it becasue it gives the flexibility to change
>relief artribute from RAISED to SUNKEN and vice versa
>
>Thanks and Regards,
>Ajaya
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>





From kalle@gnupung.net  Fri Sep  7 12:12:27 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Fri, 7 Sep 2001 13:12:27 +0200
Subject: [Tutor] sending stdout to a text box
In-Reply-To: <Pine.GSO.4.21L1.0109061711520.10065-100000@sunny>; from bill_tolbert@bigfoot.com on Thu, Sep 06, 2001 at 05:20:56PM -0400
References: <Pine.GSO.4.21L1.0109061711520.10065-100000@sunny>
Message-ID: <20010907131227.A13160@gandalf>

[Bill Tolbert]
> I have a script which works well; it sends messages to the console when
> run from a prompt. How can I catch this and route it to a text box in
> tkinter?

Something like this might work:

> from Tkinter import *

class BogusFile:
    def __init__(self, text):
        self.text = text
    def write(self, s):
        self.text.insert(END, s)

> class App:
> 
> ##  Create GUI 
> 
>     def __init__(self, master):
> 
>         frame = Frame(master)
>         frame.pack()
>         self.t = StringVar()
> 	# this line doesn't work
>         #self.text_box = Text(frame, textvariable=self.t)
>         self.text_box = Text(frame)
>         self.text_box.pack()
>         
> 	# this call to dobackup works but no redirect of stdout
>         self.dobackup = Button(frame, text="Do Backup",
> 				command=self.backup)
> 
>         self.dobackup.pack(side=TOP)
> 
>     def backup(self):
>         import ICAREBackup
>         #self.t = sys.stdout
>         #sys.stdout = self.t

          sys.stdout = BogusFile(self.text_box)

>         ICAREBackup.ICAREBackup()
> 
> root = Tk()
> 
> app = App(root)
> 
> root.mainloop()
> 

Incredibly untested, but might work.

Peace,
  Kalle
-- 
[  kalle@gnupung.net  ][ Thought control, brought to you by the WIPO! ]
[ http://gnupung.net/ ][ http://anti-dmca.org/ http://eurorights.org/ ]


From tzuming@sanbi.ac.za  Fri Sep  7 12:58:05 2001
From: tzuming@sanbi.ac.za (Tzu-Ming Chern)
Date: Fri, 7 Sep 2001 13:58:05 +0200 (SAST)
Subject: [Tutor] processing files in a directory
Message-ID: <Pine.BSF.4.21.0109071353560.14683-100000@fling.sanbi.ac.za>

Hi,

Basically I would like to go into a single directory and a run my other
script on those individual files present in the directory. I'm having
headaches using perl to try and process these files since I keep
overwriting the files. Is there an easier solution?

With thanks,

tzuming













******************************************************************************
Tzu-Ming Chern 
South African National Bioinformatics Institute
University of Western Cape
PO box X17
Bellville
Cape Town
South Africa
Tel#:27-21-959-3908/3645
Fax:27-21-959-2512
Email:tzuming@fling.sanbi.ac.za

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++






From Charlie@begeistert.org  Fri Sep  7 13:08:05 2001
From: Charlie@begeistert.org (Charlie Clark)
Date: Fri, 07 Sep 2001 14:08:05 +0200
Subject: [Tutor] Selection of Plaform specific modules
Message-ID: <999864485_PM_BeOS.Charlie@begeistert.org>

For some database work I've written the following little function in a 
tools module

def check_platform():
	if sys.version.find("MSC") >= 0:
		base_path = "viven/"
		from mx.ODBC.Windows import DriverConnect
	else:
		base_path = ""
	return base_path

It works fine when I call but it doesn't make the imported module 
available. What do I need to change this?

Charlie



From rnd@onego.ru  Fri Sep  7 13:22:11 2001
From: rnd@onego.ru (Roman Suzi)
Date: Fri, 7 Sep 2001 16:22:11 +0400 (MSD)
Subject: [Tutor] processing files in a directory
In-Reply-To: <Pine.BSF.4.21.0109071353560.14683-100000@fling.sanbi.ac.za>
Message-ID: <Pine.LNX.4.21.BCL.0109071618130.5424-100000@suzi.com.onego.ru>

On Fri, 7 Sep 2001, Tzu-Ming Chern wrote:

> 
> Hi,
> 
> Basically I would like to 

import os
# go into a single directory and 

os.chdir("single")

# a run my other script on those individual files present in the directory

other_script = "other.py"
for file in os.listdir("."):    # or glob.glob("*")
  os.system(other_script + " " + file)

> I'm having
> headaches using perl to try and process these files since I keep
> overwriting the files. Is there an easier solution?

???

> With thanks,

Sincerely yours, Roman A.Suzi
-- 
 - Petrozavodsk - Karelia - Russia - mailto:rnd@onego.ru -
 



From dsh8290@rit.edu  Fri Sep  7 14:26:25 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 7 Sep 2001 09:26:25 -0400
Subject: [Tutor] Selection of Plaform specific modules
In-Reply-To: <999864485_PM_BeOS.Charlie@begeistert.org>; from Charlie@begeistert.org on Fri, Sep 07, 2001 at 02:08:05PM +0200
References: <999864485_PM_BeOS.Charlie@begeistert.org>
Message-ID: <20010907092625.E23012@harmony.cs.rit.edu>

On Fri, Sep 07, 2001 at 02:08:05PM +0200, Charlie Clark wrote:
| For some database work I've written the following little function in a 
| tools module
| 
| def check_platform():
| 	if sys.version.find("MSC") >= 0:
| 		base_path = "viven/"
| 		from mx.ODBC.Windows import DriverConnect

This line causes the reference to the module to be in the function's
local scope.  You want it to be in some sort of global scope, or
return it from the function and let the client stick it in the global
scope.  (Since you already have a return value make it a 2-tuple
instead)

-D



From lumbricus@gmx.net  Fri Sep  7 11:53:12 2001
From: lumbricus@gmx.net (Joerg Woelke)
Date: Fri, 7 Sep 2001 12:53:12 +0200
Subject: [Tutor] Problem with IDLE in Windows
In-Reply-To: <999854257_PM_BeOS.Charlie@begeistert.org>; from Charlie@begeistert.org on Fri, Sep 07, 2001 at 11:17:37AM +0200
References: <999854257_PM_BeOS.Charlie@begeistert.org>
Message-ID: <20010907125312.A1868@Laplace.localdomain>

On Fri, Sep 07, 2001 at 11:17:37AM +0200, Charlie Clark wrote:
> Dear list,
> 
> can anyone tell me why this line causes problems when I try to edit the 
> file in IDLE under windows? 

No sorry! 

It seems that the ´ is a unicode symbol 
> that causes IDLE to throw a unicode -> ascii error and delete the file. 
> Does this count as a bug?
> 
> content = "some text"
> content = content.replace( "'":"´")

Have you tried "\264"?

> 
> Any suggestions for an alternative? I need to replace simple apostrophes 
> with something else as they get inserted into an SQL statement which 
> subsequently doesn't work if they are kept.
> 
> Thanx
> 
> Charlie
> 

HTH,HAND
J"o!

-- 
"It's a dog-eat-dog world out there, and I'm wearing Milkbone underware."
-- Norm, from _Cheers_


From alan.gauld@bt.com  Fri Sep  7 15:26:25 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 7 Sep 2001 15:26:25 +0100
Subject: [Tutor] Browser-based Python Interpreter
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF30@mbtlipnt02.btlabs.bt.co.uk>

------_=_NextPart_001_01C137A9.1367B950
Content-type: text/plain; charset="iso-8859-1"

there was a mail abt NT related automation and somebody mentioned WSH. 
I have installed it. Alan mentions about "Active Scripting support for 
Python". Is there another component that I need to install after WSH 
so that I can proceed ?  

Once you have WSH and Python installed you need to
also install the winall package(already done if you 
used the ActiveState Python in the first place)
 
Now you can take either of two routes:
 
1) Install activeScripting by running a file within the 
   winall package. This allows you to write .pys WSH 
   scripts and run them using wscript.exe or cscript.exe
 
2) Just use winall's native COM facilities to create 
   the WSH COM objects - this seems to be Mark Hamonds 
   personal favourite method.
 
Using method 1 and stealing an example from Marks Win32 
book we get the following example:
 
######## wshtest.pys #######
WScript.Echo('The script is: ',WScript.SciptName) # Use WSH natively
if len(WScript.Arguments):
   wshell = WScript.CreateObject("WScript.Shell")
   wshell.Run("notepad.exe " + WScript.Arguments(0))
else:
   WScript.Echo('No arguments passed')
 
############################
 
Run it by entering 
C:\> cscript wshtest.pys  foo bar 
at a DOS prompt or
C:\> wscript wshtest.pys baz
to get GUI style messages
 
 
Doing the same in native Python requires a mix of WSH 
and raw Python:
 
######## wshtest.py ########
from win32com.client import Dispatch
import sys
 
print 'The script is: ',sys.argv[0]

if len(sys.argv) > 1:
   wshell = Dispatch("WScript.Shell")
   wshell.Run("notepad.exe "+sys.argv[1])
else:
   print 'No arguments passed'

############################
 
HTH,
 
Alan g
 


------_=_NextPart_001_01C137A9.1367B950
Content-type: text/html; charset="iso-8859-1"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>RE: [Tutor] Browser-based Python Interpreter</TITLE>

<META content="MSHTML 5.00.3013.2600" name=GENERATOR></HEAD>
<BODY>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
  <P><FONT size=2>there was a mail abt NT related automation and somebody 
  mentioned WSH.</FONT> <BR><FONT size=2>I have installed it. Alan mentions 
  about "Active Scripting support for </FONT><BR><FONT size=2>Python". Is there 
  another component that I need to install after WSH</FONT> <BR><FONT size=2>so 
  that I can proceed ?</FONT>&nbsp;<FONT color=#0000ff face="Courier New" 
  size=2><SPAN class=150565113-07092001>&nbsp;</SPAN></FONT></P></BLOCKQUOTE>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>Once you have WSH and Python installed you need 
to</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>also install the winall package(already done if you 
</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>used the ActiveState Python in the first 
place)</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>Now you c</SPAN></FONT><FONT color=#0000ff 
face="Courier New" size=2><SPAN class=150565113-07092001>an take 
</SPAN></FONT><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>either of two routes:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>1) Install activeScripting by running a file within the 
</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>&nbsp;&nbsp;&nbsp;winall package. This allows you to 
write .pys WSH </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>&nbsp;&nbsp; scripts and run them using wscript.exe or 
cscript.exe</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>2) Just use winall's native COM facilities to create 
</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>&nbsp;&nbsp;&nbsp;the WSH COM objects - this seems to 
be Mark Hamonds </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>&nbsp;&nbsp;&nbsp;personal favourite 
method.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>Using method&nbsp;1 and stealing an example from Marks 
Win32 </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>book we get the following example:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>######## wshtest.pys #######</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>WScript.Echo('The script is: ',WScript.SciptName) # Use 
WSH natively</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>if len(WScript.Arguments):</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>&nbsp;&nbsp; wshell = 
WScript.CreateObject("WScript.Shell")</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>&nbsp;&nbsp; wshell.Run("notepad.exe " + 
WScript.Arguments(0))</SPAN></FONT></DIV></SPAN></FONT><FONT color=#0000ff 
face="Courier New" size=2><SPAN 
class=150565113-07092001>else:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>&nbsp;&nbsp; WScript.Echo('No arguments 
passed')</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>############################</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>Run it by entering </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>C:\&gt; cscript wshtest.pys&nbsp; foo bar 
</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>at a DOS prompt or</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>C:\&gt; wscript wshtest.pys baz</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>to get GUI style messages</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>Doing the same in native Python requires&nbsp;a mix of 
WSH </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>and raw Python:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>######## wshtest.py ########</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>from win32com.client import 
Dispatch</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>import sys</SPAN></FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>print 'The script is: ',sys.argv[0]</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001><BR>if len(sys.argv) &gt; 1:<BR>&nbsp;&nbsp; wshell = 
Dispatch("WScript.Shell")<BR>&nbsp;&nbsp; wshell.Run("notepad.exe 
"+sys.argv[1])<BR>else:<BR>&nbsp;&nbsp; print 'No arguments 
passed'<BR></SPAN></FONT></DIV></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>############################</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>HTH,</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=150565113-07092001>Alan g</SPAN></FONT></DIV><FONT color=#0000ff 
face="Zurich BT" size=1>
<P 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">&nbsp;</P></FONT></BODY></HTML>

------_=_NextPart_001_01C137A9.1367B950--


From urnerk@qwest.net  Fri Sep  7 18:06:51 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Fri, 07 Sep 2001 10:06:51 -0700
Subject: [Tutor] Problem with IDLE in Windows
In-Reply-To: <999854257_PM_BeOS.Charlie@begeistert.org>
Message-ID: <4.2.0.58.20010907100541.00cf3240@pop3.norton.antivirus>

>
>Does this count as a bug?
>
>content =3D "some text"
>content =3D content.replace( "'":"=B4")


I just ran this in IDLE 0.8 in Windows with no problems,
except the syntax is , in place of :

Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)]
on win32 Type "copyright", "credits" or "license" for more
information.
IDLE 0.8 -- press F1 for help

 >>> content =3D "some text"
 >>> content =3D content.replace( "'":"=B4")
SyntaxError: invalid syntax
 >>> content =3D content.replace( "'","=B4")
 >>> content
'some text'

Kirby




From urnerk@qwest.net  Fri Sep  7 18:30:27 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Fri, 07 Sep 2001 10:30:27 -0700
Subject: [Tutor] Problem with IDLE in Windows
In-Reply-To: <4.2.0.58.20010907100541.00cf3240@pop3.norton.antivirus>
References: <999854257_PM_BeOS.Charlie@begeistert.org>
Message-ID: <4.2.0.58.20010907102751.00cf51d0@pop3.norton.antivirus>

>
> >>> content =3D content.replace( "'","=B4")
> >>> content
>'some text'
>
>Kirby

Sorry, this wasn't a good test anyway, because "some text"
doesn't have an apostrophe to replace in it, and single-
quote is what you get back from __repr__ even if you
double quote a string i.e.

   >>> content =3D "some test"
   >>> content
   'some test'

So my little test above does precisely nothing.

However:

   >>> content =3D "some ' test"
   >>> content.replace("'","`")
   'some ` test'

The ' was replaced with a `.  So is there a problem
here?  Maybe we're using different versions of
Windows Python/IDLE.

Kirby



From dyoo@hkn.eecs.berkeley.edu  Fri Sep  7 18:50:07 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 7 Sep 2001 10:50:07 -0700 (PDT)
Subject: [Tutor] Problem with IDLE in Windows
In-Reply-To: <999854257_PM_BeOS.Charlie@begeistert.org>
Message-ID: <Pine.LNX.4.21.0109071040380.12164-100000@hkn.eecs.berkeley.edu>

On Fri, 7 Sep 2001, Charlie Clark wrote:

> can anyone tell me why this line causes problems when I try to edit the=
=20
> file in IDLE under windows? It seems that the =B4 is a unicode symbol=20
> that causes IDLE to throw a unicode -> ascii error and delete the file.=
=20
> Does this count as a bug?
>=20
> content =3D "some text"
> content =3D content.replace( "'":"=B4")


Under a regular Python (2.1) shell (without IDLE), this works:

###
>>> content =3D "some text with a ' quote"
>>> content =3D content.replace("'", "")
>>> content
'some text with a \xb4 quote
###


Can anyone confirm that it's IDLE that's doing something weird?


> Any suggestions for an alternative? I need to replace simple
> apostrophes with something else as they get inserted into an SQL
> statement which subsequently doesn't work if they are kept.

Are you using the parameterized style of SQL querying?  If so, then you
don't need to worry so much about properly quoting things.  For example,
instead of:

###
fname, lname =3D 'Issac', 'Asimov'
cursor.execute("""insert into authors (fname, lname)
                  values ('%s', '%s')""" % (fname, lname))
###

we can use:

###
fname, lname =3D 'Issac', 'Asimov'
cursor.execute("""insert into authors (fname, lname)
                  values (?, ?)""", fname, lname)
###

The database handler should then take care of the quoting for you, and
should even escape any apostrophies in strings we insert into the
database.  The topic guide touches on this a little when it talks about
"paramstyle":

    http://python.org/topics/database/DatabaseAPI-2.0.html


Hope this helps!



From dyoo@hkn.eecs.berkeley.edu  Fri Sep  7 18:56:03 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 7 Sep 2001 10:56:03 -0700 (PDT)
Subject: [Tutor] processing files in a directory
In-Reply-To: <Pine.BSF.4.21.0109071353560.14683-100000@fling.sanbi.ac.za>
Message-ID: <Pine.LNX.4.21.0109071051360.12164-100000@hkn.eecs.berkeley.edu>

On Fri, 7 Sep 2001, Tzu-Ming Chern wrote:

> Basically I would like to go into a single directory and a run my
> other script on those individual files present in the directory. I'm

Using the glob.glob() function will give you a list of files in a specific
directory:

###
>>> glob.glob('*.txt')
['notes.txt']
###

This works identically to Perl's globbing operator '<>'.


> having headaches using perl to try and process these files since I
> keep overwriting the files. Is there an easier solution?

Hmmm!  Can you explain a little more about how you're processing the
files?  Are you replacing content in each of those files?



From rick@niof.net  Fri Sep  7 19:09:19 2001
From: rick@niof.net (Rick Pasotto)
Date: Fri, 7 Sep 2001 14:09:19 -0400
Subject: [Tutor] using 'mailbox'
Message-ID: <20010907140918.D20746@tc.niof.net>

What am I overlooking? I have a file in unix mailbox format that I would
like to process by changing the body of each message. Using the mailbox
module I can get and deal with the headers but I'm not seeing how to
deal with the body.

-- 
"The whole aim of practical politics is to keep the populace alarmed -- and
thus clamorous to be led to safety -- by menacing it with an endless series
of hobgoblins, all of them imaginary." -- H.L. Mencken
		Rick Pasotto email: rickp@telocity.com
		               web: www.niof.net


From sheila@thinkspot.net  Fri Sep  7 19:24:17 2001
From: sheila@thinkspot.net (Sheila King)
Date: Fri, 07 Sep 2001 11:24:17 -0700
Subject: [Tutor] using 'mailbox'
In-Reply-To: <20010907140918.D20746@tc.niof.net>
References: <20010907140918.D20746@tc.niof.net>
Message-ID: <870DA1B3A5C@kserver.org>

On Fri, 7 Sep 2001 14:09:19 -0400, Rick Pasotto <rick@niof.net>  wrote
about [Tutor] using 'mailbox':

:What am I overlooking? I have a file in unix mailbox format that I would
:like to process by changing the body of each message. Using the mailbox
:module I can get and deal with the headers but I'm not seeing how to
:deal with the body.

from the mailbox module docs:
"By defaul this is an rfc822.Message object (see the rfc822 module)."

The rfc822.Message object is only the headers. You need to read in the
message body separately.

When an instance of an rfc822.Message has just been read in, the file
pointer will be at the beginning of the message body. Read that in, I
guess.

Alternately, I have some code I've been working on (in very rough form)
that subclasses rfc822.Message and will read in separate messages in
mbox format (I've used it for such myself, for some utilities I've
worked with). If you are interested in that, give me a shout and I'll
send you what I have.

Also, if you'd just like to see examples how to read in message bodies
when working with rfc822.Message, I can give examples of those, also.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/



From rick@niof.net  Fri Sep  7 20:16:54 2001
From: rick@niof.net (Rick Pasotto)
Date: Fri, 7 Sep 2001 15:16:54 -0400
Subject: [Tutor] using 'mailbox'
In-Reply-To: <870DA1B3A5C@kserver.org>
References: <20010907140918.D20746@tc.niof.net> <870DA1B3A5C@kserver.org>
Message-ID: <20010907151654.F20746@tc.niof.net>

On Fri, Sep 07, 2001 at 11:24:17AM -0700, Sheila King wrote:
> On Fri, 7 Sep 2001 14:09:19 -0400, Rick Pasotto <rick@niof.net>  wrote
> about [Tutor] using 'mailbox':
> 
> :What am I overlooking? I have a file in unix mailbox format that I would
> :like to process by changing the body of each message. Using the mailbox
> :module I can get and deal with the headers but I'm not seeing how to
> :deal with the body.
> 
> from the mailbox module docs:
> "By defaul this is an rfc822.Message object (see the rfc822 module)."
> 
> The rfc822.Message object is only the headers. You need to read in the
> message body separately.

This is what I didn't know how to do. Just figured it out.

>>> import mailbox
>>> filep = open('mbox')
>>> mb = mailbox.UnixMailbox(filep)
>>> msg = mb.next()
>>> body = msg.fp.readlines()

Now msg contains all the headers and body contains the rest of the
message.

Repeat the last two lines as needed.

-- 
Certain nations seem particularly liable to fall prey to
governmental plunder. They are those in which men, lacking faith
in their own dignity and capability, would feel themselves lost if
they were not governed and administered every step of the way.
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net


From bill_tolbert@bigfoot.com  Fri Sep  7 20:38:59 2001
From: bill_tolbert@bigfoot.com (Bill Tolbert)
Date: Fri, 7 Sep 2001 15:38:59 -0400 (EDT)
Subject: [Tutor] using 'mailbox'
In-Reply-To: <20010907151654.F20746@tc.niof.net>
Message-ID: <Pine.GSO.4.21L1.0109071532380.20924-100000@sunny>

Here's some sample code that reads a mailbox file and outputs the headers,
body, and information about the attachments. It was specifically written
to parse a Calypso mailbox archive and stuff the values into a
database. Pass in the full name and path of the mailbox file as an
argument.

Bill

# Read a Calypso mailbox in archive format
# Tolbert, 10/3/00
import sys
import string
import cStringIO
import cgi, rfc822
import os

def IndexMailArchive(archive):
    mb = open(archive,"r")
    msg = rfc822.Message(mb)
    while msg.items():
            gFrom = msg.getheader('from')
            gSub = msg.getheader('subject')
            gTo = TakeFirstNonBlank(msg.getaddrlist('to'))
            gCc = TakeFirstNonBlank(msg.getaddrlist('cc'))
            gBcc = TakeFirstNonBlank(msg.getaddrlist('bcc'))
            gAttachment = msg.getallmatchingheaders('X-Attachment')
            gBody = ''
        
            # Deal with the body. Just read until you see the next
message.
            # Not sure where I got the "From ???@???"
            parse = mb.readline()
            while parse[:12] != "From ???@???":
              gBody = gBody + parse
              pos = mb.tell()
              parse = mb.readline()
              if pos == mb.tell(): break

            print "From: ", gFrom
            print "Subject: ", gSub
            print "To: ", gTo
            print "CC: ", gCc
            print "BCC: ", gBcc
            print "Body: ", gBody
            if gAttachment:
                for i in gAttachment:
                  strAtt = i[14:string.find(i, ';', 14)]
                  strAtt = string.join(string.split(strAtt, '"'), '')
                  strFile = os.path.split(strAtt)[1]
                  print "Attachments: %s, %s" % (strFile, strAtt)
            print "==========================================="
            print ""            msg = rfc822.Message(mb)
            
    mb.close()   
              
            
def TakeFirstNonBlank(addlist):
	newlist = []
	for i,j in addlist:		if
i:		  newlist.append(i)		else:		  newlist.append(j)
	return string.join(string.split(string.join(newlist, "'"), "'"),
", ")


if __name__=='__main__':
    if len(sys.argv)<2:
        print "Usage:", sys.argv[0], "Full path name for archive is
required."
    else:
        IndexMailArchive(sys.argv[1])
    



From lsloan@umich.edu  Fri Sep  7 21:33:53 2001
From: lsloan@umich.edu (Lance E Sloan)
Date: Fri, 07 Sep 2001 16:33:53 -0400
Subject: [Tutor] trouble running Grail
Message-ID: <200109072033.QAA18501@birds.us.itd.umich.edu>

I know this isn't a Grail support mailing list, but since I am in the
process of learning Python, I thought his might be a good place to
ask about this.

I'm using a Sun machine running Solaris 2.6 with Python 2.0 installed.
I downloaded Grail 0.6 and when I try to run it, I get this error:
    
    Traceback (most recent call last):
      File "grail.py", line 499, in ?
        main()
      File "grail.py", line 108, in main
        app = Application(prefs=prefs, display=display)
      File "grail.py", line 248, in __init__
        self.stylesheet = Stylesheet.Stylesheet(self.prefs)
      File "/var/tmp/grail-0.6/Stylesheet.py", line 21, in __init__
        self.load()
      File "/var/tmp/grail-0.6/Stylesheet.py", line 45, in load
        massaged.append((g, c), v % fparms_dict)
    TypeError: append requires exactly 1 argument; 2 given

Why would the Grail author give two arguments to append?  Was
there an old version of Python that allowed two arguments?

--
Lance E Sloan
Web Services, Univ. of Michigan: Full-service Web and database design,
development, and hosting.  Specializing in Python & Perl CGIs.
http://websvcs.itd.umich.edu/ - "Putting U on the Web"


From urnerk@qwest.net  Fri Sep  7 21:41:00 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Fri, 07 Sep 2001 13:41:00 -0700
Subject: [Tutor] trouble running Grail
In-Reply-To: <200109072033.QAA18501@birds.us.itd.umich.edu>
Message-ID: <4.2.0.58.20010907133953.00cf6100@pop3.norton.antivirus>

At 04:33 PM 9/7/2001 -0400, you wrote:

>List-Id: Discussion for learning programming with Python

Before version 2.0 or thereabouts, you could append(a,b,c)
-- multi-arg append.  But now you can only append 1 arg,
and use extend for more.  Looks to me that grail.py is
stumbling on this backward incompatibility.

Kirby



From dsh8290@rit.edu  Fri Sep  7 22:13:21 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 7 Sep 2001 17:13:21 -0400
Subject: [Tutor] trouble running Grail
In-Reply-To: <4.2.0.58.20010907133953.00cf6100@pop3.norton.antivirus>; from urnerk@qwest.net on Fri, Sep 07, 2001 at 01:41:00PM -0700
References: <200109072033.QAA18501@birds.us.itd.umich.edu> <4.2.0.58.20010907133953.00cf6100@pop3.norton.antivirus>
Message-ID: <20010907171321.B24531@harmony.cs.rit.edu>

On Fri, Sep 07, 2001 at 01:41:00PM -0700, Kirby Urner wrote:
| At 04:33 PM 9/7/2001 -0400, you wrote:
| 
| >List-Id: Discussion for learning programming with Python
| 
| Before version 2.0 or thereabouts, you could append(a,b,c)
| -- multi-arg append.  But now you can only append 1 arg,
| and use extend for more.  Looks to me that grail.py is
| stumbling on this backward incompatibility.

Actually, it was an implementation accident that was fixed in 2.0.

Prior to 2.0 the following were equivalent, but shouldn't have been :

l.append( a , b ,c )
l.append(  ( a , b , c )  )
a_tuple = ( a , b , c )
l.append( a_tuple )

The solution to that problem is to put parenthesis around the
arguments to the append() call so that the tuple grouping is correct.

HTH,
-D



From ignacio@openservices.net  Fri Sep  7 22:19:15 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Fri, 7 Sep 2001 17:19:15 -0400 (EDT)
Subject: [Tutor] trouble running Grail
In-Reply-To: <4.2.0.58.20010907133953.00cf6100@pop3.norton.antivirus>
Message-ID: <Pine.LNX.4.33.0109071718130.21138-100000@terbidium.openservices.net>

On Fri, 7 Sep 2001, Kirby Urner wrote:

> Before version 2.0 or thereabouts, you could append(a,b,c)
> -- multi-arg append.  But now you can only append 1 arg,
> and use extend for more.  Looks to me that grail.py is
> stumbling on this backward incompatibility.

Grail is _ancient_. I remember using Grail 0.6 a _looooong_ time ago.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From dyoo@hkn.eecs.berkeley.edu  Sat Sep  8 10:23:02 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sat, 8 Sep 2001 02:23:02 -0700 (PDT)
Subject: [Tutor] Help with cookies
In-Reply-To: <999717518_PM_BeOS.Charlie@begeistert.org>
Message-ID: <Pine.LNX.4.21.0109080218400.27846-100000@hkn.eecs.berkeley.edu>

On Wed, 5 Sep 2001, Charlie Clark wrote:

> >I have a silly example of one here: 
> > 
> >    http://hkn.eecs.berkeley.edu/~dyoo/python/cookiecounter.py 
> > 
> >The important thing is that we send off the cookie before any of the 
> other 
> >headers: otherwise, the browser will ignore the cookie.  I think that 
> the 
> >RFC says something to this effect here: 
> 
> No, this is the wrong way round. I'm writing HTML-parsers (thanx to your 
> help) and I need to pass a cookie to the server to get the page I need. 
> I need some kind of hook into urllib, I think but that's where I'm lost 
> ;-~
> 
> page = "http://blah-blah.com"
> cookie = "194.175.44.82 / 2137622400 CFID=988743 FALSE ACCEPT"
> src = urllib.urlopen(page, cookie)


I did some Google hunting, and found:

    http://webunit.sourceforge.net/

It looks like the folks there have written something to make it easier to
deal with cookies.  Unfortunately, I have to profess complete ignorance on
this subject.  Can anyone suggest other alternatives?

Best of wishes!



From lha2@columbia.edu  Sat Sep  8 12:13:52 2001
From: lha2@columbia.edu (Lloyd Hugh Allen)
Date: Sat, 08 Sep 2001 07:13:52 -0400
Subject: [Tutor] wxpython
Message-ID: <3B99FD70.D5F52130@mail.verizon.net>

I'd like to look at PythonCard, but it seems that first I must install
wxpython. My issue is that the installer for (windows 98) wxpython 2.3.1
for python 2.1 won't recognize my Python 2.1a2. Even if I launch the
installer from the directory where Python lives, I get the error, "No
installation of Python 2.1 found. Aborting..."

Is there a way to get around this?

Thanks,
LHA


From wrong@crosswinds.net  Sat Sep  8 14:08:42 2001
From: wrong@crosswinds.net (Charlie Derr)
Date: Sat, 8 Sep 2001 09:08:42 -0400
Subject: [Tutor] wxpython
In-Reply-To: <3B99FD70.D5F52130@mail.verizon.net>
Message-ID: <LOBBJCAMDNLNCGCCHGEIMEGOPHAA.cderr@simons-rock.edu>

Install Python 2.1.1.  If you don't want to remove your 2.1a2 immediately,
you can just point the 2.1.1 installer to use a different directory
(assuming 2.1a2 is installed at C:\Python21 -- if it's not installed there,
that's where you would want to install 2.1.1).

	~c

~ -----Original Message-----
~ From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
~ Lloyd Hugh Allen
~ Sent: Saturday, September 08, 2001 7:14 AM
~ To: tutor@python.org
~ Subject: [Tutor] wxpython
~
~
~ I'd like to look at PythonCard, but it seems that first I must install
~ wxpython. My issue is that the installer for (windows 98) wxpython 2.3.1
~ for python 2.1 won't recognize my Python 2.1a2. Even if I launch the
~ installer from the directory where Python lives, I get the error, "No
~ installation of Python 2.1 found. Aborting..."
~
~ Is there a way to get around this?
~
~ Thanks,
~ LHA
~
~ _______________________________________________
~ Tutor maillist  -  Tutor@python.org
~ http://mail.python.org/mailman/listinfo/tutor



From Griesbaum@aol.com  Sat Sep  8 14:18:00 2001
From: Griesbaum@aol.com (Griesbaum@aol.com)
Date: Sat, 8 Sep 2001 09:18:00 EDT
Subject: [Tutor] Learning Python
Message-ID: <c3.15d2b202.28cb7488@aol.com>

I'm a complete newbie to programming and have heard from Leo Laporte on Tech 
TV that python is good for people just starting out. Early on in the book I'm 
having some problems. When I type this line in the book under the heading 
(Running Module Files) % python spam.py -i eggs -o bacon I get SyntaxError: 
invalid syntax. Am I reading this correctly in the book? Is the symbol before 
the python a percentage mark? This seems to be an ongoing problem in the book 
whenever I type something exactly the way it is in the book I get some type 
of error message. Is there a better python book to start out with for 
complete beginners? Is there a better book for complete beginners?  


From lkvam@venix.com  Sat Sep  8 14:56:48 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Sat, 08 Sep 2001 09:56:48 -0400
Subject: [Tutor] Learning Python
References: <c3.15d2b202.28cb7488@aol.com>
Message-ID: <3B9A23A0.AE6336EA@venix.com>

The % is probably a Unix or Linux prompt character.  Under Windows/Dos the prompt usually is >

You should be typing:
	python spam.py -i eggs -o bacon

Be sure you are doing this from the correct directory.

Breaking this down a bit:
	python		starts the pythoin interpreter
	spam.py		python program you want to run
	-i eggs		parameter to the program (maybe input??)
	-o bacon	parameter to the program (maybe output??)

Griesbaum@aol.com wrote:
> 
> I'm a complete newbie to programming and have heard from Leo Laporte on Tech
> TV that python is good for people just starting out. Early on in the book I'm
> having some problems. When I type this line in the book under the heading
> (Running Module Files) % python spam.py -i eggs -o bacon I get SyntaxError:
> invalid syntax. Am I reading this correctly in the book? Is the symbol before
> the python a percentage mark? This seems to be an ongoing problem in the book
> whenever I type something exactly the way it is in the book I get some type
> of error message. Is there a better python book to start out with for
> complete beginners? Is there a better book for complete beginners?
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582


From wrong@crosswinds.net  Sat Sep  8 15:00:54 2001
From: wrong@crosswinds.net (Charlie Derr)
Date: Sat, 8 Sep 2001 10:00:54 -0400
Subject: [Tutor] Learning Python
In-Reply-To: <c3.15d2b202.28cb7488@aol.com>
Message-ID: <LOBBJCAMDNLNCGCCHGEIMEHAPHAA.cderr@simons-rock.edu>

The % represents a command prompt.  Probably if you're on a windows machine
you have a > instead of a %.  In any case you shouldn't type it.

If you've got python installed, and your PATH is set properly, and you've
created a "spam.py" file (and perhaps an "eggs" file as well?)  in the
current directory then I assume the following should work for you:

python spam.py -i eggs -o bacon

I don't have a copy of Learning Python in front of me at the moment, but
it's pretty good from what I remember.  You may also find
http://python.org/doc/Newbies.html helpful.  Alan Gauld also has some great
stuff at http://www.crosswinds.net/~agauld/.

And don't hesitate to come back here and ask more questions as you have
them.  That's what the list is for  :-]


	~c

~ -----Original Message-----
~ From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
~ Griesbaum@aol.com
~ Sent: Saturday, September 08, 2001 9:18 AM
~ To: tutor@python.org
~ Subject: [Tutor] Learning Python
~
~
~ I'm a complete newbie to programming and have heard from Leo
~ Laporte on Tech
~ TV that python is good for people just starting out. Early on in
~ the book I'm
~ having some problems. When I type this line in the book under the heading
~ (Running Module Files) % python spam.py -i eggs -o bacon I get
~ SyntaxError:
~ invalid syntax. Am I reading this correctly in the book? Is the
~ symbol before
~ the python a percentage mark? This seems to be an ongoing problem
~ in the book
~ whenever I type something exactly the way it is in the book I get
~ some type
~ of error message. Is there a better python book to start out with for
~ complete beginners? Is there a better book for complete beginners?
~
~ _______________________________________________
~ Tutor maillist  -  Tutor@python.org
~ http://mail.python.org/mailman/listinfo/tutor



From lkvam@venix.com  Sat Sep  8 15:10:00 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Sat, 08 Sep 2001 10:10:00 -0400
Subject: [Tutor] Learning Python
References: <c3.15d2b202.28cb7488@aol.com>
Message-ID: <3B9A26B8.13F3CEDA@venix.com>

Unfortunately, it is hard to turn the instructions in a book into the exactly correct input your computer expects.  Very often the best solution is a knowledgeable friend at your side to help you get started.

Griesbaum@aol.com wrote:
> 
> I'm a complete newbie to programming and have heard from Leo Laporte on Tech
> TV that python is good for people just starting out. Early on in the book I'm
> having some problems. When I type this line in the book under the heading
> (Running Module Files) % python spam.py -i eggs -o bacon I get SyntaxError:
> invalid syntax. Am I reading this correctly in the book? Is the symbol before
> the python a percentage mark? This seems to be an ongoing problem in the book
> whenever I type something exactly the way it is in the book I get some type
> of error message. Is there a better python book to start out with for
> complete beginners? Is there a better book for complete beginners?
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582


From csmith@blakeschool.org  Sat Sep  8 15:36:26 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Sat, 08 Sep 2001 09:36:26 -0500
Subject: [Tutor] Re: What is the best way to count the number of lines in a huge file?
Message-ID: <fc.004c4b6b007a6aa1004c4b6b007a6aa1.7a6acc@blakeschool.org>

>On Thu, 6 Sep 2001, dman wrote:
>
>> On Thu, Sep 06, 2001 at 09:07:08AM -0400, Ignacio Vazquez-Abrams wrote:
>> | Fair enough:
>> |
>> | ---
>> | a=None
>> | n=0
>> | while not a='':
>> |   a=file.read(262144)
>> |   n+=a.count(os.linesep)
>> | ---
>>
>> The only problem with this is it only (truly properly) counts the
>> lines of files that were created with the same OS as the one
>> counting.
>>
>> You'd probably want to use a regex to search for "\r\n|\r|\n", but it
>> all depends on the source(s) of the files you want to count.
>>
>> Make your script "good enough", not "perfect according to some misty
>> definition".  :-).
>>
>> -D
>
>Even using that RE (and in fact, of using the given code on Windows) is
>that
>the \r\n may straddle a 256k boundary, losing one line in the code, and
>gaining one with the RE.


Fair enough again...how about this to count the number occurances of
separators
(or anything else) in a file:

def countInFile(f,sep):
	'''Count the number of occurance of sep that occur in f and return
	a tuple (count,x) where x is 1 if the last chunk read from f did not
	contain sep.  This might be useful if you are counting line endings
	in f and the last line of f does not have an explicit sep at the end; 
	in this case the calling script should add x to the count.'''
	#
	# Notes:
	#  whatever is passed in as f must have a 'read' method
	#   that returns '' when there is no more to read.
	#  make chunksize as large as you can on your system
	#
	chunksize=262144
	sepl=len(sep)
	last=''
	count=0
	more=f.read(chunksize)
	while more:
		chunk=last+more
		count+=chunk.count(sep)
		last=chunk[-sepl:] #there might be a split sep in here
		if last==sep:      #nope, just a whole one that we already counted
			last=''
		more=f.read(chunksize)
	
	if last<>'':
		x=1
	else:
		x=0
	
	return count,x

/c



From uselesspython@yahoo.com  Sat Sep  8 16:08:16 2001
From: uselesspython@yahoo.com (Rob)
Date: Sat, 08 Sep 2001 10:08:16 -0500
Subject: [Tutor] Learning Python
References: <c3.15d2b202.28cb7488@aol.com>
Message-ID: <3B9A3460.36C7A739@yahoo.com>

Griesbaum@aol.com wrote:
> 
> I'm a complete newbie to programming and have heard from Leo Laporte on Tech
> TV that python is good for people just starting out. Early on in the book I'm
> having some problems. When I type this line in the book under the heading
> (Running Module Files) % python spam.py -i eggs -o bacon I get SyntaxError:
> invalid syntax. Am I reading this correctly in the book? Is the symbol before
> the python a percentage mark? This seems to be an ongoing problem in the book
> whenever I type something exactly the way it is in the book I get some type
> of error message. Is there a better python book to start out with for
> complete beginners? Is there a better book for complete beginners?
> 

In addition to books (which tend to cost money), there are a number of
nifty tutorials out there:

http://www.lowerstandard.com/python/tutoriallinks.html

*Learning to Program* (the second link from the top) is quite handy,
introducing programming concepts using Python and a couple of other
languages for comparison, and has a book version focused on Python in
particular.

*Teach Yourself Python in 24 Hours* is another good book for beginners,
as is *Core Python Programming* by Wesley Chun. We're all happy to help
answer puzzling questions, so ask away. There are also lots of working
examples of newbie and other Python code at Useless Python, so you can
find interesting code to play with.

Happy Whatever Day It Is,
Rob
-- 
Aw, c'mon.... You indent ANYWAY!
Useless Python!
http://www.lowerstandard.com/python


From uselesspython@yahoo.com  Sat Sep  8 16:10:08 2001
From: uselesspython@yahoo.com (Rob)
Date: Sat, 08 Sep 2001 10:10:08 -0500
Subject: [Tutor] Learning Python
References: <c3.15d2b202.28cb7488@aol.com>
Message-ID: <3B9A34D0.E36A43E7@yahoo.com>

Griesbaum@aol.com wrote:
> 
> I'm a complete newbie to programming and have heard from Leo Laporte on Tech
> TV that python is good for people just starting out. 

Yea Leo! I keep telling people he's alright.

Rob
-- 
Aw, c'mon.... You indent ANYWAY!
Useless Python!
http://www.lowerstandard.com/python


From ignacio@openservices.net  Sat Sep  8 16:39:16 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Sat, 8 Sep 2001 11:39:16 -0400 (EDT)
Subject: [Tutor] Re: What is the best way to count the number of lines
 in a huge file?
In-Reply-To: <fc.004c4b6b007a6aa1004c4b6b007a6aa1.7a6acc@blakeschool.org>
Message-ID: <Pine.LNX.4.33.0109081132250.22125-100000@terbidium.openservices.net>

On Sat, 8 Sep 2001, Christopher Smith wrote:

> >Even using that RE (and in fact, of using the given code on Windows) is
> >that
> >the \r\n may straddle a 256k boundary, losing one line in the code, and
> >gaining one with the RE.
>
>
> Fair enough again...how about this to count the number occurances of
> separators
> (or anything else) in a file:
>
> def countInFile(f,sep):
> 	'''Count the number of occurance of sep that occur in f and return
> 	a tuple (count,x) where x is 1 if the last chunk read from f did not
> 	contain sep.  This might be useful if you are counting line endings
> 	in f and the last line of f does not have an explicit sep at the end;
> 	in this case the calling script should add x to the count.'''
> 	#
> 	# Notes:
> 	#  whatever is passed in as f must have a 'read' method
> 	#   that returns '' when there is no more to read.
> 	#  make chunksize as large as you can on your system
> 	#
> 	chunksize=262144
> 	sepl=len(sep)
> 	last=''
> 	count=0
> 	more=f.read(chunksize)
> 	while more:

I got chewed out by someone else for writing code this way, so consider
yourself chewed out ;) :

---
       more=None
       while not more=='':
---

> 		chunk=last+more
> 		count+=chunk.count(sep)
> 		last=chunk[-sepl:] #there might be a split sep in here
> 		if last==sep:      #nope, just a whole one that we already counted
> 			last=''
> 		more=f.read(chunksize)
>
> 	if last<>'':
> 		x=1
> 	else:
> 		x=0
>
> 	return count,x

Instead of returning a tuple, it might be better to take a third argument
(defaulted to 1) that determines whether or not the last line counts if it
doesn't end with the seperator.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From csmith@blakeschool.org  Sat Sep  8 18:21:38 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Sat, 08 Sep 2001 12:21:38 -0500
Subject: [Tutor] Re: What is the best way to count the number of lines in a huge file?
Message-ID: <fc.004c4b6b007a6b87004c4b6b007a6b87.7a6bc7@blakeschool.org>

I just got chewed out by Ignacio for writing 

more=f.read(stuff)
while more
	process more
	more=f.read(stuff)

and it was suggested that I write

# suggestion 1
more=None
while not more=='':
	process more
	more=f.read(stuff)

I consider myself wounded by a friend :-)  How to handle
this construct in the "one right way" has bothered me and
even bothered me as I struggled with what to send in this
morning, Ignacio.  I thought of two other approaches:

# suggestion 2
while 1:
	more=f.read(stuff)
	if more=='':
		break
	process more

# suggestion 2b
while 1:
	more=f.read(stuff)
	if more<>'':
		process more
	else:
		break

and 

# suggestion 3
more='go'
while more<>'':
	more=f.read(stuff)
	if more<>'':
		process more
	
	
I now consider #2 to be the best; in #1 and #3 you are setting a flag
which must be something not equal to the terminating flag, though in 
both cases you can clearly see that the loop will initiate, there is
a chance of making a mistake on the initialization.  In addition #3
is a bit repugnant in that you have a test repeated twice (and, for
what got me chewed out in the first place, I think this double test
is prone to error).  

I prefer (and wouldn't mind comment) on proposal #2.  Here's what it
has going for it:

	-it's obvious the loop will start
	-it's soon obvious what will stop the loop
	-the stop condition and request for more data to process
	 occurs only once in the loop
	-it's better than 2b b/c in 2b the "else" loop is too far
	 away (if the process code is long)
	-it's better not to use an "else" part to reduce the amount
	 of indentation that must be done.

So...here is the updated lineCount incorporating this change and the
suggestion that whether or not to count the trailing line is specified
as an input option rather than being returned as count information.

Thanks for the constructive criticism :-)

/c

####

def lineCount(f,sep,countTrailer=1):
	'''Return a count of the number of occurance of sep that occur in f.
	By default this routine assumes that sep indicates the end of a line
	and that if the last line doesn't end in sep it should be counted anyway.
	To get a strict count of the occurances of sep send a 0 for the 3rd
argument.'''
	#
	# Notes:
	#  whatever is passed in as f must have a 'read' method
	#   that returns '' when there is no more to read.
	#  make chunksize as large as you can on your system
	#
	chunksize=262144
	sepl=len(sep)
	last=''
	count=0
	while 1:
		more=f.read(chunksize)
		if more=='':
			break
		chunk=last+more
		count+=chunk.count(sep)
		last=chunk[-sepl:] #there might be a split sep in here
		if last==sep:      #nope, just a whole one that we already counted
			last=''
	
	if last<>'' and countTrailer==1:
		count+=1

	return count



From alan.gauld@bt.com  Sat Sep  8 18:20:30 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sat, 8 Sep 2001 18:20:30 +0100
Subject: [Tutor] Display standard output in Tk widget
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20F6E7079@mbtlipnt02.btlabs.bt.co.uk>

Here's a short script to demonstrate stdout going to 
a Text widget, as requested by somebody recently. 
Its very basic but shows the principle...
Rob, if you want it for Useless python feel free to grab it...

Alan Gauld
BT computing partners
Tel : 0141 220 8795
Fax : 0141 248 1284 

#######################
# File: tkoutput.py
# Author: A.J. Gauld
# Date: September 2001
#
from Tkinter import *
import sys

class Display(Frame):
    ''' Demonstrate python interpreter output in Tkinter Text widget

type python expression in the entry, hit DoIt and see the results
in the text pane.'''
    
    def __init__(self,parent=0):
       Frame.__init__(self,parent)
       self.entry = Entry(self)
       self.entry.pack()
       self.doIt = Button(self,text="DoIt", command=self.onEnter)
       self.doIt.pack()
       self.output = Text(self)
       self.output.pack()
       sys.stdout = self
       self.pack()

    def onEnter(self):
        print eval(self.entry.get())

    def write(self, txt):
        self.output.insert(END,str(txt))

if __name__ == '__main__':
    Display().mainloop()


From dell2100@prodigy.net  Sat Sep  8 19:14:00 2001
From: dell2100@prodigy.net (David L. Lerner)
Date: Sat, 8 Sep 2001 14:14:00 -0400
Subject: [Tutor] proper import syntax
References: <E15fkXy-0007dW-00@mail.python.org>
Message-ID: <000a01c13892$096b6b60$79e1fcd1@prodigy.net>

Let's say I need to use several different functions from the module
'string'...

Do I use 'from string import *',  import each function individually, or put
'string.' in front of each function?

I've seen it all three ways.

Thank you

David L. Lerner
dell2100@prodigy.net
Often, the most striking and innovative solutions come from realizing that
your concept of the problem was wrong.
Eric Steven Raymond





From uselesspython@yahoo.com  Sat Sep  8 19:34:58 2001
From: uselesspython@yahoo.com (Rob)
Date: Sat, 08 Sep 2001 13:34:58 -0500
Subject: [Tutor] proper import syntax
References: <E15fkXy-0007dW-00@mail.python.org> <000a01c13892$096b6b60$79e1fcd1@prodigy.net>
Message-ID: <3B9A64D2.C70F1EBE@yahoo.com>

"David L. Lerner" wrote:
> 
> Let's say I need to use several different functions from the module
> 'string'...
> 
> Do I use 'from string import *',  import each function individually, or put
> 'string.' in front of each function?
> 
> I've seen it all three ways.
> 
> Thank you
> 

This is a great question, and I look forward to seeing the different
answers offered. Are you specifically interested in the answer as it
would apply to the string module, or as a practice in general?

Any time you face this decision for a given module, there are a number
of factors to consider. Most of the really interesting problems I've
seen people run into seem related to naming conflicts. "import string"
imports the module and directly executes the top-level part of the
module (but only the first time you import the module), whereas "from
string import *" imports each individual module element.

"from [some module] import *" is sometimes useful, but you need to
exercise some care to make sure you don't use names in your module that
are identical to names you import directly this way.

Rob
-- 
Aw, c'mon.... You indent ANYWAY!
Useless Python!
http://www.lowerstandard.com/python


From lumbricus@gmx.net  Sat Sep  8 19:56:15 2001
From: lumbricus@gmx.net (Joerg Woelke)
Date: Sat, 8 Sep 2001 20:56:15 +0200
Subject: [Tutor] Re: What is the best way to count the number of lines in a huge file?
In-Reply-To: <fc.004c4b6b007a6b87004c4b6b007a6b87.7a6bc7@blakeschool.org>; from csmith@blakeschool.org on Sat, Sep 08, 2001 at 12:21:38PM -0500
References: <fc.004c4b6b007a6b87004c4b6b007a6b87.7a6bc7@blakeschool.org>
Message-ID: <20010908205615.A5383@Laplace.localdomain>

On Sat, Sep 08, 2001 at 12:21:38PM -0500, Christopher Smith wrote:
> I just got chewed out by Ignacio for writing 
> 
> I consider myself wounded by a friend :-)  How to handle
> this construct in the "one right way" has bothered me and
> even bothered me as I struggled with what to send in this
> morning, Ignacio.  I thought of two other approaches:
> 
> # suggestion 2
> while 1:
> 	more=f.read(stuff)
> 	if more=='':
> 		break
> 	process more
> 

How about

while 1:
	more=f.read(stuff)
	if not more: break
	process more
	
YMMV
HTH,HAND
J"o! :-)

-- 
	"I suppose you expect me to talk."
	"No, Mr. Bond.  I expect you to die."
		-- Goldfinger


From ak@silmarill.org  Sat Sep  8 20:18:57 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Sat, 08 Sep 2001 15:18:57 -0400
Subject: [Tutor] proper import syntax
In-Reply-To: <000a01c13892$096b6b60$79e1fcd1@prodigy.net>
References: <E15fkXy-0007dW-00@mail.python.org>
 <000a01c13892$096b6b60$79e1fcd1@prodigy.net>
Message-ID: <20010908151857.A2333@sill.silmarill.org>

On Sat, Sep 08, 2001 at 02:14:00PM -0400, David L. Lerner wrote:
> Let's say I need to use several different functions from the module
> 'string'...
> 
> Do I use 'from string import *',  import each function individually, or put
> 'string.' in front of each function?
> 
> I've seen it all three ways.

from module import * is the "wrong" way. You only use it from interactive
interpreter or very small scripts. There are two problems with it: first,
someone reading the code will see a function used but will have no idea
where it came from. If you have many such import statements, it can be
quite hard to figure out which module the function belongs to; second, you
may overshadow variables or functions, for instance if you do from os
import * you overshadow open() function that normally opens a file, but
os.open() does something different. It can be very confusing - you do the
import and suddenly files stop opening with odd errors! Newbies get this
problem quite often. The only advantage is that there's least typing
involved, of all three ways.

from module import func is good if you use func many times and don't want
to type module.func every time. However, this comes at a cost: when
someone's reading your code he may not immediately see where the function
came from, he'll have to look where the import statement is to figure it out.

import module; module.func() is the preferred usage in most cases - you do
a bit more typing with each invocation but it's the clearest and most
explicit. No confusion is possible here.

Did I miss anything?

- Andrei 

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From ak@silmarill.org  Sat Sep  8 20:22:42 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Sat, 08 Sep 2001 15:22:42 -0400
Subject: [Tutor] proper import syntax
In-Reply-To: <000a01c13892$096b6b60$79e1fcd1@prodigy.net>
References: <E15fkXy-0007dW-00@mail.python.org>
 <000a01c13892$096b6b60$79e1fcd1@prodigy.net>
Message-ID: <20010908152242.B2333@sill.silmarill.org>

On Sat, Sep 08, 2001 at 02:14:00PM -0400, David L. Lerner wrote:
> Let's say I need to use several different functions from the module
> 'string'...
> 
> Do I use 'from string import *',  import each function individually, or put
> 'string.' in front of each function?
> 
> I've seen it all three ways.
> 

Oh yes, I did forget something... If you need to reload module later in
the program, like this: reload(module), then you *have* to use import
module; module.func() method of usage. In other two, functions get
imported, but when you reload the module, functions are still the 'old'
ones. You can still do import module as mod and then do reload(mod),
though.

- Andrei 

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From urnerk@qwest.net  Sat Sep  8 20:46:29 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Sat, 08 Sep 2001 12:46:29 -0700
Subject: [Tutor] proper import syntax
In-Reply-To: <20010908151857.A2333@sill.silmarill.org>
References: <000a01c13892$096b6b60$79e1fcd1@prodigy.net>
 <E15fkXy-0007dW-00@mail.python.org>
 <000a01c13892$096b6b60$79e1fcd1@prodigy.net>
Message-ID: <4.2.0.58.20010908123221.00cfa160@pop3.norton.antivirus>

>
>Did I miss anything?
>
>- Andrei

I think you gave a pretty good answer.

When it comes to others reading code, there are always
comments and __doc__ strings etc., so you have the ability
to give more clues if your think a readership might be
appreciative.

Sometimes what we're importing are packages, not just
modules, as defined by some __init__.py in the package
directory.  These may be written in such a way that
'from package import *' gives you a small set of classes
you'd like to have top-level.  If that might be confusing
for readers, just say something in comments.

Booting to IDLE:

  >>> dir()
  ['__builtins__', '__doc__', '__name__']

This shows an initially "empty" shell namespace.  Now
I bring in a package:

  >>> from mathobjects import *
  >>> dir()
  ['Fraction', 'Matrix', 'Poly', 'Sqmatrix', '__builtins__',
  '__doc__', '__name__', 'deriv', 'polynomial', 'pyfraction',
  'simplematrix']

Some new tools have been added.  But it's not clear which
of these might be variables, which might be modules etc.
If I'm in shell mode and want to do some introspection,
I could go:

  >>> for i in dir():  eval(i)

This spits back some useful information about what's in
my bag:

  <class mathobjects.pyfraction.Fraction at 00B49B4C>
  <class mathobjects.simplematrix.Matrix at 00B4029C>
  <class mathobjects.polynomial.Poly at 00B4C41C>
  <class mathobjects.simplematrix.Sqmatrix at 00B41D6C>
  <module '__builtin__' (built-in)>
  '__main__'
  <function deriv at 00B4D66C>
  'i'
  <module 'mathobjects.polynomial' from
  'D:\PROGRAM  FILES\PYTHON21\ocn\mathobjects\polynomial.pyc'>
  <module 'mathobjects.pyfraction' from
  'D:\PROGRAM FILES\PYTHON21\ocn\mathobjects\pyfraction.pyc'>
  <module 'mathobjects.simplematrix' from
  'D:\PROGRAM FILES\PYTHON21\ocn\mathobjects\simplematrix.pyc'>

I see that I've imported some classes and modules.

I might further analyze a class:

  >>> dir(Fraction)
  ['__abs__', '__add__', '__div__', '__doc__', '__eq__',
  '__float__', '__gt__', '__init__', '__lt__', '__module__',
  '__mul__', '__neg__', '__pow__', '__radd__', '__rdiv__',
  '__repr__', '__rmul__', '__rsub__', '__sub__', 'denom',
  'fformat', 'float', 'list', 'mkfract', 'numer', 'recip',
  'simplify']

Hmmm....  looks like I can add, subtract Fraction objects.

The author (me) doesn't seem to have put in a lot of helpful
__doc__ strings, so I'm not sure how to initialize a Fraction
object.  I can look at the code, if I have Python source (not
always the case).

...  not disagreeing with anything you typed, just riffing
on how a user might probe and prod imported stuff, to figure
out what's going on.  In this sense, I'm inspired by your
excellent model:  always try to look at what you're doing
from the point of view of some reader who doesn't have the
benefit of your intimate knowledge of whatever it is you're
doing (good advice for life-at-large, I'd add).

Kirby




From girishg@india.ti.com  Sat Sep  8 21:29:01 2001
From: girishg@india.ti.com (Girish Gajwani)
Date: Sun, 09 Sep 2001 01:59:01 +0530
Subject: [Tutor] How do I do this
Message-ID: <3B9A7F8D.ADE3EC36@india.ti.com>

Hi All,

I was trying to get the documentation of all functions in a
particular module, as follows:


############################################
#! /usr/bin/env  python

"""Documentation comes like this.

this will be the documentation for this file(module)

"""
import sys, os, string, getopt

def main():
  for i in dir(getopt):
    print i, getopt.i.__doc__  # assuming i will be
substituted for each of the 
                               # modules, functions and we
will get __doc__ for 
                               # each of these
main()

############################################

This does not work. How do I do this?

Thanks & Best regards
Girish


From kalle@gnupung.net  Sat Sep  8 21:47:01 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Sat, 8 Sep 2001 22:47:01 +0200
Subject: [Tutor] How do I do this
In-Reply-To: <3B9A7F8D.ADE3EC36@india.ti.com>; from girishg@india.ti.com on Sun, Sep 09, 2001 at 01:59:01AM +0530
References: <3B9A7F8D.ADE3EC36@india.ti.com>
Message-ID: <20010908224701.A21381@gandalf>

[Girish Gajwani]
> Hi All,
> 
> I was trying to get the documentation of all functions in a
> particular module, as follows:
> 
> 
> ############################################
> #! /usr/bin/env  python
> 
> """Documentation comes like this.
> 
> this will be the documentation for this file(module)
> 
> """
> import sys, os, string, getopt
> 
> def main():
>   for i in dir(getopt):
>     print i, getopt.i.__doc__  # assuming i will be substituted for each of the 
>                                # modules, functions and we will get __doc__ for 
>                                # each of these
> main()
> 
> ############################################
> 
> This does not work. How do I do this?

def main():
    for i in dir(getopt):
        try:
	    print i, getattr(getopt, i).__doc__
	except AttributeError:
	    print "getopt.%s has no __doc__ attribute" % i

seems to work.

Peace,
  Kalle
-- 
[  kalle@gnupung.net  ][ Thought control, brought to you by the WIPO! ]
[ http://gnupung.net/ ][ http://anti-dmca.org/ http://eurorights.org/ ]


From dsh8290@rit.edu  Sat Sep  8 21:38:19 2001
From: dsh8290@rit.edu (dman)
Date: Sat, 08 Sep 2001 16:38:19 -0400
Subject: [Tutor] How do I do this
In-Reply-To: <3B9A7F8D.ADE3EC36@india.ti.com>
References: <3B9A7F8D.ADE3EC36@india.ti.com>
Message-ID: <20010908163819.A21669@hudson>

On Sun, Sep 09, 2001 at 01:59:01AM +0530, Girish Gajwani wrote:
| Hi All,
| 
| I was trying to get the documentation of all functions in a
| particular module, as follows:

Take a look at pydoc -- all the hard work has been done for you.

| ############################################
| #! /usr/bin/env  python
| 
| """Documentation comes like this.
| 
| this will be the documentation for this file(module)
| 
| """
| import sys, os, string, getopt
| 
| def main():
|   for i in dir(getopt):
|     print i, getopt.i.__doc__  # assuming i will be
                     
This line is the problem.  When you write 
    foo.bar
in the source code 'foo' is the name of an object and 'bar' is the
name of its member.  As you have it here you are printing each object
of the getopt module by a *reference* to it ('i'), then trying to get
the member of the getopt module *named* i, which probably doesn't
exist.

Instead try this

    print i , i.__doc__

HTH,
-D



From ignacio@openservices.net  Sat Sep  8 21:46:31 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Sat, 8 Sep 2001 16:46:31 -0400 (EDT)
Subject: [Tutor] How do I do this
In-Reply-To: <3B9A7F8D.ADE3EC36@india.ti.com>
Message-ID: <Pine.LNX.4.33.0109081645420.22125-100000@terbidium.openservices.net>

On Sun, 9 Sep 2001, Girish Gajwani wrote:

> Hi All,
>
> I was trying to get the documentation of all functions in a
> particular module, as follows:
>
>  [snip]
>
> This does not work. How do I do this?
>
> Thanks & Best regards
> Girish

def getdocs(n):
  for i in dir(n):
    try:
      print '%s: %s' % (i, getattr(n, i).__doc__)
      print
    except:
      print

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From girishg@india.ti.com  Sat Sep  8 23:08:59 2001
From: girishg@india.ti.com (Girish Gajwani)
Date: Sun, 09 Sep 2001 03:38:59 +0530
Subject: [Tutor] more help required ( __doc__ & dir() )
Message-ID: <3B9A96FB.157538C0@india.ti.com>

Hi All,

Thanks for a reply to my earlier post. It solved my problem

Next, what I wish to do is this:

#######################
#! /usr/bin/env  python 

import sys
def main():
  print dir() # gives []

main()
print dir()   # gives ['__builtins__', '__doc__',
'__name__', 'main', 'sys']
#######################

In the main() function, why am I not able to see the module
sys? while i can see it from the outermost level. How do i
make it visible to the inner directory level(hope it is
clear)

Also, I am currently subscribed to the mailing list in
digest mode. If I were to switch to individual mail, would I
lose the mails in between(i.e., those mails which were
supposed to come in the next digest?)

TIA,
Girish


From ignacio@openservices.net  Sat Sep  8 23:23:26 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Sat, 8 Sep 2001 18:23:26 -0400 (EDT)
Subject: [Tutor] more help required ( __doc__ & dir() )
In-Reply-To: <3B9A96FB.157538C0@india.ti.com>
Message-ID: <Pine.LNX.4.33.0109081821570.22125-100000@terbidium.openservices.net>

On Sun, 9 Sep 2001, Girish Gajwani wrote:

> Hi All,
>
> Thanks for a reply to my earlier post. It solved my problem
>
> Next, what I wish to do is this:
>
>  [snip]
>
> In the main() function, why am I not able to see the module
> sys? while i can see it from the outermost level. How do i
> make it visible to the inner directory level(hope it is
> clear)

Use globals().

> Also, I am currently subscribed to the mailing list in
> digest mode. If I were to switch to individual mail, would I
> lose the mails in between(i.e., those mails which were
> supposed to come in the next digest?)

Stay subscribed to the digest until you're sure that it's safe to unsubscribe.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From girishg@india.ti.com  Sat Sep  8 23:50:42 2001
From: girishg@india.ti.com (Girish Gajwani)
Date: Sun, 09 Sep 2001 04:20:42 +0530
Subject: [Tutor] more help required ( __doc__ & dir() )
References: <3B9AA028.F6F9595C@india.ti.com>
Message-ID: <3B9AA0C2.7B3E6CE4@india.ti.com>

The Use globals() was not very clear to me.

regards,
Girish

> [Tutor] more help required ( __doc__ & dir() )
> 
> Ignacio Vazquez-Abrams ignacio@openservices.net
> Sat, 8 Sep 2001 18:23:26 -0400 (EDT)
> 

> 
> On Sun, 9 Sep 2001, Girish Gajwani wrote:
> 
> > Hi All,
> >
> > Thanks for a reply to my earlier post. It solved my problem
> >
> > Next, what I wish to do is this:
> >
> >  [snip]
> >
> > In the main() function, why am I not able to see the module
> > sys? while i can see it from the outermost level. How do i
> > make it visible to the inner directory level(hope it is
> > clear)
> 
> Use globals().
> 
> > Also, I am currently subscribed to the mailing list in
> > digest mode. If I were to switch to individual mail, would I
> > lose the mails in between(i.e., those mails which were
> > supposed to come in the next digest?)
> 
> Stay subscribed to the digest until you're sure that it's safe to unsubscribe.
> 
> --
> Ignacio Vazquez-Abrams  <ignacio@openservices.net>


From kalle@gnupung.net  Sat Sep  8 23:58:51 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Sun, 9 Sep 2001 00:58:51 +0200
Subject: OT: Digest to ordinary (Was: [Tutor] more help required ( __doc__ & dir() ))
In-Reply-To: <3B9A96FB.157538C0@india.ti.com>; from girishg@india.ti.com on Sun, Sep 09, 2001 at 03:38:59AM +0530
References: <3B9A96FB.157538C0@india.ti.com>
Message-ID: <20010909005850.A21805@gandalf>

[Girish Gajwani]
> Also, I am currently subscribed to the mailing list in
> digest mode. If I were to switch to individual mail, would I
> lose the mails in between(i.e., those mails which were
> supposed to come in the next digest?)

I don't think so.  I think you will begin receiving individual messages
immediately.

Peace,
  Kalle
-- 
[  kalle@gnupung.net  ][ Thought control, brought to you by the WIPO! ]
[ http://gnupung.net/ ][ http://anti-dmca.org/ http://eurorights.org/ ]


From uselesspython@yahoo.com  Sat Sep  8 23:56:31 2001
From: uselesspython@yahoo.com (Rob)
Date: Sat, 08 Sep 2001 17:56:31 -0500
Subject: OT: Digest to ordinary (Was: [Tutor] more help required ( __doc__ &
 dir() ))
References: <3B9A96FB.157538C0@india.ti.com> <20010909005850.A21805@gandalf>
Message-ID: <3B9AA21F.29E3BBA9@yahoo.com>

Kalle Svensson wrote:
> 
> [Girish Gajwani]
> > Also, I am currently subscribed to the mailing list in
> > digest mode. If I were to switch to individual mail, would I
> > lose the mails in between(i.e., those mails which were
> > supposed to come in the next digest?)
> 
> I don't think so.  I think you will begin receiving individual messages
> immediately.
> 

And you can always check the Tutor Archives the next day just to make
sure you didn't miss anything.

Rob

-- 
Aw, c'mon.... You indent ANYWAY!
Useless Python!
http://www.lowerstandard.com/python


From ignacio@openservices.net  Sun Sep  9 00:01:55 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Sat, 8 Sep 2001 19:01:55 -0400 (EDT)
Subject: [Tutor] more help required ( __doc__ & dir() )
In-Reply-To: <3B9AA0C2.7B3E6CE4@india.ti.com>
Message-ID: <Pine.LNX.4.33.0109081900180.22125-100000@terbidium.openservices.net>

On Sun, 9 Sep 2001, Girish Gajwani wrote:

> The Use globals() was not very clear to me.
>
> regards,
> Girish

The globals() function returns the global namespace as a dictionary:

---
>>> print globals()
{'__doc__': None, '__name__': '__main__', '__builtins__': <module
'__builtin__' (built-in)>}
>>>
---

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From dsh8290@rit.edu  Sun Sep  9 00:51:28 2001
From: dsh8290@rit.edu (dman)
Date: Sat, 08 Sep 2001 19:51:28 -0400
Subject: [Tutor] more help required ( __doc__ & dir() )
In-Reply-To: <3B9A96FB.157538C0@india.ti.com>
References: <3B9A96FB.157538C0@india.ti.com>
Message-ID: <20010908195128.A2514@hudson>

On Sun, Sep 09, 2001 at 03:38:59AM +0530, Girish Gajwani wrote:
| Hi All,
| 
| Thanks for a reply to my earlier post. It solved my problem
| 
| Next, what I wish to do is this:
| 
| #######################
| #! /usr/bin/env  python 
| 
| import sys
| def main():
|   print dir() # gives []
| 
| main()
| print dir()   # gives ['__builtins__', '__doc__',
| '__name__', 'main', 'sys']
| #######################
| 
| In the main() function, why am I not able to see the module
| sys? while i can see it from the outermost level. How do i
| make it visible to the inner directory level(hope it is
| clear)

>>> print dir.__doc__
dir([object]) -> list of strings

Return an alphabetized list of names comprising (some of) the attributes
of the given object.  Without an argument, the names in the current scope
are listed.  With an instance argument, only the instance attributes are
returned.  With a class argument, attributes of the base class are not
returned.  For other types or arguments, this may list members or methods.
>>>

Apparently if you don't give an argument to dir() it returns a list of
the *current* scope.  The second dir is at the module level so the
current scope for it is the module.  When you are in the function
main, the current scope is the local scope of the function.  The sys
module is in the current module's scope, but not main's local scope.

HTH,
-D



From grimmtoothtoo@yahoo.com  Sun Sep  9 03:10:01 2001
From: grimmtoothtoo@yahoo.com (Grimmtooth)
Date: Sat, 8 Sep 2001 22:10:01 -0400
Subject: [Tutor] proper import syntax
In-Reply-To: <4.2.0.58.20010908123221.00cfa160@pop3.norton.antivirus>
Message-ID: <NLEIJCOLEACIANLABPOEAEHCCBAA.grimmtoothtoo@yahoo.com>

> excellent model:  always try to look at what you're doing
> from the point of view of some reader who doesn't have the
> benefit of your intimate knowledge of whatever it is you're
> doing (good advice for life-at-large, I'd add).

Don't forget yourself! "Any source code you haven't touched in two months
might as well been written by a stranger." :-D



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



From planets3000@hotmail.com  Sun Sep  9 05:11:24 2001
From: planets3000@hotmail.com (Charles Lim)
Date: Sun, 9 Sep 2001 12:11:24 +0800
Subject: [Tutor] log
Message-ID: <OE74D8iPN895EFIJEg900006651@hotmail.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0005_01C13928.8BA66EE0
Content-Type: text/plain;
	charset="gb2312"
Content-Transfer-Encoding: base64

RGVhciBTaXIvTWFkYW0sICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
IDkvOS8yMDAxDQoNCg0KSWYgc29tZW9uZSBrbm93cyBob3cgdG8gd3JpdGUgYSBwcm9ncmFtIHRo
YXQgY29tcHV0ZXMgbG9nIGJhc2UgMTAgYW5kIG5hdHVyYWwgbG9nIHBsZWFzZSB3cml0ZSBtZSBh
IGZldyBleGFtcGxlcyBhbmQgZXhwbGFpbiBob3cgdGhleSB3b3JrLiBUaGFuayB5b3UuDQoNClNp
bmNlcmVseSwNCg0KQ2hhcmxlcw0KDQoNCg==

------=_NextPart_000_0005_01C13928.8BA66EE0
Content-Type: text/html;
	charset="gb2312"
Content-Transfer-Encoding: base64

PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwv
L0VOIj4NCjxIVE1MPjxIRUFEPg0KPE1FVEEgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PWdi
MjMxMiIgaHR0cC1lcXVpdj1Db250ZW50LVR5cGU+DQo8TUVUQSBjb250ZW50PSJNU0hUTUwgNS4w
MC4yNjE0LjM1MDAiIG5hbWU9R0VORVJBVE9SPg0KPFNUWUxFPjwvU1RZTEU+DQo8L0hFQUQ+DQo8
Qk9EWSBiZ0NvbG9yPSNmZmZmZmY+DQo8RElWPjxGT05UIHNpemU9Mj5EZWFyIA0KU2lyL01hZGFt
LCZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZu
YnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNw
OyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZu
YnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNw
OyZuYnNwOyZuYnNwOyZuYnNwOyZuYnNwOyANCjkvOS8yMDAxPC9GT05UPjwvRElWPg0KPERJVj4m
bmJzcDs8L0RJVj4NCjxESVY+Jm5ic3A7PC9ESVY+DQo8RElWPjxGT05UIHNpemU9Mj5JZiBzb21l
b25lIGtub3dzIGhvdyB0byB3cml0ZSBhIHByb2dyYW0gdGhhdCBjb21wdXRlcyBsb2cgYmFzZSAN
CjEwIGFuZCBuYXR1cmFsIGxvZyBwbGVhc2Ugd3JpdGUgbWUgYSBmZXcgZXhhbXBsZXMgYW5kIGV4
cGxhaW4gaG93IHRoZXkgd29yay4gDQpUaGFuayB5b3UuPC9GT05UPjwvRElWPg0KPERJVj4mbmJz
cDs8L0RJVj4NCjxESVY+PEZPTlQgc2l6ZT0yPlNpbmNlcmVseSw8L0ZPTlQ+PC9ESVY+DQo8RElW
PiZuYnNwOzwvRElWPg0KPERJVj48Rk9OVCBzaXplPTI+Q2hhcmxlczwvRk9OVD48L0RJVj4NCjxE
SVY+Jm5ic3A7PC9ESVY+DQo8RElWPiZuYnNwOzwvRElWPjwvQk9EWT48L0hUTUw+DQo=

------=_NextPart_000_0005_01C13928.8BA66EE0--


From planets3000@hotmail.com  Sun Sep  9 05:16:10 2001
From: planets3000@hotmail.com (Charles Lim)
Date: Sun, 9 Sep 2001 12:16:10 +0800
Subject: [Tutor] log
Message-ID: <OE47SJvGol05eDg0qls0000677b@hotmail.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0005_01C13929.3604A140
Content-Type: text/plain;
	charset="gb2312"
Content-Transfer-Encoding: base64

RGVhciBTaXIvTWFkYW0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
IDkvOS8yMDAxDQoNCklmIHNvbWVvbmUga25vd3MgaG93IHRvIHdyaXRlIHByb2dyYW1zIHRoYXQg
Y29tcHV0ZXMgbG9nIGJhc2UgdGVuIGFuZCBuYXR1cmFsIGxvZyBvZiBudW1iZXJzIHBsZWFzZSB3
cml0ZSBtZSBhIGZldyBleGFtcGxlcyBhbmQgZXhwbGFpbiBob3cgdGhleSB3b3JrLiBUaGFuayB5
b3UuDQoNClNpbmNlcmVseSwNCg0KQ2hhcmxlcw0K

------=_NextPart_000_0005_01C13929.3604A140
Content-Type: text/html;
	charset="gb2312"
Content-Transfer-Encoding: base64

PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwv
L0VOIj4NCjxIVE1MPjxIRUFEPg0KPE1FVEEgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PWdi
MjMxMiIgaHR0cC1lcXVpdj1Db250ZW50LVR5cGU+DQo8TUVUQSBjb250ZW50PSJNU0hUTUwgNS4w
MC4yNjE0LjM1MDAiIG5hbWU9R0VORVJBVE9SPg0KPFNUWUxFPjwvU1RZTEU+DQo8L0hFQUQ+DQo8
Qk9EWSBiZ0NvbG9yPSNmZmZmZmY+DQo8RElWPjxGT05UIHNpemU9Mj5EZWFyIA0KU2lyL01hZGFt
Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5i
c3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7
Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5i
c3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7
Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7Jm5ic3A7IA0KOS85LzIwMDE8L0ZPTlQ+PC9ESVY+DQo8
RElWPiZuYnNwOzwvRElWPg0KPERJVj48Rk9OVCBzaXplPTI+SWYgc29tZW9uZSBrbm93cyBob3cg
dG8gd3JpdGUgcHJvZ3JhbXMgdGhhdCBjb21wdXRlcyBsb2cgYmFzZSANCnRlbiBhbmQgbmF0dXJh
bCBsb2cgb2YgbnVtYmVycyBwbGVhc2Ugd3JpdGUgbWUgYSBmZXcgZXhhbXBsZXMgYW5kIGV4cGxh
aW4gaG93IA0KdGhleSB3b3JrLiBUaGFuayB5b3UuPC9GT05UPjwvRElWPg0KPERJVj4mbmJzcDs8
L0RJVj4NCjxESVY+PEZPTlQgc2l6ZT0yPlNpbmNlcmVseSw8L0ZPTlQ+PC9ESVY+DQo8RElWPiZu
YnNwOzwvRElWPg0KPERJVj48Rk9OVCBzaXplPTI+Q2hhcmxlczwvRk9OVD48L0RJVj48L0JPRFk+
PC9IVE1MPg0K

------=_NextPart_000_0005_01C13929.3604A140--


From ignacio@openservices.net  Sun Sep  9 05:08:47 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Sun, 9 Sep 2001 00:08:47 -0400 (EDT)
Subject: [Tutor] log
In-Reply-To: <OE74D8iPN895EFIJEg900006651@hotmail.com>
Message-ID: <Pine.LNX.4.33.0109090008210.22125-100000@terbidium.openservices.net>

On Sun, 9 Sep 2001, Charles Lim wrote:

> If someone knows how to write a program that computes log base 10 and natural log please write me a few examples and explain how they work. Thank you.

Umm, 'import math'?

  http://www.python.org/doc/current/lib/module-math.html

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From uselesspython@yahoo.com  Sun Sep  9 05:09:54 2001
From: uselesspython@yahoo.com (Rob)
Date: Sat, 08 Sep 2001 23:09:54 -0500
Subject: [Tutor] log
References: <OE74D8iPN895EFIJEg900006651@hotmail.com>
Message-ID: <3B9AEB92.908232AD@yahoo.com>

> Charles Lim wrote:
> 
> Dear Sir/Madam,                                           9/9/2001
> 
> 
> If someone knows how to write a program that computes log base 10 and
> natural log please write me a few examples and explain how they work.
> Thank you.
> 

Until someone gives you a better answer than this, here's the link to
the math module documentation at python.org.

http://www.python.org/doc/current/lib/module-math.html

Among many other features, it includes:

log(x) 
    Return the natural logarithm of x. 

log10(x) 
    Return the base-10 logarithm of x. 

> Sincerely,
> 
> Charles
> 
> 

Rob
-- 
Aw, c'mon.... You indent ANYWAY!
Useless Python!
http://www.lowerstandard.com/python


From dyoo@hkn.eecs.berkeley.edu  Sun Sep  9 06:28:31 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sat, 8 Sep 2001 22:28:31 -0700 (PDT)
Subject: [Tutor] log
In-Reply-To: <3B9AEB92.908232AD@yahoo.com>
Message-ID: <Pine.LNX.4.21.0109082210210.9859-100000@hkn.eecs.berkeley.edu>

On Sat, 8 Sep 2001, Rob wrote:

> > If someone knows how to write a program that computes log base 10 and
> > natural log please write me a few examples and explain how they work.
> > Thank you.
> > 
> 
> Until someone gives you a better answer than this, here's the link to
> the math module documentation at python.org.
> 
> http://www.python.org/doc/current/lib/module-math.html
> 
> Among many other features, it includes:
> 
> log(x) 
>     Return the natural logarithm of x. 
> 
> log10(x) 
>     Return the base-10 logarithm of x. 


[Note: this next post is not meant to be a serious response to your
question.]


I thought it might be fun to try this in a completely Useless manner.  
*grin*


###
"""A small program to play around with the Taylor expansion of
the natural logarithm.

Danny Yoo (dyoo@hkn.eecs.berkeley.edu)

In Calculus, we learn that a function f(x) can be approximated
using a Taylor expansion.  That is,

    f(x) = \sum_{n>=0} [f^n (c_0)  (x - c_0)^n] / (n!)

or, in less TeXiee terms:

    SUM    (Nth Derivative of f, applied on c_0) * (x - c_0)**n
    n>=0   ----------------------------------------------------
                                  n!

When we apply this formula to the natural logarithm function, what
we get is pretty neat:

    ln(x) = \sum_{n>=1} [(-1)^{n-1} (x-1)^n] / n

This is the Taylor expansion of ln(x), centered on x=1.  Of course, this
is useless, since we can't add this infinite sum up. This version of log
has HORRIBLE accuracy the farther we get from the center of the
approximation.
"""

from __future__ import nested_scopes

def log(x, iterations = 1000):
    result = 0
    for n in range(1, iterations+1):
        result += nth_log_term(n)(x)
    return result

def nth_log_term(n):
    def func(x):
        if odd(n):
            return (float(x-1)**n) / float(n)
        else:
            return (-float(x-1)**n) / float(n)
    return func

def odd(x): return x % 2 == 1
###


Let's see it in action:

###
>>> log(1)
0.0                       ## Well, at least it got that right.
>>> log(2)
0.69264743055982225       ## Hmmm.
                          ## How far is this from math.log?
>>> math.log(2)
0.69314718055994529       ## Ok, so it's sorta close.
>>> log(3)
-7.1410087914218761e+297  ## That's way off!
###


I don't recommend you use this method for your program.  *grin*



From nwertz@home.com  Sun Sep  9 16:17:05 2001
From: nwertz@home.com (Nick Wertzberger)
Date: Sun, 9 Sep 2001 10:17:05 -0500
Subject: [Tutor] i have a major problem
Message-ID: <JKEDIBPDANGDJLHJHCICCEDBCBAA.nwertz@home.com>

every time i try to access a file named snakeoil.txt, i get htis message:
Traceback (most recent call last):
  File "<pyshell#2>", line 1, in ?
    data=open("snakeoil.txt")
IOError: [Errno 2] No such file or directory: 'snakeoil.txt'

how do i fix this PROBLEM!?!?!?!?

i am getting really frustrated, the file is in the same folder as the
program, and i have made a copy on the mail part of my drive so it would be
at the beginning.

im using version 2.1.1

here's the code i use

#!/usr/bin/python

# open file
data = open("snakeoil.txt")

# read file
dump = data.read()
print dump, "-- EOF -- EOF --"

# clean up
data.close()



From Charlie@begeistert.org  Sun Sep  9 16:22:54 2001
From: Charlie@begeistert.org (Charlie Clark)
Date: Sun, 09 Sep 2001 17:22:54 +0200
Subject: [Tutor] Problem with IDLE in Windows
In-Reply-To: <Pine.LNX.4.21.0109071040380.12164-100000@hkn.eecs.berkeley.edu>
Message-ID: <1000048974_PM_BeOS.Charlie@begeistert.org>

Danny and Kirby both wrote to me about a problem I was having in 
replacing a single apostrophe.

I will post the error in another mail, need to boot windows to generate 
it but I think replacing a single apostrpohe with an escaped one seems 
to work fine

>### 
>fname, lname = 'Issac', 'Asimov' 
>cursor.execute("""insert into authors (fname, lname) 
>                  values ('%s', '%s')""" % (fname, lname)) 
>### 
> 
>we can use: 
> 
>### 
>fname, lname = 'Issac', 'Asimov' 
>cursor.execute("""insert into authors (fname, lname) 
>                  values (?, ?)""", fname, lname) 
>### 
The thing I'm trying to set up a generalised method to work with data 
coming from dictionaries with different keys so I need to compose the 
various parts of the SQL commands (database name, column headings, data 
values) and carefully put them together. I've managed to do this with 
eval() but since I put the things into a class I'm getting some strange 
errors.

Here's my code:

class Database:
	def __init__(self, database):
		self.database = database
		self.db = DriverConnect('DSN=demo-image;UID=sa;PWD=')
		self.c = self.db.cursor()
	
	def clear_database(self):
		command = "'DELETE FROM " + self.database + "'"
#		print command
		self.c.execute(command)
		
	def insert_database(self, items, keys = []):
		## default is all keys in items, otherwise list of selected keys
		if keys == []:
			keys = items[0].keys()

		names, values = [], []	# list of keys for formatted printing
		for key in keys:
			names.append(key)
			values.append("' %(" + key + ")s '")
		insert = ", ".join(values)
		insert = "\"( " + insert + " )\"%item"
		names = ", ".join(names)
#		print "names", names
#		print insert
		
		for item in items:
			sql = eval(insert)
#			print insert
			command = "'INSERT INTO " + self.database + "( " + names + " ) VALUES 
'" + sql
#			print command
			self.c.excecute(command)

I've had lots of fun getting this work and learned quite a bit while 
doing it such as why there is such a thing as self. I think self only 
exists to give a globally addressable namespace within the class.

This is currently generating an attribute error on running

from mx.ODBC.Windows import DriverConnect # or equivalent

dict = [{'name':'charlie', 'age':'too old'}, {'name':'charlies brother', 
'age':'too young'}]

d = Database("charlies_database")
d.insert_database[dict] 		# this generates an attribute error


It's been very useful to be able to test this in the interactive 
interpreter but the broken history function is a bit annoying.

Charlie




From ignacio@openservices.net  Sun Sep  9 16:25:13 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Sun, 9 Sep 2001 11:25:13 -0400 (EDT)
Subject: [Tutor] i have a major problem
In-Reply-To: <JKEDIBPDANGDJLHJHCICCEDBCBAA.nwertz@home.com>
Message-ID: <Pine.LNX.4.33.0109091124440.22125-100000@terbidium.openservices.net>

On Sun, 9 Sep 2001, Nick Wertzberger wrote:

> every time i try to access a file named snakeoil.txt, i get htis message:
> Traceback (most recent call last):
>   File "<pyshell#2>", line 1, in ?
>     data=open("snakeoil.txt")
> IOError: [Errno 2] No such file or directory: 'snakeoil.txt'
>
> how do i fix this PROBLEM!?!?!?!?

Are you sure that you're getting the case right?

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From urnerk@qwest.net  Sun Sep  9 17:18:32 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Sun, 09 Sep 2001 09:18:32 -0700
Subject: [Tutor] Problem with IDLE in Windows
In-Reply-To: <1000048974_PM_BeOS.Charlie@begeistert.org>
References: <Pine.LNX.4.21.0109071040380.12164-100000@hkn.eecs.berkeley.edu>
Message-ID: <4.2.0.58.20010909091240.00cfcb30@pop3.norton.antivirus>

>
>d = Database("charlies_database")
>d.insert_database[dict]  # this generates an attribute error

The use of square brackets isn't defined in your object.
insert_database is a regular "callable" method, expecting
parentheses.  If you want to supply your own meaning for
square brackets, as if you were trying to set the value
of a list or dictionary item, you'd have to define
__setitem__ in your class -- but I don't see that this
is a priority in your case.  Just go:

d.insert_database(dict)

instead.  You may still get an error message, but it should
be a different one :-D

Kirby

PS:  didn't understand about escaped apostrophe exactly,
as your examples don't include any, but I'm glad you've
got that working.




From jcosby@mindspring.com  Sun Sep  9 18:19:33 2001
From: jcosby@mindspring.com (Jon Cosby)
Date: Sun, 9 Sep 2001 10:19:33 -0700
Subject: [Tutor] "Internal Server Error"
Message-ID: <MBBBIFMLIJLJLMBAJBPOOECGCAAA.jcosby@mindspring.com>

Can somebody tell me why this works:

x = dict.items()
x.sort(paircomp)
for k, v in x:
	k = string.replace(k, dir + '/', url)
	k1 = string.replace(k, url, "")
	print '<a href=\"' + k + '\">'
	print '<b>', k1, '</b></a>&nbsp;', v, counter(v), 'matches<br>'
print '</body>'


But when I modify it slightly,


if len(dict) = 0:
	print '<h3>No matches found</h3>'
else:
	x = dict.items()
	x.sort(paircomp)
	for k, v in x:
		k = string.replace(k, dir + '/', url)
		k1 = string.replace(k, url, "")
		print '<a href=\"' + k + '\">'
		print '<b>', k1, '</b></a>&nbsp;', v, counter(v), 'matches<br>'
print '</body>'


I get an "internal server error"?


Jon Cosby

jcosby@mindspring.com
www.jcosby.com 


From ignacio@openservices.net  Sun Sep  9 18:25:48 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Sun, 9 Sep 2001 13:25:48 -0400 (EDT)
Subject: [Tutor] "Internal Server Error"
In-Reply-To: <MBBBIFMLIJLJLMBAJBPOOECGCAAA.jcosby@mindspring.com>
Message-ID: <Pine.LNX.4.33.0109091325000.22125-100000@terbidium.openservices.net>

On Sun, 9 Sep 2001, Jon Cosby wrote:

> Can somebody tell me why this works:
>
> x = dict.items()
> x.sort(paircomp)
> for k, v in x:
> 	k = string.replace(k, dir + '/', url)
> 	k1 = string.replace(k, url, "")
> 	print '<a href=\"' + k + '\">'
> 	print '<b>', k1, '</b></a>&nbsp;', v, counter(v), 'matches<br>'
> print '</body>'
>
>
> But when I modify it slightly,
>
>
> if len(dict) = 0:
              ^^^

> 	print '<h3>No matches found</h3>'
> else:
> 	x = dict.items()
> 	x.sort(paircomp)
> 	for k, v in x:
> 		k = string.replace(k, dir + '/', url)
> 		k1 = string.replace(k, url, "")
> 		print '<a href=\"' + k + '\">'
> 		print '<b>', k1, '</b></a>&nbsp;', v, counter(v), 'matches<br>'
> print '</body>'
>
>
> I get an "internal server error"?

If you try running it manually, you'll get a SyntaxError exception.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From urnerk@qwest.net  Sun Sep  9 18:36:29 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Sun, 09 Sep 2001 10:36:29 -0700
Subject: [Tutor] "Internal Server Error"
In-Reply-To: <MBBBIFMLIJLJLMBAJBPOOECGCAAA.jcosby@mindspring.com>
Message-ID: <4.2.0.58.20010909103159.00cf9a10@pop3.norton.antivirus>

>
>if len(dict) = 0:

                ^
Needs to be:   ==

Difficult to debug when running cgi unless you
trap the Python error and display it on the
server.  One option is to do something like
this:

==============================

   #!/usr/local/bin/python
   import cgi
   import sys        # include this
   import traceback  # include this

   sys.stderr = sys.stdout
   print "Content-Type: text/html\n"

   try:

     print """
   <html>\n
   <head>\n
   <title>Feedback</title>\n
   </head>\n<body>
   </body>\n
   </html>"""

   except:  # trap Python error and display in browser

       print "\n\n<PRE>"
       traceback.print_exc()
       print "\n</PRE>"

==============================

Kirby



From sheila@thinkspot.net  Sun Sep  9 18:44:15 2001
From: sheila@thinkspot.net (Sheila King)
Date: Sun, 09 Sep 2001 10:44:15 -0700
Subject: [Tutor] i have a major problem
In-Reply-To: <JKEDIBPDANGDJLHJHCICCEDBCBAA.nwertz@home.com>
References: <JKEDIBPDANGDJLHJHCICCEDBCBAA.nwertz@home.com>
Message-ID: <426CC144F33@kserver.org>

On Sun, 9 Sep 2001 10:17:05 -0500, "Nick Wertzberger" <nwertz@home.com>
wrote about [Tutor] i have a major problem:

:every time i try to access a file named snakeoil.txt, i get htis message:
:Traceback (most recent call last):
:  File "<pyshell#2>", line 1, in ?
:    data=open("snakeoil.txt")
:IOError: [Errno 2] No such file or directory: 'snakeoil.txt'
:
:how do i fix this PROBLEM!?!?!?!?

I've recently been having problems of this type, myself.
If python says the file doesn't exist, then you must be doing something
wrong, like being in the wrong directory, spelling or case error or
something.

One thing that I have found to help, is adding a few lines to my script,
something like this:

>>> import os
>>> os.listdir(os.curdir)

This will return a list of all the files in the current directory.
Sometimes looking at the list of files that Python sees in the current
directory can be quite insightful.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/




From mailgrabber-feedback-1@lb.bcentral.com  Sun Sep  9 22:09:28 2001
From: mailgrabber-feedback-1@lb.bcentral.com (Anonymouse)
Date: 9 Sep 2001 21:09:28 -0000
Subject: [Tutor] Ïðîäàæà,ïîêóïêà ïðîäóêöèè,ïîèñê ïàðòíåðîâ.
Message-ID: <1000069768.79405.qmail@ech>

                  Óâàæàåìûå ãîñïîäà!

	        ×òî òàêîå Èíôîðìàöèÿ ?   
Èíôîðìàöèÿ – ýòî âëàñòü, áîãàòñòâî, óñïåõ, ïðîöâåòàíèå.
Êòî âëàäååò èíôîðìàöèåé, òîò óïðàâëÿåò.

	ÎÎÎ «ÂÈÝËÜ-Ì» ïðåäëàãàåò Âàì âîñïîëüçîâàòüñÿ òàêîé èíôîðìàöèåé è âçÿòü íà ñåáÿ ïðîáëåìó ïîèñêà íåîáõîäèìîãî Âàì îáîðóäîâàíèÿ, ñûðüÿ, ïðèáîðîâ, ìàòåðèàëîâ è ò. ä., ñëîâîì âñåãî òîãî, áåç ÷åãî íå ìîæåò ñóùåñòâîâàòü Âàøå ïðîèçâîäñòâî, óñïåøíî ïðîöâåòàòü Âàø áèçíåñ. 
	Áëàãîäàðÿ îáøèðíûì ñâÿçÿì ñ âåäóùèìè ïðîèçâîäèòåëÿìè è ïîñòàâùèêàìè íå òîëüêî â Ðîññèè, íî è çà ðóáåæîì, ìû èìååì âîçìîæíîñòü âûïîëíÿòü Âàøè çàêàçû íàèáîëåå ïîëíî è â êðàò÷àéøèå ñðîêè.
	Ñïåêòð íàøåé äåÿòåëüíîñòè äîâîëüíî øèðîê. 
        Ýòî îáëàñòü ýëåêòðîíèêè, ïðè÷åì íå òîëüêî ïîñòàâêè ïðèáîðîâ, àïïàðàòóðû, íî è ðàçëè÷íûå êîìïëåêòóþùèå êàê îòå÷åñòâåííûõ, òàê è çàðóáåæíûõ ïðîèçâîäèòåëåé ýëåêòðîííîé òåõíèêè. Ýòî òàêèå ôèðìû êàê International Rectifier, Epcos, Bourns, Metex, unit-t è äð.
        Ýòî îáëàñòü ìåòàëëîâåäåíèÿ- ñâàðî÷íûå ýëåêòðîäû, ìåòàëë-ëèñò, óãîëîê, øâåëëåð, ëåíòà, òðóáû è ò.ä.
        Ýòî ïîñòàâêè ñòàíêîâ, îáîðóäîâàíèÿ äëÿ ïðîèçâîäñòâà, àïïàðàòû ãàçâîäû, ñâåòèëüíèêè äëÿ îôèñîâ è ïðîìûøëåííûõ ïðåäïðèÿòèé, ëþñòðû, ñâàðî÷íîå îáîðóäîâàíèå è ò.ä.
        Ýòî îáëàñòü ìåäèöèíû- â íàñòîÿùåå âðåìÿ ìû ïðåäñòàâëÿåì óíèêàëüíîå èçîáðåòåíèå ðóññêîãî ó÷åíîãî-ëþñòðó ×èæåâñêîãî.
	
      Ñ ïîëíûì ïåðå÷íåì ïðîäóêöèè, ïîñòàâëÿåìîé íàøåé ôèðìîé,Âû ñìîæåòå îçíàêîìèòüñÿ íà íàøåì ñàéòå â èíòåðíåò:
		     vielm.narod.ru

   Èíôîðìàöèÿ íà äàííîì ñàéòå áóäåò ïîñòîÿííî îáíîâëÿòüñÿ è ñîâåðøåíñòâîâàòüñÿ.
    Ìû íå ïðîñòî ïðåäîñòàâëÿåì  èíôîðìàöèþ, ãäå ìîæíî äîñòàòü íóæíóþ Âàì ïðîäóêöèþ, ìû ñàìè ïîñòàâèì Âàì çàêàçàííûé òîâàð ïî âûãîäíûì äëÿ Âàñ öåíàì è â îïòèìàëüíî êîðîòêèå ñðîêè.
    Âàøó ïîòðåáíîñòü â  ïðîäóêöèè ïðåäñòàâëåííîé íà íàøåì ñàéòå, Âû ìîæåòå îòïðàâèòü íà íàø ôàêñ:  (095)  275-89-94, èëè ïî ýëåêòðîííîé ïî÷òå: tandiv@mail.ru .
    Ìû æäåì Âàñ è âûðàæàåì óâåðåííîñòü â òîì, ÷òî îáðàòèâøèñü ê íàì, Âû ïîëó÷èòå êâàëèôèöèðîâàííóþ ïîìîùü, âíèìàòåëüíîå îòíîøåíèå ê Âàøèì ïîòðåáíîñòÿì, îïåðàòèâíóþ îáðàáîòêó Âàøåãî çàêàçà.

      Ïî âñåì âîïðîñàì âû ìîæåòå îáðàùàòüñÿ ïî òåëåôîíàì: 275-89-94, 746-68-78.


_______________________________________________________________________
Powered by List Builder
To unsubscribe follow the link:
http://lb.bcentral.com/ex/manage/subscriberprefs?customerid=15131&subid=4F31E628C99B6F48&msgnum=1


From SBrunning@trisystems.co.uk  Mon Sep 10 08:45:31 2001
From: SBrunning@trisystems.co.uk (Simon Brunning)
Date: Mon, 10 Sep 2001 08:45:31 +0100
Subject: [Tutor] trouble running Grail
Message-ID: <31575A892FF6D1118F5800600846864D78C0F7@intrepid>

> From:	Lance E Sloan [SMTP:lsloan@umich.edu]
> Why would the Grail author give two arguments to append?  Was
> there an old version of Python that allowed two arguments?
 
In a word, yes. See
<http://amk.ca/python/2.0/new-python.html#SECTION0001100000000000000000> for
an explanation.

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning@trisystems.co.uk




-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.


From nidhi@ncoretech.com  Mon Sep 10 10:05:20 2001
From: nidhi@ncoretech.com (Sreenidhi.B.G)
Date: Mon, 10 Sep 2001 14:35:20 +0530
Subject: [Tutor] need some help
Message-ID: <3B9C8250.6B01E6C8@ncoretech.com>

Helo,
    I am working on a small example where in I call my c function, and
I'm unable to link to the python library. I'm getting undefined
reference to these function calls, - PyArg_ParseTuple and Py_BuildValue.

can you please help me link this to python library. We are working on
Linux7.1.and we are using python 1.5

regards,
-sreenidhi,



From ajaya@ncoretech.com  Mon Sep 10 12:34:55 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Mon, 10 Sep 2001 17:04:55 +0530
Subject: [Tutor] Windows IDE ..., Problems while executing python code ?
Message-ID: <000001c139ec$9e373d90$6501a8c0@ncoretech.com>

Hi,

I am getting a suprising error with Windows IDE, When I want to test my code
on windows to check I jsut run uing Ctrl + F5, but when I have a import
statements for the user defined modules ..., python is telling me Import
error...like this...,

 File "C:\Python20\projects\VirtualHandset\utils.py", line 8, in ?
    from HandSetUtils import *
ImportError: No module named HandSetUtils


But suprisingly my modules are present there it self. Then I just copied
these files to the python installation directory...it started working
fine..., then I deleted from python installation directory..., but it
started working fine...then I closed all windows ..., this time again it
started giving the above problem...,

I very much cross checked the name and direcotry...,

I tried with setting path variable to solve this problem. But it did not
help much...,

Can any one suggest some thing to fix this problem.

with regards,
Ajaya





From sendme105@hotmail.com  Mon Sep 10 12:38:04 2001
From: sendme105@hotmail.com (James)
Date: Mon, 10 Sep 2001 04:38:04 -0700
Subject: [Tutor] Re: Help with cookies
References: <E15eyty-000093-00@mail.python.org>
Message-ID: <OE57kBnccYTjr8cU6xf00004c74@hotmail.com>

> Dear Python gurus and those who want to become such,
> I need to be able to pass a cookie in a url request.

import os, string
from urllib import *
from mimetools import Message

#redefine (override?) urlopen to enable cookie sending

def urlopen(url, data=None, headers=None):
    u = FancyURLopener()
    if headers:
        if type(headers) == type({}):
            headers = headers.items()
        for kw, val in headers:
            u.addheader(kw, val)
    return u.open(url, data)

# The following gets the cookie info I need...

temppage= urlopen(source_url)
headers=temppage.info()
cookie = headers.getheader("set-cookie")
clist = string.split(cookie, ';')
temppage.close()

# ...to successfully open the page:

page = urlopen(source_url, headers=[('Cookie', clist[0])])


########

Warning: I'm new to programming.  I edited this code entirely from a
comp.python post found via google.

Let me know if it works.

James.






From alan.gauld@bt.com  Mon Sep 10 13:59:56 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 10 Sep 2001 13:59:56 +0100
Subject: [Tutor] sending stdout to a text box
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF37@mbtlipnt02.btlabs.bt.co.uk>

> > run from a prompt. How can I catch this and route it to a 
> text box in tkinter?

I posted a short example of this but it wasn't wondersfully commented.


Essentially you make sys.stdout point to an object which has 
a write() method. (This could be your Tkinter application for 
example)

Now when you call print the output will go to the new object.

Thus

class MyApp(Frame):
   def __init__(self):
     # do stuff here
     self.display = Text(....)  # create our text widget
     sys.stdout = self          # Set stdout here

   def write(self, s):   # provide the necessary write method
     self.display.insert(END.s)  # append the string s to the widget

   # other methods as usual...
   def foo(self):
      print "This is foo"	  # will appear in text widget

Hope thats a little clearer.

Alan G.


From bill_tolbert@bigfoot.com  Mon Sep 10 14:30:46 2001
From: bill_tolbert@bigfoot.com (Bill Tolbert)
Date: Mon, 10 Sep 2001 09:30:46 -0400 (EDT)
Subject: [Tutor] sending stdout to a text box
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF37@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <Pine.GSO.4.21L1.0109100909230.22370-100000@sunny>

Thanks for the reply Alan. Kalle posted a good example too (I'm the one
who asked originally). I'm close, but not quite where I want to be.

I'm trying to incorporate some utility scripts that use print statements
to tell the user what's going on (success, error, busy, etc). I want my
gui to consolidate these and just redirect the existing print statements
to the text widget on the gui.

Output from ICAREBackup goes to BogusFile and on to the text box, but not
until ICAREBackup finishes. I was looking for a way to provide
immediate feedback. Some of these utilities could run for a very long
time, leaving the user confused and ready to reboot without
feedback. Output to the shell window is immediate; it doesn't wait
until the script finishes. Can I duplicate that immediate feedback?

    def backup(self):
        import ICAREBackup
        sys.stdout = BogusFile(self.text_box)
        ICAREBackup.stdout = BogusFile(self.text_box)
        ICAREBackup.ICAREBackup()

Thanks guys,

Bill

On Mon, 10 Sep 2001 alan.gauld@bt.com wrote:

> > > run from a prompt. How can I catch this and route it to a 
> > text box in tkinter?
> 
> I posted a short example of this but it wasn't wondersfully commented.
> 
> 
> Essentially you make sys.stdout point to an object which has 
> a write() method. (This could be your Tkinter application for 
> example)
> 
> Now when you call print the output will go to the new object.
> 
> Thus
> 
> class MyApp(Frame):
>    def __init__(self):
>      # do stuff here
>      self.display = Text(....)  # create our text widget
>      sys.stdout = self          # Set stdout here
> 
>    def write(self, s):   # provide the necessary write method
>      self.display.insert(END.s)  # append the string s to the widget
> 
>    # other methods as usual...
>    def foo(self):
>       print "This is foo"	  # will appear in text widget
> 
> Hope thats a little clearer.
> 
> Alan G.
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 



=-=-=-=-=-=-=-=-=
Bill Tolbert



From lsloan@umich.edu  Mon Sep 10 14:55:54 2001
From: lsloan@umich.edu (Lance E Sloan)
Date: Mon, 10 Sep 2001 09:55:54 -0400
Subject: [Tutor] trouble running Grail
In-Reply-To: Your message of "Fri, 07 Sep 2001 17:19:15 EDT."
 <Pine.LNX.4.33.0109071718130.21138-100000@terbidium.openservices.net>
Message-ID: <200109101355.JAA00076@birds.us.itd.umich.edu>

Ignacio Vazquez-Abrams wrote:
> Grail is _ancient_. I remember using Grail 0.6 a _looooong_ time ago.

Yes, it is pretty old.  But I'm convinced that most of the available
web browsers do several things wrong, or at least stupidly.  Since I'm
getting the hang of Python, Grail sounded like a good browser to poke
around in the guts of without feeling tainted afterwards.

--
Lance E Sloan
Web Services, Univ. of Michigan: Full-service Web and database design,
development, and hosting.  Specializing in Python & Perl CGIs.
http://websvcs.itd.umich.edu/ - "Putting U on the Web"


From jcosby@mindspring.com  Mon Sep 10 18:09:15 2001
From: jcosby@mindspring.com (Jon Cosby)
Date: Mon, 10 Sep 2001 10:09:15 -0700
Subject: [Tutor] Lists and removal
Message-ID: <MBBBIFMLIJLJLMBAJBPOAECMCAAA.jcosby@mindspring.com>

Sorry, I got careless the first time. I was referring to the Python list
operation, not removal from the mailing list. I imagine a lot of people
ignored my first message. Let's try this again:

I'm doing a Web search that is succesful until I try to configure it to
ignore specified directories using the "remove" operation. I'm not getting
any error messages, but the script stops when it comes to the function
below. I've run the first few lines in the interpreter, and I can't see
anything wrong with it. Any ideas?


def getFile(text, dir):
	hits = []
	dl = os.listdir(dir)
	for item in ignore:	# List of directories to ignore
		dl.remove(item)   # Works in interpreter, but list comes up empty here
	text = string.lower(text)
	for d in dl:
		d = dir + '\\' + d
		if os.path.isfile(d):
			hits.extend(searchtext(d, text))
		elif os.path.isdir(d):
			hits.extend(getFile(text, d))
	return hits


Jon Cosby

jcosby@mindspring.com
www.jcosby.com



From girishg@india.ti.com  Mon Sep 10 18:29:18 2001
From: girishg@india.ti.com (Girish Gajwani)
Date: Mon, 10 Sep 2001 22:59:18 +0530
Subject: [Tutor] loading modules dynamically
Message-ID: <3B9CF86E.7868D460@india.ti.com>

Hi all,

I have been trying to load modules dynamically using the
__import__ hook , as follows:

#######################
#! /usr/bin/env  python

def my_import(name):
  mod = __import__(name)
  print mod
  print dir(mod)
  return mod

mod = my_import("os")
print mod.listdir(".")
#######################

My interpretation of the __import__ hook is that it loads
the module mentioned & also, aliases it to mod. Is this
correct? I could not understand the documentation mentioned
in the library reference wrt __import__, hence this
question.

Also, in what case can the above scene fail? What error
checking would I need to add here?

Regards
Girish


From dyoo@hkn.eecs.berkeley.edu  Mon Sep 10 23:37:22 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 10 Sep 2001 15:37:22 -0700 (PDT)
Subject: [Tutor] loading modules dynamically
In-Reply-To: <3B9CF86E.7868D460@india.ti.com>
Message-ID: <Pine.LNX.4.21.0109101532160.17299-100000@hkn.eecs.berkeley.edu>

On Mon, 10 Sep 2001, Girish Gajwani wrote:

> Hi all,
> 
> I have been trying to load modules dynamically using the
> __import__ hook , as follows:
> 
> #######################
> #! /usr/bin/env  python
> 
> def my_import(name):
>   mod = __import__(name)
>   print mod
>   print dir(mod)
>   return mod
> 
> mod = my_import("os")
> print mod.listdir(".")
> #######################
> 
> My interpretation of the __import__ hook is that it loads
> the module mentioned & also, aliases it to mod. Is this
> correct? I could not understand the documentation mentioned
> in the library reference wrt __import__, hence this
> question.

Yes, __import__ does load the module and return it:

###
>>> m = __import__('os')
>>> m
<module 'os' from '/home/dyoo/local/lib/python2.1/os.pyc'>
###

Note, though, that importing modules this way doesn't automatically allow
us to reference the os module with the name 'os':

###
>>> os
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: name 'os' is not defined
###




> Also, in what case can the above scene fail? What error
> checking would I need to add here?

When Python imports a module, and runs into an error, it will raise an
"ImportError".  For example:

###
>>> m = __import__('skljfflskj')
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ImportError: No module named skljfflskj
###

What we can do is write a small exception handler that checks for this
situation.  Here's one version of my_import() that checks for
ImportErrors:


def my_import(name):
    try:
        mod = __import__(name)
    except ImportError:
        print "Whoops, I don't know about", name
        return None
    print mod
    print dir(mod)
    return mod


HOpe this helps!



From jeff@ccvcorp.com  Tue Sep 11 01:44:41 2001
From: jeff@ccvcorp.com (Jeff Shannon)
Date: Mon, 10 Sep 2001 17:44:41 -0700
Subject: [Tutor] Windows IDE ..., Problems while executing python code ?
References: <E15gTUu-0007FX-00@mail.python.org>
Message-ID: <3B9D5E79.2D1CA1E@ccvcorp.com>

> Hi,
>
> I am getting a suprising error with Windows IDE, When I want to test my code
> on windows to check I jsut run uing Ctrl + F5, but when I have a import
> statements for the user defined modules ..., python is telling me Import
> error...like this...,
>
>  File "C:\Python20\projects\VirtualHandset\utils.py", line 8, in ?
>     from HandSetUtils import *
> ImportError: No module named HandSetUtils
>
> But suprisingly my modules are present there it self. Then I just copied
> these files to the python installation directory...it started working
> fine..., then I deleted from python installation directory..., but it
> started working fine...then I closed all windows ..., this time again it
> started giving the above problem...,

You're almost certainly on the right track, in that it's a path problem.  Python is not looking in your \projects\* directory for modules, and won't unless you specifically tell it to.  When you put your modules into the regular python install dir, then they were found.  As
for why it worked after you deleted those copies, until you shut down PythonWin (I'm presuming that's what you mean by Windows IDE, but the same would happen with IDLE), you have to know how module imports work.  Once Python has loaded a module, further calls to import it
simply add a reference to the existing module in memory.  Since you'd already imported your modules, the IDE didn't need to find the files to do a second import, so it never noticed that you'd deleted them.  However, once you shut down the IDE and restarted it, then the
modules were (obviously) no longer in memory and needed to be loaded from the files... and you're back to where you were to start off with.

The simplest solution to this whole problem, is to create a text file in your main Python directory (c:\Python20\).  The file needs to have the extension .pth (best bet is to name it python.pth).  Each line in this file should contain a directory name.  Each directory so
named (and any subdirectories, IIRC), will be added to Python's search path.  So, if you create this file with the single line  "C:\Python20\projects", your problem should be solved.  If that doesn't work, you *might* need to add another line
"C:\Python20\projects\VirtualHandset".  Once you have this file, restart your IDE.  From then on, you should be set.

HTH

Jeff Shannon
Technician/Programmer
Credit International




From ajaya@ncoretech.com  Tue Sep 11 06:16:35 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Tue, 11 Sep 2001 10:46:35 +0530
Subject: [Tutor] How to implement portable message queue betwwen Python application and another application ??
Message-ID: <000001c13a80$ede81780$6501a8c0@ncoretech.com>

Hi,

I've some doubts regarding desiging portable application on Linux and Windos
using python. My requirements are..,

I need to send data from Python interface to the C application which is
running indipendently. I was thiking of implemenitg using message queue. But
since it is different I was thinking some alternative ways of implementing
it.

What is general way of implementing message queues (for sending messages
from python to another application.), I've some idea of implementing using
socket pipe (in the same system). But I really don't what are the drawbacks
when I implement using sockets rather than using normal approch of sending
messages using message ques..,


Thanks and Regards,
Ajaya



From ignacio@openservices.net  Tue Sep 11 06:39:59 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Tue, 11 Sep 2001 01:39:59 -0400 (EDT)
Subject: [Tutor] How to implement portable message queue betwwen Python
 application and another application ??
In-Reply-To: <000001c13a80$ede81780$6501a8c0@ncoretech.com>
Message-ID: <Pine.LNX.4.33.0109110138320.27450-100000@terbidium.openservices.net>

On Tue, 11 Sep 2001, Ajaya Babu wrote:

> I've some doubts regarding desiging portable application on Linux and Windos
> using python. My requirements are..,
>
> I need to send data from Python interface to the C application which is
> running indipendently. I was thiking of implemenitg using message queue. But
> since it is different I was thinking some alternative ways of implementing
> it.

Unix Domain sockets (AF_UNIX) are usable on both Linux and Windows, and is
probably the most portable method.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From r.b.rigilink@chello.nl  Tue Sep 11 07:48:48 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Tue, 11 Sep 2001 08:48:48 +0200
Subject: [Tutor] Lists and removal
References: <MBBBIFMLIJLJLMBAJBPOAECMCAAA.jcosby@mindspring.com>
Message-ID: <3B9DB3D0.CC71D119@chello.nl>

Hi Jon,

At first sight, what you do looks OK.

One idea:

If ignore contains items that are not in dl. Then

for item in ignore:
    dl.remove(item)

will raise a ValueError. Are you sure that you're not catching this
Exception
somewhere.

If that's not the case some judiously placed print stetements should
find the bug
For instance:

def getFile(text, dir):
        hits = []
        dl = os.listdir(dir)
        print dl, ignore
        for item in ignore:
                print item, dl.index(item)
                dl.remove(item)
        print dl
        text = string.lower(text)
        for d in dl:
                d = dir + '\\' + d
                if os.path.isfile(d):
                        hits.extend(searchtext(d, text))
                elif os.path.isdir(d):
                        hits.extend(getFile(text, d))
        return hits


By the way: this function does two things. it searches for files, and
then it searches
for text in files. It might be a good idea to rewrite this as (untested)

def getFile(dir, ignore=[]):
        '''recursevly search for files in dir, ignoring files from
ignore'''
        hits = []
        dl = os.listdir(dir)
        for item in ignore:
		try:
                        dl.remove(item)
                except ValueError:
                        pass
        for d in dl:
                d = os.path.join(dir, d) # platform idependent
                if os.path.isfile(d):
                        hits.extend([d])
                elif os.path.isdir(d):
                        hits.extend(getFile(d))
        return hits

use with:

result = []
for file in getFile(dir, ignore):
    result.extend(searchtext(file, text))

Hope this helps,

Roeland    

Jon Cosby wrote:
> 
> Sorry, I got careless the first time. I was referring to the Python list
> operation, not removal from the mailing list. I imagine a lot of people
> ignored my first message. Let's try this again:
> 
> I'm doing a Web search that is succesful until I try to configure it to
> ignore specified directories using the "remove" operation. I'm not getting
> any error messages, but the script stops when it comes to the function
> below. I've run the first few lines in the interpreter, and I can't see
> anything wrong with it. Any ideas?
> 
> def getFile(text, dir):
>         hits = []
>         dl = os.listdir(dir)
>         for item in ignore:     # List of directories to ignore
>                 dl.remove(item)   # Works in interpreter, but list comes up empty here
>         text = string.lower(text)
>         for d in dl:
>                 d = dir + '\\' + d
>                 if os.path.isfile(d):
>                         hits.extend(searchtext(d, text))
>                 elif os.path.isdir(d):
>                         hits.extend(getFile(text, d))
>         return hits
> 
> Jon Cosby
> 
> jcosby@mindspring.com
> www.jcosby.com
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"



From ajaya@ncoretech.com  Tue Sep 11 07:46:26 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Tue, 11 Sep 2001 12:16:26 +0530
Subject: [Tutor] How to convert integer to binay packed string...,?
Message-ID: <000201c13a8d$7b71cd60$6501a8c0@ncoretech.com>

Hi All,

I've a small doubt, How to convert integers into bytestream in python. What
actually I want to do is send integer to another system in the network. But
since there is nothing like integer in python...I am just wondering how can
i manipulate a integer to a string of two bytes which corresponds to the two
binary coded bytes of the integer.

My be my doubt is more basic.., But I've tough time from finding documents

with regards,
Ajaya



From ignacio@openservices.net  Tue Sep 11 07:52:31 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Tue, 11 Sep 2001 02:52:31 -0400 (EDT)
Subject: [Tutor] How to convert integer to binay packed string...,?
In-Reply-To: <000201c13a8d$7b71cd60$6501a8c0@ncoretech.com>
Message-ID: <Pine.LNX.4.33.0109110252060.27450-100000@terbidium.openservices.net>

On Tue, 11 Sep 2001, Ajaya Babu wrote:

> I've a small doubt, How to convert integers into bytestream in python. What
> actually I want to do is send integer to another system in the network. But
> since there is nothing like integer in python...I am just wondering how can
> i manipulate a integer to a string of two bytes which corresponds to the two
> binary coded bytes of the integer.

  http://www.python.org/doc/current/lib/module-struct.html

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From smt@pacific.net.hk  Tue Sep 11 09:40:39 2001
From: smt@pacific.net.hk (Kenneth Tsang)
Date: Tue, 11 Sep 2001 16:40:39 +0800
Subject: [Tutor] Accessing database
References: <E15gTUv-0007Fh-00@mail.python.org>
Message-ID: <03e301c13a9d$6ff52da0$a800a8c0@orange>

Hi, I am working on an applications which need to have database access.
Please advise which module I should use (seems there are lot of them, lik=
e
sql.pyd-which I collect from zope, odbc.pyd-comes with win32 from Mark
Hammond's win32extensions...). And would like to see some sample code, if
possible.

My current development environment
win2000 running python
win32 extensions installed
wxPython installed use for front end development

Target database is ODBC based, (currently need to support MSAccess, MSSQL
and mySQL)

I have been looking around in web sites and different articles and no res=
ult
yet. Thanks.

cheers, Kenneth
--
Kenneth Tsang
email: smt@pacific.net.hk tel: +852 9468 4772
----- Original Message -----
From: <tutor-request@python.org>
To: <tutor@python.org>
Sent: Tuesday, September 11, 2001 12:01 AM
Subject: Tutor digest, Vol 1 #1081 - 13 msgs


Send Tutor mailing list submissions to
tutor@python.org

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@python.org

You can reach the person managing the list at
tutor-admin@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: Problem with IDLE in Windows (Kirby Urner)
   2. "Internal Server Error" (Jon Cosby)
   3. Re: "Internal Server Error" (Ignacio Vazquez-Abrams)
   4. Re: "Internal Server Error" (Kirby Urner)
   5. Re: i have a major problem (Sheila King)
   6. =CF=F0=EE=E4=E0=E6?=EF=EE=EA=F3=EF=EA?=EF=F0=EE=E4=F3=EA=F6=E8?=EF=EE=
=E8=F1?=EF=E0=F0=F2=ED=E5=F0=EE? (Anonymouse)
   7. RE: trouble running Grail (Simon Brunning)
   8. need some help (Sreenidhi.B.G)
   9. Windows IDE ..., Problems while executing python code ? (Ajaya Babu=
)
  10. Re: Help with cookies (James)
  11. RE: sending stdout to a text box (alan.gauld@bt.com)
  12. RE: sending stdout to a text box (Bill Tolbert)
  13. Re: trouble running Grail (Lance E Sloan)

--__--__--

Message: 1
Date: Sun, 09 Sep 2001 09:18:32 -0700
To: Charlie@begeistert.org
From: Kirby Urner <urnerk@qwest.net>
Subject: Re: [Tutor] Problem with IDLE in Windows
Cc: tutor@python.org


>
>d =3D Database("charlies_database")
>d.insert_database[dict]  # this generates an attribute error

The use of square brackets isn't defined in your object.
insert_database is a regular "callable" method, expecting
parentheses.  If you want to supply your own meaning for
square brackets, as if you were trying to set the value
of a list or dictionary item, you'd have to define
__setitem__ in your class -- but I don't see that this
is a priority in your case.  Just go:

d.insert_database(dict)

instead.  You may still get an error message, but it should
be a different one :-D

Kirby

PS:  didn't understand about escaped apostrophe exactly,
as your examples don't include any, but I'm glad you've
got that working.




--__--__--

Message: 2
Reply-To: <jcosby@mindspring.com>
From: "Jon Cosby" <jcosby@mindspring.com>
To: <tutor@python.org>
Date: Sun, 9 Sep 2001 10:19:33 -0700
Subject: [Tutor] "Internal Server Error"

Can somebody tell me why this works:

x =3D dict.items()
x.sort(paircomp)
for k, v in x:
k =3D string.replace(k, dir + '/', url)
k1 =3D string.replace(k, url, "")
print '<a href=3D\"' + k + '\">'
print '<b>', k1, '</b></a>&nbsp;', v, counter(v), 'matches<br>'
print '</body>'


But when I modify it slightly,


if len(dict) =3D 0:
print '<h3>No matches found</h3>'
else:
x =3D dict.items()
x.sort(paircomp)
for k, v in x:
k =3D string.replace(k, dir + '/', url)
k1 =3D string.replace(k, url, "")
print '<a href=3D\"' + k + '\">'
print '<b>', k1, '</b></a>&nbsp;', v, counter(v), 'matches<br>'
print '</body>'


I get an "internal server error"?


Jon Cosby

jcosby@mindspring.com
www.jcosby.com


--__--__--

Message: 3
Date: Sun, 9 Sep 2001 13:25:48 -0400 (EDT)
From: Ignacio Vazquez-Abrams <ignacio@openservices.net>
To: <tutor@python.org>
Subject: Re: [Tutor] "Internal Server Error"

On Sun, 9 Sep 2001, Jon Cosby wrote:

> Can somebody tell me why this works:
>
> x =3D dict.items()
> x.sort(paircomp)
> for k, v in x:
> k =3D string.replace(k, dir + '/', url)
> k1 =3D string.replace(k, url, "")
> print '<a href=3D\"' + k + '\">'
> print '<b>', k1, '</b></a>&nbsp;', v, counter(v), 'matches<br>'
> print '</body>'
>
>
> But when I modify it slightly,
>
>
> if len(dict) =3D 0:
              ^^^

> print '<h3>No matches found</h3>'
> else:
> x =3D dict.items()
> x.sort(paircomp)
> for k, v in x:
> k =3D string.replace(k, dir + '/', url)
> k1 =3D string.replace(k, url, "")
> print '<a href=3D\"' + k + '\">'
> print '<b>', k1, '</b></a>&nbsp;', v, counter(v), 'matches<br>'
> print '</body>'
>
>
> I get an "internal server error"?

If you try running it manually, you'll get a SyntaxError exception.

--
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



--__--__--

Message: 4
Date: Sun, 09 Sep 2001 10:36:29 -0700
To: <jcosby@mindspring.com>
From: Kirby Urner <urnerk@qwest.net>
Subject: Re: [Tutor] "Internal Server Error"
Cc: tutor@python.org


>
>if len(dict) =3D 0:

                ^
Needs to be:   =3D=3D

Difficult to debug when running cgi unless you
trap the Python error and display it on the
server.  One option is to do something like
this:

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D

   #!/usr/local/bin/python
   import cgi
   import sys        # include this
   import traceback  # include this

   sys.stderr =3D sys.stdout
   print "Content-Type: text/html\n"

   try:

     print """
   <html>\n
   <head>\n
   <title>Feedback</title>\n
   </head>\n<body>
   </body>\n
   </html>"""

   except:  # trap Python error and display in browser

       print "\n\n<PRE>"
       traceback.print_exc()
       print "\n</PRE>"

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D

Kirby



--__--__--

Message: 5
From: Sheila King <sheila@thinkspot.net>
To: "Nick Wertzberger" <nwertz@home.com>
Cc: tutor@python.org
Subject: Re: [Tutor] i have a major problem
Date: Sun, 09 Sep 2001 10:44:15 -0700

On Sun, 9 Sep 2001 10:17:05 -0500, "Nick Wertzberger" <nwertz@home.com>
wrote about [Tutor] i have a major problem:

:every time i try to access a file named snakeoil.txt, i get htis message=
:
:Traceback (most recent call last):
:  File "<pyshell#2>", line 1, in ?
:    data=3Dopen("snakeoil.txt")
:IOError: [Errno 2] No such file or directory: 'snakeoil.txt'
:
:how do i fix this PROBLEM!?!?!?!?

I've recently been having problems of this type, myself.
If python says the file doesn't exist, then you must be doing something
wrong, like being in the wrong directory, spelling or case error or
something.

One thing that I have found to help, is adding a few lines to my script,
something like this:

>>> import os
>>> os.listdir(os.curdir)

This will return a list of all the files in the current directory.
Sometimes looking at the list of files that Python sees in the current
directory can be quite insightful.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/




--__--__--

Message: 6
Date: 9 Sep 2001 21:09:28 -0000
To: List Member <tutor@python.org>
Reply-To: mailgrabber-feedback-1@lb.bcentral.com
From: "Anonymouse" <massmail@lb.bcentral.com>
Subject: [Tutor] =CF=F0=EE=E4=E0=E6?=EF=EE=EA=F3=EF=EA?=EF=F0=EE=E4=F3=EA=
=F6=E8?=EF=EE=E8=F1?=EF=E0=F0=F2=ED=E5=F0=EE?

                  =D3=E2=E0=E6=E0=E5=EC=FB?=E3=EE=F1=EF=EE=E4?

        =D7=F2?=F2=E0=EA=EE?=C8=ED=F4=EE=F0=EC=E0=F6? ?
=C8=ED=F4=EE=F0=EC=E0=F6? ?=FD=F2?=E2=EB=E0=F1=F2=FC, =E1=EE=E3=E0=F2=F1=F2=
=E2? =F3=F1=EF=E5? =EF=F0=EE=F6=E2=E5=F2=E0=ED=E8?
=CA=F2?=E2=EB=E0=E4=E5=E5?=E8=ED=F4=EE=F0=EC=E0=F6=E8=E5? =F2=EE?=F3=EF=F0=
=E0=E2=EB=FF=E5=F2.

=CE=CE?=AB=C2=C8=DD=CB=DC-=CC=BB =EF=F0=E5=E4=EB=E0=E3=E0=E5=F2 =C2=E0?=E2=
=EE=F1=EF=EE=EB=FC=E7=EE=E2=E0=F2=FC=F1=FF =F2=E0=EA=EE?=E8=ED=F4=EE=F0=EC=
=E0=F6=E8=E5??=E2=E7=FF=F2=FC =ED=E0 =F1=E5?
=EF=F0=EE=E1=EB=E5=EC=F3 =EF=EE=E8=F1=EA=E0 =ED=E5=EE=E1=F5=EE=E4=E8=EC=EE=
=E3=EE =C2=E0?=EE=E1=EE=F0=F3=E4=EE=E2=E0=ED?, =F1=FB=F0=FC=FF, =EF=F0=E8=
=E1=EE=F0=EE=E2, =EC=E0=F2=E5=F0=E8=E0=EB=EE=E2 ??
?, =F1=EB=EE=E2=EE=EC =E2=F1=E5=E3?=F2=EE=E3=EE, =E1=E5?=F7=E5=E3=EE =ED=E5=
 =EC=EE=E6=E5?=F1=F3=F9=E5=F1=F2=E2=EE=E2=E0=F2=FC =C2=E0=F8=E5 =EF=F0=EE=
=E8=E7=E2=EE=E4=F1=F2=E2=EE, =F3=F1=EF=E5=F8=ED?
=EF=F0=EE=F6=E2=E5=F2=E0=F2=FC =C2=E0?=E1=E8=E7=ED=E5=F1.
=C1=EB=E0=E3=EE=E4=E0=F0=FF =EE=E1=F8=E8=F0=ED=FB=EC =F1=E2=FF???=E2=E5=F3=
=F9=E8=EC?=EF=F0=EE=E8=E7=E2=EE=E4=E8=F2=E5=EB=FF=EC=E8 ?=EF=EE=F1=F2=E0=E2=
=F9=E8=EA=E0=EC=E8 =ED=E5 =F2=EE=EB=FC=EA=EE ?
=D0=EE=F1=F1=E8=E8, =ED=EE ?=E7=E0 =F0=F3=E1=E5=E6=EE? =EC=FB =E8=EC=E5=E5=
?=E2=EE=E7=EC=EE=E6=ED=EE=F1=F2?=E2=FB=EF=EE=EB=ED=FF=F2=FC =C2=E0=F8=E8 =
=E7=E0=EA=E0=E7=FB =ED=E0=E8=E1=EE=EB=E5=E5 =EF=EE
=EB=ED???=EA=F0=E0=F2=F7=E0=E9=F8=E8=E5 =F1=F0=EE=EA?
=D1=EF=E5=EA=F2=F0 =ED=E0=F8=E5?=E4=E5=FF=F2=E5=EB=FC=ED=EE=F1=F2?=E4=EE=E2=
=EE=EB=FC=ED=EE =F8=E8=F0=EE?
        =DD=F2?=EE=E1=EB=E0=F1=F2?=FD=EB=E5=EA=F2=F0=EE=ED=E8=EA? =EF=F0=E8=
=F7=E5=EC =ED=E5 =F2=EE=EB=FC=EA=EE =EF=EE=F1=F2=E0=E2=EA=E8 =EF=F0=E8=E1=
=EE=F0=EE=E2, =E0=EF=EF=E0=F0=E0=F2=F3=F0=FB
, =ED=EE ?=F0=E0=E7=EB=E8=F7=ED=FB?=EA=EE=EC=EF=EB=E5=EA=F2=F3=FE=F9=E8?=EA=
=E0?=EE=F2=E5=F7=E5=F1=F2=E2=E5=ED=ED=FB? =F2=E0??=E7=E0=F0=F3=E1=E5=E6=ED=
=FB=F5 =EF=F0=EE=E8=E7=E2=EE=E4=E8=F2=E5=EB=E5=E9
=FD=EB=E5=EA=F2=F0=EE=ED=ED=EE?=F2=E5=F5=ED=E8=EA? =DD=F2?=F2=E0=EA=E8?=F4=
=E8=F0=EC?=EA=E0?International Rectifier, Epcos, Bourns,
Metex, unit-t ?=E4=F0.
        =DD=F2?=EE=E1=EB=E0=F1=F2?=EC=E5=F2=E0=EB=EB=EE=E2=E5=E4=E5=ED?- =
=F1=E2=E0=F0=EE=F7=ED=FB?=FD=EB=E5=EA=F2=F0=EE=E4? =EC=E5=F2=E0=EB=EB-=EB=
=E8=F1=F2, =F3=E3=EE=EB=EE=EA, =F8=E2
=E5=EB=EB=E5? =EB=E5=ED=F2? =F2=F0=F3=E1????
        =DD=F2?=EF=EE=F1=F2=E0=E2=EA=E8 =F1=F2=E0=ED=EA=EE? =EE=E1=EE=F0=F3=
=E4=EE=E2=E0=ED? =E4=EB=FF =EF=F0=EE=E8=E7=E2=EE=E4=F1=F2=E2=E0, =E0=EF=EF=
=E0=F0=E0=F2=FB =E3=E0=E7=E2=EE=E4?
=F1=E2=E5=F2=E8=EB=FC=ED=E8=EA?=E4=EB=FF =EE=F4=E8=F1=EE=E2 ?=EF=F0=EE=EC=
=FB=F8=EB=E5=ED=ED=FB=F5 =EF=F0=E5=E4=EF=F0?=F2=E8? =EB=FE=F1=F2=F0=FB, =F1=
=E2=E0=F0=EE=F7=ED=EE?=EE=E1=EE=F0=F3=E4=EE=E2=E0=ED
=E8=E5 ???
        =DD=F2?=EE=E1=EB=E0=F1=F2?=EC=E5=E4=E8=F6=E8=ED=FB- ?=ED=E0=F1=F2=
?=F9=E5?=E2=F0=E5=EC=FF =EC=FB =EF=F0=E5=E4=F1=F2=E0=E2?=E5=EC =F3=ED=E8=EA=
=E0=EB=FC=ED=EE=E5 =E8=E7=EE=E1=F0=E5
=F2=E5=ED=E8?=F0=F3=F1=F1=EA=EE=E3=EE =F3=F7=E5=ED=EE=E3?=EB=FE=F1=F2=F0=F3=
 =D7=E8=E6=E5=E2=F1=EA=EE=E3=EE.

      ?=EF=EE=EB=ED=FB=EC =EF=E5=F0=E5=F7=ED=E5=EC =EF=F0=EE=E4=F3=EA=F6=E8=
? =EF=EE=F1=F2=E0=E2?=E5=EC=EE=E9 =ED=E0=F8=E5?=F4=E8=F0=EC=EE=E9,=C2=FB =
=F1=EC=EE=E6=E5=F2?=EE=E7=ED=E0=EA=EE=EC=E8
=F2=FC? =ED=E0 =ED=E0=F8=E5?=F1=E0=E9=F2??=E8=ED=F2=E5=F0=ED=E5=F2:
     vielm.narod.ru

   =C8=ED=F4=EE=F0=EC=E0=F6? =ED=E0 =E4=E0=ED=ED=EE=EC =F1=E0=E9=F2?=E1=F3=
=E4=E5?=EF=EE=F1=F2?=ED=ED?=EE=E1=ED=EE=E2=EB=FF=F2=FC? ?=F1=EE=E2=E5=F0=F8=
=E5=ED=F1=F2=E2=EE=E2=E0=F2=FC?.
    =CC=FB =ED=E5 =EF=F0=EE=F1=F2=EE =EF=F0=E5=E4=EE=F1=F2=E0=E2=EB=FF=E5=
=EC  =E8=ED=F4=EE=F0=EC=E0=F6=E8=FE, =E3=E4?=EC=EE=E6=ED?=E4=EE=F1=F2=E0=F2=
?=ED=F3=E6=ED=F3=FE =C2=E0?=EF=F0=EE=E4=F3=EA
=F6=E8? =EC=FB =F1=E0=EC=E8 =EF=EE=F1=F2=E0=E2=E8=EC =C2=E0?=E7=E0=EA=E0=E7=
=E0=ED=ED=FB=E9 =F2=EE=E2=E0?=EF=EE =E2=FB=E3=EE=E4=ED=FB=EC =E4=EB=FF =C2=
=E0?=F6=E5=ED=E0???=EE=EF=F2=E8=EC=E0=EB=FC
=ED=EE =EA=EE=F0=EE=F2=EA=E8=E5 =F1=F0=EE=EA?
    =C2=E0=F8=F3 =EF=EE=F2=F0=E5=E1=ED=EE=F1=F2?? =EF=F0=EE=E4=F3=EA=F6=E8=
?=EF=F0=E5=E4=F1=F2=E0=E2=EB=E5=ED=ED=EE=E9 =ED=E0 =ED=E0=F8=E5?=F1=E0=E9=
=F2? =C2=FB =EC=EE=E6=E5=F2=E5 =EE=F2=EF=F0=E0=E2
=E8=F2?=ED=E0 =ED=E0?=F4=E0=EA=F1:  (095)  275-89-94, =E8=EB?=EF=EE =FD=EB=
=E5=EA=F2=F0=EE=ED=ED=EE?=EF=EE=F7=F2? tandiv@mail.ru .
    =CC=FB =E6=E4=E5=EC =C2=E0??=E2=FB=F0=E0=E6=E0=E5=EC =F3=E2=E5=F0=E5=ED=
=ED=EE=F1=F2??=F2=EE? =F7=F2?=EE=E1=F0=E0=F2=E8=E2=F8=E8=F1??=ED=E0? =C2=FB=
 =EF=EE=EB=F3=F7=E8=F2=E5 =EA=E2=E0=EB
=E8=F4=E8=F6=E8=F0=EE=E2=E0=ED=ED=F3?=EF=EE=EC=EE=A2=A2, =E2=ED=E8=EC=E0=F2=
=E5=EB=FC=ED=EE=E5 =EE=F2=ED=EE=F8=E5=ED=E8??=C2=E0=F8=E8?=EF=EE=F2=F0=E5=
=E1=ED=EE=F1=F2=FF? =EE=EF=E5=F0=E0=F2=E8=E2=ED=F3?=EE=E1
=F0=E0=E1=EE=F2=EA?=C2=E0=F8=E5=E3=EE =E7=E0=EA=E0=E7=E0.

      =CF=EE =E2=F1=E5=EC =E2=EE=EF=F0=EE=F1=E0=EC =E2=FB =EC=EE=E6=E5=F2=
=E5 =EE=E1=F0=E0=F9=E0=F2=FC? =EF=EE =F2=E5=EB=E5=F4=EE=ED=E0? 275-89-94,
746-68-78.


_______________________________________________________________________
Powered by List Builder
To unsubscribe follow the link:
http://lb.bcentral.com/ex/manage/subscriberprefs?customerid=3D15131&subid=
=3D4F31
E628C99B6F48&msgnum=3D1


--__--__--

Message: 7
From: Simon Brunning <SBrunning@trisystems.co.uk>
To: 'Lance E Sloan' <lsloan@umich.edu>, tutor@python.org,
python-list@python.org
Subject: RE: [Tutor] trouble running Grail
Date: Mon, 10 Sep 2001 08:45:31 +0100

> From: Lance E Sloan [SMTP:lsloan@umich.edu]
> Why would the Grail author give two arguments to append?  Was
> there an old version of Python that allowed two arguments?

In a word, yes. See
<http://amk.ca/python/2.0/new-python.html#SECTION0001100000000000000000> =
for
an explanation.

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning@trisystems.co.uk




-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileg=
ed.
It is intended solely for the addressee. Access to this email by anyone e=
lse
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.


--__--__--

Message: 8
Date: Mon, 10 Sep 2001 14:35:20 +0530
From: "Sreenidhi.B.G" <nidhi@ncoretech.com>
Organization: Encore Software Ltd
To: tutor@python.org
Subject: [Tutor] need some help

Helo,
    I am working on a small example where in I call my c function, and
I'm unable to link to the python library. I'm getting undefined
reference to these function calls, - PyArg_ParseTuple and Py_BuildValue.

can you please help me link this to python library. We are working on
Linux7.1.and we are using python 1.5

regards,
-sreenidhi,



--__--__--

Message: 9
From: "Ajaya Babu" <ajaya@ncoretech.com>
To: "PythonTutorlist (E-mail)" <tutor@python.org>
Date: Mon, 10 Sep 2001 17:04:55 +0530
Subject: [Tutor] Windows IDE ..., Problems while executing python code ?


Hi,

I am getting a suprising error with Windows IDE, When I want to test my c=
ode
on windows to check I jsut run uing Ctrl + F5, but when I have a import
statements for the user defined modules ..., python is telling me Import
error...like this...,

 File "C:\Python20\projects\VirtualHandset\utils.py", line 8, in ?
    from HandSetUtils import *
ImportError: No module named HandSetUtils


But suprisingly my modules are present there it self. Then I just copied
these files to the python installation directory...it started working
fine..., then I deleted from python installation directory..., but it
started working fine...then I closed all windows ..., this time again it
started giving the above problem...,

I very much cross checked the name and direcotry...,

I tried with setting path variable to solve this problem. But it did not
help much...,

Can any one suggest some thing to fix this problem.

with regards,
Ajaya





--__--__--

Message: 10
From: "James" <sendme105@hotmail.com>
To: <tutor@python.org>
Cc: <Charlie@begeistert.org>
Date: Mon, 10 Sep 2001 04:38:04 -0700
Subject: [Tutor] Re: Help with cookies

> Dear Python gurus and those who want to become such,
> I need to be able to pass a cookie in a url request.

import os, string
from urllib import *
from mimetools import Message

#redefine (override?) urlopen to enable cookie sending

def urlopen(url, data=3DNone, headers=3DNone):
    u =3D FancyURLopener()
    if headers:
        if type(headers) =3D=3D type({}):
            headers =3D headers.items()
        for kw, val in headers:
            u.addheader(kw, val)
    return u.open(url, data)

# The following gets the cookie info I need...

temppage=3D urlopen(source_url)
headers=3Dtemppage.info()
cookie =3D headers.getheader("set-cookie")
clist =3D string.split(cookie, ';')
temppage.close()

# ...to successfully open the page:

page =3D urlopen(source_url, headers=3D[('Cookie', clist[0])])


########

Warning: I'm new to programming.  I edited this code entirely from a
comp.python post found via google.

Let me know if it works.

James.






--__--__--

Message: 11
From: alan.gauld@bt.com
To: kalle@gnupung.net, tutor@python.org
Subject: RE: [Tutor] sending stdout to a text box
Date: Mon, 10 Sep 2001 13:59:56 +0100

> > run from a prompt. How can I catch this and route it to a
> text box in tkinter?

I posted a short example of this but it wasn't wondersfully commented.


Essentially you make sys.stdout point to an object which has
a write() method. (This could be your Tkinter application for
example)

Now when you call print the output will go to the new object.

Thus

class MyApp(Frame):
   def __init__(self):
     # do stuff here
     self.display =3D Text(....)  # create our text widget
     sys.stdout =3D self          # Set stdout here

   def write(self, s):   # provide the necessary write method
     self.display.insert(END.s)  # append the string s to the widget

   # other methods as usual...
   def foo(self):
      print "This is foo"   # will appear in text widget

Hope thats a little clearer.

Alan G.


--__--__--

Message: 12
Date: Mon, 10 Sep 2001 09:30:46 -0400 (EDT)
From: Bill Tolbert <bill_tolbert@bigfoot.com>
To: tutor@python.org
Subject: RE: [Tutor] sending stdout to a text box

Thanks for the reply Alan. Kalle posted a good example too (I'm the one
who asked originally). I'm close, but not quite where I want to be.

I'm trying to incorporate some utility scripts that use print statements
to tell the user what's going on (success, error, busy, etc). I want my
gui to consolidate these and just redirect the existing print statements
to the text widget on the gui.

Output from ICAREBackup goes to BogusFile and on to the text box, but not
until ICAREBackup finishes. I was looking for a way to provide
immediate feedback. Some of these utilities could run for a very long
time, leaving the user confused and ready to reboot without
feedback. Output to the shell window is immediate; it doesn't wait
until the script finishes. Can I duplicate that immediate feedback?

    def backup(self):
        import ICAREBackup
        sys.stdout =3D BogusFile(self.text_box)
        ICAREBackup.stdout =3D BogusFile(self.text_box)
        ICAREBackup.ICAREBackup()

Thanks guys,

Bill

On Mon, 10 Sep 2001 alan.gauld@bt.com wrote:

> > > run from a prompt. How can I catch this and route it to a
> > text box in tkinter?
>
> I posted a short example of this but it wasn't wondersfully commented.
>
>
> Essentially you make sys.stdout point to an object which has
> a write() method. (This could be your Tkinter application for
> example)
>
> Now when you call print the output will go to the new object.
>
> Thus
>
> class MyApp(Frame):
>    def __init__(self):
>      # do stuff here
>      self.display =3D Text(....)  # create our text widget
>      sys.stdout =3D self          # Set stdout here
>
>    def write(self, s):   # provide the necessary write method
>      self.display.insert(END.s)  # append the string s to the widget
>
>    # other methods as usual...
>    def foo(self):
>       print "This is foo"   # will appear in text widget
>
> Hope thats a little clearer.
>
> Alan G.
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D
Bill Tolbert



--__--__--

Message: 13
To: Ignacio Vazquez-Abrams <ignacio@openservices.net>
cc: tutor@python.org
Subject: Re: [Tutor] trouble running Grail
Date: Mon, 10 Sep 2001 09:55:54 -0400
From: Lance E Sloan <lsloan@umich.edu>


Ignacio Vazquez-Abrams wrote:
> Grail is _ancient_. I remember using Grail 0.6 a _looooong_ time ago.

Yes, it is pretty old.  But I'm convinced that most of the available
web browsers do several things wrong, or at least stupidly.  Since I'm
getting the hang of Python, Grail sounded like a good browser to poke
around in the guts of without feeling tainted afterwards.

--
Lance E Sloan
Web Services, Univ. of Michigan: Full-service Web and database design,
development, and hosting.  Specializing in Python & Perl CGIs.
http://websvcs.itd.umich.edu/ - "Putting U on the Web"



--__--__--

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


End of Tutor Digest



From  Kerim Borchaev ( WarKiD ) " <warkid@storm.ru  Tue Sep 11 09:55:51 2001
From:  Kerim Borchaev ( WarKiD ) " <warkid@storm.ru ( Kerim Borchaev ( WarKiD ) )
Date: Tue, 11 Sep 2001 12:55:51 +0400
Subject: [Tutor] PythonWin and tabs
Message-ID: <18538.010911@storm.ru>

Hello ,

      Recently I've found a bad thing about PythonWin - even if
      "insert spaces" option is checked it still uses tabs - in
      interactive window. It happended a couple of times before but I
      thought I just don't get Python.
      So be careful cut'n'pasting code from PW.
      
      And if it is a bug someone please report it to ActiveState...

Best regards,
 Kerim                          mailto:warkid@storm.ru




From dsh8290@rit.edu  Tue Sep 11 11:22:29 2001
From: dsh8290@rit.edu (dman)
Date: Tue, 11 Sep 2001 06:22:29 -0400
Subject: [Tutor] How to implement portable message queue betwwen Python
 application and another application ??
In-Reply-To: <000001c13a80$ede81780$6501a8c0@ncoretech.com>
References: <000001c13a80$ede81780$6501a8c0@ncoretech.com>
Message-ID: <20010911062229.A14431@hudson>

On Tue, Sep 11, 2001 at 10:46:35AM +0530, Ajaya Babu wrote:
| 
| Hi,
| 
| I've some doubts regarding desiging portable application on Linux and Windos
| using python. My requirements are..,
| 
| I need to send data from Python interface to the C application which is
| running indipendently. I was thiking of implemenitg using message queue. But
| since it is different I was thinking some alternative ways of implementing
| it.

There are many ways of communicating between distributed object.  Some
of them include XML-RPC, CORBA, SOAP, COM (MS Windows only).  The
advantage of using a standard like these is the communication layer
has already been implemented for you, you just need to use their
interface.  You could use some sort of socket and implement your own
communication protocol, but I think that would likely be more work for
you.

-D



From dsh8290@rit.edu  Tue Sep 11 11:30:53 2001
From: dsh8290@rit.edu (dman)
Date: Tue, 11 Sep 2001 06:30:53 -0400
Subject: [Tutor] How to convert integer to binay packed string...,?
In-Reply-To: <000201c13a8d$7b71cd60$6501a8c0@ncoretech.com>
References: <000201c13a8d$7b71cd60$6501a8c0@ncoretech.com>
Message-ID: <20010911063053.B14431@hudson>

On Tue, Sep 11, 2001 at 12:16:26PM +0530, Ajaya Babu wrote:
| 
| Hi All,
| 
| I've a small doubt, How to convert integers into bytestream in python. What
| actually I want to do is send integer to another system in the network. But
| since there is nothing like integer in python...I am just wondering how can
| i manipulate a integer to a string of two bytes which corresponds to the two
| binary coded bytes of the integer.

Ignacio has shown you the struct module (which I just tried out last
night, pretty coool), but I want to warn you about the differences
between big-endian and little-endian systems.  If the two systems you
are using have different endianness then you will probably run into
problems with the bytes getting reversed.  (I haven't done any playing
with connecting the two so test it thoroughly if you use the struct
module)  The most portable easiest way, I think, and quite easy, from
the python side anyways, is to simply convert the integer to a string
and vice versa.  Ex:  (with C you'd have to use sprintf() and
sscanf())

    # send the number
    an_int = 1234
    try :
        my_socket.write( str( an_int ) )
    except IOError :
        print "Couldn't write to socket!"

    # receive the number
    try :
        raw_data = my_socket.readline() # however you define an
                                        # "entity" in your
                                        # communication protocol
    except IOError :
        print "Couldn't read from socket"
        sys.exit( 1 )

    try :
        an_int = int( raw_data )  # convert the string to an int
    except ValueError :
        print "Invalid data received from socket"
        sys.exit( 1 )

    print "We got %d" % an_int


If you use an existing middleware package such as XML-RPC then you
won't have to deal with any of this low-level communication details.

HTH,
-D



From alan.gauld@bt.com  Tue Sep 11 13:05:27 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 11 Sep 2001 13:05:27 +0100
Subject: [Tutor] sending stdout to a text box
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF3B@mbtlipnt02.btlabs.bt.co.uk>

> I'm trying to incorporate some utility scripts that use print 

Yes thats what my examnple did. All print statements executed 
by your program after the assignment of stdout will go to the 
text widget.


> until ICAREBackup finishes. I was looking for a way to provide
> immediate feedback. Some of these utilities could run for a very long
> time, leaving the user confused and ready to reboot without
> feedback. Output to the shell window is immediate; it doesn't wait
> until the script finishes. Can I duplicate that immediate feedback?

Yes, by using the write() method it will put the output onto 
the screen as it happens. What I illustrated was how to avoid 
using a temporary file or String buffer(as Danny suggested in 
an earlier post)



>     def backup(self):
>         import ICAREBackup
>         sys.stdout = BogusFile(self.text_box)

Don't need this line if you set it up in __init__ of 
the Tkinter application as:
          sys.stdout = self


>         ICAREBackup.stdout = BogusFile(self.text_box)

Don't need this at all I think.


>         ICAREBackup.ICAREBackup()

The print statemewnts in ICAREBackup will call self.write()

> > class MyApp(Frame):
> >    def __init__(self):
> >      # do stuff here
> >      self.display = Text(....)  # create our text widget
> >      sys.stdout = self          # Set stdout here
> > 
> >    def write(self, s):   # provide the necessary write method
> >      self.display.insert(END.s)  # append the string s to the widget
> > 
> >    # other methods as usual...
> >    def foo(self):
> >       print "This is foo"	  # will appear in text widget
       def backup(self):
          ICAREBackup.ICAREBackup()  # likewise


Alan G.


From alan.gauld@bt.com  Tue Sep 11 13:10:41 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 11 Sep 2001 13:10:41 +0100
Subject: [Tutor] How to implement portable message queue betwwen Pytho n
 application and another application ??
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF3C@mbtlipnt02.btlabs.bt.co.uk>

> I need to send data from Python interface to the C 
> application which is running indipendently. 

So you need a platform indepoendant way of intefacing Python to a C
application.

There are two easy ways:

1) Use sockets(see below)

2) If you control the C app use text files. Get the C app 
and Python app to poll the files(In background threads)

IMHO 1 is easier 2 is robuster but slower.

> What is general way of implementing message queues (for 
> sending messages from python to another application.), 

I don't think there is one thats common to both Win32 
and Linux. 

ng
> socket pipe (in the same system). But I really don't what are 
> the drawbacks when I implement using sockets rather than 
> use normal approch of sending messages using message ques..,

I think on Linux sockets are the normal approach!
The disadvantages are the need to marshal data in and out 
of the sockket. Only a problem if you don't own both ends 
or the interface changes regularly.

Alan G


From Brmfq@aol.com  Tue Sep 11 14:37:01 2001
From: Brmfq@aol.com (Brmfq@aol.com)
Date: Tue, 11 Sep 2001 09:37:01 EDT
Subject: [Tutor] Getting total of a list (newbie)
Message-ID: <68.13f2203d.28cf6d7d@aol.com>

Good Day,

I'm running Python 1.5.2 on win16 (going to upgrade both soon). I've been 
working on an exercise of writing a program that reads 100 numbers from the 
user and prints out the sum. Here's the best I've come up with:

num = input("Please enter a number:")
tot = [num]
while len(tot) < 10:
     nex = input("Please enter another number: ")
     tot.append (nex)
print 'total of 10 numbers is', 
tot[0]+tot[1]+tot[2]+tot[3]+tot[4]+tot[5]+tot[6]+tot[7]+tot[8]+tot[9]

This works, but it's only for 10 numbers. Could someone please show me a 
better way? Thanks in advance to anyone who replies.

Joe


From ignacio@openservices.net  Tue Sep 11 14:56:56 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Tue, 11 Sep 2001 09:56:56 -0400 (EDT)
Subject: [Tutor] Getting total of a list (newbie)
In-Reply-To: <68.13f2203d.28cf6d7d@aol.com>
Message-ID: <Pine.LNX.4.33.0109110955540.2578-100000@terbidium.openservices.net>

On Tue, 11 Sep 2001 Brmfq@aol.com wrote:

> I'm running Python 1.5.2 on win16 (going to upgrade both soon). I've been
> working on an exercise of writing a program that reads 100 numbers from the
> user and prints out the sum. Here's the best I've come up with:
>
> num = input("Please enter a number:")
> tot = [num]
> while len(tot) < 10:
>      nex = input("Please enter another number: ")
>      tot.append (nex)
> print 'total of 10 numbers is',
> tot[0]+tot[1]+tot[2]+tot[3]+tot[4]+tot[5]+tot[6]+tot[7]+tot[8]+tot[9]
>
> This works, but it's only for 10 numbers. Could someone please show me a
> better way? Thanks in advance to anyone who replies.

This works for an arbitrary list or tuple of numbers:

---
import operator

print reduce(operator.add, tot)
---

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From ak@silmarill.org  Tue Sep 11 17:45:53 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Tue, 11 Sep 2001 12:45:53 -0400
Subject: [Tutor] Getting total of a list (newbie)
In-Reply-To: <68.13f2203d.28cf6d7d@aol.com>
References: <68.13f2203d.28cf6d7d@aol.com>
Message-ID: <20010911124553.A23332@sill.silmarill.org>

On Tue, Sep 11, 2001 at 09:37:01AM -0400, Brmfq@aol.com wrote:
> Good Day,
> 
> I'm running Python 1.5.2 on win16 (going to upgrade both soon). I've been 
> working on an exercise of writing a program that reads 100 numbers from the 
> user and prints out the sum. Here's the best I've come up with:
> 
> num = input("Please enter a number:")
> tot = [num]
> while len(tot) < 10:
>      nex = input("Please enter another number: ")
>      tot.append (nex)
> print 'total of 10 numbers is', 
> tot[0]+tot[1]+tot[2]+tot[3]+tot[4]+tot[5]+tot[6]+tot[7]+tot[8]+tot[9]
> 
> This works, but it's only for 10 numbers. Could someone please show me a 
> better way? Thanks in advance to anyone who replies.
> 
> Joe

total = 0
while 1:
    ans = raw_input("Enter number: ")
    if not ans: break
    total = total + int(ans)
print "Total is", total

> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From alan.gauld@bt.com  Tue Sep 11 17:44:34 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 11 Sep 2001 17:44:34 +0100
Subject: [Tutor] How to implement portable message queue betwwen Pytho n
 application and another application ??
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF3E@mbtlipnt02.btlabs.bt.co.uk>

> | I need to send data from Python interface to the C 
> | application which is running indipendently. 
> There are many ways of communicating between distributed object.  Some
> of them include XML-RPC, CORBA, SOAP, COM (MS Windows only).  

I assumed from the request that the apps were on a 
local LAN not distributed widely.
Of course assume makes an ass of u and me...

> advantage of using a standard like these is the communication layer
> has already been implemented for you, you just need to use their
> interface.  

I'm not sure its that simple. For XML-RPC you need a web 
server available, CORBA needs an orb setting up and IDL 
defined, SOAP is also http based I think(but am not sure)

If those things aren't readily available a simple socket 
connection is far easier. These protocols are great if you 
want to publish an API for several clients on different 
platforms need to communicate but if its a case of a 
single client talking to acsingle application sockets 
are much easier to do.

> You could use some sort of socket and implement your own
> communication protocol, but I think that would likely be 
> more work for you.

I disagree if its not for a published API.
OTOH if a public API is the desired end game then yes some 
of the suggested protocols might be best. XML-RPC and SOAP 
are both XML based and as such are extremely inefficient in bandwidth usage.
> 
> -D
> 
> 
> 


From alan.gauld@bt.com  Tue Sep 11 17:50:17 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 11 Sep 2001 17:50:17 +0100
Subject: [Tutor] Getting total of a list (newbie)
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF3F@mbtlipnt02.btlabs.bt.co.uk>

Probably stating the obvious but....

> > num = input("Please enter a number:")
> > tot = [num]
> > while len(tot) < 10:
> >      nex = input("Please enter another number: ")
> >      tot.append (nex)
> > print 'total of 10 numbers is',
> > 
> tot[0]+tot[1]+tot[2]+tot[3]+tot[4]+tot[5]+tot[6]+tot[7]+tot[8]+tot[9]
> This works for an arbitrary list or tuple of numbers:
> 
> print reduce(operator.add, tot)

Only replaces the summing line not all the input stuff!
The input stuff is fine as it is, except you should probably 
use raw_input() instead of input() - its safer from abuse...

An alternative is:
total = 0
for item in tot:
   total = total + item
print total

Alan g


From alan.gauld@bt.com  Tue Sep 11 17:51:49 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 11 Sep 2001 17:51:49 +0100
Subject: [Tutor] PythonWin and tabs
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF40@mbtlipnt02.btlabs.bt.co.uk>

>       Recently I've found a bad thing about PythonWin - even if
>       "insert spaces" option is checked it still uses tabs - in

What version are you using?
I had that on the version I downloaded with 1.5.1 but the 
version that comes with Python 2.0 doesn't do that anymore 
- at least I've not seen it...

Alan G


From dyoo@hkn.eecs.berkeley.edu  Tue Sep 11 19:05:43 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 11 Sep 2001 11:05:43 -0700 (PDT)
Subject: [Tutor] Getting total of a list (newbie)
In-Reply-To: <68.13f2203d.28cf6d7d@aol.com>
Message-ID: <Pine.LNX.4.21.0109111030350.3751-100000@hkn.eecs.berkeley.edu>

On Tue, 11 Sep 2001 Brmfq@aol.com wrote:

> num = input("Please enter a number:")
> tot = [num]
> while len(tot) < 10:
>      nex = input("Please enter another number: ")
>      tot.append (nex)
> print 'total of 10 numbers is', 
> tot[0]+tot[1]+tot[2]+tot[3]+tot[4]+tot[5]+tot[6]+tot[7]+tot[8]+tot[9]
> 
> This works, but it's only for 10 numbers. Could someone please show me
> a better way? Thanks in advance to anyone who replies.


Hello!  Have you learned about functions yet?  We can write a sumUp()
function that takes in a list, and returns its total:

###
def sumUp(numbers):
    total = 0
    for n in numbers:
        total = total + n
    return total
###


What makes this function so useful is that now we can use it for your
program:

###
print 'total of 10 numbers is', sumUp(numbers)
###



for random, gratuitous summations:

###
>>> sumUp(range(10))
45
###


or even for the definitions of other functions:

###
def average(numbers):
    return sumUp(numbers) / float(len(numbers))
    ## float() might be necessary because of possibility
    ## of integer division (as of Python 2.1.1)
###


Only our sumUp() function has to do this "sum" thing.  When we make a
sumUp() function, we can treat the summing of lists as a new tool that we
can fiddle with.

As you can tell, I'm something of a function fanatic.  *grin*


If you have more questions, please feel free to ask.



From dyoo@hkn.eecs.berkeley.edu  Tue Sep 11 20:03:42 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 11 Sep 2001 12:03:42 -0700 (PDT)
Subject: [Tutor] How to convert integer to binay packed string...,?
In-Reply-To: <000201c13a8d$7b71cd60$6501a8c0@ncoretech.com>
Message-ID: <Pine.LNX.4.21.0109111156070.5497-100000@hkn.eecs.berkeley.edu>

On Tue, 11 Sep 2001, Ajaya Babu wrote:

> I've a small doubt, How to convert integers into bytestream in python.
> What actually I want to do is send integer to another system in the
> network. But since there is nothing like integer in python...I am just
> wondering how can

Actually, Python Integers are 32-bit integers, and we can do bitwise
manipulation with them:

###
>>> x = 2
>>> x>>2
0
>>> x<<2
8
>>> 0xffffffff & 0x00002000
8192
###

As Ignacio as mentioned, it sounds like you'll want to look at the
"struct" module, a module that deals exclusively with packing things into
bytes.


Alternatively, you might want to look at the "pickle" module:

    http://python.org/doc/current/lib/module-pickle.html

pickle will allow us to preserve integers into strings --- in effect, it
turns things into a bytestream.  pickle will "serialize" Python objects
into something that we can save, or send!  If you're sending something
across the network to another Python system, pickle might be useful for
you.

Hope this helps!



From dyoo@hkn.eecs.berkeley.edu  Tue Sep 11 20:19:37 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 11 Sep 2001 12:19:37 -0700 (PDT)
Subject: [Tutor] need some help
In-Reply-To: <3B9C8250.6B01E6C8@ncoretech.com>
Message-ID: <Pine.LNX.4.21.0109111217170.5497-100000@hkn.eecs.berkeley.edu>

On Mon, 10 Sep 2001, Sreenidhi.B.G wrote:

> can you please help me link this to python library. We are working on
> Linux7.1.and we are using python 1.5

Hello!  Have you looked at the example Demos/Embed directory?  It comes
with the Python source, and is a good example on getting this sort of
stuff working. The Makefile, in particular, has the flags you'll want to
link to the Python library.

You might also look at:

    http://www.python.org/doc/current/ext/link-reqs.html

which explains a little more about the linking requirements.

Hope this helps!



From girishg@india.ti.com  Tue Sep 11 20:44:37 2001
From: girishg@india.ti.com (Girish Gajwani)
Date: Wed, 12 Sep 2001 01:14:37 +0530
Subject: [Tutor] Non Blocking I/O on stdin
Message-ID: <3B9E69A5.ED50F5E3@india.ti.com>

Hi,

I wish to read the keyboard(stdin) but the read should not
be blocking

I essentially want to spawn off 2 threads, one of which will
constantly be reading from stdin. Just to give it a try, I
used the raw_input() & input() functions but neither of them
work. Infact they cause the program to quit. Is this due to
the non-blocking nature of the thread causing it to quit *
baffled *

                  ----------------------
                     consider this  
                  ----------------------


#### DOES NOT WORK ####

#! /usr/bin/env python
def acc(args):
    while(1):
        print "just b4"    # comes here
        str = input()
        print "just after" # never comes here :(

args = 0,                  # create list of arguments
thread.start_new_thread(acc, args)
#######################

                  ----------------------
                   & consider this now
                  ----------------------

#### THIS WORKS ####

#! /usr/bin/env python
def acc(args):
    while(1):
        print "just b4"    # comes here
        str = input()
        print "just after" # comes here but still not what i
want :(

args = 0,                  # create list of arguments
acc(args)
#######################
Also please advise on reading the keyboard in non-blocking
mode

Help wrt the thread module (scheduling, etc) will also be
helpful.

best regards
Girish


From uselesspython@yahoo.com  Tue Sep 11 20:51:52 2001
From: uselesspython@yahoo.com (Rob)
Date: Tue, 11 Sep 2001 14:51:52 -0500
Subject: [Tutor] OT: I hope everyone's okay.
Message-ID: <3B9E6B58.D80E0A77@yahoo.com>

Everywhere you go, you can find suffering. Today, some of the suffering
is particularly obvious, in the U.S. and in many other parts of the
world.

Just about all my family and friends in known danger spots have removed
themselves from danger or missed it entirely, and I feel fortunate for
this. I hope the same or better for each of you.

Positive wishes for all,
Rob
-- 
Aw, c'mon.... You indent ANYWAY!
Useless Python!
http://www.lowerstandard.com/python


From girishg@india.ti.com  Tue Sep 11 21:01:08 2001
From: girishg@india.ti.com (Girish Gajwani)
Date: Wed, 12 Sep 2001 01:31:08 +0530
Subject: [Tutor] OT - My Best wishes to you
Message-ID: <3B9E6D84.91B25E65@india.ti.com>

To all on the list,

What happened was bad. I know for I have several friends in
US and it is surely hard on their families. My heart goes
out to all who were unfortunate to be in the WTO & Pentagon
at the time of the crash landings.

Peace be to all. All the best.
Girish


From ignacio@openservices.net  Tue Sep 11 21:03:18 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Tue, 11 Sep 2001 16:03:18 -0400 (EDT)
Subject: [Tutor] Non Blocking I/O on stdin
In-Reply-To: <3B9E69A5.ED50F5E3@india.ti.com>
Message-ID: <Pine.LNX.4.33.0109111559420.9819-100000@terbidium.openservices.net>

On Wed, 12 Sep 2001, Girish Gajwani wrote:

> Hi,
>
> I wish to read the keyboard(stdin) but the read should not
> be blocking
>
>  [snip]
>
> #### DOES NOT WORK ####
>
> #! /usr/bin/env python
> def acc(args):
>     while(1):
>         print "just b4"    # comes here
>         str = input()
>         print "just after" # never comes here :(
>
> args = 0,                  # create list of arguments
> thread.start_new_thread(acc, args)
> #######################

No wonder this doesn't work; if the main thread dies, then all the others die
too.

>                   ----------------------
>                    & consider this now
>                   ----------------------
>
> #### THIS WORKS ####
>
> #! /usr/bin/env python
> def acc(args):
>     while(1):
>         print "just b4"    # comes here
>         str = input()
>         print "just after" # comes here but still not what i
> want :(
>
> args = 0,                  # create list of arguments
> acc(args)
> #######################
> Also please advise on reading the keyboard in non-blocking
> mode
>
> Help wrt the thread module (scheduling, etc) will also be
> helpful.

A couple of tips:

1) Use the threading module instead of the thread module. That way your main
thread can join a spawned thread and not die immediately.
2) Use the select module in conjunction with sys.stdin instead of input() or
raw_input().

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From jcosby@mindspring.com  Mon Sep 10 16:10:26 2001
From: jcosby@mindspring.com (Jon Cosby)
Date: Mon, 10 Sep 2001 08:10:26 -0700
Subject: [Tutor] Remove
Message-ID: <MBBBIFMLIJLJLMBAJBPOOECJCAAA.jcosby@mindspring.com>

I'm doing a Web search that is succesful until I try to configure it to
ignore specified directories using the "remove" operation. I'm not getting
any error messages, but the script stops when it comes to the function
below. I've run the first few lines in the interpreter, and I can't see
anything wrong with it. Any ideas?


def getFile(text, dir):
	hits = []
	dl = os.listdir(dir)
	for item in ignore:	# List of directories to ignore
		dl.remove(item)   # Works in interpreter, but list comes up empty here
	text = string.lower(text)
	for d in dl:
		d = dir + '\\' + d
		if os.path.isfile(d):
			hits.extend(searchtext(d, text))
		elif os.path.isdir(d):
			hits.extend(getFile(text, d))
	return hits



Jon Cosby

jcosby@mindspring.com
www.jcosby.com



From lkvam@venix.com  Tue Sep 11 23:55:20 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Tue, 11 Sep 2001 18:55:20 -0400
Subject: [Tutor] Remove
References: <MBBBIFMLIJLJLMBAJBPOOECJCAAA.jcosby@mindspring.com>
Message-ID: <3B9E9658.543F9386@venix.com>

I would add some exception handling and some print statements.  If there is too much to print, use a log file. (e.g.  print >> logfile, "removed %s" % (item)   )

I inserted suggested changes below.  Is there a higher level try that is hiding a ValueError???

Jon Cosby wrote:
> 
> I'm doing a Web search that is succesful until I try to configure it to
> ignore specified directories using the "remove" operation. I'm not getting
> any error messages, but the script stops when it comes to the function
> below. I've run the first few lines in the interpreter, and I can't see
> anything wrong with it. Any ideas?
> 
> def getFile(text, dir):
>         hits = []
>         dl = os.listdir(dir)
>         for item in ignore:     # List of directories to ignore
		try:
>                 dl.remove(item)   # Works in interpreter, but list comes up empty here
		  print "removed %s" % (item)
		except ValueError:
		  print "item %s is not present in list" % item
		  raise ValueError
>         text = string.lower(text)
>         for d in dl:
>                 d = dir + '\\' + d
>                 if os.path.isfile(d):
>                         hits.extend(searchtext(d, text))
>                 elif os.path.isdir(d):
>                         hits.extend(getFile(text, d))
>         return hits
> 
> Jon Cosby
> 
> jcosby@mindspring.com
> www.jcosby.com
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582


From dyoo@hkn.eecs.berkeley.edu  Wed Sep 12 00:49:24 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 11 Sep 2001 16:49:24 -0700 (PDT)
Subject: [Tutor] problem with list remove
In-Reply-To: <MBBBIFMLIJLJLMBAJBPOOECJCAAA.jcosby@mindspring.com>
Message-ID: <Pine.LNX.4.21.0109111642400.12095-100000@hkn.eecs.berkeley.edu>

On Mon, 10 Sep 2001, Jon Cosby wrote:

> I'm doing a Web search that is succesful until I try to configure it
> to ignore specified directories using the "remove" operation. I'm not
> getting any error messages, but the script stops when it comes to the

By the program stopping, does it seem like the program is going into an
infinite loop, or do you mean something else?

Hmm... taking a look at getFile() now...


> def getFile(text, dir):
> 	hits = []
> 	dl = os.listdir(dir)
> 	for item in ignore:	# List of directories to ignore
> 		dl.remove(item)   # Works in interpreter, but list comes up empty here

'ignore' appears to be a global variable of some kind.  Where is ignore
being defined?  Perhaps 'ignore' is a really large list --- I doubt this
possibility, but it might be good to put some debugging statement here to
see what 'ignore' looks like.


> 	text = string.lower(text)
> 	for d in dl:
> 		d = dir + '\\' + d
> 		if os.path.isfile(d):
> 			hits.extend(searchtext(d, text))
> 		elif os.path.isdir(d):
> 			hits.extend(getFile(text, d))
> 	return hits


To tell the truth, I don't see anything here that would cause an infinite
loop, but I might be overlooking something.  Can you tell us more
information?

Best of wishes to you!



From jcosby@mindspring.com  Wed Sep 12 01:08:15 2001
From: jcosby@mindspring.com (Jon Cosby)
Date: Tue, 11 Sep 2001 17:08:15 -0700
Subject: [Tutor] string.replace
Message-ID: <MBBBIFMLIJLJLMBAJBPOCECOCAAA.jcosby@mindspring.com>

Thanks for the help so far. Here's one more that has me stumped. I need a
function to strip HTML tags from lines. What I have looks like it should
work, but it stops at the first occurence of the tags. I've gone through it
step by step, and it's finding all of the tags, but for some reason it's not
replacing them. The routine is


>>> from string import *
>>> def striptabs(line):
... 	if "<" in line:
... 		l = find(line, "<", 0)
... 		m = find(line, ">", l)
... 		if l and m:
... 			print "Tag found"		# Test
... 		line = replace(line, line[l:m+1], "")
... 		striptabs(line)
... 	else:
... 		return line
... 	return line
...
>>> f = open("c:\\temp\\test.txt", "r")
>>> l = f.readline()
>>> l
"This is a <test> file. It's <purpose> is to test <methods> for removing
HTML tags.\n"
>>> striptabs(l)
Tag found
Tag found
Tag found
"This is a  file. It's <purpose> is to test <methods> for removing HTML
tags.\n"
>>>


As you can see, it is finding all of the tags. Why isn't it replacing them?


Jon Cosby

jcosby@mindspring.com
www.jcosby.com



From allan.crooks@btinternet.com  Wed Sep 12 01:30:02 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Wed, 12 Sep 2001 01:30:02 +0100
Subject: [Tutor] string.replace
In-Reply-To: <MBBBIFMLIJLJLMBAJBPOCECOCAAA.jcosby@mindspring.com>
Message-ID: <3B9EBA9A.28981.DEF8E71@localhost>

On 11 Sep 2001, at 17:08, Jon Cosby wrote:

> >>> def striptabs(line):
> ... 	if "<" in line:
> ... 		l = find(line, "<", 0)
> ... 		m = find(line, ">", l)
> ... 		if l and m:
> ... 			print "Tag found"		# Test
> ... 		line = replace(line, line[l:m+1], "")
> ... 		striptabs(line)

This line should be "return striptabs(line)". Otherwise it's returning 
the line which has the first tag removed (it processes the rest of the 
string, but does nothing with it. 

> ... 	else:
> ... 		return line
> ... 	return line

Allan.


From jcosby@mindspring.com  Wed Sep 12 01:37:56 2001
From: jcosby@mindspring.com (Jon Cosby)
Date: Tue, 11 Sep 2001 17:37:56 -0700
Subject: [Tutor] problem with list remove
In-Reply-To: <Pine.LNX.4.21.0109111642400.12095-100000@hkn.eecs.berkeley.edu>
Message-ID: <MBBBIFMLIJLJLMBAJBPOAECPCAAA.jcosby@mindspring.com>

The problem was in the second loop. Once the list had been removed, "remove"
didn't take kindly to removing them a second time. I added the line:

for item in ignore:
	if item in dl:
		dl.remove(item)

Problem gone. Thanks.

Jon

-----Original Message-----
From: Danny Yoo [mailto:dyoo@hkn.eecs.berkeley.edu]
Sent: Tuesday, September 11, 2001 4:49 PM
To: Jon Cosby
Cc: tutor@python.org
Subject: Re: [Tutor] problem with list remove


On Mon, 10 Sep 2001, Jon Cosby wrote:

> I'm doing a Web search that is succesful until I try to configure it
> to ignore specified directories using the "remove" operation. I'm not
> getting any error messages, but the script stops when it comes to the

By the program stopping, does it seem like the program is going into an
infinite loop, or do you mean something else?

Hmm... taking a look at getFile() now...


> def getFile(text, dir):
> 	hits = []
> 	dl = os.listdir(dir)
> 	for item in ignore:	# List of directories to ignore
> 		dl.remove(item)   # Works in interpreter, but list comes up empty here

'ignore' appears to be a global variable of some kind.  Where is ignore
being defined?  Perhaps 'ignore' is a really large list --- I doubt this
possibility, but it might be good to put some debugging statement here to
see what 'ignore' looks like.


> 	text = string.lower(text)
> 	for d in dl:
> 		d = dir + '\\' + d
> 		if os.path.isfile(d):
> 			hits.extend(searchtext(d, text))
> 		elif os.path.isdir(d):
> 			hits.extend(getFile(text, d))
> 	return hits


To tell the truth, I don't see anything here that would cause an infinite
loop, but I might be overlooking something.  Can you tell us more
information?

Best of wishes to you!



From dyoo@hkn.eecs.berkeley.edu  Wed Sep 12 01:55:44 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 11 Sep 2001 17:55:44 -0700 (PDT)
Subject: [Tutor] string.replace
In-Reply-To: <MBBBIFMLIJLJLMBAJBPOCECOCAAA.jcosby@mindspring.com>
Message-ID: <Pine.LNX.4.21.0109111741150.13252-100000@hkn.eecs.berkeley.edu>

On Tue, 11 Sep 2001, Jon Cosby wrote:

> Thanks for the help so far. Here's one more that has me stumped. I
> need a function to strip HTML tags from lines. What I have looks like
> it should work, but it stops at the first occurence of the tags. I've
> gone through it step by step, and it's finding all of the tags, but
> for some reason it's not replacing them. The routine is
> 
> 
> >>> from string import *
> >>> def striptabs(line):
> ... 	if "<" in line:
> ... 		l = find(line, "<", 0)
> ... 		m = find(line, ">", l)
> ... 		if l and m:
> ... 			print "Tag found"		# Test

This has a small bug in it: if string.find()ing is unsuccessfuly, it
doesn't return a false value, but instead it returns -1:

###
>>> string.find('hello', 'z')
-1
###

So your test for tag finding should be:

    if l >= 0 and m >= 0:

instead.  The reason it doesn't return a "false" value is because 0 is a
perfectly good return value for find: it would mean a match at the very
beginning of the string.



> ... 		line = replace(line, line[l:m+1], "")

You probably want to include the line above as part of the if-block.  We
should only be replacing things only if we've found matching braces.



> ... 		striptabs(line)

As Allan has pointed out, you'll want to somehow save the rest of the
changes done to your line.  Either:

    return striptabs(line)

or

    line = striptabs(line)

would be good ways of doing this.  It's nice to see that you're taking a
recursive approach here to strip tags until there aren't any more; just be
careful that you send that result off to the user.



When you learn about regular expressions (the re module), you may find
them useful toward stripping tags off a line.  If you're interested, you
can take a look at:

    http://www.python.org/doc/lib/module-re.html

and look for re.sub().

It looks like you may be using Python 1.52.  If so, be wary of a similar
module called "regex": regex is buggy and should be avoided.



I'm off to look at the news; things look grim, but let's do our best to
support each other.  Best of wishes to you.



From ignacio@openservices.net  Wed Sep 12 04:52:46 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Tue, 11 Sep 2001 23:52:46 -0400 (EDT)
Subject: [Tutor] string.replace
In-Reply-To: <MBBBIFMLIJLJLMBAJBPOCECOCAAA.jcosby@mindspring.com>
Message-ID: <Pine.LNX.4.33.0109112350580.9819-100000@terbidium.openservices.net>

On Tue, 11 Sep 2001, Jon Cosby wrote:

> >>> from string import *
> >>> def striptabs(line):
> ... 	if "<" in line:
> ... 		l = find(line, "<", 0)
> ... 		m = find(line, ">", l)
> ... 		if l and m:
> ... 			print "Tag found"		# Test
> ... 		line = replace(line, line[l:m+1], "")
> ... 		striptabs(line)
> ... 	else:
> ... 		return line
> ... 	return line
> ...
> >>> f = open("c:\\temp\\test.txt", "r")
> >>> l = f.readline()
> >>> l
> "This is a <test> file. It's <purpose> is to test <methods> for removing
> HTML tags.\n"
> >>> striptabs(l)
> Tag found
> Tag found
> Tag found
> "This is a  file. It's <purpose> is to test <methods> for removing HTML
> tags.\n"
> >>>
>
> As you can see, it is finding all of the tags. Why isn't it replacing them?

Ypur function has a rather large logic error; it's only find the first tag
because you only go through the process once. You need to change the if to a
while and get rid of the embedded call to stribtabs().

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From dyoo@hkn.eecs.berkeley.edu  Wed Sep 12 05:49:25 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 11 Sep 2001 21:49:25 -0700 (PDT)
Subject: [Tutor] string.replace
In-Reply-To: <Pine.LNX.4.33.0109112350580.9819-100000@terbidium.openservices.net>
Message-ID: <Pine.LNX.4.21.0109112139150.16825-100000@hkn.eecs.berkeley.edu>

On Tue, 11 Sep 2001, Ignacio Vazquez-Abrams wrote:

> On Tue, 11 Sep 2001, Jon Cosby wrote:
> 
> > >>> from string import *
> > >>> def striptabs(line):
> > ... 	if "<" in line:
> > ... 		l = find(line, "<", 0)
> > ... 		m = find(line, ">", l)
> > ... 		if l and m:
> > ... 			print "Tag found"		# Test
> > ... 		line = replace(line, line[l:m+1], "")
> > ... 		striptabs(line)
> > ... 	else:
> > ... 		return line
> > ... 	return line

> Ypur function has a rather large logic error; it's only find the first
> tag because you only go through the process once. You need to change
> the if to a while and get rid of the embedded call to stribtabs().

The recursive striptabs() call is buggy, but's also intentionally
recursive: if Jon changes the line from:

 		striptabs(line)

to:

                line = striptabs(line)

and corrects a few more logical bugs, the code should work because
striptabs should only call itself recursivly if the line still contains
tags --- his use of recursion is about the same as if he had used an
explicit while loop.

I have a corrected version of it below.  Jon, don't look if you want to
work it out for yourself.

** spoiler space **
















** spoiler space **

Here's a corrected version of Jon's striptabs() function, with some
simplifications to the logic:

###
from string import find, replace
def striptabs(line):
    l = find(line, "<", 0)
    m = find(line, ">", l)
    if l >= 0 and m >= 0:
        line = replace(line, line[l:m+1], "")
        line = striptabs(line)
    return line
###


And a small test case:

###
>>> striptabs('hello world')
'hello world'
>>> striptabs('i have <some tags> <around> me')
'i have   me
###



From ignacio@openservices.net  Wed Sep 12 05:56:14 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Wed, 12 Sep 2001 00:56:14 -0400 (EDT)
Subject: [Tutor] string.replace
In-Reply-To: <Pine.LNX.4.21.0109112139150.16825-100000@hkn.eecs.berkeley.edu>
Message-ID: <Pine.LNX.4.33.0109120051260.9819-100000@terbidium.openservices.net>

> The recursive striptabs() call is buggy, but's also intentionally
> recursive: if Jon changes the line from:
>
>  		striptabs(line)
>
> to:
>
>                 line = striptabs(line)
>
> and corrects a few more logical bugs, the code should work because
> striptabs should only call itself recursivly if the line still contains
> tags --- his use of recursion is about the same as if he had used an
> explicit while loop.

That's true, but 95-97% of the time iterative constructs are faster than
recursive mechanisms, plus by definition they don't cause recursion overflows.
Both of those points can be a big advantage if very large documents are being
processed.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>





From lonetwin <lonetwin@yahoo.com>  Wed Sep 12 06:54:46 2001
From: lonetwin <lonetwin@yahoo.com> (lonetwin)
Date: Wed, 12 Sep 2001 11:24:46 +0530 (IST)
Subject: [Tutor] problem with os.chmod()
Message-ID: <Pine.LNX.4.30.0109121108180.14924-100000@mercury.worli>

Hi everybody,
    I've got a problem with the os.chmod() function, it just doesn't
seem to do the right thing, let me explain, the code given below, is
something that I needed, I'm running this on a linux system, this code
changes the permissions of directories and files recursively. I initially
used os.chmod() function but it just screws up the permissions, so now I
do a os.system() to the chmod command, but I'd like to know what is
happening here....
###########################################################
#!/usr/bin/python
# chperm.py
# Usage: chperm.py <top-level dirname>

import os
def chmd(foo, dirname, names):
	dirmode = 744
	flmode = 700
	names = [ os.path.join(dirname, x) for x in names ]
	for fl in names:
		if os.path.isdir(fl):
			os.system('chmod %d "%s"' % (dirmode, fl))
			# os.chmod(fl, dirmode)   # <--- Does not work
		elif os.path.isfile(fl):
			os.system('chmod %d "%s"' % (flmode, fl))
			# os.chmod(fl, flmode)    # <--- Does not work


if __name__ == '__main__':
	os.path.walk(os.sys.argv[1], chmd, None)
###########################################################

-- 
Peace
Steve

P.S: sincere sympathies to all Americans and all the victims of
terrorism on this dark day.



From ajaya@ncoretech.com  Wed Sep 12 06:51:58 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Wed, 12 Sep 2001 11:21:58 +0530
Subject: [Tutor] OT: I hope everyone's okay.
In-Reply-To: <3B9E6B58.D80E0A77@yahoo.com>
Message-ID: <000c01c13b4f$0a061330$6501a8c0@ncoretech.com>

It is a real deep shok to all of us...,The pictures of fear and pain are
still
going on my eyes. Just because of some stupid fellow(s)...., innocents...,
normal citizens are suffering today, and it is every ware.

There is say in Indian Languages "With more cuts dimond become stronger and
stroger, and value goes higher and higher"

Hope that Mankind goes stronger and stronger.

wishing for the best!
Ajaya

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Rob
Sent: Wednesday, September 12, 2001 1:22 AM
To: tutor@python.org
Subject: [Tutor] OT: I hope everyone's okay.


Everywhere you go, you can find suffering. Today, some of the suffering
is particularly obvious, in the U.S. and in many other parts of the
world.

Just about all my family and friends in known danger spots have removed
themselves from danger or missed it entirely, and I feel fortunate for
this. I hope the same or better for each of you.

Positive wishes for all,
Rob
--
Aw, c'mon.... You indent ANYWAY!
Useless Python!
http://www.lowerstandard.com/python

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From ignacio@openservices.net  Wed Sep 12 07:00:52 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Wed, 12 Sep 2001 02:00:52 -0400 (EDT)
Subject: [Tutor] problem with os.chmod()
In-Reply-To: <Pine.LNX.4.30.0109121108180.14924-100000@mercury.worli>
Message-ID: <Pine.LNX.4.33.0109120159261.9819-100000@terbidium.openservices.net>

On Wed, 12 Sep 2001, lonetwin wrote:

>     I've got a problem with the os.chmod() function, it just doesn't
> seem to do the right thing, let me explain, the code given below, is
> something that I needed, I'm running this on a linux system, this code
> changes the permissions of directories and files recursively. I initially
> used os.chmod() function but it just screws up the permissions, so now I
> do a os.system() to the chmod command, but I'd like to know what is
> happening here....

The problem is that your permission values are in the wrong radix. Try using
octal instead of decimal, e.g., 0700 instead of 700.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From Python Tutor list" <tutor@python.org  Wed Sep 12 07:02:53 2001
From: Python Tutor list" <tutor@python.org (Tim Peters)
Date: Wed, 12 Sep 2001 02:02:53 -0400
Subject: [Tutor] problem with os.chmod()
In-Reply-To: <Pine.LNX.4.30.0109121108180.14924-100000@mercury.worli>
Message-ID: <LNBBLJKPBEHFEDALKOLCGEHDLLAA.tim.one@home.com>

[lonetwin]
>     I've got a problem with the os.chmod() function
> ...
> 	dirmode = 744
> 	flmode = 700

Those are decimal literals, but arguments to chmod are usually expressed in
octal notation.  Try

 	dirmode = 0744
 	flmode = 0700

instead and I bet you'll be happier.

> ...
> P.S: sincere sympathies to all Americans and all the victims of
> terrorism on this dark day.

Relax, they didn't get to Python's chmod() implementation yet <wink>.

hard-to-know-what-they-hoped-to-accomplish-but-the-consequences-
    won't-please-them-ly y'rs  - tim



From lonetwin <lonetwin@yahoo.com>  Wed Sep 12 07:21:33 2001
From: lonetwin <lonetwin@yahoo.com> (lonetwin)
Date: Wed, 12 Sep 2001 11:51:33 +0530 (IST)
Subject: [Tutor] problem with os.chmod()
In-Reply-To: <Pine.LNX.4.33.0109120159261.9819-100000@terbidium.openservices.net>
Message-ID: <Pine.LNX.4.30.0109121150340.15245-100000@mercury.worli>

On Wed, 12 Sep 2001, Ignacio Vazquez-Abrams wrote:

>On Wed, 12 Sep 2001, lonetwin wrote:
>
>>     I've got a problem with the os.chmod() function, it just doesn't
>> seem to do the right thing, let me explain, the code given below, is
>> something that I needed, I'm running this on a linux system, this code
>> changes the permissions of directories and files recursively. I initially
>> used os.chmod() function but it just screws up the permissions, so now I
>> do a os.system() to the chmod command, but I'd like to know what is
>> happening here....
>
>The problem is that your permission values are in the wrong radix. Try using
>octal instead of decimal, e.g., 0700 instead of 700.
>
>
Thanx ! that worked, what can I say, I'm slow :)
-- 
Peace
Steve



From lonetwin <lonetwin@yahoo.com>  Wed Sep 12 08:22:58 2001
From: lonetwin <lonetwin@yahoo.com> (lonetwin)
Date: Wed, 12 Sep 2001 12:52:58 +0530 (IST)
Subject: [Tutor] problem with threading module
Message-ID: <Pine.LNX.4.30.0109121247510.15418-100000@mercury.worli>

Hi everybody,
     Could someone please explain this:
###########################################################
Python 2.0 (#1, Apr 11 2001, 19:18:08)
[GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux-i386
Type "copyright", "credits" or "license" for more information.
>>> import thread
>>> import threading
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "./threading.py", line 12, in ?
    class TestThread(threading.Thread):
AttributeError: Thread
>>>
#########################################################
the threading module exists, and so does the definition of the Thread
class.....I'm just learning about threading, so I'm clue-less right now

-- 
Peace
Steve



From zhusm@neusoft.com  Wed Sep 12 08:16:43 2001
From: zhusm@neusoft.com (=?gb2312?B?16PLs8Px?=)
Date: Wed, 12 Sep 2001 15:16:43 +0800
Subject: [Tutor] help me please
Message-ID: <00f701c13b5a$e2d26820$4201010a@zhushunmin>

ÕâÊÇ MIME ¸ñʽµÄ¾ßÓкܶಿ·ÖÏûÏ¢¡£

--Boundary_(ID_0oq7fIwnhAjEDPKstES2YQ)
Content-type: text/plain; charset=gb2312
Content-transfer-encoding: QUOTED-PRINTABLE



help me please ,why can't parse the xml on linux.
my os is slcakware -linux-7.0
but the below programme have been executed on the windows 2000.
the programme is cut from the python doc on the www.python.org.
if you can help me .thank u very much.

>>> import xml.dom.minidom
>>>=20
>>> document =3D """\
=2E.. <slideshow>
=2E.. <title>Demo slideshow</title>
=2E.. <slide><title>Slide title</title>
=2E.. <point>This is a demo</point>
=2E.. <point>Of a program for processing slides</point>
=2E.. </slide>
=2E..=20
=2E.. <slide><title>Another demo slide</title>
=2E.. <point>It is important</point>
=2E.. <point>To have more than</point>
=2E.. <point>one slide</point>
=2E.. </slide>
=2E.. </slideshow>
=2E.. """
>>>=20
>>> dom =3D xml.dom.minidom.parseString(document)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.0/xml/dom/minidom.py", line 475, in parseStr=
ing
    return _doparse(pulldom.parseString, args, kwargs)
  File "/usr/lib/python2.0/xml/dom/minidom.py", line 464, in _doparse
    events =3D apply(func, args, kwargs)
  File "/usr/lib/python2.0/xml/dom/pulldom.py", line 237, in parseStr=
ing
    parser =3D xml.sax.make_parser()
  File "/usr/lib/python2.0/xml/sax/__init__.py", line 76, in make_par=
ser
    return _create_parser(parser_name)
  File "/usr/lib/python2.0/xml/sax/__init__.py", line 101, in _create=
_parser
    return drv_module.create_parser()
AttributeError: create_parser
>>>=20
>>> space =3D " "
>>> def getText(nodelist):
=2E..     rc =3D ""
=2E..     for node in nodelist:
=2E..         if node.nodeType =3D=3D node.TEXT_NODE:
=2E..             rc =3D rc + node.data
=2E..     return rc
=2E..=20
>>> def handleSlideshow(slideshow):
=2E..     print "<html>"
=2E..     handleSlideshowTitle(slideshow.getElementsByTagName("title"=
)[0])
=2E..     slides =3D slideshow.getElementsByTagName("slide")
=2E..     handleToc(slides)
=2E..     handleSlides(slides)
=2E..     print "</html>"
=2E..=20
>>> def handleSlides(slides):
=2E..     for slide in slides:
=2E..        handleSlide(slide)
=2E..=20
>>> def handleSlide(slide):
=2E..     handleSlideTitle(slide.getElementsByTagName("title")[0])
=2E..     handlePoints(slide.getElementsByTagName("point"))
=2E..=20
>>> def handleSlideshowTitle(title):
=2E..     print "<title>%s</title>" % getText(title.childNodes)
=2E..=20
>>> def handleSlideTitle(title):
=2E..     print "<h2>%s</h2>" % getText(title.childNodes)
=2E..=20
>>> def handlePoints(points):
=2E..     print "<ul>"
=2E..     for point in points:
=2E..         handlePoint(point)
=2E..     print "</ul>"
=2E..=20
>>> def handlePoint(point):
=2E..     print "<li>%s</li>" % getText(point.childNodes)
=2E..=20
>>> def handleToc(slides):
=2E..     for slide in slides:
=2E..         title =3D slide.getElementsByTagName("title")[0]
=2E..         print "<p>%s</p>" % getText(title.childNodes)
=2E..=20
>>> handleSlideshow(dom)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
NameError: There is no variable named 'dom'


--Boundary_(ID_0oq7fIwnhAjEDPKstES2YQ)
Content-type: text/html; charset=gb2312
Content-transfer-encoding: QUOTED-PRINTABLE

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dgb231=
2">
<META content=3D"MSHTML 6.00.2462.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#c0c0c0>
<DIV><BR>&nbsp;</DIV>
<DIV><FONT size=3D2>
<DIV><FONT size=3D2>help me please ,why can't parse the xml on linux.=
</FONT></DIV>
<DIV><FONT size=3D2>my os is slcakware -linux-7.0</FONT></DIV>
<DIV><FONT size=3D2>but the below programme have been executed on the=
 windows=20
2000.</FONT></DIV>
<DIV>the programme is cut from the python doc on the <A=20
href=3D"http://www.python.org">www.python.org</A>.</DIV>
<DIV>if you can help me .thank u very much.</DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>&gt;&gt;&gt; import xml.dom.minidom<BR>&gt;&gt;&g=
t;=20
<BR>&gt;&gt;&gt; document =3D """\<BR>... &lt;slideshow&gt;<BR>...=
=20
&lt;title&gt;Demo slideshow&lt;/title&gt;<BR>... &lt;slide&gt;&lt;tit=
le&gt;Slide=20
title&lt;/title&gt;<BR>... &lt;point&gt;This is a demo&lt;/point&gt;<=
BR>...=20
&lt;point&gt;Of a program for processing slides&lt;/point&gt;<BR>...=
=20
&lt;/slide&gt;<BR>... <BR>... &lt;slide&gt;&lt;title&gt;Another demo=
=20
slide&lt;/title&gt;<BR>... &lt;point&gt;It is important&lt;/point&gt;=
<BR>...=20
&lt;point&gt;To have more than&lt;/point&gt;<BR>... &lt;point&gt;one=
=20
slide&lt;/point&gt;<BR>... &lt;/slide&gt;<BR>... &lt;/slideshow&gt;<B=
R>...=20
"""<BR>&gt;&gt;&gt; <BR>&gt;&gt;&gt; dom =3D=20
xml.dom.minidom.parseString(document)<BR>Traceback (most recent call=
=20
last):<BR>&nbsp; File "&lt;stdin&gt;", line 1, in ?<BR>&nbsp; File=
=20
"/usr/lib/python2.0/xml/dom/minidom.py", line 475, in=20
parseString<BR>&nbsp;&nbsp;&nbsp; return _doparse(pulldom.parseString=
, args,=20
kwargs)<BR>&nbsp; File "/usr/lib/python2.0/xml/dom/minidom.py", line =
464, in=20
_doparse<BR>&nbsp;&nbsp;&nbsp; events =3D apply(func, args, kwargs)<B=
R>&nbsp; File=20
"/usr/lib/python2.0/xml/dom/pulldom.py", line 237, in=20
parseString<BR>&nbsp;&nbsp;&nbsp; parser =3D xml.sax.make_parser()<BR=
>&nbsp; File=20
"/usr/lib/python2.0/xml/sax/__init__.py", line 76, in=20
make_parser<BR>&nbsp;&nbsp;&nbsp; return _create_parser(parser_name)<=
BR>&nbsp;=20
File "/usr/lib/python2.0/xml/sax/__init__.py", line 101, in=20
_create_parser<BR>&nbsp;&nbsp;&nbsp; return=20
drv_module.create_parser()<BR>AttributeError: create_parser<BR>&gt;&g=
t;&gt;=20
<BR>&gt;&gt;&gt; space =3D " "<BR>&gt;&gt;&gt; def=20
getText(nodelist):<BR>...&nbsp;&nbsp;&nbsp;&nbsp; rc =3D=20
""<BR>...&nbsp;&nbsp;&nbsp;&nbsp; for node in=20
nodelist:<BR>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if=
=20
node.nodeType =3D=3D=20
node.TEXT_NODE:<BR>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;=20
rc =3D rc + node.data<BR>...&nbsp;&nbsp;&nbsp;&nbsp; return rc<BR>...=
=20
<BR>&gt;&gt;&gt; def handleSlideshow(slideshow):<BR>...&nbsp;&nbsp;&n=
bsp;&nbsp;=20
print "&lt;html&gt;"<BR>...&nbsp;&nbsp;&nbsp;&nbsp;=20
handleSlideshowTitle(slideshow.getElementsByTagName("title")[0])<BR>.=
..&nbsp;&nbsp;&nbsp;&nbsp;=20
slides =3D slideshow.getElementsByTagName("slide")<BR>...&nbsp;&nbsp;=
&nbsp;&nbsp;=20
handleToc(slides)<BR>...&nbsp;&nbsp;&nbsp;&nbsp;=20
handleSlides(slides)<BR>...&nbsp;&nbsp;&nbsp;&nbsp; print "&lt;/html&=
gt;"<BR>...=20
<BR>&gt;&gt;&gt; def handleSlides(slides):<BR>...&nbsp;&nbsp;&nbsp;&n=
bsp; for=20
slide in slides:<BR>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
=20
handleSlide(slide)<BR>... <BR>&gt;&gt;&gt; def=20
handleSlide(slide):<BR>...&nbsp;&nbsp;&nbsp;&nbsp;=20
handleSlideTitle(slide.getElementsByTagName("title")[0])<BR>...&nbsp;=
&nbsp;&nbsp;&nbsp;=20
handlePoints(slide.getElementsByTagName("point"))<BR>... <BR>&gt;&gt;=
&gt; def=20
handleSlideshowTitle(title):<BR>...&nbsp;&nbsp;&nbsp;&nbsp; print=
=20
"&lt;title&gt;%s&lt;/title&gt;" % getText(title.childNodes)<BR>...=
=20
<BR>&gt;&gt;&gt; def handleSlideTitle(title):<BR>...&nbsp;&nbsp;&nbsp=
;&nbsp;=20
print "&lt;h2&gt;%s&lt;/h2&gt;" % getText(title.childNodes)<BR>...=
=20
<BR>&gt;&gt;&gt; def handlePoints(points):<BR>...&nbsp;&nbsp;&nbsp;&n=
bsp; print=20
"&lt;ul&gt;"<BR>...&nbsp;&nbsp;&nbsp;&nbsp; for point in=20
points:<BR>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
handlePoint(point)<BR>...&nbsp;&nbsp;&nbsp;&nbsp; print "&lt;/ul&gt;"=
<BR>...=20
<BR>&gt;&gt;&gt; def handlePoint(point):<BR>...&nbsp;&nbsp;&nbsp;&nbs=
p; print=20
"&lt;li&gt;%s&lt;/li&gt;" % getText(point.childNodes)<BR>... <BR>&gt;=
&gt;&gt;=20
def handleToc(slides):<BR>...&nbsp;&nbsp;&nbsp;&nbsp; for slide in=
=20
slides:<BR>...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; title =
=3D=20
slide.getElementsByTagName("title")[0]<BR>...&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;=20
print "&lt;p&gt;%s&lt;/p&gt;" % getText(title.childNodes)<BR>...=20
<BR>&gt;&gt;&gt; handleSlideshow(dom)<BR>Traceback (most recent call=
=20
last):<BR>&nbsp; File "&lt;stdin&gt;", line 1, in ?<BR>NameError: The=
re is no=20
variable named 'dom'</FONT></DIV></FONT></DIV></BODY></HTML>


--Boundary_(ID_0oq7fIwnhAjEDPKstES2YQ)--


From dyoo@hkn.eecs.berkeley.edu  Wed Sep 12 08:21:13 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Wed, 12 Sep 2001 00:21:13 -0700 (PDT)
Subject: [Tutor] problem with threading module
In-Reply-To: <Pine.LNX.4.30.0109121247510.15418-100000@mercury.worli>
Message-ID: <Pine.LNX.4.21.0109120015530.18904-100000@hkn.eecs.berkeley.edu>

On Wed, 12 Sep 2001, lonetwin wrote:

> Hi everybody,
>      Could someone please explain this:
> ###########################################################
> Python 2.0 (#1, Apr 11 2001, 19:18:08)
> [GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux-i386
> Type "copyright", "credits" or "license" for more information.
> >>> import thread
> >>> import threading
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "./threading.py", line 12, in ?
>     class TestThread(threading.Thread):
> AttributeError: Thread

As a guess: it sounds like you may have called your program
"threading.py", or perhaps there's a file called 'threading.py' in your
current directory.

If so, you might want to either move or rename it, as 'threading' is also
the name of the Python module 'threading'. It sounds like Python's getting
confused between the official module and the one in your current
directory, so they may be conflicting.

However, these are wild guesses.  Can you give us some more information?



From ignacio@openservices.net  Wed Sep 12 08:25:08 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Wed, 12 Sep 2001 03:25:08 -0400 (EDT)
Subject: [Tutor] problem with threading module
In-Reply-To: <Pine.LNX.4.30.0109121247510.15418-100000@mercury.worli>
Message-ID: <Pine.LNX.4.33.0109120323300.24747-100000@terbidium.openservices.net>

On Wed, 12 Sep 2001, lonetwin wrote:

> Hi everybody,
>      Could someone please explain this:
> ###########################################################
> Python 2.0 (#1, Apr 11 2001, 19:18:08)
> [GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux-i386
> Type "copyright", "credits" or "license" for more information.
> >>> import thread
> >>> import threading
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "./threading.py", line 12, in ?
>     class TestThread(threading.Thread):
> AttributeError: Thread
> >>>
> #########################################################
> the threading module exists, and so does the definition of the Thread
> class.....I'm just learning about threading, so I'm clue-less right now

You have a local file called threading.py that is masking access to the
standard Python module of the same name.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From alan.gauld@bt.com  Wed Sep 12 10:49:55 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 12 Sep 2001 10:49:55 +0100
Subject: [Tutor] string.replace
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF42@mbtlipnt02.btlabs.bt.co.uk>

> >>> from string import *
> >>> def striptabs(line):
> ... 	if "<" in line:
> ... 		l = find(line, "<", 0)
> ... 		m = find(line, ">", l)
> ... 		if l and m:
> ... 			print "Tag found"		# Test
> ... 		line = replace(line, line[l:m+1], "")
> ... 		striptabs(line)
                  return striptabs(line)
> ... 	return line

You eren't returning the result to the top level so only 
the top level actually did anything....

Alan g.


From printers@sendme.cz  Wed Sep 12 11:13:43 2001
From: printers@sendme.cz (A)
Date: Wed, 12 Sep 2001 12:13:43 +0200
Subject: [Tutor] List of lists
Message-ID: <3B9F5177.19317.46DDB8@localhost>

Hi,
How can I create a List of Lists and how I can acess each item in 
this List.
Thank you
Ladislav
 


From ignacio@openservices.net  Wed Sep 12 11:22:37 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Wed, 12 Sep 2001 06:22:37 -0400 (EDT)
Subject: [Tutor] List of lists
In-Reply-To: <3B9F5177.19317.46DDB8@localhost>
Message-ID: <Pine.LNX.4.33.0109120621400.24747-100000@terbidium.openservices.net>

On Wed, 12 Sep 2001, A wrote:

> How can I create a List of Lists and how I can acess each item in
> this List.

t=[[1,2],[3,4,5],[6]]

print t[0][1],t[1][2],t[2][0]

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From dsh8290@rit.edu  Wed Sep 12 11:38:04 2001
From: dsh8290@rit.edu (dman)
Date: Wed, 12 Sep 2001 06:38:04 -0400
Subject: [Tutor] string.replace
In-Reply-To: <Pine.LNX.4.33.0109120051260.9819-100000@terbidium.openservices.net>
References: <Pine.LNX.4.21.0109112139150.16825-100000@hkn.eecs.berkeley.edu>
 <Pine.LNX.4.33.0109120051260.9819-100000@terbidium.openservices.net>
Message-ID: <20010912063804.A4055@hudson>

On Wed, Sep 12, 2001 at 12:56:14AM -0400, Ignacio Vazquez-Abrams wrote:
| > The recursive striptabs() call is buggy, but's also intentionally
| > recursive: if Jon changes the line from:
| >
| >  		striptabs(line)
| >
| > to:
| >
| >                 line = striptabs(line)
| >
| > and corrects a few more logical bugs, the code should work because
| > striptabs should only call itself recursivly if the line still contains
| > tags --- his use of recursion is about the same as if he had used an
| > explicit while loop.
| 
| That's true, but 95-97% of the time iterative constructs are faster than
| recursive mechanisms, plus by definition they don't cause recursion overflows.
| Both of those points can be a big advantage if very large documents are being
| processed.

I just want to mention that, while this is true for Python, C, C++,
and Java (and others too I am sure), it is not necessarily true for
Common Lisp or Scheme.  If a tail-recursive style is used then the
Listp/Scheme compiler will optimize out all of the recursive calls and
it will be just as fast as an iterative solution.

-D



From alan.gauld@bt.com  Wed Sep 12 11:52:53 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 12 Sep 2001 11:52:53 +0100
Subject: [Tutor] string.replace
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF43@mbtlipnt02.btlabs.bt.co.uk>

> That's true, but 95-97% of the time iterative constructs are 
> faster than recursive mechanisms, 

I suppose thats true if you consider that every loop can 
be implemented recursively. However for those cases where 
recursion is the most natural solution (tree walking being 
a good example) the recursive approach is usually both much 
shorter and faster.


> plus by definition they don't cause recursion overflows.

But this is a valid comment (for Python) because in striptabs() 
case it could very easily be passed a large file with lots 
of tags(reading a complete HTML file as a string for example)
and the recursion limit(999?) would be burst.

Alan G


From ajaya@ncoretech.com  Wed Sep 12 12:06:56 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Wed, 12 Sep 2001 16:36:56 +0530
Subject: some more doubts:? RE: [Tutor] How to convert integer to binay packed string...,?
In-Reply-To: <Pine.LNX.4.21.0109111156070.5497-100000@hkn.eecs.berkeley.edu>
Message-ID: <000001c13b7b$09b64180$6501a8c0@ncoretech.com>

Hi,
I've some more doubts regarding serilizing objects and converting integer
data to binary packed string.


First when I use struct module...there is problem I am facing.., My code
looks like

class EventDial(Event):

    def __init__(self, Pipe, DigitStr):
        Event.__init__(self, Pipe)
        self.DialedNumber = DigitStr
        print self.DialedNumber
        self.EventType = 1

    def Serialize(self):
        a = len(self.DialedNumber)
        data = pack('IIs', self.EventType, len(self.DialedNumber),
                    self.DialedNumber)
        self.Pipe.SendData(data)

but packing data using 'IIs' givign problem when my string size is more than
1. For example if I dail a number 911 my string size is 3 when I pack and
receive at the toher end

It is giving like this...,
1l, 3l, '9'

When i went through the documentation i got a feeling that I should give
sring size as a prefix to the 's' parameter. But i've variable string
lenght. So How can I use this prefix notation...,?


Second thing when I tried using pickle. I confused with the documentation.
there is a pcikle.dump(obj, file, bin=0) function.., but it always needs
file. If I want to send to network (LAN) then why I need to have a file
operation in between it is slow right? If I don't need to do this plese give
me example or  link to the docs. I quite confused with the pickle...,


Thanks and Regards,
Ajaya Babu










-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Danny Yoo
Sent: Wednesday, September 12, 2001 12:34 AM
To: Ajaya Babu
Cc: PythonTutorlist (E-mail)
Subject: Re: [Tutor] How to convert integer to binay packed string...,?


On Tue, 11 Sep 2001, Ajaya Babu wrote:

> I've a small doubt, How to convert integers into bytestream in python.
> What actually I want to do is send integer to another system in the
> network. But since there is nothing like integer in python...I am just
> wondering how can

Actually, Python Integers are 32-bit integers, and we can do bitwise
manipulation with them:

###
>>> x = 2
>>> x>>2
0
>>> x<<2
8
>>> 0xffffffff & 0x00002000
8192
###

As Ignacio as mentioned, it sounds like you'll want to look at the
"struct" module, a module that deals exclusively with packing things into
bytes.


Alternatively, you might want to look at the "pickle" module:

    http://python.org/doc/current/lib/module-pickle.html

pickle will allow us to preserve integers into strings --- in effect, it
turns things into a bytestream.  pickle will "serialize" Python objects
into something that we can save, or send!  If you're sending something
across the network to another Python system, pickle might be useful for
you.

Hope this helps!


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From cerulean_rodent@yahoo.co.uk  Wed Sep 12 13:50:25 2001
From: cerulean_rodent@yahoo.co.uk (Cerulean Rodent)
Date: Wed, 12 Sep 2001 16:50:25 +0400 (MSD)
Subject: [Tutor] adding users from a script
Message-ID: <Pine.LNX.4.21.0109121626290.7399-100000@ecosse.net>

Hello hello hello, 

I haven't got the foggiest as to whether introductory messages are
obligatory and am moving on to what's been bugging me lately skipping that
part. Our existence is all pretty illusionary anyway, so why bother?

What I'm trying to do at the moment is writing a script that would add
users without creating a home directory, then generating and assigning
random passwords. The proggy itself is ugly and messy and I'll have to
work on making it presentable; but I would really like to make it
functional first. So here goes:

#!/usr/bin/python
 
import os

import whrandom

rnd = whrandom.whrandom()

validfirst  = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ23456789"

pwlen = 8

pw = ""

idx = 0

while idx < pwlen:
	str = validfirst[rnd.randint(0,(len(validfirst)-1))]
	pw = pw + str
	idx = idx + 1

print "\nEnter your desired username:\n"

nomme = raw_input (">>")

os.system ('useradd ' + nomme) 

Now this is the part I got really stuck on

os.system ('passwd ' + nomme) gets me a prompt which I need about as much
as I need a hole in my cranium; I want the password to be read from the pw
variable directly. How could I possibly accomplish it? From what I have
understood from the excellent (but, sadly, a touch arcane) tome by Mark
Lutz, I might be better off using os.popen - but the directions on its
correct syntax are far from clear. And am I right about useradd -p
requiring an encrypted password? Blimey, this script is probably worse off
than the Medical Love Song protagonist... 


Pope Mickey XXIII, Chief Ov Thee Church Police
 
-----------------------------------------------------
 
 " The stars go waltzing out in blue and red,
   And arbitrary blackness gallops in:
   I shut my eyes and all the world drops dead. "
  
    --Sylvia Plath

-----------------------------------------------------



From lonetwin@yahoo.com  Wed Sep 12 14:41:29 2001
From: lonetwin@yahoo.com (lonetwin)
Date: Wed, 12 Sep 2001 19:11:29 +0530
Subject: [Tutor] adding users from a script
In-Reply-To: <Pine.LNX.4.21.0109121626290.7399-100000@ecosse.net>
References: <Pine.LNX.4.21.0109121626290.7399-100000@ecosse.net>
Message-ID: <01091219112903.18667@mercury.worli>

Hi,
    A suggestion ....maybe you should look at the crypt module...it 
implements the crypt(3) function and returns an encrypted passwd that the 
'useradd -p' option expects.

references:
man useradd // look at the -p option
man passwd  
man 3 crypt // this is the function that the python crypt module implements

HTH

Peace
Steve

On Wednesday 12 September 2001 18:20, you wrote:
> Hello hello hello,
>
> I haven't got the foggiest as to whether introductory messages are
> obligatory and am moving on to what's been bugging me lately skipping that
> part. Our existence is all pretty illusionary anyway, so why bother?
>
> What I'm trying to do at the moment is writing a script that would add
> users without creating a home directory, then generating and assigning
> random passwords. The proggy itself is ugly and messy and I'll have to
> work on making it presentable; but I would really like to make it
> functional first. So here goes:
>
> #!/usr/bin/python
>
> import os
>
> import whrandom
>
> rnd = whrandom.whrandom()
>
> validfirst  =
> "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ23456789"
>
> pwlen = 8
>
> pw = ""
>
> idx = 0
>
> while idx < pwlen:
> 	str = validfirst[rnd.randint(0,(len(validfirst)-1))]
> 	pw = pw + str
> 	idx = idx + 1
>
> print "\nEnter your desired username:\n"
>
> nomme = raw_input (">>")
>
> os.system ('useradd ' + nomme)
>
> Now this is the part I got really stuck on
>
> os.system ('passwd ' + nomme) gets me a prompt which I need about as much
> as I need a hole in my cranium; I want the password to be read from the pw
> variable directly. How could I possibly accomplish it? From what I have
> understood from the excellent (but, sadly, a touch arcane) tome by Mark
> Lutz, I might be better off using os.popen - but the directions on its
> correct syntax are far from clear. And am I right about useradd -p
> requiring an encrypted password? Blimey, this script is probably worse off
> than the Medical Love Song protagonist...
>
>
> Pope Mickey XXIII, Chief Ov Thee Church Police
>
> -----------------------------------------------------
>
>  " The stars go waltzing out in blue and red,
>    And arbitrary blackness gallops in:
>    I shut my eyes and all the world drops dead. "
>
>     --Sylvia Plath


From lonetwin@yahoo.com  Wed Sep 12 14:46:07 2001
From: lonetwin@yahoo.com (lonetwin)
Date: Wed, 12 Sep 2001 19:16:07 +0530
Subject: [Tutor] adding users from a script
In-Reply-To: <Pine.LNX.4.21.0109121626290.7399-100000@ecosse.net>
References: <Pine.LNX.4.21.0109121626290.7399-100000@ecosse.net>
Message-ID: <01091219160704.18667@mercury.worli>

Hi,
    A suggestion ....maybe you should look at the crypt module...it 
implements the crypt(3) function and returns an encrypted passwd that the 
'useradd -p' option expects.

references:
man useradd // look at the -p option
man passwd  
man 3 crypt // this is the function that the python crypt module implements
==================================================================

To add to that ealier post ....the url for crypt documentation:
http://www.python.org/doc/current/lib/module-crypt.html

Peace
Steve


From ajaya@ncoretech.com  Wed Sep 12 14:31:58 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Wed, 12 Sep 2001 19:01:58 +0530
Subject: [Tutor] doubts with socket asychronous doc..,
Message-ID: <000001c13b8f$4ca41b70$6501a8c0@ncoretech.com>

Hi,

I've some dbouts of using asyncore module for asychronous socket service
clients and servers.

http://www.python.org/doc/current/lib/module-asyncore.html



Example is given like this


class http_client(asyncore.dispatcher):
    def __init__(self, host,path):
        asyncore.dispatcher.__init__(self)
        self.path = path
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.connect( (host, 80) )
        self.buffer = 'GET %s HTTP/1.0\r\n\r\n' % self.path

    def handle_connect(self):
        pass

    def handle_read(self):
        data = self.recv(8192)
        print data

    def writable(self):
        return (len(self.buffer) > 0)

    def handle_write(self):
        sent = self.send(self.buffer)
        self.buffer = self.buffer[sent:]


from the documentation I understand handle_read will be called when ever new
data to be read from the socket..., and handle_write will be called when
attempt to write the object.

but I did not understand these terms properly. I had a confustion who is
going to initiate these events. Like read or write....,

For example my C server send some data on port x, suppose my python
appliation should recive that data as a asynchronous menas is this just ok
if I make a instant of the above class and connect to the
server...,(Assuming that handle_read) will be called asynchronously when
data arives to that port.

but Documentation is telling me it is wraper around the select() fuction.
Generally select() function need to be polled as my understanding. It just
gives the idea that can performing certain action is worth or not..., but
from the above example it is nor clear that who is polling  on this function
to call handle_read functions.

One more thing is if I want to send some data to my C host again.., How do I
do it. Do I need to send just like mysocket.send(buffer)...or handle_write()
how can I use.., it is not clear from the documentation

May be my understanding is poor....since I just started learning python..,
Please send me some doc liks or give  me suggestion to make my study
progress,

Thanks allot  for great help.

with regards,
Ajaya



From ignacio@openservices.net  Wed Sep 12 16:46:37 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Wed, 12 Sep 2001 11:46:37 -0400 (EDT)
Subject: some more doubts:? RE: [Tutor] How to convert integer to binay
 packed string...,?
In-Reply-To: <000001c13b7b$09b64180$6501a8c0@ncoretech.com>
Message-ID: <Pine.LNX.4.33.0109121145140.8904-100000@terbidium.openservices.net>

On Wed, 12 Sep 2001, Ajaya Babu wrote:

> but packing data using 'IIs' givign problem when my string size is more than
> 1. For example if I dail a number 911 my string size is 3 when I pack and
> receive at the toher end
>
> It is giving like this...,
> 1l, 3l, '9'
>
> When i went through the documentation i got a feeling that I should give
> sring size as a prefix to the 's' parameter. But i've variable string
> lenght. So How can I use this prefix notation...,?

Look at using Pascal-style strings whereby the first byte is the length of
the string. It restricts your string to 255 characters, but that should be
enough for most cases.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From dsh8290@rit.edu  Wed Sep 12 17:09:26 2001
From: dsh8290@rit.edu (dman)
Date: Wed, 12 Sep 2001 12:09:26 -0400
Subject: some more doubts:? RE: [Tutor] How to convert integer to binay
 packed string...,?
In-Reply-To: <000001c13b7b$09b64180$6501a8c0@ncoretech.com>
References: <Pine.LNX.4.21.0109111156070.5497-100000@hkn.eecs.berkeley.edu>
 <000001c13b7b$09b64180$6501a8c0@ncoretech.com>
Message-ID: <20010912120926.A1092@hudson>

On Wed, Sep 12, 2001 at 04:36:56PM +0530, Ajaya Babu wrote:
| Hi,
| I've some more doubts regarding serilizing objects and converting integer
| data to binary packed string.
| 
| 
| First when I use struct module...there is problem I am facing.., My code
| looks like
| 
| class EventDial(Event):
| 
|     def __init__(self, Pipe, DigitStr):
|         Event.__init__(self, Pipe)
|         self.DialedNumber = DigitStr
|         print self.DialedNumber
|         self.EventType = 1
| 
|     def Serialize(self):
|         a = len(self.DialedNumber)
|         data = pack('IIs', self.EventType, len(self.DialedNumber),
|                     self.DialedNumber)
|         self.Pipe.SendData(data)
| 
| but packing data using 'IIs' givign problem when my string size is more than
| 1. For example if I dail a number 911 my string size is 3 when I pack and
| receive at the toher end
| 
| It is giving like this...,
| 1l, 3l, '9'
| 
| When i went through the documentation i got a feeling that I should give
| sring size as a prefix to the 's' parameter. But i've variable string
| lenght. So How can I use this prefix notation...,?
 

        data = pack('II%ds' % len( self.DialedNumber ) , self.EventType, len(self.DialedNumber),
                    self.DialedNumber)

Use string interpolation or addition to add the number in dynamically.
Nothing says that the string has to be static.  I don't know how this
would work on the receiving side though.  Perhaps you would have to
extract the length integer first, then you would be able to construct
the format string to unpack the data string.

| Second thing when I tried using pickle. I confused with the documentation.
| there is a pcikle.dump(obj, file, bin=0) function.., but it always needs
| file. If I want to send to network (LAN) then why I need to have a file
| operation in between it is slow right? If I don't need to do this plese give
| me example or  link to the docs. I quite confused with the pickle...,

Does it need a 'file' or a 'file-like object'?  (I haven't checked the
docs myself)  If it is the latter, then a socket connection would
work.  It definitely needs something that it can write() to to dump
the object and something it can read() from to retrieve the object.

HTH,
-D



From alan.gauld@bt.com  Wed Sep 12 17:43:53 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 12 Sep 2001 17:43:53 +0100
Subject: [Tutor] adding users from a script
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF52@mbtlipnt02.btlabs.bt.co.uk>

> I haven't got the foggiest as to whether introductory messages are
> obligatory 

Nope, just ask quetions :-)

> import whrandom
> rnd = whrandom.whrandom()
> 
> validfirst  = 
> "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ23456789"

You might find it easier in future to use:

validfirst = string.letters + string.digits[2:]

I notice you disallow 1 and 0 - any reason?

> pwlen = 8
> pw = ""
> idx = 0
> 
> while idx < pwlen:
> 	str = validfirst[rnd.randint(0,(len(validfirst)-1))]

      str = rnd.choice(validfirst)  # a bit easier?

> 	pw = pw + str
Could combine these two lines:

      pw = pw + rnd.choice(validfirst)

> 	idx = idx + 1
> 
> print "\nEnter your desired username:\n"
> nomme = raw_input (">>")
Why not combine these:
nomme = raw_input("\nEnter your desired username:\n>> ")

> os.system ('useradd ' + nomme) 
> 
> Now this is the part I got really stuck on
> os.system ('passwd ' + nomme) gets me a prompt 

Thats why you need to use popen or popen2.
They allow you to write to that prompt.

> correct syntax are far from clear. 

Treat it as a file. In your case open to write 
- you want to send data to it...
Try searching the ActiveState version of this list
archive for popen you should find lots of code examples.

That should solve it.

Alan G


From python.tutorial@jarava.org  Wed Sep 12 19:45:50 2001
From: python.tutorial@jarava.org (Javier JJ)
Date: Wed, 12 Sep 2001 20:45:50 +0200
Subject: [Tutor] test (something seems to be wrong)
Message-ID: <007a01c13bbb$25c70e50$0124a8c0@uno>




From python.tutorial@jarava.org  Wed Sep 12 19:50:57 2001
From: python.tutorial@jarava.org (Javier JJ)
Date: Wed, 12 Sep 2001 20:50:57 +0200
Subject: [Tutor] RE: test (something seems to be wrong)
Message-ID: <000d01c13bbb$dc69aa00$0124a8c0@uno>

----- Mensaje original -----
De: "Javier JJ" <python.tutorial@jarava.org>
Para: "Lista Python" <tutor@python.org>
Enviado: miércoles, 12 de septiembre de 2001 20:45
Asunto: test (something seems to be wrong)


>
>



From csmith@blakeschool.org  Wed Sep 12 20:46:37 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Wed, 12 Sep 2001 14:46:37 -0500
Subject: [Tutor] redefining builtin function
Message-ID: <fc.004c4b6b007adf29004c4b6b007adf29.7ae048@blakeschool.org>

Hi list,

I am trying to redefine a built in function.  I can do the following in
the 
interactive window but not in a script.  Can anyone help me with the
script?

>>> from math import floor, log10
>>> def round(x,n=0):
...  if n%1==0:
...   return __builtins__.round(x,n)
...  return __builtins__.round(x,int(10*n)-1-floor(log10(abs(x))))
... 
>>> print round(1.234567,2)
1.23
>>> print round(1.234567,0.2)
1.2
>>>

When I do the same thing in a script I get an "attribute error" so
apparently I am 
working with a different namespace.  Is there a way to make sure that I
can get 
access to the global _builtins__.round no matter where round is defined?

/c



From shalehperry@home.com  Wed Sep 12 20:57:35 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Wed, 12 Sep 2001 12:57:35 -0700 (PDT)
Subject: [Tutor] redefining builtin function
In-Reply-To: <fc.004c4b6b007adf29004c4b6b007adf29.7ae048@blakeschool.org>
Message-ID: <XFMail.20010912125735.shalehperry@home.com>

Seems to work here.

$ cat test.py
#! /usr/bin/python

def round(x, n=0):
        print x, n
        print __builtins__.round(x,n)

round(5.0, 1)
round(3.23)
$ python test.py 
5.0 1
5.0
3.23 0
3.0

This is under 1.5.2.


From pobrien@orbtech.com  Wed Sep 12 20:59:37 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 12 Sep 2001 14:59:37 -0500
Subject: [Tutor] redefining builtin function
In-Reply-To: <fc.004c4b6b007adf29004c4b6b007adf29.7ae048@blakeschool.org>
Message-ID: <NBBBIOJPGKJEKIECEMCBKEKOKKAA.pobrien@orbtech.com>

You need to explicitly import __builtins__. It is imported by default in the
shell, which is why your code worked interactively. You need to add an
import statement somewhere, like this:

def round(x,n=0):
    import __builtins__  # Add this.
    if n%1==0:
    ...

---
Patrick K. O'Brien
Orbtech (http://www.orbtech.com)
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Christopher Smith
Sent: Wednesday, September 12, 2001 2:47 PM
To: tutor@python.org
Subject: [Tutor] redefining builtin function

Hi list,

I am trying to redefine a built in function.  I can do the following in
the
interactive window but not in a script.  Can anyone help me with the
script?

>>> from math import floor, log10
>>> def round(x,n=0):
...  if n%1==0:
...   return __builtins__.round(x,n)
...  return __builtins__.round(x,int(10*n)-1-floor(log10(abs(x))))
...
>>> print round(1.234567,2)
1.23
>>> print round(1.234567,0.2)
1.2
>>>

When I do the same thing in a script I get an "attribute error" so
apparently I am
working with a different namespace.  Is there a way to make sure that I
can get
access to the global _builtins__.round no matter where round is defined?

/c


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From jcosby@mindspring.com  Wed Sep 12 21:06:16 2001
From: jcosby@mindspring.com (Jon Cosby)
Date: Wed, 12 Sep 2001 13:06:16 -0700
Subject: [Tutor] Thanks
Message-ID: <MBBBIFMLIJLJLMBAJBPOMEDCCAAA.jcosby@mindspring.com>

Thanks to everybody for all your help the last few days. I've been modifying
a search engine originally written for plain text files to search my
website. It's been fun, and I've learned a lot in the process. I need to get
better at error handling, that might have saved a lot of trouble. If your
interested in seeing this, follow the link below. It will be on the Python
page. Let me know if you see any bugs.


Jon Cosby

jcosby@mindspring.com
www.jcosby.com



From shalehperry@home.com  Wed Sep 12 21:11:49 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Wed, 12 Sep 2001 13:11:49 -0700 (PDT)
Subject: [Tutor] redefining builtin function
In-Reply-To: <NBBBIOJPGKJEKIECEMCBKEKOKKAA.pobrien@orbtech.com>
Message-ID: <XFMail.20010912131149.shalehperry@home.com>

On 12-Sep-2001 Patrick K. O'Brien wrote:
> You need to explicitly import __builtins__. It is imported by default in the
> shell, which is why your code worked interactively. You need to add an
> import statement somewhere, like this:
> 

odd, importing builtins triggers an exception for me under both 1.5.x and 2.x.


From mascher@crg.ha.nw.schule.de  Wed Sep 12 21:32:38 2001
From: mascher@crg.ha.nw.schule.de (Christian Mascher)
Date: Wed, 12 Sep 2001 22:32:38 +0200
Subject: [Tutor] round() errors
Message-ID: <3B9FC666.1EC16FE5@gmx.de>

Hi All,

I don't understand some response from the round()-function. 

>>> round(1.4783321399,2)
1.48
>>> round(1.95583,2) # this is the ratio of EURO to DM
1.96

so far, so good, but ...

>>> round(10*1.95583,2) 
19.559999999999999
>>> round(20*1.95583,2)
39.119999999999997
>>> a=20*1.95583
>>> a
39.116599999999998
>>> round(a,2)
39.119999999999997

I recall reading somebody explain this behaviour with the problem of
representing base-10 float-numbers in a binary system. Still, I ask
myself, why can't round() be smart enough to handle this on its own
(especially the last case)?  
Since you can do

>>> print '%.2f' %a
39.12
>>> 

why can't round() do the same? Is there any reason?

Christian



From tim.one@home.com  Wed Sep 12 21:42:00 2001
From: tim.one@home.com (Tim Peters)
Date: Wed, 12 Sep 2001 16:42:00 -0400
Subject: [Tutor] redefining builtin function
In-Reply-To: <XFMail.20010912125735.shalehperry@home.com>
Message-ID: <LNBBLJKPBEHFEDALKOLCMEJFLLAA.tim.one@home.com>

Tere is no module named

    __builtins__

The name of the module you want is

    __builtin__

(note that lack of the letter 's').  So

    import __builtin__

followed by references to

    __builtin__.round

always works.  __builtins__ (with the trailing 's') is an implementation
detail you should never use directly (you can read more about that in the
Reference Manual, but in the end you'll simply agree you should never use it
directly <wink>).



From ignacio@openservices.net  Wed Sep 12 21:42:44 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Wed, 12 Sep 2001 16:42:44 -0400 (EDT)
Subject: [Tutor] round() errors
In-Reply-To: <3B9FC666.1EC16FE5@gmx.de>
Message-ID: <Pine.LNX.4.33.0109121641510.8904-100000@terbidium.openservices.net>

On Wed, 12 Sep 2001, Christian Mascher wrote:

> Hi All,
>
> I don't understand some response from the round()-function.
>
> >>> round(1.4783321399,2)
> 1.48
> >>> round(1.95583,2) # this is the ratio of EURO to DM
> 1.96
>
> so far, so good, but ...
>
> >>> round(10*1.95583,2)
> 19.559999999999999
> >>> round(20*1.95583,2)
> 39.119999999999997
> >>> a=20*1.95583
> >>> a
> 39.116599999999998
> >>> round(a,2)
> 39.119999999999997
>
> I recall reading somebody explain this behaviour with the problem of
> representing base-10 float-numbers in a binary system. Still, I ask
> myself, why can't round() be smart enough to handle this on its own
> (especially the last case)?
> Since you can do
>
> >>> print '%.2f' %a
> 39.12
> >>>
>
> why can't round() do the same? Is there any reason?

It's because round() returns a floating-point number, whereas format
specifiers convert it to a string.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From kalle@gnupung.net  Wed Sep 12 21:54:24 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Wed, 12 Sep 2001 22:54:24 +0200
Subject: [Tutor] round() errors
In-Reply-To: <3B9FC666.1EC16FE5@gmx.de>; from christian.mascher@gmx.de on Wed, Sep 12, 2001 at 10:32:38PM +0200
References: <3B9FC666.1EC16FE5@gmx.de>
Message-ID: <20010912225424.A19740@gandalf>

[Christian Mascher]
> I don't understand some response from the round()-function. 
> 
> >>> round(1.4783321399,2)
> 1.48
> >>> round(1.95583,2) # this is the ratio of EURO to DM
> 1.96
> 
> so far, so good, but ...
> 
> >>> round(10*1.95583,2) 
> 19.559999999999999
> >>> round(20*1.95583,2)
> 39.119999999999997
> >>> a=20*1.95583
> >>> a
> 39.116599999999998
> >>> round(a,2)
> 39.119999999999997
> 
> >>> print '%.2f' %a
> 39.12
> >>> 
> 
> why can't round() do the same? Is there any reason?

>>> round(20*1.95583,2)
39.119999999999997
>>> print round(20*1.95583,2)
39.12
>>> repr(round(20*1.95583,2))
'39.119999999999997'
>>> str(round(20*1.95583,2))
'39.12'
>>> 

Peace,
  Kalle
-- 
[  kalle@gnupung.net  ][ Thought control, brought to you by the WIPO! ]
[ http://gnupung.net/ ][ http://anti-dmca.org/ http://eurorights.org/ ]


From tutor@python.org  Wed Sep 12 21:53:30 2001
From: tutor@python.org (Tim Peters)
Date: Wed, 12 Sep 2001 16:53:30 -0400
Subject: [Tutor] round() errors
In-Reply-To: <3B9FC666.1EC16FE5@gmx.de>
Message-ID: <LNBBLJKPBEHFEDALKOLCAEJHLLAA.tim.one@home.com>

[Christian Mascher]
> I don't understand some response from the round()-function. 
> ...
 
> >>> round(10*1.95583,2) 
> 19.559999999999999
> >>> round(20*1.95583,2)
> 39.119999999999997
> >>> a=20*1.95583
> >>> a
> 39.116599999999998
> >>> round(a,2)
> 39.119999999999997

Please read

    http://python.sourceforge.net/devel-docs/tut/node14.html

which discusses this specific issue (among others).

> ...
> Is there any reason?

Yes <wink>.



From pobrien@orbtech.com  Wed Sep 12 22:02:33 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 12 Sep 2001 16:02:33 -0500
Subject: [Tutor] redefining builtin function
In-Reply-To: <XFMail.20010912131149.shalehperry@home.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBMELAKKAA.pobrien@orbtech.com>

Sorry, that module is actually __builtin__ with no "s". Not to be confused
(as I always do) with the __builtins__ attribute of the module, which is the
dictionary you see in the shell. So remove the "s" from all references to
__builtins__ in your code. Make sense?

---
Patrick K. O'Brien
Orbtech (http://www.orbtech.com)
"I am, therefore I think."

-----Original Message-----
From: Sean Perry [mailto:shaleh@one.local]On Behalf Of Sean 'Shaleh' Perry
Sent: Wednesday, September 12, 2001 3:12 PM
To: Patrick K. O'Brien
Cc: tutor@python.org
Subject: RE: [Tutor] redefining builtin function


On 12-Sep-2001 Patrick K. O'Brien wrote:
> You need to explicitly import __builtins__. It is imported by default in
the
> shell, which is why your code worked interactively. You need to add an
> import statement somewhere, like this:
>

odd, importing builtins triggers an exception for me under both 1.5.x and
2.x.



From lco@gofuse.com  Wed Sep 12 22:06:21 2001
From: lco@gofuse.com (lco )
Date: Wed, 12 Sep 2001 14:06:21 -0700
Subject: [Tutor] network file copy
Message-ID: <200109121406.AA6488536@mail1.gofuse.com>

can someone give me some ideas as to how I can copy files to a network share on the Win32 platform?

I've tried to copy using the shutil module but it does not recognize share formats such as //server-name/share-name 

TIA

lco


From csmith@blakeschool.org  Wed Sep 12 22:18:32 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Wed, 12 Sep 2001 16:18:32 -0500
Subject: [Tutor] Re: redefining builtin function
In-Reply-To: <XFMail.20010912125735.shalehperry@home.com>
References: <XFMail.20010912125735.shalehperry@home.com>
Message-ID: <fc.004c4b6b007ae494004c4b6b007adf29.7ae4d0@blakeschool.org>

shalehperry@home.com writes:
>Seems to work here.

hmm...but not here.  Here is my IDE header

Python 2.1.1 (#97, Aug  2 2001, 21:56:33)  [CW CARBON GUSI2 THREADS]
Type "copyright", "credits" or "license" for more information.
>>>

I tried pasting the following script (now like yours) into a fresh 
script window of a fresh session and still get the AttributeError.

####
def round(x,n=0):
	return __builtins__.round(x,n)

print round(1.23,1)
####

No problem in the interactive window, though. :-(

/c



From danny.kohn@systematik.se  Thu Sep 13 00:33:07 2001
From: danny.kohn@systematik.se (Danny Kohn)
Date: Thu, 13 Sep 2001 01:33:07 +0200
Subject: [Tutor] What to choose - database
Message-ID: <OGEPIJONPINEELIFKPBOGELCDNAA.danny.kohn@systematik.se>

Hi.
I am a total newbie having spent the last week to read a lot of stuff =
about Python, coming to think that it could be a good language for my =
program project. My question is regarding databases. The application I =
want to write does probably need some form of database support. It is =
very much material to digest and I am a very slow reader so I would like =
to get some advice which path that might be most successful or easiest.

By background is from 20 years ago when computers, even microcomputers, =
had a control panel and you could single step them. The program language =
was assembler. Have also done some Basic and also in nearer time some =
small tasks in Visual Basic.

Now, I have come to like the MySQL concept although I am not attached to =
it (yet). Now I'm sure my questions seem unenlightened and they are but =
that is what this list is about so here they are.

1. It seems that I can do database access two ways, through the DB-API =
spec v2.0 or through ODBC (which I understand is also support in Linux). =
Is this a correct understanding?

2. If this is so, what way would be the best choice and why?

3. I need to be able to create tables from the program. But I have not =
found any way to do it. How to do this?

4. Does one run SQL to access tables from Python. If so, how is this =
done? If not, what does one do instead? Running through the API? But =
then, what does one do when one want to access the database(s) when the =
"specified" ways are inadequate?

H=E4lsningar / Regards                                 (\_/)  ))
Danny Kohn                 Tel: +46 (0)708 140 300  =3D('.')=3D//  Miau!
Systematik Consulting AB   ICQ: 1328817             ( ~~~ )/   Rrrrrui!
http://www.systematik.se   HAM: SM0NBJ              `w---w=B4=20






From lkvam@venix.com  Thu Sep 13 00:47:45 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Wed, 12 Sep 2001 19:47:45 -0400
Subject: [Tutor] What to choose - database
References: <OGEPIJONPINEELIFKPBOGELCDNAA.danny.kohn@systematik.se>
Message-ID: <3B9FF421.927B79F4@venix.com>

Danny Kohn wrote:
> =

> Hi.
> I am a total newbie having spent the last week to read a lot of stuff a=
bout Python, coming to think that it could be a good language for my prog=
ram project. My question is regarding databases. The application I want t=
o write does probably need some form of database support. It is very much=
 material to digest and I am a very slow reader so I would like to get so=
me advice which path that might be most successful or easiest.
> =

> By background is from 20 years ago when computers, even microcomputers,=
 had a control panel and you could single step them. The program language=
 was assembler. Have also done some Basic and also in nearer time some sm=
all tasks in Visual Basic.
> =

> Now, I have come to like the MySQL concept although I am not attached t=
o it (yet). Now I'm sure my questions seem unenlightened and they are but=
 that is what this list is about so here they are.
> =

> 1. It seems that I can do database access two ways, through the DB-API =
spec v2.0 or through ODBC (which I understand is also support in Linux). =
Is this a correct understanding?

YES
> =

> 2. If this is so, what way would be the best choice and why?
> =

ODBC gives you easy portability between SQL servers.  It also allows non-=
Python applications access to the database.  If you have any of these (e.=
g. SAS, Excel, Access) you will wind up doing the ODBC anyway.

The DB-API will give slightly better performance.  I normally use ODBC.

> 3. I need to be able to create tables from the program. But I have not =
found any way to do it. How to do this?

SQL create table commands.  Just pass them to the database using your int=
erface using ODBC or whatever.
> =

> 4. Does one run SQL to access tables from Python. If so, how is this do=
ne? If not, what does one do instead? Running through the API? But then, =
what does one do when one want to access the database(s) when the "specif=
ied" ways are inadequate?

For instance:
		DB.shared_conn=3DODBC.Windows.connect('shared',clear_auto_commit=3D0)
cursor =3D DB.shared_conn.cursor()
# Start with first Database found
cursor.execute("SHOW DATABASES")
DB.ds.fromCursor(cursor)

This gets a list of available databases into the DB.ds object.

> =

> H=E4lsningar / Regards                                 (\_/)  ))
> Danny Kohn                 Tel: +46 (0)708 140 300  =3D('.')=3D//  Miau=
!
> Systematik Consulting AB   ICQ: 1328817             ( ~~~ )/   Rrrrrui!=

> http://www.systematik.se   HAM: SM0NBJ              `w---w=B4
> =

> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- =

Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582


From ajaya@ncoretech.com  Thu Sep 13 06:04:57 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Thu, 13 Sep 2001 10:34:57 +0530
Subject: [Tutor] doubts with socket asychronous doc..,
In-Reply-To: <000001c13b8f$4ca41b70$6501a8c0@ncoretech.com>
Message-ID: <000901c13c11$a30ccc00$6501a8c0@ncoretech.com>

Hi my earliar message not seems to catch up any one eye so I am re posting
this. Please help me regarding this socket module.

Thanks and Regards,
Ajaya

Hi,

I've some dbouts of using asyncore module for asychronous socket service
clients and servers.

http://www.python.org/doc/current/lib/module-asyncore.html



Example is given like this


class http_client(asyncore.dispatcher):
    def __init__(self, host,path):
        asyncore.dispatcher.__init__(self)
        self.path = path
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.connect( (host, 80) )
        self.buffer = 'GET %s HTTP/1.0\r\n\r\n' % self.path

    def handle_connect(self):
        pass

    def handle_read(self):
        data = self.recv(8192)
        print data

    def writable(self):
        return (len(self.buffer) > 0)

    def handle_write(self):
        sent = self.send(self.buffer)
        self.buffer = self.buffer[sent:]


from the documentation I understand handle_read will be called when ever new
data to be read from the socket..., and handle_write will be called when
attempt to write the object.

but I did not understand these terms properly. I had a confustion who is
going to initiate these events. Like read or write....,

For example my C server send some data on port x, suppose my python
appliation should recive that data as a asynchronous menas is this just ok
if I make a instant of the above class and connect to the
server...,(Assuming that handle_read) will be called asynchronously when
data arives to that port.

but Documentation is telling me it is wraper around the select() fuction.
Generally select() function need to be polled as my understanding. It just
gives the idea that can performing certain action is worth or not..., but
from the above example it is nor clear that who is polling  on this function
to call handle_read functions.

One more thing is if I want to send some data to my C host again.., How do I
do it. Do I need to send just like mysocket.send(buffer)...or handle_write()
how can I use.., it is not clear from the documentation

May be my understanding is poor....since I just started learning python..,
Please send me some doc liks or give  me suggestion to make my study
progress,

Thanks allot  for great help.

with regards,
Ajaya


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From alan.gauld@bt.com  Thu Sep 13 11:19:03 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 13 Sep 2001 11:19:03 +0100
Subject: [Tutor] network file copy
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF59@mbtlipnt02.btlabs.bt.co.uk>

> can someone give me some ideas as to how I can copy files to 
> a network share on the Win32 platform?

See my recent post about using WSH from within Python.
You can do this stuff using the WSH objects, specifically 
the filesystem object allows access to shares but I think 
the net object also does it. (I don't have my WSH book to 
hand right now...)

HTH,

Alan G.


From danny.kohn@systematik.se  Thu Sep 13 12:23:03 2001
From: danny.kohn@systematik.se (Danny Kohn)
Date: Thu, 13 Sep 2001 13:23:03 +0200
Subject: SV: [Tutor] What to choose - database
In-Reply-To: <3B9FF421.927B79F4@venix.com>
Message-ID: <OGEPIJONPINEELIFKPBOIELKDNAA.danny.kohn@systematik.se>

Thanks for ansering so promptly.
What ODBC package for Pyhon would be the moste approperiate?
/Danny

| -----Ursprungligt meddelande-----
| Fr=E5n: tutor-admin@python.org [mailto:tutor-admin@python.org]F=F6r =
Lloyd
| Kvam
| Skickat: den 13 september 2001 01:48
| Till: Danny Kohn
| Kopia: Python Tutor mailing list
| =C4mne: Re: [Tutor] What to choose - database
|=20
|=20
| Danny Kohn wrote:
| >=20
| > Hi.
| > I am a total newbie having spent the last week to read a lot of=20
| stuff about Python, coming to think that it could be a good=20
| language for my program project. My question is regarding=20
| databases. The application I want to write does probably need=20
| some form of database support. It is very much material to digest=20
| and I am a very slow reader so I would like to get some advice=20
| which path that might be most successful or easiest.
| >=20
| > By background is from 20 years ago when computers, even=20
| microcomputers, had a control panel and you could single step=20
| them. The program language was assembler. Have also done some=20
| Basic and also in nearer time some small tasks in Visual Basic.
| >=20
| > Now, I have come to like the MySQL concept although I am not=20
| attached to it (yet). Now I'm sure my questions seem=20
| unenlightened and they are but that is what this list is about so=20
| here they are.
| >=20
| > 1. It seems that I can do database access two ways, through the=20
| DB-API spec v2.0 or through ODBC (which I understand is also=20
| support in Linux). Is this a correct understanding?
|=20
| YES
| >=20
| > 2. If this is so, what way would be the best choice and why?
| >=20
| ODBC gives you easy portability between SQL servers.  It also=20
| allows non-Python applications access to the database.  If you=20
| have any of these (e.g. SAS, Excel, Access) you will wind up=20
| doing the ODBC anyway.
|=20
| The DB-API will give slightly better performance.  I normally use =
ODBC.
|=20
| > 3. I need to be able to create tables from the program. But I=20
| have not found any way to do it. How to do this?
|=20
| SQL create table commands.  Just pass them to the database using=20
| your interface using ODBC or whatever.
| >=20
| > 4. Does one run SQL to access tables from Python. If so, how is=20
| this done? If not, what does one do instead? Running through the=20
| API? But then, what does one do when one want to access the=20
| database(s) when the "specified" ways are inadequate?
|=20
| For instance:
| 	=09
| DB.shared_conn=3DODBC.Windows.connect('shared',clear_auto_commit=3D0)
| cursor =3D DB.shared_conn.cursor()
| # Start with first Database found
| cursor.execute("SHOW DATABASES")
| DB.ds.fromCursor(cursor)
|=20
| This gets a list of available databases into the DB.ds object.
|=20
| >=20
| > H=E4lsningar / Regards                                 (\_/)  ))
| > Danny Kohn                 Tel: +46 (0)708 140 300  =3D('.')=3D//  =
Miau!
| > Systematik Consulting AB   ICQ: 1328817             ( ~~~ )/   =
Rrrrrui!
| > http://www.systematik.se   HAM: SM0NBJ              `w---w=B4
| >=20
| > _______________________________________________
| > Tutor maillist  -  Tutor@python.org
| > http://mail.python.org/mailman/listinfo/tutor
|=20
| --=20
| Lloyd Kvam
| Venix Corp.
| 1 Court Street, Suite 378
| Lebanon, NH 03766-1358
|=20
| voice:	603-443-6155
| fax:	801-459-9582
|=20
| _______________________________________________
| Tutor maillist  -  Tutor@python.org
| http://mail.python.org/mailman/listinfo/tutor
|=20



From tescoil@irtc.net  Fri Sep 14 00:44:15 2001
From: tescoil@irtc.net (Tesla Coil)
Date: Thu, 13 Sep 2001 18:44:15 -0500
Subject: [Tutor] [0.75 OT] Congress Mulls Stiff Crypto Laws
Message-ID: <3BA144CF.32DEC432@irtc.net>

Congress Mulls Stiff Crypto Laws.
http://www.wired.com/news/politics/0,1283,46816,00.html

Wonder if I've written some soon to be *Illegal* Python:
http://www.lowerstandard.com/python/uselesspython1.html

Which is much less secure than this standard equipment:
http://www.python.org/doc/current/lib/module-rotor.html

I'd like to say the US government wouldn't consider
these antique methods as qualifying, but...
http://www.zdnet.com/zdnn/stories/comment/0,5859,2800985,00.html



From dsh8290@rit.edu  Fri Sep 14 01:50:48 2001
From: dsh8290@rit.edu (dman)
Date: Thu, 13 Sep 2001 20:50:48 -0400
Subject: [Tutor] doubts with socket asychronous doc..,
In-Reply-To: <000901c13c11$a30ccc00$6501a8c0@ncoretech.com>
References: <000001c13b8f$4ca41b70$6501a8c0@ncoretech.com>
 <000901c13c11$a30ccc00$6501a8c0@ncoretech.com>
Message-ID: <20010913205048.B2565@hudson>

I haven't done much socket work, and haven't looked at asyncore at
all, but I'll try and add some help, if I can.

On Thu, Sep 13, 2001 at 10:34:57AM +0530, Ajaya Babu wrote:
| 
| Hi my earliar message not seems to catch up any one eye so I am re posting
| this. Please help me regarding this socket module.
| 
| Thanks and Regards,
| Ajaya
| 
| Hi,
| 
| I've some dbouts of using asyncore module for asychronous socket service
| clients and servers.
 

| server...,(Assuming that handle_read) will be called asynchronously when
| data arives to that port.
... 
| but Documentation is telling me it is wraper around the select() fuction.
| Generally select() function need to be polled as my understanding. It just

I would imagine that you need to poll the receiving side of the socket
if it is asynchronous.  Being asynchronous means that if there is no
data ready, then you can go do something else.  I think that you would
need to check for data when you are ready.  I don't think the socket
would notify you that data is ready, but I really don't know.

Check the docs and play with the code a bit.  Try some things.   Use
print liberally to see what is going on at various points.  You can
use 'telnet' (if you are on Unix anyways) to interact with the socket.
This means you can start programming the server side and use telnet to
test it.

HTH,
-D



From cerulean_rodent@yahoo.co.uk  Fri Sep 14 13:00:43 2001
From: cerulean_rodent@yahoo.co.uk (Cerulean Rodent)
Date: Fri, 14 Sep 2001 16:00:43 +0400 (MSD)
Subject: [Tutor] adding users from a script
In-Reply-To: <Pine.LNX.4.21.0109121626290.7399-100000@ecosse.net>
Message-ID: <Pine.LNX.4.21.0109141554360.25165-100000@ecosse.net>

So here we go. Thanks to everyone for the tips - I'm posting the
functional version of the script I was working at. It might look pretty
ugly at times - but it's the first thing halfway resembling a programme
that I've written, so maybe all hope is not lost...

#!/usr/bin/python
 
import os
import re
import whrandom

rnd = whrandom.whrandom()

validfirst  = "abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ23456789"

# l, 0, 1 & o omitted so as not to confuse the (l)users

pwlen = 8

pw = ""

idx = 0

while idx < pwlen:
	pw = pw + rnd.choice(validfirst)
	idx = idx + 1

encr = os.popen('mkpasswd ' + pw + ' dread', 'r')
z = re.sub(r'\n','',encr.read())


nomme = raw_input("\nPrint your desired username:\n>>")

if nomme != '':
	os.system('useradd -p ' + z + ' -s /bin/false' + ' ' + '-G mail' + ' ' + nomme) 
else:
	print "\nYou must enter a valid username!"

logfile = open('passlog', 'a')

logfile.write(nomme + "\t" + pw + "\n")

logfile.close

Scary, huh? The gurus must be grinding their teeth in horror wishing to
orally decapitate yours truly... newbies are a plague, and something must
be done to us - since murder is illegal, one has to think of something
else... 

PM XXIII 
 
-----------------------------------------------------
 
 " The stars go waltzing out in blue and red,
   And arbitrary blackness gallops in:
   I shut my eyes and all the world drops dead. "
  
    --Sylvia Plath

-----------------------------------------------------



From wilson@visi.com  Fri Sep 14 18:06:43 2001
From: wilson@visi.com (Timothy Wilson)
Date: Fri, 14 Sep 2001 12:06:43 -0500 (CDT)
Subject: [Tutor] unit testing
Message-ID: <Pine.GSO.4.21.0109141154570.19562-100000@isis.visi.com>

Hi everyone,

I'd like to introduce the concept of unit testing to my beginning progamming
students as early in the year as possible. I think they'll be motivated to
learn it because our first project was to write a little leap year
calculator. They spent a lot of time entering the same years over and over
again while testing their program logic.

I don't think they're quite ready for PyUnit. Does anyone have any useful
resources or hints about doing basic unit testing?

-Tim

--
Tim Wilson      |   Visit Sibley online:   | Check out:
Henry Sibley HS |  http://www.isd197.org   | http://www.zope.com
W. St. Paul, MN |                          | http://slashdot.org
wilson@visi.com |  <dtml-var pithy_quote>  | http://linux.com



From shalehperry@home.com  Fri Sep 14 18:49:37 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Fri, 14 Sep 2001 10:49:37 -0700 (PDT)
Subject: [Tutor] unit testing
In-Reply-To: <Pine.GSO.4.21.0109141154570.19562-100000@isis.visi.com>
Message-ID: <XFMail.20010914104937.shalehperry@home.com>

On 14-Sep-2001 Timothy Wilson wrote:
> Hi everyone,
> 
> I'd like to introduce the concept of unit testing to my beginning progamming
> students as early in the year as possible. I think they'll be motivated to
> learn it because our first project was to write a little leap year
> calculator. They spent a lot of time entering the same years over and over
> again while testing their program logic.
> 
> I don't think they're quite ready for PyUnit. Does anyone have any useful
> resources or hints about doing basic unit testing?
> 

Unit testing at its simplest is ensuring that each function acts sanely.  So
you end up writing things like:

value = is_leap('1999')
if value != false:
        print "is_leap failure on parameter 1999"

i.e. pass it a value you know the answer for.  Now this is a silly case you
would really like to make sure they got things like every 400 years or not when
the moon is blue.  In other words pick places where the algorithm could have
been broken.  This is not easy for beginners and whether they use pyunit or not
it will still be a task for them to learn.  What my profs told us was pass
values to test every if, else and while.

In a language like python what I typically do is write my functions then start
the interpreter and load my code as a module and run the functions dynamically.
 This has spoiled me to no end and makes writing C painful now.


From urnerk@qwest.net  Fri Sep 14 19:15:59 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Fri, 14 Sep 2001 11:15:59 -0700
Subject: [Tutor] unit testing
In-Reply-To: <XFMail.20010914104937.shalehperry@home.com>
References: <Pine.GSO.4.21.0109141154570.19562-100000@isis.visi.com>
Message-ID: <4.2.0.58.20010914110934.00b77100@pop3.norton.antivirus>

>
>In a language like python what I typically do is write my functions then start
>the interpreter and load my code as a module and run the functions 
>dynamically.
>  This has spoiled me to no end and makes writing C painful now.

Yes, by all means take full advantage of the shell.

Sometimes beginners (including "beginners" experienced in
languages without much of a shell) waste a lot of time
prompting themselves for input using raw_input loops,
the purpose of which is simply to pass values back to
functions in the context of running a script as a program.

It's much simpler to just test these functions interactively
in shell mode.

Another strategy is to put test code in the

   if __name__ == "__main__":
       test1
       test2
       test3

section so that check routines get run if the module is
run as a program, vs. imported.  This can be useful for
informing the reader what the functions are supposed to do,
i.e. error tests are also function definitions (provide
documentation).

Kirby



From bsass@freenet.edmonton.ab.ca  Fri Sep 14 21:04:19 2001
From: bsass@freenet.edmonton.ab.ca (Bruce Sass)
Date: Fri, 14 Sep 2001 14:04:19 -0600 (MDT)
Subject: [Tutor] unit testing
In-Reply-To: <XFMail.20010914104937.shalehperry@home.com>
Message-ID: <Pine.LNX.4.33.0109141357170.5980-100000@bms>

On Fri, 14 Sep 2001, Sean 'Shaleh' Perry wrote:
<...>
> i.e. pass it a value you know the answer for.  Now this is a silly case you
> would really like to make sure they got things like every 400 years or not when
> the moon is blue.  In other words pick places where the algorithm could have
> been broken.  This is not easy for beginners and whether they use pyunit or not
> it will still be a task for them to learn.  What my profs told us was pass
> values to test every if, else and while.

To expand on what Sean wrote...

What you want to test are the so-called `boundry conditions', where
the behaviour of the algorithm changes.  i.e., if you have a block of
code that accepts a range of values, say min to max, you want to test
it at: min-1, min, max, and max +1.

> In a language like python what I typically do is write my functions then start
> the interpreter and load my code as a module and run the functions dynamically.
>  This has spoiled me to no end and makes writing C painful now.

ditto... I think this is where the doctest module comes into play.


- Bruce



From dyoo@hkn.eecs.berkeley.edu  Sat Sep 15 00:04:00 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 14 Sep 2001 16:04:00 -0700 (PDT)
Subject: [Tutor] unit testing
In-Reply-To: <Pine.GSO.4.21.0109141154570.19562-100000@isis.visi.com>
Message-ID: <Pine.LNX.4.21.0109141549590.22468-100000@hkn.eecs.berkeley.edu>

On Fri, 14 Sep 2001, Timothy Wilson wrote:

> I'd like to introduce the concept of unit testing to my beginning
> progamming students as early in the year as possible. I think they'll
> be motivated to learn it because our first project was to write a
> little leap year calculator. They spent a lot of time entering the
> same years over and over again while testing their program logic.
>
> I don't think they're quite ready for PyUnit. Does anyone have any
> useful resources or hints about doing basic unit testing?

One "obvious" tip: if your students are testing a boolean function, then
they should show at least that the function has the potential of returning
a false value.


As a somewhat contrived example, here's a somewhat broken function:

###
def isConsonant(letter):
    return letter != 'aeiou'
###

A hasty student could point out that this works pretty well:

###
>>> isConsonant('f')
1
###

but it pays to have a student show how to get isConsonant() to return 0 as
well.  Make sure to tell trigger-happy students to slow down and to make
sure their tests make some sort of sense... *grin*

Unit testing is good because it emphasises the fact that programming can
be something experimental --- most of us are human, and we often need to
test our own inventions to increase our confidence.  But unit testing
depends on the quality of the test.

I think it's important to stress that the correctness of a program isn't
dependent just in its "positive" results, but also in its "negative" ones.

Hope this helps!



From dyoo@hkn.eecs.berkeley.edu  Sat Sep 15 00:55:22 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 14 Sep 2001 16:55:22 -0700 (PDT)
Subject: [Tutor] adding users from a script
In-Reply-To: <Pine.LNX.4.21.0109141554360.25165-100000@ecosse.net>
Message-ID: <Pine.LNX.4.21.0109141624040.22468-100000@hkn.eecs.berkeley.edu>

On Fri, 14 Sep 2001, Cerulean Rodent wrote:

> So here we go. Thanks to everyone for the tips - I'm posting the
> functional version of the script I was working at. It might look
> pretty ugly at times - but it's the first thing halfway resembling a
> programme that I've written, so maybe all hope is not lost...

Let's take a look.


> import os
> import re
> import whrandom
> 
> rnd = whrandom.whrandom()

I see that you're creating a random number generator called "rnd".  It's
actually ok to use the choice() function of whrandom directly: Python
keeps a personal copy of whrandom.whrandom(), and uses it for
whrandom.choice().  So:

###
>>> whrandom.choice('abcdefghijklmnopquvwxyz')
'g'
###

should work as well.



> validfirst ="abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\
> 23456789"

Looks good.


> pwlen = 8
> 
> pw = ""
> 
> idx = 0
> 
> while idx < pwlen:
> 	pw = pw + rnd.choice(validfirst)
> 	idx = idx + 1


I see, so this makes up a password of length 'pwlen'.  You can also do
this with a Python 'for' loop:

###
for idx in range(pwlen):
    pw = pw + rnd.choice(validfirst)
###

which has a similar effect to the while loop, and is a line shorter.  
*grin*




> encr = os.popen('mkpasswd ' + pw + ' dread', 'r')
> z = re.sub(r'\n','',encr.read())

Good use of regular expressions to strip off newlines from input.  You can
also use the replace() method of strings:

###
z = encr.read().replace(r'\n', '')
###

if the pattern is simple enough.  Another nice string method, strip(),
will remove leading and trailing whitespace from a string:

###
z = encr.read().strip()
###



> nomme = raw_input("\nPrint your desired username:\n>>")
> 
> if nomme != '':
> 	os.system('useradd -p ' + z + ' -s /bin/false' + ' ' + '-G mail' + ' ' + nomme) 
> else:
> 	print "\nYou must enter a valid username!"

If the user doesn't enter a vaild username, you should probably continue
asking them for a good username until they give one to you.  At the
moment, your program gives a small wrist slap, but then continues on.


> logfile = open('passlog', 'a')
> 
> logfile.write(nomme + "\t" + pw + "\n")
> 
> logfile.close

Ah; use:

###
logfile.close()
###

instead --- In Python, functions don't fire off without the parentheses,
even if they don't take any arguments.  There's a reason why it's this
way, and you'll see it when you learn about "callback" functions and
functional programming in the future.



> Scary, huh? The gurus must be grinding their teeth in horror wishing
> to orally decapitate yours truly... newbies are a plague, and

Not so!  The program works, and it makes sense.  Newbies are newcomers,
and that's where all of us started from.  We're here to make Python fun,
not fearful.  And don't worry about upsetting us --- we have tough skin.  
*grin*


Thanks for sharing your program with us!



From ignacio@openservices.net  Sat Sep 15 01:19:46 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Fri, 14 Sep 2001 20:19:46 -0400 (EDT)
Subject: [Tutor] adding users from a script
In-Reply-To: <Pine.LNX.4.21.0109141624040.22468-100000@hkn.eecs.berkeley.edu>
Message-ID: <Pine.LNX.4.33.0109142015420.398-100000@terbidium.openservices.net>

On Fri, 14 Sep 2001, Danny Yoo wrote:

> On Fri, 14 Sep 2001, Cerulean Rodent wrote:
>
> > pwlen = 8
> >
> > pw = ""
> >
> > idx = 0
> >
> > while idx < pwlen:
> > 	pw = pw + rnd.choice(validfirst)
> > 	idx = idx + 1
>
>
> I see, so this makes up a password of length 'pwlen'.  You can also do
> this with a Python 'for' loop:
>
> ###
> for idx in range(pwlen):
>     pw = pw + rnd.choice(validfirst)
> ###
>
> which has a similar effect to the while loop, and is a line shorter.
> *grin*

Or if you want to be even _more_ clever: ;)

---
pw=''.join(map(rnd.choice, [validfirst] * pwdlen))
---

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From gp@familiehaase.de  Sat Sep 15 01:59:50 2001
From: gp@familiehaase.de (Gerrit P. Haase)
Date: Sat, 15 Sep 2001 02:59:50 +0200
Subject: [Tutor] where is CPAN for python?
Message-ID: <3BA2C426.15558.1662C8C2@localhost>

Hi, 

i come from perl and want to do some stuff with python.
Now i realize that i'm missing some modules.
Where do i get these additional modules from?
I found a link at python.org to parnassus,
but the site seems to be down?

Is there s.th. lke CPAN for perl which is mirrored
arund the world?

Gerrit


-- 
=^..^=


From ignacio@openservices.net  Sat Sep 15 02:10:07 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Fri, 14 Sep 2001 21:10:07 -0400 (EDT)
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <3BA2C426.15558.1662C8C2@localhost>
Message-ID: <Pine.LNX.4.33.0109142109140.398-100000@terbidium.openservices.net>

On Sat, 15 Sep 2001, Gerrit P. Haase wrote:

> i come from perl and want to do some stuff with python.
> Now i realize that i'm missing some modules.
> Where do i get these additional modules from?

Use Google to find them.

> I found a link at python.org to parnassus,
> but the site seems to be down?

The Vaults are down? Aw nuts...

> Is there s.th. lke CPAN for perl which is mirrored
> arund the world?

No(t yet).

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From ak@silmarill.org  Sat Sep 15 02:10:33 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Fri, 14 Sep 2001 21:10:33 -0400
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <3BA2C426.15558.1662C8C2@localhost>
References: <3BA2C426.15558.1662C8C2@localhost>
Message-ID: <20010914211032.A10572@sill.silmarill.org>

On Sat, Sep 15, 2001 at 02:59:50AM +0200, Gerrit P. Haase wrote:
> Hi, 
> 
> i come from perl and want to do some stuff with python.
> Now i realize that i'm missing some modules.
> Where do i get these additional modules from?
> I found a link at python.org to parnassus,
> but the site seems to be down?

Parnassus is the closest thing to CPAN. It works for me right now.

What module (or modules) do you need, exactly?

> 
> Is there s.th. lke CPAN for perl which is mirrored
> arund the world?
> 
> Gerrit
> 
> 
> -- 
> =^..^=
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From gp@familiehaase.de  Sat Sep 15 04:01:13 2001
From: gp@familiehaase.de (Gerrit P. Haase)
Date: Sat, 15 Sep 2001 05:01:13 +0200
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <20010914211032.A10572@sill.silmarill.org>
References: <3BA2C426.15558.1662C8C2@localhost>
Message-ID: <3BA2E099.25304.16D1E786@localhost>

Andrei Kulakov schrieb am 2001-09-14, 21:10:

>On Sat, Sep 15, 2001 at 02:59:50AM +0200, Gerrit P. Haase wrote:
>> Hi, 
>> 
>> i come from perl and want to do some stuff with python.
>> Now i realize that i'm missing some modules.
>> Where do i get these additional modules from?
>> I found a link at python.org to parnassus,
>> but the site seems to be down?
>
>Parnassus is the closest thing to CPAN. It works for me right now.
>
>What module (or modules) do you need, exactly?

That script says:

import resource

besides other things, but if i delete it it works (at least
script.py --help works).

Gerrit


-- 
=^..^=


From ak@silmarill.org  Sat Sep 15 04:08:11 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Fri, 14 Sep 2001 23:08:11 -0400
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <3BA2E099.25304.16D1E786@localhost>
References: <3BA2C426.15558.1662C8C2@localhost>
 <3BA2E099.25304.16D1E786@localhost>
Message-ID: <20010914230811.A10988@sill.silmarill.org>

On Sat, Sep 15, 2001 at 05:01:13AM +0200, Gerrit P. Haase wrote:
> Andrei Kulakov schrieb am 2001-09-14, 21:10:
> 
> >On Sat, Sep 15, 2001 at 02:59:50AM +0200, Gerrit P. Haase wrote:
> >> Hi, 
> >> 
> >> i come from perl and want to do some stuff with python.
> >> Now i realize that i'm missing some modules.
> >> Where do i get these additional modules from?
> >> I found a link at python.org to parnassus,
> >> but the site seems to be down?
> >
> >Parnassus is the closest thing to CPAN. It works for me right now.
> >
> >What module (or modules) do you need, exactly?
> 
> That script says:
> 
> import resource
> 
> besides other things, but if i delete it it works (at least
> script.py --help works).
> 
> Gerrit

This sounds like whoever made the script simply forgot to include a helper
module. If it was a "public" module, it'd have a more descriptive name!

I'd email the author if I were you.

[snip]

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From ignacio@openservices.net  Sat Sep 15 04:21:46 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Fri, 14 Sep 2001 23:21:46 -0400 (EDT)
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <3BA2E099.25304.16D1E786@localhost>
Message-ID: <Pine.LNX.4.33.0109142320460.398-100000@terbidium.openservices.net>

On Sat, 15 Sep 2001, Gerrit P. Haase wrote:

> That script says:
>
> import resource

Is this what you're looking for?

  http://www.python.org/doc/current/lib/module-resource.html

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From dsh8290@rit.edu  Sat Sep 15 04:21:04 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 14 Sep 2001 23:21:04 -0400
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <Pine.LNX.4.33.0109142320460.398-100000@terbidium.openservices.net>
References: <3BA2E099.25304.16D1E786@localhost>
 <Pine.LNX.4.33.0109142320460.398-100000@terbidium.openservices.net>
Message-ID: <20010914232104.B3615@hudson>

On Fri, Sep 14, 2001 at 11:21:46PM -0400, Ignacio Vazquez-Abrams wrote:
| On Sat, 15 Sep 2001, Gerrit P. Haase wrote:
| 
| > That script says:
| >
| > import resource
| 
| Is this what you're looking for?
| 
|   http://www.python.org/doc/current/lib/module-resource.html

I noticed that that module is only available on Unix, but Gerrit is
mailing from Windows.  If this is the "missing" module, then it means
the script will only work on a Unix system.

-D



From gp@familiehaase.de  Sat Sep 15 04:45:18 2001
From: gp@familiehaase.de (Gerrit P. Haase)
Date: Sat, 15 Sep 2001 05:45:18 +0200
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <Pine.LNX.4.33.0109142320460.398-100000@terbidium.openservices.net>
References: <3BA2E099.25304.16D1E786@localhost>
Message-ID: <3BA2EAEE.32758.16FA4703@localhost>

Ignacio Vazquez-Abrams schrieb am 2001-09-14, 23:21:

>On Sat, 15 Sep 2001, Gerrit P. Haase wrote:
>
>> That script says:
>>
>> import resource
>
>Is this what you're looking for?
>
>  http://www.python.org/doc/current/lib/module-resource.html

Yes, I think that is it.
Where is the download link;)

http://www.python.org/doc/current/lib/unix.html
Hmmm, seems to be part of the standard library for UNIX.

Well, a core module that isn't included in my python.
There is surely a good reason why it is like it is...
MIST, why am I doomed with this Windo*s *&%^@

Gerrit


-- 
=^..^=


From ignacio@openservices.net  Sat Sep 15 04:54:16 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Fri, 14 Sep 2001 23:54:16 -0400 (EDT)
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <20010914232104.B3615@hudson>
Message-ID: <Pine.LNX.4.33.0109142353410.398-100000@terbidium.openservices.net>

On Fri, 14 Sep 2001, dman wrote:

> I noticed that that module is only available on Unix, but Gerrit is
> mailing from Windows.  If this is the "missing" module, then it means
> the script will only work on a Unix system.

Based on the language in his latest message, I think that you're right ;)

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From ignacio@openservices.net  Sat Sep 15 04:55:27 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Fri, 14 Sep 2001 23:55:27 -0400 (EDT)
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <3BA2EAEE.32758.16FA4703@localhost>
Message-ID: <Pine.LNX.4.33.0109142354320.398-100000@terbidium.openservices.net>

On Sat, 15 Sep 2001, Gerrit P. Haase wrote:

> Well, a core module that isn't included in my python.
> There is surely a good reason why it is like it is...
> ****, why am I doomed with this Windo*s *&%^@

What does the script do? There may be an equivalent for Windows readily
available.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From gp@familiehaase.de  Sat Sep 15 04:47:31 2001
From: gp@familiehaase.de (Gerrit P. Haase)
Date: Sat, 15 Sep 2001 05:47:31 +0200
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <20010914232104.B3615@hudson>
References: <Pine.LNX.4.33.0109142320460.398-100000@terbidium.openservices.net>
Message-ID: <3BA2EB73.11617.16FC4D37@localhost>

dman schrieb am 2001-09-14, 23:21:

>On Fri, Sep 14, 2001 at 11:21:46PM -0400, Ignacio Vazquez-Abrams wrote:
>| On Sat, 15 Sep 2001, Gerrit P. Haase wrote:
>| 
>| > That script says:
>| >
>| > import resource
>| 
>| Is this what you're looking for?
>| 
>|   http://www.python.org/doc/current/lib/module-resource.html
>
>I noticed that that module is only available on Unix, but Gerrit is
>mailing from Windows.  If this is the "missing" module, then it means
>the script will only work on a Unix system.
>
>-D

Yes, *&%^@.

Gerrit


-- 
=^..^=


From dsh8290@rit.edu  Sat Sep 15 04:55:23 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 14 Sep 2001 23:55:23 -0400
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <3BA2EAEE.32758.16FA4703@localhost>
References: <3BA2E099.25304.16D1E786@localhost>
 <3BA2EAEE.32758.16FA4703@localhost>
Message-ID: <20010914235523.A582@hudson>

On Sat, Sep 15, 2001 at 05:45:18AM +0200, Gerrit P. Haase wrote:
| Ignacio Vazquez-Abrams schrieb am 2001-09-14, 23:21:
| 
| >On Sat, 15 Sep 2001, Gerrit P. Haase wrote:
| >
| >> That script says:
| >>
| >> import resource
| >
| >Is this what you're looking for?
| >
| >  http://www.python.org/doc/current/lib/module-resource.html
| 
| Yes, I think that is it.
| Where is the download link;)
| 
| http://www.python.org/doc/current/lib/unix.html
| Hmmm, seems to be part of the standard library for UNIX.
| 
| Well, a core module that isn't included in my python.
| There is surely a good reason why it is like it is...

Yeah, getrlimit() and setrlimit() are Unix system calls.  They are
prototyped in unistd.h which doesn't exist on windows.

| MIST, why am I doomed with this Windo*s *&%^@

I hear you.  For temporary relief, install cygwin.  It comes with
python now and that should have the Unix-only modules available
(because cygwin is (to some extent) unix).  FYI XFree86 and KDE are
available (as precompiled binaries, no less) for cygwin.  That's what
I'm using at work until I get to install Debian.

HTH,
-D



From gubitz@netcologne.de  Sat Sep 15 11:17:56 2001
From: gubitz@netcologne.de (Hans Gubitz)
Date: Sat, 15 Sep 2001 12:17:56 +0200
Subject: [Tutor] uid
Message-ID: <20010915121756.A5517@redwitz79.de>

I want to cp a file and extract it to different users. I can do this
as root, but I want extract  to be done with the uid of the user.

import os, pwd
users = ['usera','userb']

def copy(user):
        list = pwd.getpwnam(user)
        #uid = list[2]
        home = list[5]
        os.chdir(home)
        os.system('cp /tmp/file.tgz .')
        os.system('tar -xzf file.tgz')

for u in info_1:
        copy(u)
            
        
??????        
-- 
Hans Gubitz <gubitz@netcologne.de>



From lumbricus@gmx.net  Sat Sep 15 13:09:15 2001
From: lumbricus@gmx.net (Joerg Woelke)
Date: Sat, 15 Sep 2001 14:09:15 +0200
Subject: [Tutor] uid
In-Reply-To: <20010915121756.A5517@redwitz79.de>; from gubitz@netcologne.de on Sat, Sep 15, 2001 at 12:17:56PM +0200
References: <20010915121756.A5517@redwitz79.de>
Message-ID: <20010915140915.A15664@ID-96242.user.dfncis.de>

On Sat, Sep 15, 2001 at 12:17:56PM +0200, Hans Gubitz wrote:
> I want to cp a file and extract it to different users. I can do this
> as root, but I want extract  to be done with the uid of the user.
> 
> import os, pwd
> users = ['usera','userb']
> 
> def copy(user):
>         list = pwd.getpwnam(user)
>         #uid = list[2]
>         home = list[5]
>         os.chdir(home)
>         os.system('cp /tmp/file.tgz .')
>         os.system('tar -xzf file.tgz')
> 
> for u in info_1:
>         copy(u)
>             
>         
> ??????        

os.suid()

> -- 
> Hans Gubitz <gubitz@netcologne.de>
> 

HTH und Gruss 
J"o! :-)

-- 
The shortest distance between any two puns is a straight line.


From rick@niof.net  Sat Sep 15 15:58:41 2001
From: rick@niof.net (Rick Pasotto)
Date: Sat, 15 Sep 2001 10:58:41 -0400
Subject: [Tutor] uid
In-Reply-To: <20010915140915.A15664@ID-96242.user.dfncis.de>
References: <20010915121756.A5517@redwitz79.de> <20010915140915.A15664@ID-96242.user.dfncis.de>
Message-ID: <20010915105841.A17572@tc.niof.net>

On Sat, Sep 15, 2001 at 02:09:15PM +0200, Joerg Woelke wrote:
> On Sat, Sep 15, 2001 at 12:17:56PM +0200, Hans Gubitz wrote:
> > I want to cp a file and extract it to different users. I can do this
> > as root, but I want extract  to be done with the uid of the user.
> > 
> > import os, pwd
> > users = ['usera','userb']
> > 
> > def copy(user):
> >         list = pwd.getpwnam(user)
> >         #uid = list[2]
> >         home = list[5]
> >         os.chdir(home)
> >         os.system('cp /tmp/file.tgz .')
> >         os.system('tar -xzf file.tgz')
> > 
> > for u in info_1:
> >         copy(u)
> >         
> > ??????        
> 
> os.suid()

Did you *try* that? It doesn't exist on my system.

'suid' -- meaning 'set user id' -- is not at all what he wants.

He simply needs to set the owner of the file so

os.chown(user) 

will do what he wants.

-- 
If man were perfect, if he were infallible, society would present
a very different kind of harmony from that which we may actually
expect it to offer us. Our idea of harmony is not Fourier's. It
does not exclude the existence of evil; it leaves room for
discord; and yet we shall recognize that harmony nonetheless
exists, provided that discord serves to prepare the way and to
lead us back to harmony.
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net


From lumbricus@gmx.net  Sat Sep 15 18:21:14 2001
From: lumbricus@gmx.net (Joerg Woelke)
Date: Sat, 15 Sep 2001 19:21:14 +0200
Subject: [Tutor] uid
In-Reply-To: <20010915105841.A17572@tc.niof.net>; from rick@niof.net on Sat, Sep 15, 2001 at 10:58:41AM -0400
References: <20010915121756.A5517@redwitz79.de> <20010915140915.A15664@ID-96242.user.dfncis.de> <20010915105841.A17572@tc.niof.net>
Message-ID: <20010915192114.A16255@ID-96242.user.dfncis.de>

On Sat, Sep 15, 2001 at 10:58:41AM -0400, Rick Pasotto wrote:
> On Sat, Sep 15, 2001 at 02:09:15PM +0200, Joerg Woelke wrote:
> > On Sat, Sep 15, 2001 at 12:17:56PM +0200, Hans Gubitz wrote:
> > > I want to cp a file and extract it to different users. I can do this
> > > as root, but I want extract  to be done with the uid of the user.
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > > 
> > os.suid()
> 
> Did you *try* that? It doesn't exist on my system.

Aeh sorry - os.setuid() *duck*

> 
> 'suid' -- meaning 'set user id' -- is not at all what he wants.
> 
> He simply needs to set the owner of the file so
> 
> os.chown(user) 
> 
> will do what he wants.
> 

Then I misunderstood the marked sentence.

Greets J"o!


-- 
It would be illogical to assume that all conditions remain stable.
		-- Spock, "The Enterprise" Incident", stardate 5027.3


From printers@sendme.cz  Sat Sep 15 21:45:18 2001
From: printers@sendme.cz (A)
Date: Sat, 15 Sep 2001 22:45:18 +0200
Subject: [Tutor] SMTPLIB module - how to add subject ?
Message-ID: <3BA3D9FE.30092.76C3D5@localhost>

Hi,
I tried 
11.11.2 SMTP Example from Python docs.
Does anyone know how I can add subject to an email send by this example?
Thank you very much for help
Ladislav



From kalle@gnupung.net  Sat Sep 15 22:03:38 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Sat, 15 Sep 2001 23:03:38 +0200
Subject: [Tutor] SMTPLIB module - how to add subject ?
In-Reply-To: <3BA3D9FE.30092.76C3D5@localhost>
References: <3BA3D9FE.30092.76C3D5@localhost>
Message-ID: <20010915230338.A27615@sandrew.lysator.liu.se>

[A]
> Hi,
> I tried 
> 11.11.2 SMTP Example from Python docs.
> Does anyone know how I can add subject to an email send by this example?

Something like
msg = ("From: %s\r\nTo: %s\r\nSubject: %s\r\n\r\n"
       % (fromaddr, string.join(toaddrs, ", "), subject))
might work.

Peace,
  Kalle
-- 
[ Thought control, brought to you by the WIPO! ]
[ http://anti-dmca.org/ http://eurorights.org/ ]


From sheila@spamcop.net  Sat Sep 15 22:05:40 2001
From: sheila@spamcop.net (Sheila King)
Date: Sat, 15 Sep 2001 14:05:40 -0700
Subject: [Tutor] SMTPLIB module - how to add subject ?
In-Reply-To: <3BA3D9FE.30092.76C3D5@localhost>
References: <3BA3D9FE.30092.76C3D5@localhost>
Message-ID: <5FEF7E62AE5@kserver.org>

On Sat, 15 Sep 2001 22:45:18 +0200, "A" <printers@sendme.cz>  wrote
about [Tutor] SMTPLIB module - how to add subject ?:

:Hi,
:I tried 
:11.11.2 SMTP Example from Python docs.
:Does anyone know how I can add subject to an email send by this example?
:Thank you very much for help
:Ladislav

I've pasted the example below. Actually, I really dislike this example.
They are using
"\r\n"
as a character for newlines. Whose idea was that???
It should be just
"\n"

Below this sample code I've pasted some suggested mods:

import smtplib
import string

def prompt(prompt):
    return raw_input(prompt).strip()

fromaddr = prompt("From: ")
toaddrs  = prompt("To: ").split()
print "Enter message, end with ^D:"

# Add the From: and To: headers at the start!
msg = ("From: %s\r\nTo: %s\r\n\r\n"
       % (fromaddr, string.join(toaddrs, ", ")))
while 1:
    try:
        line = raw_input()
    except EOFError:
        break
    if not line:
        break
    msg = msg + line

print "Message length is " + `len(msg)`

server = smtplib.SMTP('localhost')
server.set_debuglevel(1)
server.sendmail(fromaddr, toaddrs, msg)
server.quit()


Suggested mods:

Add a line that prompts for the subject:

subj = prompt("Subject: ")

Then change this line:

msg = ("From: %s\r\nTo: %s\r\n\r\n"
       % (fromaddr, string.join(toaddrs, ", ")))

To something like this:

msg = ("From: %s\r\nTo: %s\r\nSubject:%s\r\n\r\n"
       % (fromaddr, string.join(toaddrs, ", "), subj))

Caution! untested, but should work.

I still don't like the "\r\n" in this example. Bad. :(

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/



From dsh8290@rit.edu  Sun Sep 16 01:32:41 2001
From: dsh8290@rit.edu (dman)
Date: Sat, 15 Sep 2001 20:32:41 -0400
Subject: [Tutor] SMTPLIB module - how to add subject ?
In-Reply-To: <5FEF7E62AE5@kserver.org>
References: <3BA3D9FE.30092.76C3D5@localhost> <5FEF7E62AE5@kserver.org>
Message-ID: <20010915203241.B2641@hudson>

On Sat, Sep 15, 2001 at 02:05:40PM -0700, Sheila King wrote:
| On Sat, 15 Sep 2001 22:45:18 +0200, "A" <printers@sendme.cz>  wrote
| about [Tutor] SMTPLIB module - how to add subject ?:
| 
| :Hi,
| :I tried 
| :11.11.2 SMTP Example from Python docs.
| :Does anyone know how I can add subject to an email send by this example?
| :Thank you very much for help
| :Ladislav
| 
| I've pasted the example below. Actually, I really dislike this example.
| They are using
| "\r\n"
| as a character for newlines. Whose idea was that???
| It should be just
| "\n"

Well, in RFC2821 the SMTP protocol states that \r\n is used as the
line delimiter.  (RFC821 was the original SMTP definition but has been
superceded by RFC2821)

However, the Subject: of a message is part of the message itself which
is defined by RFC822, but I haven't read that RFC.

| I still don't like the "\r\n" in this example. Bad. :(

See above -- the RFC actually states that being lenient and allowing
\n as a line separator (mainly for Unix servers) is highly
un-recommended (if I can make up that word).

-D



From GJuliusCaesar@aol.com  Sun Sep 16 01:51:23 2001
From: GJuliusCaesar@aol.com (GJuliusCaesar@aol.com)
Date: Sat, 15 Sep 2001 20:51:23 EDT
Subject: [Tutor] trying to Learn.  Need help.
Message-ID: <157.108039c.28d5518b@aol.com>

--part1_157.108039c.28d5518b_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

Hey, I got a book "SAMS TEACH YOURSELF PYTHON" Written by Ivan Van Laningham, 
and the first excercise for writting a program is the "Hello World" program.  
I created the simple program and when I try to run it ((using Windows 98))  
the DOS box pops up but then is disappears really quick not allowing me to 
see the program I created.  When the program ends I know the DOS box 
disappears but I want the DOS box to stay so I can see whats happening.  how 
can I do this?   ((PS, this is a great book.  Thanks Ivan Van Liningham))

--part1_157.108039c.28d5518b_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

<HTML><FONT FACE=arial,helvetica><FONT  SIZE=2 FAMILY="SERIF" FACE="Times New Roman" LANG="0">Hey, I got a book "SAMS TEACH YOURSELF PYTHON" Written by Ivan Van Laningham, and the first excercise for writting a program is the "Hello World" program. &nbsp;I created the simple program and when I try to run it ((using Windows 98)) &nbsp;the DOS box pops up but then is disappears really quick not allowing me to see the program I created. &nbsp;When the program ends I know the DOS box disappears but I want the DOS box to stay so I can see whats happening. &nbsp;how can I do this? &nbsp;&nbsp;((PS, this is a great book. &nbsp;Thanks Ivan Van Liningham))</FONT></HTML>

--part1_157.108039c.28d5518b_boundary--


From gp@familiehaase.de  Sun Sep 16 02:03:49 2001
From: gp@familiehaase.de (Gerrit P. Haase)
Date: Sun, 16 Sep 2001 03:03:49 +0200
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <Pine.LNX.4.33.0109142354320.398-100000@terbidium.openservices.net>
References: <3BA2EAEE.32758.16FA4703@localhost>
Message-ID: <3BA41695.11986.1B8CC8E8@localhost>

Ignacio Vazquez-Abrams schrieb am 2001-09-14, 23:55:

>On Sat, 15 Sep 2001, Gerrit P. Haase wrote:
>
>> Well, a core module that isn't included in my python.
>> There is surely a good reason why it is like it is...
>> ****, why am I doomed with this Windo*s *&%^@
>
>What does the script do? There may be an equivalent for Windows readily
>available.

It is from gnu lilypond:
========================
NAME
       ly2dvi - manual page for ly2dvi 1.4.7

SYNOPSIS
       ly2dvi [OPTION]... FILE

DESCRIPTION
       Generate .dvi with LaTeX for LilyPond

OPTIONS
[...]
GNU LilyPond 1.4.7        September 2001                        1

Gerrit


-- 
=^..^=


From wolf19197@hotmail.com  Sat Sep 15 16:21:57 2001
From: wolf19197@hotmail.com (Cameron Stoner)
Date: Sat, 15 Sep 2001 10:21:57 -0500
Subject: [Tutor] help
Message-ID: <F210H5qyrajdYYHcYVI0000efb7@hotmail.com>

Dear Python people,

What is wrong with this code?  When I ran this in the IDLE it brought up an 
unhashable type error.  I don’t really understand why print dict[sep_letter] 
is a problem.  Would you tell me what would fix it please or what the flaw 
in the logic is.

Thanks
Cameron


import string
y = raw_input('prompt:')
while y is not '':
    sep_letter = (string.split(y[0][-1]))### the ""0"" after the ""y"" is 
used to seperated the
                               ### first letter of the message from the rest
                               ### need way to split and move to anther 
variable

    while sep_letter is not '':
        dict = 
{'A':'1','B':'2','C':'3','D':'4','E':'5','F':'6','G':'7','H':'8','I':'9',
                
'J':'10','K':'11','L':'12','M':'13','N':'14','O':'15','P':'16',
                
'Q':'17','R':'18','S':'19','T':'20','U':'21','V':'22','W':'23','X':
                '24','Y':'24','Z':'25','':'','.':'~','?':'`'}
        print dict[sep_letter]


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp



From gp@familiehaase.de  Sun Sep 16 02:10:08 2001
From: gp@familiehaase.de (Gerrit P. Haase)
Date: Sun, 16 Sep 2001 03:10:08 +0200
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <20010914235523.A582@hudson>
References: <3BA2EAEE.32758.16FA4703@localhost>
Message-ID: <3BA41810.7632.1B929093@localhost>

dman schrieb am 2001-09-14, 23:55:

[...]
>| ..., why am I doomed with this Windo*s *&%^@
>
>I hear you.  For temporary relief, install cygwin.  It comes with

I use cygwin + cygwin-python, but the maintainer seems to have not 
the time to build python with this extension:(

Gerrit


-- 
=^..^=


From tbrauch@mindless.com  Sun Sep 16 02:08:20 2001
From: tbrauch@mindless.com (Timothy M. Brauch)
Date: Sat, 15 Sep 2001 21:08:20 -0400
Subject: [Tutor] trying to Learn.  Need help.
References: <157.108039c.28d5518b@aol.com>
Message-ID: <3BA3FB84.917D3D0D@mindless.com>

GJuliusCaesar@aol.com wrote:
> 
> Hey, I got a book "SAMS TEACH YOURSELF PYTHON" Written by Ivan Van
> Laningham, and the first excercise for writting a program is the
> "Hello World" program.  I created the simple program and when I try to
> run it ((using Windows 98))  the DOS box pops up but then is
> disappears really quick not allowing me to see the program I created.
>  When the program ends I know the DOS box disappears but I want the
> DOS box to stay so I can see whats happening.  how can I do this?
>   ((PS, this is a great book.  Thanks Ivan Van Liningham))

Quick solution, add something like

dummy=raw_input('Press enter to end this program.')

at the end of your code.

 - Tim


From gp@familiehaase.de  Sun Sep 16 02:12:09 2001
From: gp@familiehaase.de (Gerrit P. Haase)
Date: Sun, 16 Sep 2001 03:12:09 +0200
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <NLEIJCOLEACIANLABPOEOEIJCBAA.grimmtoothtoo@yahoo.com>
References: <3BA2EAEE.32758.16FA4703@localhost>
Message-ID: <3BA41889.30116.1B946CB0@localhost>

Grimmtooth schrieb am 2001-09-15, 8:25:

>You might try the version of Python that comes with CygWin, a Unix API
>interface for Windows. I believe that going to Redhat.com will get you
>there, but either way a Google search will turn it up in the first 3 or 4
>links.

I am on cygwin. But it is not include in cygwin python.
I have contacted the maintaner, he promised to take a
look at this issue...

Best would be to build it local.

Gerrit


-- 
=^..^=


From kalle@gnupung.net  Sun Sep 16 02:16:52 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Sun, 16 Sep 2001 03:16:52 +0200
Subject: [Tutor] help
In-Reply-To: <F210H5qyrajdYYHcYVI0000efb7@hotmail.com>
References: <F210H5qyrajdYYHcYVI0000efb7@hotmail.com>
Message-ID: <20010916031652.C27615@sandrew.lysator.liu.se>

[Cameron Stoner]
> What is wrong with this code?  When I ran this in the IDLE it brought up an
> unhashable type error.

To be used as keys in dictionaries, objects must be hashable.  This is a sort
of difficult concept to explain and it's past 3 AM here in Sweden, so I'll
just leave that to Danny Yoo... <wink>
Anyway, python lists are *not* hashable.

> import string
> y = raw_input('prompt:')
> while y is not '':
>    sep_letter = (string.split(y[0][-1]))

Try a
print sep_letter
here, and you'll see what's wrong.

>    while sep_letter is not '':
[snip]

Peace,
  Kalle
-- 
[ Thought control, brought to you by the WIPO! ]
[ http://anti-dmca.org/ http://eurorights.org/ ]


From rob@jam.rr.com  Sun Sep 16 02:21:21 2001
From: rob@jam.rr.com (Rob)
Date: Sat, 15 Sep 2001 20:21:21 -0500
Subject: [Tutor] where is CPAN for python?
References: <3BA2C426.15558.1662C8C2@localhost> <20010914211032.A10572@sill.silmarill.org>
Message-ID: <3BA3FE91.C4A52245@jam.rr.com>

Andrei Kulakov wrote:
> 
> On Sat, Sep 15, 2001 at 02:59:50AM +0200, Gerrit P. Haase wrote:
> > Hi,
> >
> > i come from perl and want to do some stuff with python.
> > Now i realize that i'm missing some modules.
> > Where do i get these additional modules from?
> > I found a link at python.org to parnassus,
> > but the site seems to be down?
> 
> Parnassus is the closest thing to CPAN. It works for me right now.
> 
> What module (or modules) do you need, exactly?
> 
> >
> > Is there s.th. lke CPAN for perl which is mirrored
> > arund the world?
> >
> > Gerrit
> >

There's also the Python Cookbook
(http://aspn.activestate.com/ASPN/Python/Cookbook/), and Useless Python,
but a google.com search tends to find any modules I need that exist out
there in the void.

Rob
-- 
Aw, c'mon.... You indent ANYWAY!
Useless Python!
http://www.lowerstandard.com/python


From urnerk@qwest.net  Sun Sep 16 02:30:03 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Sat, 15 Sep 2001 18:30:03 -0700
Subject: [Tutor] trying to Learn.  Need help.
In-Reply-To: <3BA3FB84.917D3D0D@mindless.com>
References: <157.108039c.28d5518b@aol.com>
Message-ID: <4.2.0.58.20010915182754.00bf7800@pop3.norton.antivirus>

>
> > run it ((using Windows 98))  the DOS box pops up but then is
> > disappears really quick not allowing me to see the program I created.


I hope this book introduces you to IDLE and has you
develop your skills there.  Using the DOS box for
Python is way inferior -- except for testing specific
kinds of program, e.g. involving Tkinter.

Kirby

PS:  yes, there are other useful GUI IDEs in Windows,
all superior to the DOS box.



From ignacio@openservices.net  Sun Sep 16 02:31:46 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Sat, 15 Sep 2001 21:31:46 -0400 (EDT)
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <3BA41695.11986.1B8CC8E8@localhost>
Message-ID: <Pine.LNX.4.33.0109152128440.5784-100000@terbidium.openservices.net>

On Sun, 16 Sep 2001, Gerrit P. Haase wrote:

> Ignacio Vazquez-Abrams schrieb am 2001-09-14, 23:55:
>
> >On Sat, 15 Sep 2001, Gerrit P. Haase wrote:
> >
> >> Well, a core module that isn't included in my python.
> >> There is surely a good reason why it is like it is...
> >> ****, why am I doomed with this Windo*s *&%^@
> >
> >What does the script do? There may be an equivalent for Windows readily
> >available.
>
> It is from gnu lilypond:

Well I'll be! A GNU package written in Python. It's official folks, I have now
seen everything.

I downloaded version 1.5.9 and it seems to no longer have a dependency on the
resource module. Give it a try.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From dyoo@hkn.eecs.berkeley.edu  Sun Sep 16 02:54:45 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sat, 15 Sep 2001 18:54:45 -0700 (PDT)
Subject: [Tutor] help
In-Reply-To: <F210H5qyrajdYYHcYVI0000efb7@hotmail.com>
Message-ID: <Pine.LNX.4.21.0109151837540.10234-100000@hkn.eecs.berkeley.edu>

On Sat, 15 Sep 2001, Cameron Stoner wrote:

> What is wrong with this code?  When I ran this in the IDLE it brought
> up an unhashable type error.  I don't really understand why print
> dict[sep_letter] is a problem.  Would you tell me what would fix it
> please or what the flaw in the logic is.

Let's take a look:

> import string
> y = raw_input('prompt:')
> while y is not '':
>     sep_letter = (string.split(y[0][-1]))

If y is a string, then y[0] will be a single letter of that string, and
y[0][-1] --- that is, the last letter of y[0] --- will be that same
letter:

###
>>> name = 'cameron'
>>> name[0]
'c'
>>> name[0][-1]
'c'
>>> name[0][-1][-1]
'c'
###

It will be simpler to write:

    sep_letter = string.split(y[0])

But even then, I'm a little confused, since splitting a single letter is
probably not what you were planning.  This might be the cause for the
"unhashable type error" that you're running into.


Hmmm... Do you mean:

###
sep_letter = string.split(y)[0][-1]
###

instead?  This is more effective, since this says: "Split the string into
a list of smaller strings.  Pull out the first of those strings, and grab
at the last character of it."



>     while sep_letter is not '':
>         dict = 
> {'A':'1','B':'2','C':'3','D':'4','E':'5','F':'6','G':'7','H':'8','I':'9',
>                 
> 'J':'10','K':'11','L':'12','M':'13','N':'14','O':'15','P':'16',
>                 
> 'Q':'17','R':'18','S':'19','T':'20','U':'21','V':'22','W':'23','X':
>                 '24','Y':'24','Z':'25','':'','.':'~','?':'`'}
>         print dict[sep_letter]


It might be good to pull out the definition of the dictionary outside of
the while loop, just to emphasise the fact that its definition is not
really an important part of the looping.  Also, I think there's a small
bug, since both 'X' and 'Y' both map to '24'.

Here's a small function that might help:

###
def makeCodingDictionary():
    dict = {}
    for i in range(26):
         dict[chr(ord('A') + i)] = str(i+1)
    dict.update({'' : '',
                 '.' : '~',
                 '?' : '`'})
    return dict
###


Try making those corrections first, and tell us if it helps.  The first
fix should repair the bug you were running into.  Good luck!



From dsh8290@rit.edu  Sun Sep 16 02:46:28 2001
From: dsh8290@rit.edu (dman)
Date: Sat, 15 Sep 2001 21:46:28 -0400
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <3BA41810.7632.1B929093@localhost>
References: <3BA2EAEE.32758.16FA4703@localhost>
 <3BA41810.7632.1B929093@localhost>
Message-ID: <20010915214628.B3159@hudson>

On Sun, Sep 16, 2001 at 03:10:08AM +0200, Gerrit P. Haase wrote:
| dman schrieb am 2001-09-14, 23:55:
| 
| [...]
| >| ..., why am I doomed with this Windo*s *&%^@
| >
| >I hear you.  For temporary relief, install cygwin.  It comes with
| 
| I use cygwin + cygwin-python, but the maintainer seems to have not 
| the time to build python with this extension:(

Hmm, could be that or maybe cygwin doesn't support
setrlimit/getrlimit.

Anyays, have you found XFree86 and KDE?  There are prebuilt binaries
for running with cygwin.  kvt is much better than using a DOS box, and
a free X server is cool too.

-D



From urnerk@qwest.net  Sun Sep 16 07:03:03 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Sat, 15 Sep 2001 23:03:03 -0700
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <20010915214628.B3159@hudson>
References: <3BA41810.7632.1B929093@localhost>
 <3BA2EAEE.32758.16FA4703@localhost>
 <3BA41810.7632.1B929093@localhost>
Message-ID: <4.2.0.58.20010915225813.00d16890@pop3.norton.antivirus>

At 09:46 PM 9/15/2001 -0400, dman wrote:

>Anyays, have you found XFree86 and KDE?  There are prebuilt binaries
>for running with cygwin.  kvt is much better than using a DOS box, and a 
>free X server is cool too.
>
>-D

I went the cygwin route on a Windows box once.  But if
you're going so far as to do X server, KDE and the whole
ball of wax, I'd say why not just partition and go with
Linux.  You can still access your Windows files (including
pure Python modules), and you can still boot Windows if
you want (yes, there's also the Windows emulator route).

Of course this may be completely irrelevant to the initial
poster.  I'm just sharing my own experience of finding
cygwin to be rather cumbersome and not that satisfying.
Easier to just add Linux as a boot option.

Alternatively, there are way of installing Linux right
into a Windows partition, on top of FAT32, if you're
willing to take a performance hit.  This too might be
preferable to cygwin.

Anyway, options to consider (I have no idea what CPAN
is -- another warning that this may be off-topic).

Kirby



From dyoo@hkn.eecs.berkeley.edu  Sun Sep 16 08:11:27 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sun, 16 Sep 2001 00:11:27 -0700 (PDT)
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <4.2.0.58.20010915225813.00d16890@pop3.norton.antivirus>
Message-ID: <Pine.LNX.4.21.0109152359420.14380-100000@hkn.eecs.berkeley.edu>

On Sat, 15 Sep 2001, Kirby Urner wrote:
>
> Anyway, options to consider (I have no idea what CPAN
> is -- another warning that this may be off-topic).

It's not really off-topic; it's a common question that comes up from
people who come from Perl to Python.


CPAN is the Comprehensive Perl Archive Network:

    http://cpan.org

and it's a distributed library of Perl modules.  No illusions: at the
moment, it puts the Vaults of Parnassus at

    http://www.vex.net/parnassus/

to shame.  CPAN is mirrored all over the world, and it's very powerful.


CPAN is a Good Idea, and one that Pythonistas are eager to adopt.  Toward
this end, people are organizing around the "Catalog" Special Interest
Group (SIG):

    http://www.python.org/sigs/catalog-sig/

I just hope I see the fruits of their labours in a couple of years.  
*grin*



From ak@silmarill.org  Sun Sep 16 11:32:55 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Sun, 16 Sep 2001 06:32:55 -0400
Subject: [Tutor] help
In-Reply-To: <F210H5qyrajdYYHcYVI0000efb7@hotmail.com>
References: <F210H5qyrajdYYHcYVI0000efb7@hotmail.com>
Message-ID: <20010916063254.A17429@sill.silmarill.org>

On Sat, Sep 15, 2001 at 10:21:57AM -0500, Cameron Stoner wrote:
> Dear Python people,
> 
> What is wrong with this code?  When I ran this in the IDLE it brought up an 
> unhashable type error.  I don?t really understand why print dict[sep_letter] 
> 
> is a problem.  Would you tell me what would fix it please or what the flaw 
> in the logic is.
> 
> Thanks
> Cameron

You got some good answers already, and I just want to add that generally,
if you run into some sort of problem, you should try putting print
statements in the code to see where you went wrong.

If there is an error with a variable, you should look at the code and see
where this variable came from, then look at each step that could have
changed that value and put prints near it to see if it did what it should
have done.

Please don't take this in the sense that questions aren't welcome here -
even the simplest ones are, but you will often find the problem much
faster than asking here if you do a little debugging first.

- Andrei 

[snip]


-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From gubitz@netcologne.de  Sun Sep 16 11:45:41 2001
From: gubitz@netcologne.de (Hans Gubitz)
Date: Sun, 16 Sep 2001 12:45:41 +0200
Subject: [Tutor] uid
In-Reply-To: <20010915192114.A16255@ID-96242.user.dfncis.de>
References: <20010915121756.A5517@redwitz79.de> <20010915140915.A15664@ID-96242.user.dfncis.de> <20010915105841.A17572@tc.niof.net> <20010915192114.A16255@ID-96242.user.dfncis.de>
Message-ID: <20010916124541.A2558@redwitz79.de>

On Sat, Sep 15, 2001 at 07:21:14PM +0200, Joerg Woelke wrote:
> On Sat, Sep 15, 2001 at 10:58:41AM -0400, Rick Pasotto wrote:
> > On Sat, Sep 15, 2001 at 02:09:15PM +0200, Joerg Woelke wrote:
> > > On Sat, Sep 15, 2001 at 12:17:56PM +0200, Hans Gubitz wrote:
> > > > I want to cp a file and extract it to different users. I can do this
> > > > as root, but I want extract  to be done with the uid of the user.
>                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> > > > 
> > > os.suid()
> > 
> > Did you *try* that? It doesn't exist on my system.
> 
> Aeh sorry - os.setuid() *duck*

I will try it. 
> > os.chown(user) 
This way I would have to chown each file in the tar-File.
> 
> Then I misunderstood the marked sentence.
I think you understood it the right way.

Hans Gubitz

-- 
Hans Gubitz <gubitz@netcologne.de>



From dsh8290@rit.edu  Sun Sep 16 13:01:05 2001
From: dsh8290@rit.edu (dman)
Date: Sun, 16 Sep 2001 08:01:05 -0400
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <4.2.0.58.20010915225813.00d16890@pop3.norton.antivirus>
References: <3BA41810.7632.1B929093@localhost>
 <3BA2EAEE.32758.16FA4703@localhost> <3BA41810.7632.1B929093@localhost>
 <4.2.0.58.20010915225813.00d16890@pop3.norton.antivirus>
Message-ID: <20010916080105.C911@hudson>

On Sat, Sep 15, 2001 at 11:03:03PM -0700, Kirby Urner wrote:
| At 09:46 PM 9/15/2001 -0400, dman wrote:
| 
| >Anyays, have you found XFree86 and KDE?  There are prebuilt binaries
| >for running with cygwin.  kvt is much better than using a DOS box, and a 
| >free X server is cool too.
| 
| I went the cygwin route on a Windows box once.  But if
| you're going so far as to do X server, KDE and the whole
| ball of wax, I'd say why not just partition and go with
| Linux.  

The reason is when it is your employer's machine and he wants Windows
on it.  Having X is not so bad since it is Free competition to the
commercial X servers out there (for remote logins to Unix systems).

Fortuantely for me, though, I have permission to install Debian soon
:-).

I agree with you that installing Linux is preferrable to cygwin for
many reasons including performance and stability and completeness.
Cygwin is not a complete Unix look-alike yet, but it is quite good
when windows is required as the base system.

| Alternatively, there are way of installing Linux right
| into a Windows partition, on top of FAT32, if you're
| willing to take a performance hit.  This too might be

I've vaguely heard of a couple distros that do this.

-D



From lha2@columbia.edu  Sun Sep 16 15:58:24 2001
From: lha2@columbia.edu (Lloyd Hugh Allen)
Date: Sun, 16 Sep 2001 10:58:24 -0400
Subject: [Tutor] useless banner challenge (if it's okay w/ rob)
Message-ID: <3BA4BE10.DD3B2350@mail.verizon.net>

Back in July I had made a program to create an American flag in a small
window as a Tkinter Canvas object, in order to learn and teach Tkinter
canvas drawing methods etc.

I had intended to add buttons so as to reconfigure the flag to its
various incarnations--13 star old glory, etc. Didn't get around to it.

I seem to recall Eric Raymond saying something about the strength of
open source being that projects living past the threshold of a single
person's time and motivation. If anyone cares to take this on, the
script currently lives on 

http://www.lowerstandard.com/python/uselesspython7.html

or more specifically

http://www.lowerstandard.com/python/banner.py

it would be really, really cool if they would morph into each other
(perhaps animated stars moving from present location to future location)
rather than simply blinking from one to the next. This is beyond my
current capability.

Cheers,
LHA


From rob@jam.rr.com  Sun Sep 16 17:30:17 2001
From: rob@jam.rr.com (Rob)
Date: Sun, 16 Sep 2001 11:30:17 -0500
Subject: [Tutor] useless banner challenge (if it's okay w/ rob)
References: <3BA4BE10.DD3B2350@mail.verizon.net>
Message-ID: <3BA4D399.6C9B2192@jam.rr.com>

Lloyd Hugh Allen wrote:
> 
> Back in July I had made a program to create an American flag in a small
> window as a Tkinter Canvas object, in order to learn and teach Tkinter
> canvas drawing methods etc.
> 
> I had intended to add buttons so as to reconfigure the flag to its
> various incarnations--13 star old glory, etc. Didn't get around to it.
> 
> I seem to recall Eric Raymond saying something about the strength of
> open source being that projects living past the threshold of a single
> person's time and motivation. If anyone cares to take this on, the
> script currently lives on
> 
> http://www.lowerstandard.com/python/uselesspython7.html
> 
> or more specifically
> 
> http://www.lowerstandard.com/python/banner.py
> 
> it would be really, really cool if they would morph into each other
> (perhaps animated stars moving from present location to future location)
> rather than simply blinking from one to the next. This is beyond my
> current capability.
> 
> Cheers,
> LHA
> 

Anything's fine by me. Provided the Useless server allows me ftp access
later on today, I'll upload the latest material, including this new
challenge.

If anyone can think of a script that does anything particularly
uplifting, that would be great. A script that prints the name of a
random survivor of violent acts (including, but not limited to, the WTC
attack), Pythonic words of peace, or anything that reminds us not to
focus exclusively on the profound suffering to which we are often
exposed, perhaps.

If nothing else, we should remember to keep having some fun hacking
Python scripts instead of plotting revenge.

<OT>
Just FYI, all my relatives and friends known to have been in or next to
the buildings taken down this week seem to have made it out alive and
intact. I'd like to extend a wish of peace to everyone out there, even
to the people responsible for the aggression we've all recently
witnessed. I think it's a testament to the good hearts of many people
that this business hasn't turned any worse than it has. (In fact, I'm
frankly amazed at some of these Mississippi country folk who have seen
groups of people literally dancing in the streets in joy at the bombing.
I haven't heard a single report of these questionable celebrations
suffering retaliation from witnesses, and that's nothing short of
miraculous here in the Deep South.)
</OT>

Rob
-- 
Aw, c'mon.... You indent ANYWAY!
Useless Python!
http://www.lowerstandard.com/python


From gp@familiehaase.de  Sun Sep 16 20:45:01 2001
From: gp@familiehaase.de (Gerrit P. Haase)
Date: Sun, 16 Sep 2001 21:45:01 +0200
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <Pine.LNX.4.33.0109152128440.5784-100000@terbidium.openservices.net>
References: <3BA41695.11986.1B8CC8E8@localhost>
Message-ID: <3BA51D5D.27517.1F8F4879@localhost>

Ignacio Vazquez-Abrams schrieb am 2001-09-15, 21:31:

>On Sun, 16 Sep 2001, Gerrit P. Haase wrote:
>
>> Ignacio Vazquez-Abrams schrieb am 2001-09-14, 23:55:
>>
>> >On Sat, 15 Sep 2001, Gerrit P. Haase wrote:
>> >
>> >> Well, a core module that isn't included in my python.
>> >> There is surely a good reason why it is like it is...
>> >> ****, why am I doomed with this Windo*s *&%^@
>> >
>> >What does the script do? There may be an equivalent for Windows readily
>> >available.
>>
>> It is from gnu lilypond:
>
>Well I'll be! A GNU package written in Python. It's official folks, I have now
>seen everything.
>
>I downloaded version 1.5.9 and it seems to no longer have a dependency on the
>resource module. Give it a try.

Aha, that is good news. However, it should be no problem to build python 
with this extension. Usually it builds OOTB on cygwin, though the maintainer 
has not that much time to do an update now. But he sent a patch, so I will 
build it myself here this night.

Gerrit


-- 
=^..^=


From gp@familiehaase.de  Sun Sep 16 20:47:32 2001
From: gp@familiehaase.de (Gerrit P. Haase)
Date: Sun, 16 Sep 2001 21:47:32 +0200
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <20010915214628.B3159@hudson>
References: <3BA41810.7632.1B929093@localhost>
Message-ID: <3BA51DF4.13077.1F9192F1@localhost>

dman schrieb am 2001-09-15, 21:46:

>On Sun, Sep 16, 2001 at 03:10:08AM +0200, Gerrit P. Haase wrote:
>| dman schrieb am 2001-09-14, 23:55:
>| 
>| [...]
>| >| ..., why am I doomed with this Windo*s *&%^@
>| >
>| >I hear you.  For temporary relief, install cygwin.  It comes with
>| 
>| I use cygwin + cygwin-python, but the maintainer seems to have not 
>| the time to build python with this extension:(
>
>Hmm, could be that or maybe cygwin doesn't support
>setrlimit/getrlimit.

It is patched since december last year to support it.

>Anyays, have you found XFree86 and KDE?  There are prebuilt binaries
>for running with cygwin.  kvt is much better than using a DOS box, and
>a free X server is cool too.

I wonder what it so fascinating with that KDE stuff.
I am on windows with full GUI for all I need, so why to use KDE?
I have X installed, but I don't use it that much.

Maybe it is a difference if you have real Windows (NT) or just w98.

Gerrit


-- 
=^..^=


From sobesoft@yahoo.com  Sun Sep 16 18:28:22 2001
From: sobesoft@yahoo.com (Dave Foderick)
Date: Sun, 16 Sep 2001 13:28:22 -0400
Subject: [Tutor] Python and web
Message-ID: <GNEALFKGFDKLAKPLBNFGEEDECHAA.sobesoft@yahoo.com>

I found out that my ISP supports Python as an option for programming my web
pages.

Does anyone have a sample "hello world" python script for the web?

I am trying to find a sample script that I could copy up to my web site and
find out if it is working. Is python interpreted, or do I need to compile
and copy up to the web?

Thanks.

Dave
sobesoft@yahoo.com
www.southbeachsoftware.com



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



From ignacio@openservices.net  Sun Sep 16 21:33:21 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Sun, 16 Sep 2001 16:33:21 -0400 (EDT)
Subject: [Tutor] Python and web
In-Reply-To: <GNEALFKGFDKLAKPLBNFGEEDECHAA.sobesoft@yahoo.com>
Message-ID: <Pine.LNX.4.33.0109161630580.5784-100000@terbidium.openservices.net>

On Sun, 16 Sep 2001, Dave Foderick wrote:

> Does anyone have a sample "hello world" python script for the web?

#! /usr/bin/python

print 'Content-type: text/html'
print
print 'Hello, world!'

> I am trying to find a sample script that I could copy up to my web site and
> find out if it is working. Is python interpreted, or do I need to compile
> and copy up to the web?

It's interpreted.

There may be other considerations however. Does your ISP support CGIs in any
directory, or just in /cgi-bin? Can it have an extension of .py, or is .cgi
the only one recognized?

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From alan.gauld@bt.com  Sun Sep 16 23:01:02 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sun, 16 Sep 2001 23:01:02 +0100
Subject: [Tutor] adding users from a script
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF67@mbtlipnt02.btlabs.bt.co.uk>

> ugly at times - but it's the first thing halfway resembling a 
> programme that I've written, so maybe all hope is not lost...

Looks pretty good for a first useful programming effort.

> # l, 0, 1 & o omitted so as not to confuse the (l)users

Since you are generating the passwords thats probably good thinking.
If the users were entering them it'd have the opposite effect 
- trying to figure why certain'valid' letters were failing...

> logfile = open('passlog', 'a')
> logfile.write(nomme + "\t" + pw + "\n")
> logfile.close

Just remember to clean up the log file from time to time 
- these things can grow pretty big over time. One trick 
is to generate a filename from the date(passlog20010916 say), 
thus you get a new file each day(or month) which makes 
finding entries easy and archiving old files trivial. 
Just a thought...

>  " The stars go waltzing out in blue and red,
>    And arbitrary blackness gallops in:
>    I shut my eyes and all the world drops dead. "
>   
>     --Sylvia Plath

Nice taste in poetry :-)

Alan G


From dsh8290@rit.edu  Mon Sep 17 01:40:27 2001
From: dsh8290@rit.edu (dman)
Date: Sun, 16 Sep 2001 20:40:27 -0400
Subject: [Tutor] where is CPAN for python?
In-Reply-To: <3BA51DF4.13077.1F9192F1@localhost>
References: <3BA41810.7632.1B929093@localhost>
 <3BA51DF4.13077.1F9192F1@localhost>
Message-ID: <20010916204027.H2653@hudson>

On Sun, Sep 16, 2001 at 09:47:32PM +0200, Gerrit P. Haase wrote:
| dman schrieb am 2001-09-15, 21:46:
| 
| >On Sun, Sep 16, 2001 at 03:10:08AM +0200, Gerrit P. Haase wrote:
| >| dman schrieb am 2001-09-14, 23:55:
| >| 
| >| [...]
| >| >| ..., why am I doomed with this Windo*s *&%^@
| >| >
| >| >I hear you.  For temporary relief, install cygwin.  It comes with
| >| 
| >| I use cygwin + cygwin-python, but the maintainer seems to have not 
| >| the time to build python with this extension:(
| >
| >Hmm, could be that or maybe cygwin doesn't support
| >setrlimit/getrlimit.
| 
| It is patched since december last year to support it.

Oh, ok.

| >Anyays, have you found XFree86 and KDE?  There are prebuilt binaries
| >for running with cygwin.  kvt is much better than using a DOS box, and
| >a free X server is cool too.
| 
| I wonder what it so fascinating with that KDE stuff.
| I am on windows with full GUI for all I need, so why to use KDE?

because KDE is a much better GUI than MS Windows.  (I actually prefer
GNOME, but it isn't available for cygwin/xfree)

| I have X installed, but I don't use it that much.
| 
| Maybe it is a difference if you have real Windows (NT) or just w98.

No, I have win2k at work but I prefer to use KDE.  I got the latest
gvim working with it, but couldn't do that with plain windows (I don't
have MS devel tool either though).

-D



From brian@dorseys.org  Mon Sep 17 03:35:39 2001
From: brian@dorseys.org (Brian Dorsey)
Date: Sun, 16 Sep 2001 19:35:39 -0700
Subject: [Tutor] ... GNU packages in Python
In-Reply-To: <Pine.LNX.4.33.0109152128440.5784-100000@terbidium.openservices.net>; from ignacio@openservices.net on Sat, Sep 15, 2001 at 09:31:46PM -0400
References: <3BA41695.11986.1B8CC8E8@localhost> <Pine.LNX.4.33.0109152128440.5784-100000@terbidium.openservices.net>
Message-ID: <20010916193539.B32002@dorseys.org>

Another example which some people may recognize: GNU Mailman
http://www.list.org

There are probably others as well.

Take care,
-Brian

On Sat, Sep 15, 2001 at 09:31:46PM -0400, Ignacio Vazquez-Abrams wrote:
> On Sun, 16 Sep 2001, Gerrit P. Haase wrote:
> 
> > Ignacio Vazquez-Abrams schrieb am 2001-09-14, 23:55:
> >
> > >On Sat, 15 Sep 2001, Gerrit P. Haase wrote:
> > >
> > >> Well, a core module that isn't included in my python.
> > >> There is surely a good reason why it is like it is...
> > >> ****, why am I doomed with this Windo*s *&%^@
> > >
> > >What does the script do? There may be an equivalent for Windows readily
> > >available.
> >
> > It is from gnu lilypond:
> 
> Well I'll be! A GNU package written in Python. It's official folks, I have now
> seen everything.
> 
> I downloaded version 1.5.9 and it seems to no longer have a dependency on the
> resource module. Give it a try.
> 
> -- 
> Ignacio Vazquez-Abrams  <ignacio@openservices.net>
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


From alan.gauld@bt.com  Mon Sep 17 09:33:46 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 17 Sep 2001 09:33:46 +0100
Subject: [Tutor] unit testing
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF69@mbtlipnt02.btlabs.bt.co.uk>

If using a command line/teletype interface then they can easily 
automate teting by relying on stdin redirection. Thus write a 
little test harness that reads parameters from stdin(raw_input)
and then executes the program. This can be used ineractively 
initially but then regression testing can be done by using 
redirection from a simple text file:


C:> python myprog.py		tests interactively
C:> python myprog.py < testfile.txt >results.txt

You can then compare the results file with previous test runs.

Its an easy concept to learn and powerful enough for production use.
An interesting excercise is to compare results when they use somweone 
else's testfile... Of course they need to agree input order and formats.

> calculator. They spent a lot of time entering the same years 
> over and over again while testing their program logic.

The above option solves that bit. 

The other thing to do is *encourage* finding bugs maybe 
even rewarding in some way evidence of thorough testing.

And of course get them to test each others code.

Alan G


From alan.gauld@bt.com  Mon Sep 17 09:37:07 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 17 Sep 2001 09:37:07 +0100
Subject: [Tutor] unit testing
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF6A@mbtlipnt02.btlabs.bt.co.uk>

> >the interpreter and load my code as a module and run the functions 
> >dynamically.

I don't like using the interpreter for formal testing - fine for debugging.
You can't repeat the tests consistently or accurately.

> Sometimes beginners (including "beginners" experienced in
> languages without much of a shell) waste a lot of time
> prompting themselves for input using raw_input loops,
> the purpose of which is simply to pass values back to
> functions in the context of running a script as a program.

I actually prefer this approach for formal testing because 
its easy to do regression testing using text files for input/output

Alan G


From rick@niof.net  Mon Sep 17 13:46:38 2001
From: rick@niof.net (Rick Pasotto)
Date: Mon, 17 Sep 2001 08:46:38 -0400
Subject: [Tutor] getting canvas window size
Message-ID: <20010917084638.A11891@tc.niof.net>

Why do the print statements in the following program show zero? How can
I figure out the size of the frame?

from Tkinter import *

w = Tk()
cnv = Canvas(w,bg='white',relief=SUNKEN)
cnv.config(width=400,height=200)
cnv.pack(side=LEFT,expand=YES,fill=BOTH)

f = Frame(cnv,relief=GROOVE,borderwidth=2)
for j in range(5):
	l = Label(f,text='label: %2d' % (j),
		relief=GROOVE,borderwidth=2,padx=5)
	l.pack(side=LEFT,expand=YES,fill=X,padx=5,pady=2)
f.pack()
cw = cnv.create_window(20,20,window=f,anchor=NW)

print f.cget('height'),f.cget('width')
print cnv.itemcget(cw,'height'), cnv.itemcget(cw,'width')

w.mainloop()

-- 
Certain nations seem particularly liable to fall prey to
governmental plunder. They are those in which men, lacking faith
in their own dignity and capability, would feel themselves lost if
they were not governed and administered every step of the way.
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net


From danny.kohn@systematik.se  Mon Sep 17 16:09:50 2001
From: danny.kohn@systematik.se (Danny Kohn)
Date: Mon, 17 Sep 2001 17:09:50 +0200
Subject: [Tutor] Tuples in tuples
Message-ID: <OGEPIJONPINEELIFKPBOEEPIDNAA.danny.kohn@systematik.se>

Hi.
Is it possible to reference tuple in tuple in one expression? Lets say I =
have a tuple t =3D ((6, 7, 8, 9, 0), (1, 2, 3, 4, 5)). Can I refer to =
the third element (8) in one expression or do I have to do something =
like x,y=3Dt and then x[2]?

H=E4lsningar / Regards                                 (\_/)  ))
Danny Kohn                 Tel: +46 (0)708 140 300  =3D('.')=3D//  Miau!
Systematik Consulting AB   ICQ: 1328817             ( ~~~ )/   Rrrrrui!
http://www.systematik.se   HAM: SM0NBJ              `w---w=B4=20




From ignacio@openservices.net  Mon Sep 17 16:20:59 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Mon, 17 Sep 2001 11:20:59 -0400 (EDT)
Subject: [Tutor] Tuples in tuples
In-Reply-To: <OGEPIJONPINEELIFKPBOEEPIDNAA.danny.kohn@systematik.se>
Message-ID: <Pine.LNX.4.33.0109171120340.16967-100000@terbidium.openservices.net>

On Mon, 17 Sep 2001, Danny Kohn wrote:

> Is it possible to reference tuple in tuple in one expression? Lets say I have a tuple t = ((6, 7, 8, 9, 0), (1, 2, 3, 4, 5)). Can I refer to the third element (8) in one expression or do I have to do something like x,y=t and then x[2]?

t[0][2]

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From rick@niof.net  Mon Sep 17 16:23:56 2001
From: rick@niof.net (Rick Pasotto)
Date: Mon, 17 Sep 2001 11:23:56 -0400
Subject: [Tutor] Tuples in tuples
In-Reply-To: <OGEPIJONPINEELIFKPBOEEPIDNAA.danny.kohn@systematik.se>
References: <OGEPIJONPINEELIFKPBOEEPIDNAA.danny.kohn@systematik.se>
Message-ID: <20010917112356.B32095@tc.niof.net>

On Mon, Sep 17, 2001 at 05:09:50PM +0200, Danny Kohn wrote:
> Hi.  Is it possible to reference tuple in tuple in one expression?
> Lets say I have a tuple t = ((6, 7, 8, 9, 0), (1, 2, 3, 4, 5)). Can I
> refer to the third element (8) in one expression or do I have to do
> something like x,y=t and then x[2]?

No problem.

t[0][2]

-- 
"The whole aim of practical politics is to keep the populace alarmed --
and thus clamorous to be led to safety -- by menacing it with an endless
series of hobgoblins, all of them imaginary." -- H.L. Mencken
		Rick Pasotto email: rickp@telocity.com
		               web: www.niof.net


From urnerk@qwest.net  Mon Sep 17 17:31:02 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Mon, 17 Sep 2001 09:31:02 -0700
Subject: [Tutor] unit testing
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF6A@mbtlipnt02.btlabs
 .bt.co.uk>
Message-ID: <4.2.0.58.20010917091600.00d1ba20@pop3.norton.antivirus>

At 09:37 AM 9/17/2001 +0100, alan.gauld@bt.com wrote:

>I actually prefer this approach for formal testing because
>its easy to do regression testing using text files for
>input/output
>
>Alan G

Sure if you like.  You know about the shell option but
prefer this other way.

I think many beginners waste time doing less formal
testing using raw_input loops that would be more easily
accomplished in shell mode.

Once you get into formal testing, there's a utility
called PyUnit that some people like.  It has an optional
GUI front end, and there's talk of merging that into
IDLE at some point (both are Tk apps).

http://www.onlamp.com/lpt/a/python/2001/03/28/pythonnews.html

Kirby



From jessicapolson@yahoo.com  Mon Sep 17 20:28:27 2001
From: jessicapolson@yahoo.com (jessica polson)
Date: Mon, 17 Sep 2001 12:28:27 -0700 (PDT)
Subject: [Tutor] Unsubscribe  Please
Message-ID: <20010917192827.86957.qmail@web12605.mail.yahoo.com>

 
 

__________________________________________________
Terrorist Attacks on U.S. - How can you help?
Donate cash, emergency relief information
http://dailynews.yahoo.com/fc/US/Emergency_Information/


From Charlie@begeistert.org  Mon Sep 17 20:46:27 2001
From: Charlie@begeistert.org (Charlie Clark)
Date: Mon, 17 Sep 2001 21:46:27 +0200
Subject: [Tutor] VUE
In-Reply-To: <E15j0px-0007Xr-00@mail.python.org>
Message-ID: <1000755987_PM_BeOS.Charlie@begeistert.org>

>If anyone can think of a script that does anything particularly 
>uplifting, that would be great. A script that prints the name of a 
>random survivor of violent acts (including, but not limited to, the WTC 

>attack), Pythonic words of peace, or anything that reminds us not to 
>focus exclusively on the profound suffering to which we are often 
>exposed, perhaps. 
ooh victims of the VUE (violent unknown event) would make a change in 
this world of invisible suffering. Should be possible just need to 
convert the film to an appropriate streaming form.

Charli





From dyoo@hkn.eecs.berkeley.edu  Mon Sep 17 21:41:41 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 17 Sep 2001 13:41:41 -0700 (PDT)
Subject: [Tutor] Unsubscribe  Please
In-Reply-To: <20010917192827.86957.qmail@web12605.mail.yahoo.com>
Message-ID: <Pine.LNX.4.21.0109171339140.16832-100000@hkn.eecs.berkeley.edu>

Hi Jessica,

You can unsubscribe yourself by visiting the Tutor web site:

    http://mail.python.org/mailman/listinfo/tutor

It's the same website that you use to subscribe --- there's a section on
the bottom of the page that will allow you to "Edit Options" on your
account.  You should be able to unsubscribe from the form there.

If you run into more problems while unsubscribing, feel free to email
directly to tutor-admin@python.org.


Best of wishes to you!



From fleet@teachout.org  Mon Sep 17 22:57:58 2001
From: fleet@teachout.org (fleet@teachout.org)
Date: Mon, 17 Sep 2001 17:57:58 -0400 (EDT)
Subject: [Tutor] Python and mail
Message-ID: <Pine.LNX.4.33.0109171750420.15708-100000@fleet1.paxp.com>

I'm using python 1.5.2 on RH 7.1.

I have some files (invoices) that I create once a month. I'd like to
create a script that will mail the invoices to each of my customers sort
of in a "batch" mode.

I can do the mailing using 'mail' manually (except I'm having a problem
passing a binary logo file - but I think I can handle that).  I anticipate
creating a dictionary from a flat file of customer e-mails, the file
associated with them, and possibly a "note" to add to the attachments.

Is there a (probably better) Python way to accomplish this?  I've looked
through the modules and find things for retrieving mail, but nothing about
sending mail.

Thanks,
				- fleet -



From sheila@thinkspot.net  Mon Sep 17 23:12:11 2001
From: sheila@thinkspot.net (Sheila King)
Date: Mon, 17 Sep 2001 15:12:11 -0700
Subject: [Tutor] Python and mail
In-Reply-To: <Pine.LNX.4.33.0109171750420.15708-100000@fleet1.paxp.com>
References: <Pine.LNX.4.33.0109171750420.15708-100000@fleet1.paxp.com>
Message-ID: <13DE41E0207@kserver.org>

On Mon, 17 Sep 2001 17:57:58 -0400 (EDT), <fleet@teachout.org>  wrote
about [Tutor] Python and mail:

:Is there a (probably better) Python way to accomplish this?  I've looked
:through the modules and find things for retrieving mail, but nothing about
:sending mail.

For sending mail, you will want to use the smtplib.

http://www.python.org/doc/current/lib/module-smtplib.html


Here's an example of sending mail using the smtplib:

http://www.faqts.com/knowledge_base/view.phtml/aid/2607/fid/380


Hope this helps to get you started.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/



From fleet@teachout.org  Tue Sep 18 01:38:07 2001
From: fleet@teachout.org (fleet@teachout.org)
Date: Mon, 17 Sep 2001 20:38:07 -0400 (EDT)
Subject: [Tutor] Python and mail
In-Reply-To: <13DE41E0207@kserver.org>
Message-ID: <Pine.LNX.4.33.0109172035370.16118-100000@fleet1.paxp.com>

Thanks, Sheila.  Yes, I think this will help!  It looks like I will need
to forego the binary logo (thumbnail) that I have been including - but I'm
not upset about that.

				- fleet -

On Mon, 17 Sep 2001, Sheila King wrote:

> On Mon, 17 Sep 2001 17:57:58 -0400 (EDT), <fleet@teachout.org>  wrote
> about [Tutor] Python and mail:
>
> :Is there a (probably better) Python way to accomplish this?  I've looked
> :through the modules and find things for retrieving mail, but nothing about
> :sending mail.
>
> For sending mail, you will want to use the smtplib.
>
> http://www.python.org/doc/current/lib/module-smtplib.html
>
>
> Here's an example of sending mail using the smtplib:
>
> http://www.faqts.com/knowledge_base/view.phtml/aid/2607/fid/380
>
>
> Hope this helps to get you started.
>
> --
> Sheila King
> http://www.thinkspot.net/sheila/
> http://www.k12groups.org/
>



From slim_bizkit2001@sbcglobal.net  Tue Sep 18 00:36:22 2001
From: slim_bizkit2001@sbcglobal.net (Louie Montelongo)
Date: Mon, 17 Sep 2001 18:36:22 -0500
Subject: [Tutor] (no subject)
Message-ID: <000901c13fd1$901cb600$7827fea9@computer>

This is a multi-part message in MIME format.

------=_NextPart_000_0005_01C13FA7.A64347C0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I Use Python For School Work But I Don't Know How To Use It For Squaring =
And Thngs Like That
Please Help Me   =20
                                                         Louie =
Montelongo

------=_NextPart_000_0005_01C13FA7.A64347C0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#c0c0c0>
<DIV><FONT face=3DArial size=3D2>I Use Python For School Work But I =
Don't Know How=20
To Use It For Squaring And Thngs Like That</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Please Help Me&nbsp;&nbsp;&nbsp; =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
Louie Montelongo</FONT></DIV></BODY></HTML>

------=_NextPart_000_0005_01C13FA7.A64347C0--



From urnerk@qwest.net  Tue Sep 18 03:21:53 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Mon, 17 Sep 2001 19:21:53 -0700
Subject: [Tutor] (no subject)
In-Reply-To: <000901c13fd1$901cb600$7827fea9@computer>
Message-ID: <4.2.0.58.20010917191834.00bff700@pop3.norton.antivirus>

At 06:36 PM 9/17/2001 -0500, Louie Montelongo wrote:
>I Use Python For School Work But I Don't Know How To Use It For Squaring 
>And Thngs Like That
>Please Help Me
>                                                          Louie Montelongo

Hi Louis --

check out http://www.inetarena.com/~pdx4d/ocn/numeracy0.html
for some ideas about how to use the Python shell as a
way-better-than-a-calculator tool to have at your elbow
when studying mathematics.  I pity those students who get
nothing but a steady diet of TIs (most popular classroom
calculator).

Also:  Python in Education:
http://www.python.org/sigs/edu-sig/

More algebra 'n stuff if you dig around in:
http://www.oregon-tips.com/tips/Public/PublicHomePage
(hit the browse button, center of screen, go to
Curricula).

Kirby



From dsh8290@rit.edu  Tue Sep 18 03:05:08 2001
From: dsh8290@rit.edu (dman)
Date: Mon, 17 Sep 2001 22:05:08 -0400
Subject: [Tutor] Python and mail
In-Reply-To: <Pine.LNX.4.33.0109172035370.16118-100000@fleet1.paxp.com>
References: <13DE41E0207@kserver.org>
 <Pine.LNX.4.33.0109172035370.16118-100000@fleet1.paxp.com>
Message-ID: <20010917220508.C1931@hudson>

On Mon, Sep 17, 2001 at 08:38:07PM -0400, fleet@teachout.org wrote:
| Thanks, Sheila.  Yes, I think this will help!  It looks like I will need
| to forego the binary logo (thumbnail) that I have been including - but I'm
| not upset about that.

Take a look at 'metasend' in the 'mimetools' package (at least, that's
what Debian and FreeBSD call the package).  It allows you to send
attachments (as MIME types) from the command line.  'mail' only allows
sending in-line text.  mutt can also send MIME attachments (using the
'-a' option).

HTH,
-D




From abhishek_nauti@yahoo.co.in  Tue Sep 18 05:38:12 2001
From: abhishek_nauti@yahoo.co.in (=?iso-8859-1?q?Abhishek?=)
Date: Tue, 18 Sep 2001 05:38:12 +0100 (BST)
Subject: [Tutor] Help!!
Message-ID: <20010918043812.91710.qmail@web8006.mail.in.yahoo.com>

 
 

____________________________________________________________
Do You Yahoo!?
Send a newsletter, share photos & files, conduct polls, organize chat events. Visit http://in.groups.yahoo.com


From sheila@thinkspot.net  Tue Sep 18 05:45:06 2001
From: sheila@thinkspot.net (Sheila King)
Date: Mon, 17 Sep 2001 21:45:06 -0700
Subject: [Tutor] Help!!
In-Reply-To: <20010918043812.91710.qmail@web8006.mail.in.yahoo.com>
References: <20010918043812.91710.qmail@web8006.mail.in.yahoo.com>
Message-ID: <2A5B76C0BFA@kserver.org>

You need to be a little more specific.

--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/

On Tue, 18 Sep 2001 05:38:12 +0100 (BST), Abhishek
<abhishek_nauti@yahoo.co.in>  wrote about [Tutor] Help!!:

: 
: 
:
:____________________________________________________________
:Do You Yahoo!?
:Send a newsletter, share photos & files, conduct polls, organize chat events. Visit http://in.groups.yahoo.com
:
:_______________________________________________
:Tutor maillist  -  Tutor@python.org
:http://mail.python.org/mailman/listinfo/tutor



From dyoo@hkn.eecs.berkeley.edu  Tue Sep 18 06:28:16 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 17 Sep 2001 22:28:16 -0700 (PDT)
Subject: [Tutor] (no subject)
In-Reply-To: <000901c13fd1$901cb600$7827fea9@computer>
Message-ID: <Pine.LNX.4.21.0109172210380.30185-100000@hkn.eecs.berkeley.edu>

On Mon, 17 Sep 2001, Louie Montelongo wrote:

> I Use Python For School Work But I Don't Know How To Use It For
> Squaring And Thngs Like That Please Help Me

Forgive us: we cannot give direct answers for what seems like a homework
question.  However, we can try to point you toward useful information.  

What sort of school work do you use Python with?  What stuff are they
teaching?  The reason I ask this is because it might be possible to apply
something that your class has talked about toward this problem.

Also, what do you think of when you square things?  What does squaring
mean?

You might find useful things on the new Beginners site on Python.org here:

    http://www.python.org/doc/Newbies.html

Please feel free to ask us questions as well, and we'll see what we can do
to clear things up.



From r.b.rigilink@chello.nl  Tue Sep 18 08:59:32 2001
From: r.b.rigilink@chello.nl (Roeland Rengelink)
Date: Tue, 18 Sep 2001 09:59:32 +0200
Subject: [Tutor] unit testing
References: <Pine.GSO.4.21.0109141154570.19562-100000@isis.visi.com>
Message-ID: <3BA6FEE4.AEB1C8A@chello.nl>

Timothy Wilson wrote:
> 
> Hi everyone,
> 
> I'd like to introduce the concept of unit testing to my beginning progamming
> students as early in the year as possible. I think they'll be motivated to
> learn it because our first project was to write a little leap year
> calculator. They spent a lot of time entering the same years over and over
> again while testing their program logic.
> 

I think it's a great idea to introduce unit testing early on.

One route may be to introduce the assert statement specifically for
testing purposes.
Something like:

def test_leap()
    assert is_leap(1991)==0
    assert is_leap(1992)==1

Something to impress early on is that testing new functionality in your
code should be done by writing new test functions, e.g.:

def test_century_leap():
    assert is_leap(1900)==0
    assert is_leap(2000)==1

I used to modify existing test functions to test new functionality, and
never reaped the real benefits of unit testing, which is the assurance
that after modifying or extending your code, it still works. 

Of course you end up with a lot of test functions this way, so some way
to automate execution of all the tests would be usefull. See below for a
simplified testing framework

It may be difficult to convince your student that writing all these
tests is benificial. You can easily end up with more code in your tests
than in your actual program. One way to convince them may be to tell
them to write tests before writing the program. It is an interesting
exercise to translate specifications into test code. And although the
tests may be longer than the program, they may be shorter than the
specification document. For example, let them think about what should
happen here:

def test_bad_imput():
    assert is_leap(0) == ???
    assert is_leap('abc') == ???

or here?

def test_questionable_input():
    assert is_leap(1993.7) == ???
    assert is_leap('2000') == ???
    assert is_leap('MCMXXXIII') == ???

Although if you want these calls to raise exceptions, you may have to
think a little about how to assert that something raises an error. This
may be too advanced a subject for beginning students. (For a solution
see end of this post)

> I don't think they're quite ready for PyUnit. Does anyone have any useful
> resources or hints about doing basic unit testing?
> 

PyUnit carries a lot of extra baggage that you don't need. Below you'll
find a bare-bones testing framework that does essentially the same thing
(and may be a good intro to PyUnit). 

class TestSuite:
    '''Create a suite of test functions, which can be tested together

    suite = TestSuite(func1, func2, ..., funcN)
    suite.run()

    calls each function func1,...,funcN in turn

    The functions should take no argument and return values are ignored.
    If a function raises an AssertionError it is assumed to have failed.
    If a funtion raises any other exception it is an error.
    If no exceptions are raised it is assumed to be a succes.

    Results are reported to the standard output.

    If test failures or errors are reported run these function 
    separately to get the traceback and the sepcific error messages
    '''

    def __init__(self, *test_functions):
        self.test_functions = test_functions

    def run(self):        
        for test in self.test_functions:
            print test.__name__+'...',
            try:
                test()
            except AssertionError:
                print 'FAILED'
            except:
                print 'ERROR'
            else:
                print 'OK'

# Example usage:

def test_succes():
    assert 1==1

def test_failure():
    assert 1==0

def test_error():
    assert 1/0 == None

suite = TestSuite(test_succes, test_failure, test_error)

if __name__=='__main__':
    suite.run()

--
A function to test if a function call raises an exception:

def raises(exception, function, *arguments):
    try:
        function(*arguments)
        return 0
    except exception:
        return 1

Use for example with:

def raise_ValueError():
    raise ValueError

def test_raises():
    assert raises(ValueError, raise_ValueError)



Hope this helps,

Roeland
--
r.b.rigilink@chello.nl

"Half of what I say is nonsense. Unfortunately I don't know which half"



From ajaya@ncoretech.com  Tue Sep 18 09:38:44 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Tue, 18 Sep 2001 14:08:44 +0530
Subject: [Tutor] Problem with the select function with sockets!
Message-ID: <001701c1401d$54334540$6501a8c0@ncoretech.com>

Hi Dear Good People,

I am facing a problem with python sockets..., when I use select function
with it.

Problem description:

I am using python program as a server. When I get a connection from the
peer.., I rigister with the Peersocket. Then when I try to see if data
present in that (peer) socket....using select function like this

    def ReciveData(self, length):
        iwtd = [self.PeerSocket]
        owtd = []
        ewtd = []
        buffer = ''
        readable = select(iwtd, owtd, ewtd, 0.25)
        if len(readable[0]) != 0:
            buffer = self.PeerSocket.recv(length)

        return buffer

python is givingthe exception saying socket I passed is not a valid
descriptor..., Same function is working for the local sockets when I use
python code as a client.

I don't know what could be the problem.

Any help in this reagrd will be great for me

Thanks and Regards,
Ajaya



From ajaya@ncoretech.com  Tue Sep 18 09:42:13 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Tue, 18 Sep 2001 14:12:13 +0530
Subject: [Tutor] (no subject)
Message-ID: <001801c1401d$d0cdebf0$6501a8c0@ncoretech.com>

Hi All,

I am using python on windows with IDLE but I want to shift to Linux
permanently. Can any one suggest me good editor which supports python,
 like giving keywords in different colour and auto indentation ).


Thanks and Regards,
Ajaya



From ignacio@openservices.net  Tue Sep 18 09:54:17 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Tue, 18 Sep 2001 04:54:17 -0400 (EDT)
Subject: [Tutor] (no subject)
In-Reply-To: <001801c1401d$d0cdebf0$6501a8c0@ncoretech.com>
Message-ID: <Pine.LNX.4.33.0109180450300.32641-100000@terbidium.openservices.net>

On Tue, 18 Sep 2001, Ajaya Babu wrote:

> I am using python on windows with IDLE but I want to shift to Linux
> permanently. Can any one suggest me good editor which supports python,
>  like giving keywords in different colour and auto indentation ).

My Editor of Choice(tm) under Linux is vim. It has syntax highlighting for
most languages you'll use including Python, but (unfortunately?) only
autoindents for C/C++. I use it straight from the command line, but it also
comes with a psuedo-GUI version called gvim.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From scarblac@pino.selwerd.nl  Tue Sep 18 10:01:18 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Tue, 18 Sep 2001 11:01:18 +0200
Subject: [Tutor] (no subject)
In-Reply-To: <001801c1401d$d0cdebf0$6501a8c0@ncoretech.com>; from ajaya@ncoretech.com on Tue, Sep 18, 2001 at 02:12:13PM +0530
References: <001801c1401d$d0cdebf0$6501a8c0@ncoretech.com>
Message-ID: <20010918110118.A26134@pino.selwerd.nl>

On  0, Ajaya Babu <ajaya@ncoretech.com> wrote:
> I am using python on windows with IDLE but I want to shift to Linux
> permanently. Can any one suggest me good editor which supports python,
>  like giving keywords in different colour and auto indentation ).

Firstly, IDLE also works on Linux since it was written in portable Python.

Secondly, the traditional Big Two of editors are Emacs and vi (usually vim,
vi improved, now). They have a different philosophy, vi has two modes, a
typing mode and a command mode that you switch between, and emacs has no
modes, you type, and the commands are combinations with ctrl- and alt- keys
and so on. Both have good Python modes, as far as I know.

Personally I am used to Emacs commands, and I use jed, which is a small
editor (an emacs installation is huge, emacs is programmable, everything has
already been programmed, and it comes with everything included), with a good
Python mode and emacs commands.

Both Emacs and vi have a learning curve but are extremely powerful once
you've mastered them.

I've heard that vi can actually be programmed in Python, and I've recently
heard rumours of the same for Emacs.

-- 
Remco Gerlich


From ak@silmarill.org  Tue Sep 18 10:04:13 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Tue, 18 Sep 2001 05:04:13 -0400
Subject: [Tutor] (no subject)
In-Reply-To: <Pine.LNX.4.33.0109180450300.32641-100000@terbidium.openservices.net>
References: <001801c1401d$d0cdebf0$6501a8c0@ncoretech.com>
 <Pine.LNX.4.33.0109180450300.32641-100000@terbidium.openservices.net>
Message-ID: <20010918050413.A28272@sill.silmarill.org>

On Tue, Sep 18, 2001 at 04:54:17AM -0400, Ignacio Vazquez-Abrams wrote:
> On Tue, 18 Sep 2001, Ajaya Babu wrote:
> 
> > I am using python on windows with IDLE but I want to shift to Linux
> > permanently. Can any one suggest me good editor which supports python,
> >  like giving keywords in different colour and auto indentation ).
> 
> My Editor of Choice(tm) under Linux is vim. It has syntax highlighting for
> most languages you'll use including Python, but (unfortunately?) only
> autoindents for C/C++. I use it straight from the command line, but it also
> comes with a psuedo-GUI version called gvim.

There is a way to do python auto-indenting in vim, observe:

autocmd BufNewFile,BufRead *.py set textwidth=79 expandtab smartindent
cinw=try,if,def,except,for,while,else,elif,class,finally
autocmd BufRead *.py set tabstop=4
autocmd BufRead *.py %retab

Note that 1st and 2nd line should be one line. This goes to your .vimrc,
of course.

Ajaya: vim also allows python scripting. If you're using debian, you can
get package called vim-python, which includes scripting support. Vim uses
a very unusual technique called "modal editing", it takes some time to get
used to but is faster and more powerful in the end (IMHO). There is a more
traditional editor on linux that supports python highlighting and
autoindent - EMACS (and it's flavor XEMACS).

There is a #vim channel on irc.openprojects.net - you can ask questions if
you run into problems. There's also a #python channel on that network.

- Andrei 
> 
> -- 
> Ignacio Vazquez-Abrams  <ignacio@openservices.net>
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From alan.gauld@bt.com  Tue Sep 18 12:27:01 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 18 Sep 2001 12:27:01 +0100
Subject: [Tutor] Python and web
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF70@mbtlipnt02.btlabs.bt.co.uk>

> Does anyone have a sample "hello world" python script for the web?

I think if you visit the CGI area of the Python website you'll find 
a tutorial there with sample scripts.

> find out if it is working. Is python interpreted, or do I 
> need to compile and copy up to the web?

No compilation necessary.

Alan G


From alan.gauld@bt.com  Tue Sep 18 12:38:10 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 18 Sep 2001 12:38:10 +0100
Subject: [Tutor] (no subject)
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF71@mbtlipnt02.btlabs.bt.co.uk>

> I am using python on windows with IDLE but I want to shift to Linux
> permanently. Can any one suggest me good editor which supports python,
>  like giving keywords in different colour and auto indentation ).

Well if your happy with IDLE just keep using it it works on Linux.

Others to lok at are

vim/gvim
emacs
nedit(I'm sure I read that it now has Python support)

There are dozens of editors on Linux but those are the 
most popular for programming.

Alan g


From alan.gauld@bt.com  Tue Sep 18 12:43:40 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 18 Sep 2001 12:43:40 +0100
Subject: [Tutor] (no subject)
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF72@mbtlipnt02.btlabs.bt.co.uk>

> emacs has no modes

Oooh religious war flame bait ;-)
Try typing Esc x x in emacs and tell me it has no modes...

But I know what you mean and to all intents and purposes 
its true.

> Personally I am used to Emacs commands, and I use jed, which 
> is a small editor 

Yes, good option, I forgot jed and it does do syntax 
highlighting too ISTR.

> I've heard that vi can actually be programmed in Python, 

vim has such a build but I've never usede it.

> heard rumours of the same for Emacs.

That would be much more difficult to do - unless somebody 
implemented a python intrerpreter in lisp... However its 
true the emacs folks are looking at replacing elisp with 
Guile/Common Lisp/Scheme but I haven't heard of any moves 
to a more radical departiure - it would just break too 
many lisp modules... 

Anyone got any more info on Python programmed emacs?

Alan G


From ajaya@ncoretech.com  Tue Sep 18 12:47:15 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Tue, 18 Sep 2001 17:17:15 +0530
Subject: [Tutor] (no subject)
Message-ID: <001001c14037$a9e39d90$6501a8c0@ncoretech.com>

Hi All,
I am using Python2.1 with Red Hat Linux 7.1 with Tkinter and Pmw modules.
But Now I need to test those modules with  Redhat 6.2, I serched for the
rpms in the http://www.python.org/2.1.1/rpms.html but I found only rpms
related to 7.1.1, can any one give the link to download the corresponding
rpms 6.1.1

RPMs i need is

Python, Tkinter, Pmw...,

Thanks and regards,
Ajaya



From scarblac@pino.selwerd.nl  Tue Sep 18 12:56:43 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Tue, 18 Sep 2001 13:56:43 +0200
Subject: [Tutor] (no subject)
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF72@mbtlipnt02.btlabs.bt.co.uk>; from alan.gauld@bt.com on Tue, Sep 18, 2001 at 12:43:40PM +0100
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF72@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <20010918135643.A26455@pino.selwerd.nl>

On  0, alan.gauld@bt.com wrote:
> That would be much more difficult to do - unless somebody 
> implemented a python intrerpreter in lisp... However its 
> true the emacs folks are looking at replacing elisp with 
> Guile/Common Lisp/Scheme but I haven't heard of any moves 
> to a more radical departiure - it would just break too 
> many lisp modules... 
> 
> Anyone got any more info on Python programmed emacs?

I was thinking of this mail by François Pinard, of which I only saw a
headline at the daily Python-URL:

http://groups.google.com/groups?selm=mailman.999616296.17057.python-list%40python.org

You can import python functions and call them as if they were elisp, e.g.

(import-python "os")
(os-listdir ".")

And you can eval strings of Python code. See the post.

(the daily Python URL is cool and is at http://www.secretlabs.com/daily/ )

-- 
Remco Gerlich


From lha2@columbia.edu  Tue Sep 18 13:49:14 2001
From: lha2@columbia.edu (Lloyd Hugh Allen)
Date: Tue, 18 Sep 2001 08:49:14 -0400
Subject: [Tutor] Squaring And Things Like That
References: <E15jGrK-0007s3-00@mail.python.org>
Message-ID: <3BA742CA.A0E7D2E6@mail.verizon.net>

If you want to use exponents, the symbol "**" means "raised to the". So

2**3 == 8
3**2 == 9
5**5 == 625
11**2 == 121

Don't use "^". That means something completely different (as I'm sure
you've figured out).

You'll also want to "import math" and then "dir(math)" to see what other
functions are available, and you can access them by doing stuff like

math.sqrt(25)
5.

math.pi
3.1415926535897931

math.pi * 5**2
78.539816339744831

and be careful that (for your purposes) you include a decimal point any
time that you do division--otherwise python will give you the integer
part of the quotient without the remainder (for the current version of
Python). So

10/3
3

while

10./3
3.333333333333335

and you know that the last "5" is nonsense. If you want go ahead and use
integer division and recover the remainder so as to express your answer
as a mixed number, you can do

10/3
3

10%3
1

and know that the answer is three and one third (you will always use the
remainder as the numerator and the divisor as the denominator). 

Assuming that you have Python 2.1.

Good luck and stuff.

> From: "Louie Montelongo" <slim_bizkit2001@sbcglobal.net>
> To: <tutor@python.org>
> Date: Mon, 17 Sep 2001 18:36:22 -0500
> Subject: [Tutor] (no subject)
> 
> This is a multi-part message in MIME format.
> 
> ------=_NextPart_000_0005_01C13FA7.A64347C0
> Content-Type: text/plain;
>         charset="iso-8859-1"
> Content-Transfer-Encoding: quoted-printable
> 
> I Use Python For School Work But I Don't Know How To Use It For Squaring =
> And Thngs Like That
> Please Help Me   =20
>                                                          Louie =
> Montelongo


From lkvam@venix.com  Tue Sep 18 14:33:52 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Tue, 18 Sep 2001 09:33:52 -0400
Subject: [Tutor] Python and mail
References: <13DE41E0207@kserver.org>
 <Pine.LNX.4.33.0109172035370.16118-100000@fleet1.paxp.com> <20010917220508.C1931@hudson>
Message-ID: <3BA74D40.8151F70D@venix.com>

I have no experience with this module, but MimeWriter is documented in
Fredrik Lundh's book, "Python Standard Library".  The sample snippet of code looks very straight forward.

dman wrote:
> 
> On Mon, Sep 17, 2001 at 08:38:07PM -0400, fleet@teachout.org wrote:
> | Thanks, Sheila.  Yes, I think this will help!  It looks like I will need
> | to forego the binary logo (thumbnail) that I have been including - but I'm
> | not upset about that.
> 
> Take a look at 'metasend' in the 'mimetools' package (at least, that's
> what Debian and FreeBSD call the package).  It allows you to send
> attachments (as MIME types) from the command line.  'mail' only allows
> sending in-line text.  mutt can also send MIME attachments (using the
> '-a' option).
> 
> HTH,
> -D
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582


From urnerk@qwest.net  Tue Sep 18 15:32:47 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Tue, 18 Sep 2001 07:32:47 -0700
Subject: [Tutor] (no subject)
In-Reply-To: <001801c1401d$d0cdebf0$6501a8c0@ncoretech.com>
Message-ID: <4.2.0.58.20010918073238.00bfd8e0@pop3.norton.antivirus>

At 02:12 PM 9/18/2001 +0530, Ajaya Babu wrote:

>Hi All,
>
>I am using python on windows with IDLE but I want to shift to Linux
>permanently. Can any one suggest me good editor which supports python,
>  like giving keywords in different colour and auto indentation ).

IDLE

Kirby



From urnerk@qwest.net  Tue Sep 18 15:36:13 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Tue, 18 Sep 2001 07:36:13 -0700
Subject: [Tutor] Emacs question
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF72@mbtlipnt02.btlabs
 .bt.co.uk>
Message-ID: <4.2.0.58.20010918073433.00c02cb0@pop3.norton.antivirus>

>
>Anyone got any more info on Python programmed emacs?
>
>Alan G

Yeah, if someone could go over quickly how to
mess with the colors and keywording especially,
for Python.  Some kind of "tag" file?  The
version of Xemacs I sometimes use doesn't know
about 'yield' and I think messes up the triple-
quote multi-line strings as well.

I did manage to hand-change my copy of Vi to
understand about 'yield' (a new keyword as of
2.2).

Kirby



From fleet@teachout.org  Tue Sep 18 15:39:57 2001
From: fleet@teachout.org (fleet@teachout.org)
Date: Tue, 18 Sep 2001 10:39:57 -0400 (EDT)
Subject: [Tutor] Python and mail
Message-ID: <Pine.LNX.4.33.0109181033000.17512-100000@fleet1.paxp.com>

> Take a look at 'metasend' in the 'mimetools' package (at least, that's
> what Debian and FreeBSD call the package).  It allows you to send
> attachments (as MIME types) from the command line.  'mail' only allows
> sending in-line text.  mutt can also send MIME attachments (using the
> '-a' option).

Thanks!  I checked out 'man metasend' and then noticed a reference to
'mailto,' which I also check in the man pages.  I think I'll try 'mailto.'
I'm assuming I can write a script (which Python can handle) to send the
files, including the thumbnail.

OT: I'm also thinking of trashing the logo and the html and going back to
pure text.  Most of my customers run Windows mail packages of one sort or
another, but that may change!

				- fleet -



From urnerk@qwest.net  Tue Sep 18 15:48:30 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Tue, 18 Sep 2001 07:48:30 -0700
Subject: [Tutor] More re IDLE in Linux
In-Reply-To: <4.2.0.58.20010918073238.00bfd8e0@pop3.norton.antivirus>
References: <001801c1401d$d0cdebf0$6501a8c0@ncoretech.com>
Message-ID: <4.2.0.58.20010918074339.00bfeb30@pop3.norton.antivirus>

I should add that if you want to use IDLE in Linux
you may find that the default font it gives you is
too small.  You can mess with default fonts in some
defaults file to make it bigger.  Also, if you
./configure, make, make install a version of Python,
it may not put an IDLE in place for you automatically.
The files you download will have it in a subdirectory
of the original tarball called /Tools I think it is.
Use Linux 'find' (one suggestion) to locate the IDLE
stuff.  Then copy "it" (a whole subdirectory actually)
to the appropriate place on your directory tree.

Kirby

At 07:32 AM 9/18/2001 -0700, Kirby Urner wrote:
>At 02:12 PM 9/18/2001 +0530, Ajaya Babu wrote:
>
>>Hi All,
>>
>>I am using python on windows with IDLE but I want
>>to shift to Linux permanently.



From shalehperry@home.com  Tue Sep 18 18:03:23 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Tue, 18 Sep 2001 10:03:23 -0700 (PDT)
Subject: [Tutor] Emacs question
In-Reply-To: <4.2.0.58.20010918073433.00c02cb0@pop3.norton.antivirus>
Message-ID: <XFMail.20010918100323.shalehperry@home.com>

On 18-Sep-2001 Kirby Urner wrote:
> 
>>
>>Anyone got any more info on Python programmed emacs?
>>
>>Alan G
> 
> Yeah, if someone could go over quickly how to
> mess with the colors and keywording especially,
> for Python.  Some kind of "tag" file?  The
> version of Xemacs I sometimes use doesn't know
> about 'yield' and I think messes up the triple-
> quote multi-line strings as well.
> 
> I did manage to hand-change my copy of Vi to
> understand about 'yield' (a new keyword as of
> 2.2).
> 

>From python-mode.el:
(defvar python-font-lock-keywords  
  (let ((kw1 (mapconcat 'identity
                        '("and"      "assert"   "break"   "class"
                          "continue" "def"      "del"     "elif"
                          "else"     "except"   "exec"    "for" 
                          "from"     "global"   "if"      "import"
                          "in"       "is"       "lambda"  "not"
                          "or"       "pass"     "print"   "raise" 
                          "return"   "while"
                          )
                        "\\|"))
        (kw2 (mapconcat 'identity
                        '("else:" "except:" "finally:" "try:")
                        "\\|"))
        )

Hope that helps.


From rfbrenar@cs.uchicago.edu  Tue Sep 18 18:22:24 2001
From: rfbrenar@cs.uchicago.edu (robert frank brenart)
Date: Tue, 18 Sep 2001 12:22:24 -0500 (CDT)
Subject: [Tutor] Symbol re question
Message-ID: <Pine.LNX.4.21.0109181217440.27295-100000@abyss.cs.uchicago.edu>

Alright, this should be easy and it's being a pain... I just want to find
out if my string is all numbers.

So I run...
if ((re.match("[0-9]+", mystring)) != None):
	print "Pass"
else:
	print "Fail"

But that matches things like 10:45 and 3f, which I don't want it
to.  What'm I overlooking?

-Rob



From shalehperry@home.com  Tue Sep 18 18:32:27 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Tue, 18 Sep 2001 10:32:27 -0700 (PDT)
Subject: [Tutor] Symbol re question
In-Reply-To: <Pine.LNX.4.21.0109181217440.27295-100000@abyss.cs.uchicago.edu>
Message-ID: <XFMail.20010918103227.shalehperry@home.com>

On 18-Sep-2001 robert frank brenart wrote:
> 
> Alright, this should be easy and it's being a pain... I just want to find
> out if my string is all numbers.
> 
> So I run...
> if ((re.match("[0-9]+", mystring)) != None):
>       print "Pass"
> else:
>       print "Fail"
> 
> But that matches things like 10:45 and 3f, which I don't want it
> to.  What'm I overlooking?
> 

A regex matches any part of a string.  if you want the string to ONLY be
numbers you need to say so in the regex.  Try this:

r"^[0-9]+$"

that says "from the start of my string '^', match a string of numbers
'[0-9]+' then the end of string '$'".  The 'r' before the string tells python
to read this as a raw string and should be used before any regex string.


From lkvam@venix.com  Tue Sep 18 18:39:51 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Tue, 18 Sep 2001 13:39:51 -0400
Subject: [Tutor] Symbol re question
References: <Pine.LNX.4.21.0109181217440.27295-100000@abyss.cs.uchicago.edu>
Message-ID: <3BA786E7.EB830159@venix.com>

You want "^[0-9]+$" for your regular expression ^ from the beginning $ to the end.

robert frank brenart wrote:
> 
> Alright, this should be easy and it's being a pain... I just want to find
> out if my string is all numbers.
> 
> So I run...
> if ((re.match("[0-9]+", mystring)) != None):
>         print "Pass"
> else:
>         print "Fail"
> 
> But that matches things like 10:45 and 3f, which I don't want it
> to.  What'm I overlooking?
> 
> -Rob
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582


From dyoo@hkn.eecs.berkeley.edu  Tue Sep 18 19:40:45 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 18 Sep 2001 11:40:45 -0700 (PDT)
Subject: [Tutor] Symbol re question
In-Reply-To: <XFMail.20010918103227.shalehperry@home.com>
Message-ID: <Pine.LNX.4.21.0109181136050.11411-100000@hkn.eecs.berkeley.edu>

On Tue, 18 Sep 2001, Sean 'Shaleh' Perry wrote:

> 
> On 18-Sep-2001 robert frank brenart wrote:
> > 
> > Alright, this should be easy and it's being a pain... I just want to find
> > out if my string is all numbers.
> > 
> > So I run...
> > if ((re.match("[0-9]+", mystring)) != None):
> >       print "Pass"
> > else:
> >       print "Fail"
> > 
> > But that matches things like 10:45 and 3f, which I don't want it
> > to.  What'm I overlooking?
> > 
> 
> A regex matches any part of a string.  if you want the string to ONLY be
> numbers you need to say so in the regex.  Try this:
> 
> r"^[0-9]+$"
> 
> that says "from the start of my string '^', match a string of numbers
> '[0-9]+' then the end of string '$'".  The 'r' before the string tells
> python to read this as a raw string and should be used before any
> regex string.


Somewhat related: be aware that "match" is somewhat different from
"search" in Python's regular expressions:

    http://www.python.org/doc/lib/matching-searching.html

If we're using the anchors '^' and '$', it might be good to use
re.search().



From kalle@gnupung.net  Tue Sep 18 20:40:19 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Tue, 18 Sep 2001 21:40:19 +0200
Subject: [Tutor] Emacs question
In-Reply-To: <4.2.0.58.20010918073433.00c02cb0@pop3.norton.antivirus>
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF72@mbtlipnt02.btlabs <4.2.0.58.20010918073433.00c02cb0@pop3.norton.antivirus>
Message-ID: <20010918214019.A1923@sandrew.lysator.liu.se>

[Kirby Urner]
> Yeah, if someone could go over quickly how to
> mess with the colors and keywording especially,
> for Python.  Some kind of "tag" file?  The
> version of Xemacs I sometimes use doesn't know
> about 'yield' and I think messes up the triple-
> quote multi-line strings as well.

yield:
Get a new python-mode.el, http://www.python.org/emacs/python-mode/.
You could edit your local copy to know about yield, but then you won't get the
other enhancements (if any).

multi-line strings:
These get weird if you have wuotes inside, but should work fine otherwise.
It Works For Me (tm).

Peace,
  Kalle
-- 
[ Thought control, brought to you by the WIPO! ]
[ http://anti-dmca.org/ http://eurorights.org/ ]


From michael@exasource.com  Tue Sep 18 21:33:48 2001
From: michael@exasource.com (Michael)
Date: Tue, 18 Sep 2001 14:33:48 -0600
Subject: [Tutor] Newbie Question?
Message-ID: <01091814334801.01432@orion.andromeda>

Hello,

I'm new to python and programming and have been through several lessons 
putting together programs using if, elif, else, while and for loops, etc.  
These are all math oriented programs.  I'm also working with Zope, (I'm a 
newbie on this too), and would like to be able to write programs for it to 
control logic decisions.

On my site I have a graphics version and a text version.  Currently, I'm 
using two separate headers, one for the text version and another for the 
graphics.  What I would like to be able to do is use one header for both and 
use python to control the logic of deciding which of two objects to execute 
based on the page the header is being called from.  I am using an index_html 
page for graphics and an index_text_html page for text.

I tried using dtml scripts to do this but have not had much luck.  The first 
one I tried was:

<dtml-if expr="index_text_html">
<dtml-var textnavbar_top>
<dtml-else>
<dtml-var navbar_top>
</dtml-if>

This script always executes the first command, <dtml-var textnavbar_top>,  no 
matter which page the header is being called from.  

Someone on the Zope list suggested that I try:

<dtml-if expr="id=='index_text_html'">
<dtml-var textnavbar_top>
<dtml-else>
<dtml-var navbar_top>`
</dtml-if>

This script always executes the second command, <dtml-var navbar_top>, no 
matter which page the header is being called from.

Can someone suggest a python script that might work in this situation?  I 
think if I can see how this works, I'll be able to use python for something 
besides a calculator.  I know how to write if/else statements but I'm not 
sure how to define the calling page.

Thanks,
-- 
Michael Lewis

       "Linux - The final solution"



From iconoclast@portalofevil.com  Tue Sep 18 22:02:47 2001
From: iconoclast@portalofevil.com (Empire Down )
Date: Tue, 18 Sep 2001 17:02:47 -0400
Subject: [Tutor] Copying file to multiple machines.
Message-ID: <200109181702.AA960758216@portalofevil.com>


I am new to python and am trying to copy a file from my machine to multiple machines on a network (98 machines) I know this can be done simply with a shell script but I have been wanting to learn Python and figured this would be somehting simple I could do, though it is turning out not to be so simple. I have Mark Hammond book.. but i think still need a little assistance. 

Thanks!
James M.


_________________________________________________________
Get your own FREE portalofevil.com Email account at...
http://www.evilemail.com

PortalofEvil.com - Websites by the insane for the insane.
_________________________________________________________




From ignacio@openservices.net  Tue Sep 18 22:52:20 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Tue, 18 Sep 2001 17:52:20 -0400 (EDT)
Subject: [Tutor] Copying file to multiple machines.
In-Reply-To: <200109181702.AA960758216@portalofevil.com>
Message-ID: <Pine.LNX.4.33.0109181738050.7239-100000@terbidium.openservices.net>

On Tue, 18 Sep 2001, Empire Down  wrote:

> I am new to python and am trying to copy a file from my machine to multiple machines on a network (98 machines) I know this can be done simply with a shell script but I have been wanting to learn Python and figured this would be somehting simple I could do, though it is turning out not to be so simple. I have Mark Hammond book.. but i think still need a little assistance.

You don't mention how you would do it with shell scripts, so I have no
background information to go on. With that in mind, here comes my zany
solution....

TCP/IP broadcasting/multicasting. On each of the client machines run a small
script that attaches to a socket and waits for an incoming connection. On your
server machine, you run a script that broadcasts/multicasts the filename
followed by the filecontents. The client then looks at the filename and dumps
the filecontents into the file.

The client will have to make sure that the connection is authenticated, and
that the filename isn't something important, like '/etc/passwd'.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>





From iconoclast@portalofevil.com  Tue Sep 18 23:13:14 2001
From: iconoclast@portalofevil.com (Empire Down )
Date: Tue, 18 Sep 2001 18:13:14 -0400
Subject: [Tutor] Copying file to multiple machines.
Message-ID: <200109181813.AA4048159046@portalofevil.com>

I am Sorry, I left out some info. OS is W2K adv Srv and I am admin on all the machines, all the machines are on a LAN, and the target path on all the machines are the same, all going to "all users" start up.

James   

On Tue, 18 Sep 2001, Empire Down  wrote:

>> I am new to python and am trying to copy a file from my >>machine to 
>> multiple machines on a network (98 machines) I know this >>can be done 
>> simply with a shell script but I have been wanting to learn >>Python and 
>> figured this would be somehting simple I could do, though it >>is 
>>turning out not to be so simple. I have Mark Hammond book.. >>but i 
>>think still need a little assistance.

>You don't mention how you would do it with shell scripts, so I >have no background information to go on. With that in mind, >here comes my zany solution....

>TCP/IP broadcasting/multicasting. On each of the client >machines run a small script that attaches to a socket and >waits for an incoming connection. On your server machine, you >run a script that broadcasts/multicasts the filename followed >by the filecontents. The client then looks at the filename and >dumps the filecontents into the file.

>The client will have to make sure that the connection is >authenticated, and that the filename isn't something >important, like '/etc/passwd'.

>-- 
>Ignacio Vazquez-Abrams  <ignacio@openservices.net>


_________________________________________________________
Get your own FREE portalofevil.com Email account at...
http://www.evilemail.com

PortalofEvil.com - Websites by the insane for the insane.
_________________________________________________________




From ignacio@openservices.net  Tue Sep 18 23:25:43 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Tue, 18 Sep 2001 18:25:43 -0400 (EDT)
Subject: [Tutor] Copying file to multiple machines.
In-Reply-To: <200109181813.AA4048159046@portalofevil.com>
Message-ID: <Pine.LNX.4.33.0109181821460.3454-100000@terbidium.openservices.net>

On Tue, 18 Sep 2001, Empire Down  wrote:

> I am Sorry, I left out some info. OS is W2K adv Srv and I am admin on all the machines, all the machines are on a LAN, and the target path on all the machines are the same, all going to "all users" start up.

In that case using a login script might be best. If all the machines have
Python installed then you can duplicate the effort that the copy command does,
but I can't see any good reason for it.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From lonetwin@yahoo.com  Wed Sep 19 06:56:14 2001
From: lonetwin@yahoo.com (lonetwin)
Date: Wed, 19 Sep 2001 11:26:14 +0530
Subject: [Tutor] Symbol re question
In-Reply-To: <Pine.LNX.4.21.0109181217440.27295-100000@abyss.cs.uchicago.edu>
References: <Pine.LNX.4.21.0109181217440.27295-100000@abyss.cs.uchicago.edu>
Message-ID: <01091911261400.05692@mercury.worli>

Hi Rob,

> Alright, this should be easy and it's being a pain... I just want to find
> out if my string is all numbers.
>
> So I run...
> if ((re.match("[0-9]+", mystring)) != None):
> <...snip...>
> to.  What'm I overlooking?
>
> -Rob

 How about :
================================================================
Python 2.0 (#1, Apr 11 2001, 19:18:08) 
[GCC 2.96 20000731 (Linux-Mandrake 8.0 2.96-0.48mdk)] on linux-i386
Type "copyright", "credits" or "license" for more information.
>>> import string
>>> for c in '43':
...     if c not in string.digits:
...             print 'fail'
...     else:
...             print 'pass'
... 
pass
pass
================================================================

I had done this once....just a thought,

-- 
Peace
Steve


From ajaya@ncoretech.com  Wed Sep 19 07:09:43 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Wed, 19 Sep 2001 11:39:43 +0530
Subject: [Tutor] New to Linux and facing path problems :?
Message-ID: <000f01c140d1$ae023f90$6501a8c0@ncoretech.com>

Hi,

I am new to Linux. I installed Pmw rpm in my directory tree. The problem I
am facing is from other directories I am not able to import this Pmw.

In windows I used to set path for this direcotory to solve this problem.

Please suggest me how to fix this problem.

Thanks and Regards,
Ajaya



From ignacio@openservices.net  Wed Sep 19 07:25:53 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Wed, 19 Sep 2001 02:25:53 -0400 (EDT)
Subject: [Tutor] New to Linux and facing path problems :?
In-Reply-To: <000f01c140d1$ae023f90$6501a8c0@ncoretech.com>
Message-ID: <Pine.LNX.4.33.0109190224440.13342-100000@terbidium.openservices.net>

On Wed, 19 Sep 2001, Ajaya Babu wrote:

> I am new to Linux. I installed Pmw rpm in my directory tree. The problem I
> am facing is from other directories I am not able to import this Pmw.

Where did you get this RPM? At Sourceforge they only have tarballs, and Google
doesn't show the existence of any PMW RPM.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From ajaya@ncoretech.com  Wed Sep 19 09:08:39 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Wed, 19 Sep 2001 13:38:39 +0530
Subject: [Tutor] New to Linux and facing path problems :?
In-Reply-To: <Pine.LNX.4.33.0109190224440.13342-100000@terbidium.openservices.net>
Message-ID: <001101c140e2$4ac537f0$6501a8c0@ncoretech.com>

Hi,
I am sorry I made a mistake...insted tar.....I used rpm by the way....now I
am able to  import it from any where I want...,

What I need to do is ...,

I need to untar Pwm to the usr/lib/python1.5(or 2.0)/site-packages/

Thanks allot for your response..

One more doubt I've


I want to install Python2.0 or onwards for the 6.1 linux... I am using
Redhat linux,
I searched in python.org site, but unfortunately I could only find python2.0
rpms for 7.1 onwards,

If you have any info please help me

Thanks and regards,
Ajaya

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Ignacio Vazquez-Abrams
Sent: Wednesday, September 19, 2001 11:56 AM
To: PythonTutorlist (E-mail)
Subject: Re: [Tutor] New to Linux and facing path problems :?


On Wed, 19 Sep 2001, Ajaya Babu wrote:

> I am new to Linux. I installed Pmw rpm in my directory tree. The problem I
> am facing is from other directories I am not able to import this Pmw.

Where did you get this RPM? At Sourceforge they only have tarballs, and
Google
doesn't show the existence of any PMW RPM.

--
Ignacio Vazquez-Abrams  <ignacio@openservices.net>


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From girishg@india.ti.com  Wed Sep 19 10:17:19 2001
From: girishg@india.ti.com (Girish Gajwani)
Date: Wed, 19 Sep 2001 14:47:19 +0530
Subject: [Tutor] Commenting a big block of code
Message-ID: <3BA8629F.62B9D344@india.ti.com>

Hi All,

I wish to comment out a big block of code. It is rather
painful to go and insert a "#" in front of each line of
code. 

Is there any "Block Comment" feature or perhaps someone
would just send me a VIM macro which I can use to select a
block of code in visual mode & then use some key mapped to
the macro & within a blink of an eye find all the lines
commented out.

For now, I am just cutting out these lines & putting them in
a temporary area from where I retrieve them as necessary.

Thanks 
Girish


From jyothi@ncoretech.com  Wed Sep 19 10:41:25 2001
From: jyothi@ncoretech.com (jyothi Guruprasanna)
Date: Wed, 19 Sep 2001 15:11:25 +0530
Subject: [Tutor] doubt .......
Message-ID: <NEBBKOPMNKJCOCOBFDKPOEJNCCAA.jyothi@ncoretech.com>

Hi,

	Is there any python Megawidget class which can display directory
istings( I mean treeview ).

Thanks and Regards,
Jyothi.



From girishg@india.ti.com  Wed Sep 19 11:33:34 2001
From: girishg@india.ti.com (Girish Gajwani)
Date: Wed, 19 Sep 2001 16:03:34 +0530
Subject: [Tutor] doubt .......
References: <3BA8739B.4325FDF5@india.ti.com>
Message-ID: <3BA8747E.BF5B1179@india.ti.com>

Check out

http://www.handshake.de/~dieter/pyprojects/treewidget.html

This link was available at the Vaults of Parnassus,
	http://www.vex.net/parnassus/
which is a Code repository for Python

I had earlier found a link to another treeview class, but
could not find it there today. 

HTH

Girish
	
> [Tutor] doubt .......
> 
> jyothi Guruprasanna jyothi@ncoretech.com
> Wed, 19 Sep 2001 15:11:25 +0530
> 
> 
> Hi,
> 
>         Is there any python Megawidget class which can display directory
> istings( I mean treeview ).
> 
> Thanks and Regards,
> Jyothi.
>


From alan.gauld@bt.com  Wed Sep 19 11:48:05 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 19 Sep 2001 11:48:05 +0100
Subject: [Tutor] Symbol re question
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF7F@mbtlipnt02.btlabs.bt.co.uk>

> >>> import string
> >>> for c in '43':
> ...     if c not in string.digits:
> ...             print 'fail'
> ...     else:
  ...             continue   # might be more useful?
  ... print "pass"

> pass

But the regex route is almost certainly more efficient 
and more flexible.

Alan G


From alan.gauld@bt.com  Wed Sep 19 11:54:37 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 19 Sep 2001 11:54:37 +0100
Subject: [Tutor] Commenting a big block of code
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF80@mbtlipnt02.btlabs.bt.co.uk>

> I wish to comment out a big block of code. It is rather
> painful to go and insert a "#" in front of each line of
> code. 
> 
> Is there any "Block Comment" feature or perhaps someone
> would just send me a VIM macro 

The brute force way in vi[m]:

:x,ys/^/# /

substitutes '# ' at the beginning of each line between x and y
x and y can be line numbers or a range or even a line marker...
In other words the usual way of working in vi...

Remove by using:

:x,ys/^# //

Alan G




From alan.gauld@bt.com  Wed Sep 19 12:06:33 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 19 Sep 2001 12:06:33 +0100
Subject: [Tutor] Copying file to multiple machines.
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF81@mbtlipnt02.btlabs.bt.co.uk>

> I am new to python and am trying to copy a file from my 
> machine to multiple machines on a network (98 machines) 

You have W2K they have Win98?

Do they have sharing turned on for the folders you want 
to copy to? If so you can use WSH to access the shared drives.
Hammonds book shows an example of this. Look under WSH.

However for this a simple CMD file would maybe be easier...
Although Python might make it easier to discover each 
machine in the network before running the scroipt with the 
machine name as a parameter - a hybrid approach?

Just some random thoughts.

Alan G.


From lkvam@venix.com  Wed Sep 19 14:32:04 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Wed, 19 Sep 2001 09:32:04 -0400
Subject: [Tutor] Newbie Question?
References: <01091814334801.01432@orion.andromeda>
Message-ID: <3BA89E54.536A923A@venix.com>

You will find it easier to learn Python first and then Zope.

Zope tries to make building your web site easier by automatically searching through the URL elements to find the items that are referenced in the HTML/DTML.  You normally use the same name for alternative items and count on the URLpath to find the
correct item.

In your case I think you want two items called header.
www.mysite.com/zoo/reptile	would get the graphic header
www.mysite.com/text/zoo/reptile	would find the text header

You will need to experiment a bit to find what works for you.  I am not actually using Zope right now, so I am not a thoroughly reliable source.  Hopefully, you can get good help from the Zope list.

Michael wrote:
> 
> Hello,
> 
> I'm new to python and programming and have been through several lessons
> putting together programs using if, elif, else, while and for loops, etc.
> These are all math oriented programs.  I'm also working with Zope, (I'm a
> newbie on this too), and would like to be able to write programs for it to
> control logic decisions.
> 
> On my site I have a graphics version and a text version.  Currently, I'm
> using two separate headers, one for the text version and another for the
> graphics.  What I would like to be able to do is use one header for both and
> use python to control the logic of deciding which of two objects to execute
> based on the page the header is being called from.  I am using an index_html
> page for graphics and an index_text_html page for text.
> 
> I tried using dtml scripts to do this but have not had much luck.  The first
> one I tried was:
> 
> <dtml-if expr="index_text_html">
> <dtml-var textnavbar_top>
> <dtml-else>
> <dtml-var navbar_top>
> </dtml-if>
> 
> This script always executes the first command, <dtml-var textnavbar_top>,  no
> matter which page the header is being called from.
> 
> Someone on the Zope list suggested that I try:
> 
> <dtml-if expr="id=='index_text_html'">
> <dtml-var textnavbar_top>
> <dtml-else>
> <dtml-var navbar_top>`
> </dtml-if>
> 
> This script always executes the second command, <dtml-var navbar_top>, no
> matter which page the header is being called from.
> 
> Can someone suggest a python script that might work in this situation?  I
> think if I can see how this works, I'll be able to use python for something
> besides a calculator.  I know how to write if/else statements but I'm not
> sure how to define the calling page.
> 
> Thanks,
> --
> Michael Lewis
> 
>        "Linux - The final solution"
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582


From ignacio@openservices.net  Wed Sep 19 14:45:08 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Wed, 19 Sep 2001 09:45:08 -0400 (EDT)
Subject: [Tutor] New to Linux and facing path problems :?
In-Reply-To: <001101c140e2$4ac537f0$6501a8c0@ncoretech.com>
Message-ID: <Pine.LNX.4.33.0109190942220.13342-100000@terbidium.openservices.net>

On Wed, 19 Sep 2001, Ajaya Babu wrote:

> What I need to do is ...,
>
> I need to untar Pwm to the usr/lib/python1.5(or 2.0)/site-packages/

cd /usr/lib/python1.5/site-packages
tar zxvf /path/to/tarball/Pmw.0.8.5.tar.gz

> I want to install Python2.0 or onwards for the 6.1 linux... I am using
> Redhat linux,
> I searched in python.org site, but unfortunately I could only find python2.0
> rpms for 7.1 onwards,

If you can, upgrade to 7.1. If not, then you might be better off installing
from tarball, although you can try the SRPM if you want. Oh, and install 2.1.1
instead of 2.0.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From shalehperry@home.com  Wed Sep 19 16:18:42 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Wed, 19 Sep 2001 08:18:42 -0700 (PDT)
Subject: [Tutor] Commenting a big block of code
In-Reply-To: <3BA8629F.62B9D344@india.ti.com>
Message-ID: <XFMail.20010919081842.shalehperry@home.com>

On 19-Sep-2001 Girish Gajwani wrote:
> Hi All,
> 
> I wish to comment out a big block of code. It is rather
> painful to go and insert a "#" in front of each line of
> code. 
> 
> Is there any "Block Comment" feature or perhaps someone
> would just send me a VIM macro which I can use to select a
> block of code in visual mode & then use some key mapped to
> the macro & within a blink of an eye find all the lines
> commented out.
> 
> For now, I am just cutting out these lines & putting them in
> a temporary area from where I retrieve them as necessary.
> 

if you could grab the excellent O'reilly vi book you would learn all of this
and more.  learning your editor can make you marvelously more productive,
regardless of the editor.


From girishg@india.ti.com  Wed Sep 19 16:26:48 2001
From: girishg@india.ti.com (Girish Gajwani)
Date: Wed, 19 Sep 2001 20:56:48 +0530
Subject: [Tutor] Commenting a big block of code
References: <XFMail.20010919081842.shalehperry@home.com>
Message-ID: <3BA8B938.B229ED7E@india.ti.com>

Well, Not that i am pretty bad at using vi ... Only thing
was that I was feeling too lazy to do something like that
;-)

Thanks for the advice though.
Best regards
Girish

Sean 'Shaleh' Perry wrote:
> 
> On 19-Sep-2001 Girish Gajwani wrote:
> > Hi All,
> >
> > I wish to comment out a big block of code. It is rather
> > painful to go and insert a "#" in front of each line of
> > code.
> >
> > Is there any "Block Comment" feature or perhaps someone
> > would just send me a VIM macro which I can use to select a
> > block of code in visual mode & then use some key mapped to
> > the macro & within a blink of an eye find all the lines
> > commented out.
> >
> > For now, I am just cutting out these lines & putting them in
> > a temporary area from where I retrieve them as necessary.
> >
> 
> if you could grab the excellent O'reilly vi book you would learn all of this
> and more.  learning your editor can make you marvelously more productive,
> regardless of the editor.


From ak@silmarill.org  Wed Sep 19 16:32:42 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Wed, 19 Sep 2001 11:32:42 -0400
Subject: [Tutor] Commenting a big block of code
In-Reply-To: <XFMail.20010919081842.shalehperry@home.com>
References: <3BA8629F.62B9D344@india.ti.com>
 <XFMail.20010919081842.shalehperry@home.com>
Message-ID: <20010919113242.A567@sill.silmarill.org>

On Wed, Sep 19, 2001 at 08:18:42AM -0700, Sean 'Shaleh' Perry wrote:
> 
> On 19-Sep-2001 Girish Gajwani wrote:
> > Hi All,
> > 
> > I wish to comment out a big block of code. It is rather
> > painful to go and insert a "#" in front of each line of
> > code. 
> > 
> > Is there any "Block Comment" feature or perhaps someone
> > would just send me a VIM macro which I can use to select a
> > block of code in visual mode & then use some key mapped to
> > the macro & within a blink of an eye find all the lines
> > commented out.
> > 
> > For now, I am just cutting out these lines & putting them in
> > a temporary area from where I retrieve them as necessary.
> > 
> 
> if you could grab the excellent O'reilly vi book you would learn all of this
> and more.  learning your editor can make you marvelously more productive,
> regardless of the editor.

There is a vim book out, too by steve oualline, who also wrote "practical
c" book.

> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From alan.gauld@bt.com  Wed Sep 19 17:08:42 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 19 Sep 2001 17:08:42 +0100
Subject: [Tutor] Commenting a big block of code
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF86@mbtlipnt02.btlabs.bt.co.uk>

> > if you could grab the excellent O'reilly vi book you would 
> 
> There is a vim book out, too by steve oualline, who also 

There's a very good vi tutor on the net. Its variously called 
teachvi or learnvi - they are the same thing. It runs under 
Bourne Shell on Unix - so by extension under Korn shell or 
Bash too. Which by further extension means it works on Windoze 
under cygwin...

The good thing is it really teaches the principles of operation 
of vi so that you can pretty much guess how things work even 
when you can't remember - vi really is intuitive once you 
understand the philospohy behind it.

Its plain vanilla vi but once you understand that vim is easy :-)

Alan g.


From girishg@india.ti.com  Wed Sep 19 17:14:12 2001
From: girishg@india.ti.com (Girish Gajwani)
Date: Wed, 19 Sep 2001 21:44:12 +0530
Subject: [Tutor] why do I not get a Window Title with the following?
Message-ID: <3BA8C454.460AF37B@india.ti.com>

Please check the following code:

#######################
#! /usr/bin/env  python 

import string
from Tkinter import *

root = Tk()
root.title="girish"
root.mainloop()
#######################

All I am trying  is to change the window title to something
else("girish", here)
I have seen some other code do something like this and work.
However, I could not get this even in this small piece of
code. Obviously I must be doing something silly :-). But i
could not find out what was the silly thing I was doing.

Please help

TIA
Girish
PS: I am trying to learn Tkinter


From rick@niof.net  Wed Sep 19 17:27:55 2001
From: rick@niof.net (Rick Pasotto)
Date: Wed, 19 Sep 2001 12:27:55 -0400
Subject: [Tutor] why do I not get a Window Title with the following?
In-Reply-To: <3BA8C454.460AF37B@india.ti.com>
References: <3BA8C454.460AF37B@india.ti.com>
Message-ID: <20010919122755.B28244@tc.niof.net>

On Wed, Sep 19, 2001 at 09:44:12PM +0530, Girish Gajwani wrote:
> Please check the following code:
> 
> #######################
> #! /usr/bin/env  python 
> 
> import string
> from Tkinter import *
> 
> root = Tk()
> root.title="girish"
> root.mainloop()
> #######################
> 
> All I am trying  is to change the window title to something
> else("girish", here)
> I have seen some other code do something like this and work.

"Something like this" doesn't cut it. Computers can be very picky.

What you want is root.title("girish")

-- 
And why do the political parties aspire to take over the direction
of education? Because they know the saying of Leibnitz: "Make me
the master of Education by governmental power, and I will
undertake to change the world". Education by governmental power,
then, is education by a political party, by a sect momentarily
triumphant; it is education on behalf of one idea, of one system,
to the exclusion of all others.
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net


From girishg@india.ti.com  Wed Sep 19 17:37:27 2001
From: girishg@india.ti.com (Girish Gajwani)
Date: Wed, 19 Sep 2001 22:07:27 +0530
Subject: [Tutor] why do I not get a Window Title with the following?
References: <3BA8C8F2.3D71D6DD@india.ti.com>
Message-ID: <3BA8C9C7.E3E6217C@india.ti.com>

> Rick Pasotto rick@niof.net
> Wed, 19 Sep 2001 12:27:55 -0400
> 
> ----------------------------------------------------------
> 
> On Wed, Sep 19, 2001 at 09:44:12PM +0530, Girish Gajwani wrote:
> > Please check the following code:
> >
> > #######################
> > #! /usr/bin/env  python
> >
> > import string
> > from Tkinter import *
> >
> > root = Tk()
> > root.title="girish"
> > root.mainloop()
> > #######################
> >
> > All I am trying  is to change the window title to something
> > else("girish", here)
> > I have seen some other code do something like this and work.
> 
> "Something like this" doesn't cut it. Computers can be very picky.
> 
> What you want is root.title("girish")
> 

Right!!!
Well, I must be sleepy :)
Thanks. You see the "title" looked more obvious to me as a
variable than as a function, and i did not copy-paste (my
fault)

Girish


From ravimails@lycos.com  Wed Sep 19 18:04:58 2001
From: ravimails@lycos.com (Ravikumar Devarajan)
Date: Wed, 19 Sep 2001 12:04:58 -0500
Subject: [Tutor] sockets
Message-ID: <DNMEICKMFPLJPAAA@mailcity.com>

hi all,
im trying to do the following in python
 i have 2 processes.i need them to communicate.and they will have to send and receive stuff till i close the connection.somehow this doesnt seem to work.im using sockets. and i want to know if theres any way by which i can keep the connection open as long as i want.i wud really appreciate any help in this regard.

thanks
Ravikumar 



Make a difference, help support the relief efforts in the U.S.
http://clubs.lycos.com/live/events/september11.asp


From girishg@india.ti.com  Wed Sep 19 18:50:06 2001
From: girishg@india.ti.com (Girish Gajwani)
Date: Wed, 19 Sep 2001 23:20:06 +0530
Subject: [Tutor] Commenting a big block of code
References: <3BA8629F.62B9D344@india.ti.com> <01091910395705.01245@gandalf>
Message-ID: <3BA8DACE.44DF102D@india.ti.com>

Yes, sure I could. I had thought of that. But I did not want
to use it 'coz I was thinking of some "Block commenting"
feature. But yes, this option was surely in mind.

I guess I could also try something like a "compile time
switch":
	if 0:
		Commented out portion
		of code, right shifted (for Python indentation
requirements)
		easily done by my editor (vim)
	else:
		Changes to the code
	endif

Regards
Girish

Bob Rea wrote:
> 
> On Wednesday 19 September 2001 02:17 am, you wrote:
> > Hi All,
> >
> > I wish to comment out a big block of code. It is rather
> > painful to go and insert a "#" in front of each line of
> > code.
> 
> Can't you just triple quote it at beginning and end? At
> least for now? In the long run, it would be the doc string,
> but isn't it ok temporarily?
> 
> --
> Bob Rea
> 
>         Fear of Hell is pernicious;
>                 So is fear of Heaven.
> 
> sfpetard@earthlink.net  home.earthlink.net/~rear


From dyoo@hkn.eecs.berkeley.edu  Wed Sep 19 19:05:40 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Wed, 19 Sep 2001 11:05:40 -0700 (PDT)
Subject: [Tutor] Commenting a big block of code
In-Reply-To: <3BA8629F.62B9D344@india.ti.com>
Message-ID: <Pine.LNX.4.21.0109191103450.8929-100000@hkn.eecs.berkeley.edu>

On Wed, 19 Sep 2001, Girish Gajwani wrote:

> I wish to comment out a big block of code. It is rather
> painful to go and insert a "#" in front of each line of
> code. 

For Emacs, block commenting can be done by highlighting the section, then
pressing:

    Ctrl c #

Uncommenting is similar:

    Ctrl - Ctrl c # 



From rnd@onego.ru  Wed Sep 19 20:58:59 2001
From: rnd@onego.ru (Roman Suzi)
Date: Wed, 19 Sep 2001 23:58:59 +0400 (MSD)
Subject: [Tutor] Commenting a big block of code
In-Reply-To: <Pine.LNX.4.21.0109191103450.8929-100000@hkn.eecs.berkeley.edu>
Message-ID: <Pine.LNX.4.30.0109192358270.21289-100000@rnd.onego.ru>

One more way to "comment" block:

'''
On Wed, 19 Sep 2001, Danny Yoo wrote:

>On Wed, 19 Sep 2001, Girish Gajwani wrote:
>
>> I wish to comment out a big block of code. It is rather
>> painful to go and insert a "#" in front of each line of
>> code.
>
>For Emacs, block commenting can be done by highlighting the section, then
>pressing:
>
>    Ctrl c #
>
>Uncommenting is similar:
>
>    Ctrl - Ctrl c #
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
'''

Sincerely yours, Roman Suzi
-- 
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd@onego.ru _/
_/ Wednesday, September 19, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "Shin: A device for finding furniture in the dark." _/



From SWidney@ci.las-vegas.nv.us  Wed Sep 19 22:50:26 2001
From: SWidney@ci.las-vegas.nv.us (Scott Widney)
Date: Wed, 19 Sep 2001 14:50:26 -0700
Subject: [Tutor] Copying file to multiple machines.
Message-ID: <D4EB5574F4A7D2119C9E00A0C9EA408D059F570C@sovereign.ci.las-vegas.nv.us>

> > I am new to python and am trying to copy a file from my 
> > machine to multiple machines on a network (98 machines) 
> 
> You have W2K they have Win98?
> 
> Do they have sharing turned on for the folders you want 
> to copy to? If so you can use WSH to access the shared drives.
> Hammonds book shows an example of this. Look under WSH.
> 
> However for this a simple CMD file would maybe be easier...
> Although Python might make it easier to discover each 
> machine in the network before running the scroipt with the 
> machine name as a parameter - a hybrid approach?
> 
> Just some random thoughts.

If this is a one time deal, take the quick and simple route. You may end up
spending a lot of time researching and fine-tuning (not to mention adding
error-checking and logging). It's only worth the effort if you're going to
be doing this frequently.

The copying process will be simple enough once you have a list of machine
names over which to iterate. From a command prompt, you could redirect NET
VIEW to a file to get a list of machine names (manual cleanup required).

i.e. C:\>NET VIEW > MACHINES.TXT

To get the list Pythonically, you need ActivePython or the win32 extensions.
Then you'd use the win32net module's NetServerEnum() function to get the
names (programmatic cleanup required).

Hint: look in \Python\win32\Lib\win32netcon.py for the SV_TYPE_* values.

The shutil module has the copy() function that you'll want to use.


From ignacio@openservices.net  Wed Sep 19 23:08:00 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Wed, 19 Sep 2001 18:08:00 -0400 (EDT)
Subject: [Tutor] Commenting a big block of code
In-Reply-To: <3BA8629F.62B9D344@india.ti.com>
Message-ID: <Pine.LNX.4.33.0109191805250.10457-100000@terbidium.openservices.net>

On Wed, 19 Sep 2001, Girish Gajwani wrote:

> Is there any "Block Comment" feature or perhaps someone
> would just send me a VIM macro which I can use to select a
> block of code in visual mode & then use some key mapped to
> the macro & within a blink of an eye find all the lines
> commented out.

Well, I bothered to go and do the research (and upgrade to vim 6.0aw in the
process), and here's what I came up with. Add the following lines to your
.vimrc:

---
vmap <F11> :-1/^#/s///<CR>
vmap <F12> :-1/^/s//#/<CR>
---

Go into visual mode, select the block, then press F12 to comment the block or
press F11 to uncomment the block.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From rufmetal@home.com  Thu Sep 20 03:29:03 2001
From: rufmetal@home.com (Chris Keelan)
Date: Wed, 19 Sep 2001 21:29:03 -0500
Subject: [Tutor] getopt examples
Message-ID: <01091921290300.00996@tygesen>

I've been scratching my head over the getopt module. I read the documentation 
and even scoured the source but can't quite figger out how the dang thing 
works. Anyone got a good code sample using getopt to take optional command 
line arguments for a script?

Thanks in advance.

- Chris


From lumbricus@gmx.net  Thu Sep 20 04:17:20 2001
From: lumbricus@gmx.net (Joerg Woelke)
Date: Thu, 20 Sep 2001 05:17:20 +0200
Subject: [Tutor] getopt examples
In-Reply-To: <01091921290300.00996@tygesen>; from rufmetal@home.com on Wed, Sep 19, 2001 at 09:29:03PM -0500
References: <01091921290300.00996@tygesen>
Message-ID: <20010920051720.A2555@Laplace.localdomain>

On Wed, Sep 19, 2001 at 09:29:03PM -0500, Chris Keelan wrote:
> I've been scratching my head over the getopt module. I read the documentation 
> and even scoured the source but can't quite figger out how the dang thing 
> works. Anyone got a good code sample using getopt to take optional command 
> line arguments for a script?

For example
"http://www.lowerstandard.com/python/strings.py" 
uses getopt.
I am sure, there are more :-)

> 
> Thanks in advance.
> 
> - Chris
> 

HTH,HAND
Greets J"o!

-- 
Truth never comes into the world but like a bastard, to the ignominy
of him that brought her birth.
		-- Milton


From ajaya@ncoretech.com  Thu Sep 20 05:02:42 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Thu, 20 Sep 2001 09:32:42 +0530
Subject: [Tutor] More re IDLE in Linux---Thanks
In-Reply-To: <4.2.0.58.20010918074339.00bfeb30@pop3.norton.antivirus>
Message-ID: <000901c14189$192b5600$6501a8c0@ncoretech.com>

Thanks allot now I am havig good development environment on Linux too.., It
might have taken more time with out your help..,

Thanks and Regards,
Ajaya

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Kirby Urner
Sent: Tuesday, September 18, 2001 8:19 PM
To: tutor@python.org
Cc: ajaya@ncoretech.com
Subject: [Tutor] More re IDLE in Linux



I should add that if you want to use IDLE in Linux
you may find that the default font it gives you is
too small.  You can mess with default fonts in some
defaults file to make it bigger.  Also, if you
./configure, make, make install a version of Python,
it may not put an IDLE in place for you automatically.
The files you download will have it in a subdirectory
of the original tarball called /Tools I think it is.
Use Linux 'find' (one suggestion) to locate the IDLE
stuff.  Then copy "it" (a whole subdirectory actually)
to the appropriate place on your directory tree.

Kirby

At 07:32 AM 9/18/2001 -0700, Kirby Urner wrote:
>At 02:12 PM 9/18/2001 +0530, Ajaya Babu wrote:
>
>>Hi All,
>>
>>I am using python on windows with IDLE but I want
>>to shift to Linux permanently.


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From dyoo@hkn.eecs.berkeley.edu  Thu Sep 20 07:48:40 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Wed, 19 Sep 2001 23:48:40 -0700 (PDT)
Subject: [Tutor] getopt examples
In-Reply-To: <01091921290300.00996@tygesen>
Message-ID: <Pine.LNX.4.21.0109192344250.23887-100000@hkn.eecs.berkeley.edu>

On Wed, 19 Sep 2001, Chris Keelan wrote:

> I've been scratching my head over the getopt module. I read the documentation 
> and even scoured the source but can't quite figger out how the dang thing 
> works. Anyone got a good code sample using getopt to take optional command 
> line arguments for a script?

Hi Chris!  I have a small example that uses getopt here:

    http://hkn.eecs.berkeley.edu/~dyoo/python/mmixviewer.py

I use it in the __main__ of my code.  Here's a brief fragment that should 
get you started:

###
options, args = getopt(argv[1:], 'bmcl', 'help')
for o, a in options:
    if o == '--help': _help()
    if o == '-l': linenumbering = 0
###

Hope this helps!



From neilb@nbt.co.za  Thu Sep 20 09:37:53 2001
From: neilb@nbt.co.za (Neil Beattie)
Date: Thu, 20 Sep 2001 10:37:53 +0200
Subject: [Tutor] Printing to a windows network printer
Message-ID: <NFBBKACIPKNFKAHLGHGBOECHCOAA.neilb@nbt.co.za>

Hi,
I am a newbie to Python and am looking for a pointer to example code for
printing from PythonWin 2.1.1  to a network printer from nt.

Thanks,
Neil



From danny.kohn@systematik.se  Thu Sep 20 10:11:46 2001
From: danny.kohn@systematik.se (Danny Kohn)
Date: Thu, 20 Sep 2001 11:11:46 +0200
Subject: [Tutor] Why use tuples?
Message-ID: <OGEPIJONPINEELIFKPBOIEDMDOAA.danny.kohn@systematik.se>

What I understand about the difference in functionality between lists =
and tuples is that tuples are restricted lists. But what why would I =
want to use tuples? What is the benifit?

H=E4lsningar / Regards                                 (\_/)  ))
Danny Kohn                 Tel: +46 (0)708 140 300  =3D('.')=3D//  Miau!
Systematik Consulting AB   ICQ: 1328817             ( ~~~ )/   Rrrrrui!
http://www.systematik.se   HAM: SM0NBJ              `w---w=B4=20




From SBrunning@trisystems.co.uk  Thu Sep 20 10:26:31 2001
From: SBrunning@trisystems.co.uk (Simon Brunning)
Date: Thu, 20 Sep 2001 10:26:31 +0100
Subject: [Tutor] Why use tuples?
Message-ID: <31575A892FF6D1118F5800600846864D78C1AA@intrepid>

> From:	Danny Kohn [SMTP:danny.kohn@systematik.se]
> What I understand about the difference in functionality between lists and
> tuples is that tuples are restricted lists. But what why would I want to
> use tuples? What is the benifit?
 
See <http://www.python.org/cgi-bin/faqw.py?req=all#6.15> on the FAQ.

What this *doesn't* seem to mention is that you can use an immutable tuple
as the key of a dictionary, whereas you cannot use a mutable list.

Cheers,
Simon Brunning
TriSystems Ltd.
sbrunning@trisystems.co.uk




-----------------------------------------------------------------------
The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.


From cerulean_rodent@yahoo.co.uk  Thu Sep 20 12:00:31 2001
From: cerulean_rodent@yahoo.co.uk (Cerulean Rodent)
Date: Thu, 20 Sep 2001 15:00:31 +0400 (MSD)
Subject: [Tutor] os.system refuses to print from a script
Message-ID: <Pine.LNX.4.21.0109201444490.6939-100000@ecosse.net>

Some data is written to file as the script goes about its business.

Printing the file from command line with

lpr filename

works just fine. Invoke the interpreter from the command line, get a
familiar prompt. Enter the following

import os

os.system('lpr filename') 

the file gets printed without a glitch. 

do the same from the script, and I get

lpr: unable to print file: client-error-bad-request

change os.system('lpr filename') for os.system('pwd') to check whether I'm
in the correct directory... I am. But lpr still returns an error when
invoked from a script (and so does lp, for that matter). 

I am probably overlooking something important - any ideas?

Cheerio, 

PM XXIII 

PS By the by, just how does one dump the results of one's meek attempts at
programming to Useless Python? Is it still available? All the links Google
returns for "useless python" are as dead as Spandau Ballet. 

-----------------------------------------------------
 
 " The stars go waltzing out in blue and red,
   And arbitrary blackness gallops in:
   I shut my eyes and all the world drops dead. "
  
    --Sylvia Plath

-----------------------------------------------------



From gyromagnetic@excite.com  Thu Sep 20 11:59:54 2001
From: gyromagnetic@excite.com (Leona Euler)
Date: Thu, 20 Sep 2001 03:59:54 -0700 (PDT)
Subject: [Tutor] capturing 'print'ed output and manipulating it
Message-ID: <6971677.1000983594516.JavaMail.imail@pokemon.excite.com>

Hi,
I'm calling a function written by someone else. This function basically
produces its output through a series of 'print' statements. I would like to
capture this output and manipulate it. To this end, I have written a wrapper
function that redirects stdout coming from the function into a StringIO
object like so:

def funcwrap(foo, arg):
    import sys, StringIO
    saved_stdout = sys.stdout
    sbuf = StringIO.StringIO()
    sys.stdout = sbuf                   # redirect stdout to the stringio
object
    foo(arg)                            # call function. output should now
go into sbuf
    result = sbuf.getvalue() 
    sys.stdout = saved_stdout           # clean up
    sbuf.close()
    return result

Is there a more efficient or direct way to do this?

Thanks.

-Brad





_______________________________________________________
http://inbox.excite.com




From non-feedback-1@lb.bcentral.com  Thu Sep 20 12:48:41 2001
From: non-feedback-1@lb.bcentral.com (Âçàèìîâûãäíîå ñîòðóäíè÷åñòâî.)
Date: 20 Sep 2001 11:48:41 -0000
Subject: [Tutor] Îòâåò íà çàïðîñ î ïðîäàæå è ïîêóïêå ïðîäóêöèè
Message-ID: <1000986521.16128.qmail@ech>

                   Óâàæàåìûå ãîñïîäà!

      Îðãàíèçàöèÿ ÎÎÎ “ÂÈÝËÜ-Ì” ïðåäëàãàåò Âàøåìó âíèìàíèþ ÷åòûðå  âèäà  íàøåé äåÿòåëüíîñòè: Ðàäèîýëåêòðîííûå êîìïëåêòóþùèå, ñâàðî÷íûå ýëåêòðîäû(à òàêæå àïïàðàòû ãàçâîäû), ìåòàëë è ýëåêòðîòåõíè÷åñêóþ ïðîäóêöèþ(ñþäà âõîäèò ïðîäàæà ëþñòðû ×èæåâñêîãî).
     
    Áîëåå ïîäðîáíî îçíàêîìèòüñÿ ñ íàøåé ïðîäóêöèåé, Âû ìîæåòå íà íàøåì ñàéòå â èíòåðíåò: www.viel.f2s.com 

    Áëàãîäàðÿ îáøèðíûì ñâÿçÿì ñ âåäóùèìè ïðîèçâîäèòåëÿìè è ïîñòàâùèêàìè íå òîëüêî â Ðîññèè, íî è çà ðóáåæîì, ìû èìååì âîçìîæíîñòü âûïîëíÿòü Âàøè çàêàçû íàèáîëåå ïîëíî è â êðàò÷àéøèå ñðîêè.
    Îáëàñòü ýëåêòðîíèêè, ýòî íå òîëüêî ïîñòàâêè ïðèáîðîâ, àïïàðàòóðû, íî è ðàçëè÷íûå êîìïëåêòóþùèå êàê îòå÷åñòâåííûõ, òàê è çàðóáåæíûõ ïðîèçâîäèòåëåé ýëåêòðîííîé òåõíèêè. Ýòî òàêèå ôèðìû êàê International Rectifier, Epcos, Bourns, Metex, unit-t è äð.
     Ñâàðî÷íûå ýëåêòðîäû: ìû ïðîäà¸ì ýëåêòðîäû îò âåäóùèõ îòå÷åñòâåííûõ ïðîèçâîäèòåëåé. Âñå ñâàðî÷íûå ýëåêòðîäû ñîîòâåòñòâóþò ÃÎÑÒó è èìåþò ñåðòèôèêàò êà÷åñòâà.
    
     Àïïàðàòû ãàçèðîâàííîé âîäû: ÀÃÂ, ÀÂ-2,ÀÂ-3, POST-MIX è äð. äëÿ îõëàæäåíèÿ è âûäà÷è ãàçèðîâàííûõ íàïèòêîâ â îôèñàõ, “ãîðÿ÷èõ” öåõàõ, íà ïðåäïðèÿòèÿõ è ò.ä. 

    Ìåòàëë : Ïðåäëàãàåì Õ/Ê è Ã/Ê ëèñòîâîé ìåòàëëîïðêàò.
     
    Ñâåòèëüíèêè:  Ïî ñàìûì íèçêèì öåíàì äëÿ äîìà,îôèñà, ñêâåðîâ è ïàðêîâ.

       íàñòîÿùåå âðåìÿ ìû ïðåäëàãàåì óíèêàëüíóþ ðàçðàáîòêó îòå÷åñòâåííûõ ó÷åíûõ:êîìïåíñèðóþùèå ïàòðóáêè äëÿ áåçñâàðíîãî ñîåäèíåíèÿ òðóá!!!(D îò 25 äî 1000ìì.)
   
     Íàøè ìåíåäæåðû èìåþò áîãàòûé îïûò ïðîäàæ, ìàðêåòèíãîâûõ èññëåäîâàíèé,âåäåíèÿ ïåðåãîâîðîâ ñ êðóïíûìè ïîñòàâùèêàìè è ïîòðåáèòåëÿìè òîâàðîâ,÷òî ïîçâîëÿåò íàì äîñòàòü íóæíóþ Âàì ïðîäóêöèþ ïî âûãîäíûì äëÿ Âàñ öåíàì è â îïòèìàëüíî êîðîòêèå ñðîêè.
     Âàøó ïîòðåáíîñòü â ïðîäóêöèè ïðåäñòàâëåííîé íà íàøåì ñàéòå, ìîæíî îòïðàâèòü íà íàø ôàêñ: (095) 275-89-94, èëè ïî ýëåêòðîííîé ïî÷òå:  vielmos@yahoo.com 
     
      Ìû æäåì Âàñ è âûðàæàåì óâåðåííîñòü â òîì, ÷òî îáðàòèâøèñü ê íàì, Âû ïîëó÷èòå êâàëèôèöèðîâàííóþ ïîìîùü, âíèìàòåëüíîå îòíîøåíèå ê Âàøèì ïîòðåáíîñòÿì, îïåðàòèâíóþ îáðàáîòêó Âàøåãî çàêàçà.

Ïî âñåì âîïðîñàì âû ìîæåòå îáðàùàòüñÿ ïî òåëåôîíàì  â ã. Ìîñêâà: (095) 275-89-94, 746-68-78.


_______________________________________________________________________
Powered by List Builder
To unsubscribe follow the link:
http://lb.bcentral.com/ex/manage/subscriberprefs?customerid=15203&subid=13B28172795AED1F&msgnum=1


From ajaya@ncoretech.com  Thu Sep 20 13:18:56 2001
From: ajaya@ncoretech.com (Anne Ajaya Babu)
Date: Thu, 20 Sep 2001 17:48:56 +0530
Subject: [Tutor] How to spawn python appliation from C interface in Linux
Message-ID: <3BA9DEB0.B4DE6E83@ncoretech.com>

Hi All,

I want to spawn the Python GUI appliation from C in linux. I am very new
to liux. What actually I want is I want to run the python appliation...,
after successfully started that application I should get the control.
How can I do this in linux.

Thanks allot,

with regards,
Ajaya



From baza_all@email.com  Thu Sep 20 16:45:59 2001
From: baza_all@email.com (All emails)
Date: Thu, 20 Sep 2001 18:45:59 +0300
Subject: [Tutor] Databases !!!
Message-ID: <E15k61s-0005kA-00@mail.python.org>

Íîâåéøèå ýêñêëþçèâíûå àâòîðñêèå ñåðòèôèöèðîâàííûå áàçû äàííûõ ýëåêòðîííûõ àäðåñîâ (Email) ñ ïðîãðàììîé ðàññûëêè:

- "ôèðìû Ìîñêâû"  - 22.500 àäðåñîâ (ñî âñòðîåííûì ðóáðèêàòîðîì) = 50$
- "âñå Emailû Ìîñêâû" - 42.000 àäðåñîâ (ïðåäûäóùèå ôèðìû + 19.500 áåç ðàçáèâêè) =70$
- "ôèðìû Ñàíêò-Ïåòåðáóðãà" (ñî âñòðîåííûì ðóáðèêàòîðîì) = 50$
- "ôèðìû Ðîññèè" (ñî âñòðîåííûì ðóáðèêàòîðîì) = 50$
- "ôèðìû ÑÍÃ" (ñî âñòðîåííûì ðóáðèêàòîðîì) = 50$
- "200.000 ýëåêòðîííûõ àäðåñîâ Ðîññèè è ÑÍÃ" (áåç ðàçáèâêè) = 50$

moscow_email@email.com



From non-feedback-2@lb.bcentral.com  Thu Sep 20 18:45:01 2001
From: non-feedback-2@lb.bcentral.com (Âçàèìîâûãäíîå ñîòðóäíè÷åñòâî.)
Date: 20 Sep 2001 17:45:01 -0000
Subject: [Tutor] ïÔ×ÅÔ ÎÁ ÚÁÐÒÏÓ Ï ÐÒÏÄÁÖÅ É ÐÏËÕÐËÅ ÐÒÏÄÕËÃÉÉ
Message-ID: <1001007901.5208.qmail@ech>

 kodirovra KOI-8R ili Kirilica(windows)
                
               õ×ÁÖÁÅÍÙÅ ÇÏÓÐÏÄÁ!

ïÒÇÁÎÉÚÁÃÉÑ ïïï &#8220;÷éüìø-í&#8221; ÐÒÅÄÌÁÇÁÅÔ ÷ÁÛÅÍÕ ×ÎÉÍÁÎÉÀ ÞÅÔÙÒÅ  ×ÉÄÁ  ÎÁÛÅÊ ÄÅÑÔÅÌØÎÏÓÔÉ: òÁÄÉÏÜÌÅËÔÒÏÎÎÙÅ ËÏÍÐÌÅËÔÕÀÝÉÅ, Ó×ÁÒÏÞÎÙÅ ÜÌÅËÔÒÏÄÙ(Á ÔÁËÖÅ ÁÐÐÁÒÁÔÙ ÇÁÚ×ÏÄÙ), ÍÅÔÁÌÌ É ÜÌÅËÔÒÏÔÅÈÎÉÞÅÓËÕÀ ÐÒÏÄÕËÃÉÀ(ÓÀÄÁ ×ÈÏÄÉÔ ÐÒÏÄÁÖÁ ÌÀÓÔÒÙ þÉÖÅ×ÓËÏÇÏ).

      âÏÌÅÅ ÐÏÄÒÏÂÎÏ ÏÚÎÁËÏÍÉÔØÓÑ Ó ÎÁÛÅÊ ÐÒÏÄÕËÃÉÅÊ, ÷Ù ÍÏÖÅÔÅ ÎÁ ÎÁÛÅÍ ÓÁÊÔÅ × ÉÎÔÅÒÎÅÔ: www.viel.f2s.com .

      âÌÁÇÏÄÁÒÑ ÏÂÛÉÒÎÙÍ Ó×ÑÚÑÍ Ó ×ÅÄÕÝÉÍÉ ÐÒÏÉÚ×ÏÄÉÔÅÌÑÍÉ É ÐÏÓÔÁ×ÝÉËÁÍÉ ÎÅ ÔÏÌØËÏ × òÏÓÓÉÉ, ÎÏ É ÚÁ ÒÕÂÅÖÏÍ, ÍÙ ÉÍÅÅÍ ×ÏÚÍÏÖÎÏÓÔØ ×ÙÐÏÌÎÑÔØ ÷ÁÛÉ ÚÁËÁÚÙ ÎÁÉÂÏÌÅÅ ÐÏÌÎÏ É × ËÒÁÔÞÁÊÛÉÅ ÓÒÏËÉ.
      
      ïÂÌÁÓÔØ ÜÌÅËÔÒÏÎÉËÉ, ÜÔÏ ÎÅ ÔÏÌØËÏ ÐÏÓÔÁ×ËÉ ÐÒÉÂÏÒÏ×, ÁÐÐÁÒÁÔÕÒÙ, ÎÏ É ÒÁÚÌÉÞÎÙÅ ËÏÍÐÌÅËÔÕÀÝÉÅ ËÁË ÏÔÅÞÅÓÔ×ÅÎÎÙÈ, ÔÁË É ÚÁÒÕÂÅÖÎÙÈ ÐÒÏÉÚ×ÏÄÉÔÅÌÅÊ ÜÌÅËÔÒÏÎÎÏÊ ÔÅÈÎÉËÉ. üÔÏ ÔÁËÉÅ ÆÉÒÍÙ ËÁË International Rectifier, Epcos, Bourns, Metex, unit-t É ÄÒ.
      ó×ÁÒÏÞÎÙÅ ÜÌÅËÔÒÏÄÙ: ÍÙ ÐÒÏÄÁ£Í ÜÌÅËÔÒÏÄÙ ÏÔ ×ÅÄÕÝÉÈ ÏÔÅÞÅÓÔ×ÅÎÎÙÈ ÐÒÏÉÚ×ÏÄÉÔÅÌÅÊ. ÷ÓÅ Ó×ÁÒÏÞÎÙÅ ÜÌÅËÔÒÏÄÙ ÓÏÏÔ×ÅÔÓÔ×ÕÀÔ çïóôÕ É ÉÍÅÀÔ ÓÅÒÔÉÆÉËÁÔ ËÁÞÅÓÔ×Á.

       áÐÐÁÒÁÔÙ ÇÁÚÉÒÏ×ÁÎÎÏÊ ×ÏÄÙ: áç÷, á÷-2,á÷-3, POST-MIX É ÄÒ. ÄÌÑ ÏÈÌÁÖÄÅÎÉÑ É ×ÙÄÁÞÉ ÇÁÚÉÒÏ×ÁÎÎÙÈ ÎÁÐÉÔËÏ× × ÏÆÉÓÁÈ, &#8220;ÇÏÒÑÞÉÈ&#8221; ÃÅÈÁÈ, ÎÁ ÐÒÅÄÐÒÉÑÔÉÑÈ É Ô.Ä. 
      
       íÅÔÁÌÌ : ðÒÅÄÌÁÇÁÅÍ è/ë É ç/ë ÌÉÓÔÏ×ÏÊ ÍÅÔÁÌÌÏÐÒËÁÔ.
       ó×ÅÔÉÌØÎÉËÉ:  ðÏ ÓÁÍÙÍ ÎÉÚËÉÍ ÃÅÎÁÍ ÄÌÑ ÄÏÍÁ,ÏÆÉÓÁ, ÓË×ÅÒÏ× É ÐÁÒËÏ×.

        îÁÛÉ ÍÅÎÅÄÖÅÒÙ ÉÍÅÀÔ ÂÏÇÁÔÙÊ ÏÐÙÔ ÐÒÏÄÁÖ, ÍÁÒËÅÔÉÎÇÏ×ÙÈ ÉÓÓÌÅÄÏ×ÁÎÉÊ,×ÅÄÅÎÉÑ ÐÅÒÅÇÏ×ÏÒÏ× Ó ËÒÕÐÎÙÍÉ ÐÏÓÔÁ×ÝÉËÁÍÉ É ÐÏÔÒÅÂÉÔÅÌÑÍÉ ÔÏ×ÁÒÏ×,ÞÔÏ ÐÏÚ×ÏÌÑÅÔ ÎÁÍ ÄÏÓÔÁÔØ ÎÕÖÎÕÀ ÷ÁÍ ÐÒÏÄÕËÃÉÀ ÐÏ ×ÙÇÏÄÎÙÍ ÄÌÑ ÷ÁÓ ÃÅÎÁÍ É × ÏÐÔÉÍÁÌØÎÏ ËÏÒÏÔËÉÅ ÓÒÏËÉ.
        
        ÷ÁÛÕ ÐÏÔÒÅÂÎÏÓÔØ × ÐÒÏÄÕËÃÉÉ ÐÒÅÄÓÔÁ×ÌÅÎÎÏÊ ÎÁ ÎÁÛÅÍ ÓÁÊÔÅ, ÍÏÖÎÏ ÏÔÐÒÁ×ÉÔØ ÎÁ ÎÁÛ ÆÁËÓ: (095) 275-89-94, ÉÌÉ ÐÏ ÜÌÅËÔÒÏÎÎÏÊ ÐÏÞÔÅ: vielmos@yahoo.com 

      íÙ ÖÄÅÍ ÷ÁÓ É ×ÙÒÁÖÁÅÍ Õ×ÅÒÅÎÎÏÓÔØ × ÔÏÍ, ÞÔÏ ÏÂÒÁÔÉ×ÛÉÓØ Ë ÎÁÍ, ÷Ù ÐÏÌÕÞÉÔÅ Ë×ÁÌÉÆÉÃÉÒÏ×ÁÎÎÕÀ ÐÏÍÏÝØ, ×ÎÉÍÁÔÅÌØÎÏÅ ÏÔÎÏÛÅÎÉÅ Ë ÷ÁÛÉÍ ÐÏÔÒÅÂÎÏÓÔÑÍ, ÏÐÅÒÁÔÉ×ÎÕÀ ÏÂÒÁÂÏÔËÕ ÷ÁÛÅÇÏ ÚÁËÁÚÁ.

ðÏ ×ÓÅÍ ×ÏÐÒÏÓÁÍ ×Ù ÍÏÖÅÔÅ ÏÂÒÁÝÁÔØÓÑ ÐÏ ÔÅÌÅÆÏÎÁÍ  × Ç. íÏÓË×Á: (095) 275-89-94, 746-68-78.



_______________________________________________________________________
Powered by List Builder
To unsubscribe follow the link:
http://lb.bcentral.com/ex/manage/subscriberprefs?customerid=15203&subid=589A002D010757E8&msgnum=2


From danny.kohn@systematik.se  Thu Sep 20 18:54:29 2001
From: danny.kohn@systematik.se (Danny Kohn)
Date: Thu, 20 Sep 2001 19:54:29 +0200
Subject: SV: [Tutor] Why use tuples?
In-Reply-To: <31575A892FF6D1118F5800600846864D78C1AA@intrepid>
Message-ID: <OGEPIJONPINEELIFKPBOGEEIDOAA.danny.kohn@systematik.se>

| -----Ursprungligt meddelande-----
| Fr=E5n: Simon Brunning [mailto:SBrunning@trisystems.co.uk]
| Skickat: den 20 september 2001 11:27

| > From:	Danny Kohn [SMTP:danny.kohn@systematik.se]
| > What I understand about the difference in functionality between=20
| lists and
| > tuples is that tuples are restricted lists. But what why would I =
want to
| > use tuples? What is the benifit?
| =20
| See <http://www.python.org/cgi-bin/faqw.py?req=3Dall#6.15> on the FAQ.
|=20
| What this *doesn't* seem to mention is that you can use an immutable =
tuple
| as the key of a dictionary, whereas you cannot use a mutable list.

Ok. But then again I can not use a tuple as an index which would have =
been natural for me to be able to with a datatype of this nature. So =
does the statement

if col[ColType] =3D=3D IU32:

where ColType is a tuple does not work. It is counter intuitive but I =
guess I have to get used to not using tuples.

Thanks anyhow.

/Danny



From ignacio@openservices.net  Thu Sep 20 19:03:27 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Thu, 20 Sep 2001 14:03:27 -0400 (EDT)
Subject: SV: [Tutor] Why use tuples?
In-Reply-To: <OGEPIJONPINEELIFKPBOGEEIDOAA.danny.kohn@systematik.se>
Message-ID: <Pine.LNX.4.33.0109201402240.14727-100000@terbidium.openservices.net>

On Thu, 20 Sep 2001, Danny Kohn wrote:

> Ok. But then again I can not use a tuple as an index which would have been natural for me to be able to with a datatype of this nature. So does the statement
>
> if col[ColType] == IU32:
>
> where ColType is a tuple does not work. It is counter intuitive but I guess I have to get used to not using tuples.

Have you _tried_ using a tuple as an index?

---
>>> a={}
>>> a[(1,2)]=3
>>> a
{(1, 2): 3}
>>>
---

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From danny.kohn@systematik.se  Thu Sep 20 21:08:14 2001
From: danny.kohn@systematik.se (Danny Kohn)
Date: Thu, 20 Sep 2001 22:08:14 +0200
Subject: SV: SV: [Tutor] Why use tuples?
In-Reply-To: <Pine.LNX.4.33.0109201402240.14727-100000@terbidium.openservices.net>
Message-ID: <OGEPIJONPINEELIFKPBOOEEJDOAA.danny.kohn@systematik.se>

Excuse be for being ignorant but this is the tutor group :-)

| -----Ursprungligt meddelande-----
| Fran: tutor-admin@python.org [mailto:tutor-admin@python.org]For =
Ignacio
| Vazquez-Abrams
| Skickat: den 20 september 2001 20:03

| > Ok. But then again I can not use a tuple as an index which=20
| would have been natural for me to be able to with a datatype of=20
| this nature. So does the statement
| >
| > if col[ColType] =3D=3D IU32:
| >
| > where ColType is a tuple does not work. It is counter intuitive=20
| but I guess I have to get used to not using tuples.
|=20
| Have you _tried_ using a tuple as an index?

Yes, in the above example. It didn't work out. Your example below is =
with a dictionary. I understand that it works there. But does it work =
generally thorughout Python and if so, how do I get it to work? I =
expected that it would make no difference to Python if ColType is an =
integer, a list element or a tuple. If this is so, please enlighten me.
=20
| ---
| >>> a=3D{}
| >>> a[(1,2)]=3D3
| >>> a
| {(1, 2): 3}
| >>>

/Danny



From ajaya@ncoretech.com  Thu Sep 20 21:55:33 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Fri, 21 Sep 2001 02:25:33 +0530
Subject: [Tutor] sockets
In-Reply-To: <DNMEICKMFPLJPAAA@mailcity.com>
Message-ID: <000a01c14216$97692a50$6501a8c0@ncoretech.com>

Hi,

I've not understand this problem fully. I really confused what is going
wrong.But any way I presume....that you are using sockets as a pipe to send
info between two process. For this they are many ways.

One way of doing this is using client server model using TCP sockets. It
gives reliable flow of information between end points.

Simple way of doing this is take one port common in both process

make a server in one thread like this

from socket import *

HOST = ''          #this is correct server will accept any host...,
PORT = 21568
BUFSIZ = 1024

ServerSocket = socket(AF_INET, SOCK_STREAM)

ServerSocket.bind((HOST, PORT))  #it takes tuple...as input
ServerSocket.listen()

while 1:
    data = ServerSocket.recv(BUFSIZ)  #it is just a example
    print data
    ServerSocket.send(data)




and in another process make a client like this

from socket import *
HOST = 'localhost'
PORT = 21568
BUFSIZ = 1024

ClientSocket = socket(AF_INET, SOCK_STREAM)
ClientSocket.connect((HOST, PORT))


while 1:
    data = raw_input('>')
    ClientSocket.send(data)


Some precautions...,

1. First you make sure that server starts ...this ensures that smooth
establishment
   of connections between these two.

2. Add your program to above server and client..., other wise it looks like
it got hung...,

3. Implement some kind of protocl between these two process I mean how to
shutdown the connection...and close..., what I do is I send command from
client to server or server to client then I close this connections dipend on
my data...,



Hope this helps..., If you have any specific doubt feel free.

with regards,
Ajaya babu



-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Ravikumar Devarajan
Sent: Wednesday, September 19, 2001 10:35 PM
To: tutor@python.org
Subject: [Tutor] sockets


hi all,
im trying to do the following in python
 i have 2 processes.i need them to communicate.and they will have to send
and receive stuff till i close the connection.somehow this doesnt seem to
work.im using sockets. and i want to know if theres any way by which i can
keep the connection open as long as i want.i wud really appreciate any help
in this regard.

thanks
Ravikumar



Make a difference, help support the relief efforts in the U.S.
http://clubs.lycos.com/live/events/september11.asp

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From ignacio@openservices.net  Thu Sep 20 22:09:55 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Thu, 20 Sep 2001 17:09:55 -0400 (EDT)
Subject: SV: SV: [Tutor] Why use tuples?
In-Reply-To: <OGEPIJONPINEELIFKPBOOEEJDOAA.danny.kohn@systematik.se>
Message-ID: <Pine.LNX.4.33.0109201706140.15504-100000@terbidium.openservices.net>

On Thu, 20 Sep 2001, Danny Kohn wrote:

> Excuse be for being ignorant but this is the tutor group :-)
>
> | -----Ursprungligt meddelande-----
> | Fran: tutor-admin@python.org [mailto:tutor-admin@python.org]For Ignacio
> | Vazquez-Abrams
> | Skickat: den 20 september 2001 20:03
>
> | > Ok. But then again I can not use a tuple as an index which
> | would have been natural for me to be able to with a datatype of
> | this nature. So does the statement
> | >
> | > if col[ColType] == IU32:
> | >
> | > where ColType is a tuple does not work. It is counter intuitive
> | but I guess I have to get used to not using tuples.
> |
> | Have you _tried_ using a tuple as an index?
>
> Yes, in the above example. It didn't work out. Your example below is with a dictionary. I understand that it works there. But does it work generally thorughout Python and if so, how do I get it to work? I expected that it would make no difference to Python if ColType is an integer, a list element or a tuple. If this is so, please enlighten me.

Ah, I see what you mean.

All sequence types (lists, tuples, or strings) can only use integers or slices
for indexes. Dictionaries can use any immutable type (integers, strings, or
tuples).

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From dyoo@hkn.eecs.berkeley.edu  Thu Sep 20 22:55:20 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 20 Sep 2001 14:55:20 -0700 (PDT)
Subject: [Tutor] Why use tuples?
In-Reply-To: <OGEPIJONPINEELIFKPBOIEDMDOAA.danny.kohn@systematik.se>
Message-ID: <Pine.LNX.4.21.0109201028480.31562-100000@hkn.eecs.berkeley.edu>

On Thu, 20 Sep 2001, Danny Kohn wrote:

> What I understand about the difference in functionality between lists
> and tuples is that tuples are restricted lists.

It's a little safer to say that tuples and lists are both "sequences",
things that have elements that we're able to pull out.  Strings are also
sequences, so all of these work:

###
>>> for x in (1, 2, 3): print x
... 
1
2
3
>>> for x in [1, 2, 3]: print x
... 
1
2
3
>>> for x in "123": print x
... 
1
2
3
###

Tuples conceptually do a similar thing with lists: they are containers
that hold values.



> But what why would I want to use tuples? What is the benefit?

Good question.  Python actually does quite a bunch of tuple stuff behind
our backs.  For example, when we do something like this:

###
>>> x, y = 1, 2  
>>> x
1
>>> y
2
###

... that's all tuples in the background doing the work.  What's happening
above is called "tuple assignment" because Python first constructs the
tuple (1, 2), and then pairwise assigns each value to its corresponding
variable.

Python also uses tuples whenever we want to return multiple values from a
function:

###
>>> def quadraticSolver(a, b, c):
...     """This is a function that solves the quadradic equation,
...        ax**2 + bx + c = 0"""
...     discriminant = math.sqrt(b**2 - 4 * a * c)
...     return (-b + discriminant)/(2*a), (-b - discriminant)/(2*a)
>>> quadraticSolver(5, 2, -3)
(0.59999999999999998, -1.0)
###

So tuples can be used by Python to quickly stuff multiple things into a
"single" container.


It's true that lists have more capabilities than tuples, but there's
something of an additional cost to them: they're more complicated because
they can do so much.  Lists have... let's see...

###
>>> dir([])
['append', 'count', 'extend', 'index', 'insert', 'pop', 'remove',
'reverse', 'sort']
###

... quite a few methods we can play with.  Tuples don't, but sometimes
simplicity is a good thing.


Compared to lists, tuples are very "lightweight": they support the very
minimum that a "sequence" should do, and because of that, they're
computationally cheaper to work with.  Tuples also correspond nicely with
the mathematical concept by the same name, so if you're a mathematician,
you'll feel right at home.  *grin*


But it's not necessarily a terrible thing if we get a tuple and want it as
a list: it's actually easy to go from tuples to lists and vice versa
because Python gives us a bunch of type-converting functions:

###
>>> secret_message = "hello world"
>>> list(secret_message)
['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']
>>> tuple(secret_message)
('h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd')
>>> list(tuple(list(secret_message)))
['h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd']
>>> ''.join(list(tuple(list(secret_message))))
'hello world'
###


If you have more questions, please feel free to ask.



From dyoo@hkn.eecs.berkeley.edu  Thu Sep 20 23:02:48 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 20 Sep 2001 15:02:48 -0700 (PDT)
Subject: SV: SV: [Tutor] Why use tuples?
In-Reply-To: <Pine.LNX.4.33.0109201706140.15504-100000@terbidium.openservices.net>
Message-ID: <Pine.LNX.4.21.0109201456390.4057-100000@hkn.eecs.berkeley.edu>

On Thu, 20 Sep 2001, Ignacio Vazquez-Abrams wrote:

> > | > Ok. But then again I can not use a tuple as an index which
> > | would have been natural for me to be able to with a datatype of
> > | this nature. So does the statement
> > | >
> > | > if col[ColType] == IU32:
> > | >
> > | > where ColType is a tuple does not work. It is counter intuitive
> > | but I guess I have to get used to not using tuples.
> > |
> > | Have you _tried_ using a tuple as an index?
> >
> > Yes, in the above example. It didn't work out. Your example below is with a dictionary. I understand that it works there. But does it work generally thorughout Python and if so, how do I get it to work? I expected that it would make no difference to Python if ColType is an integer, a list element or a tuple. If this is so, please enlighten me.
> 
> Ah, I see what you mean.
> 
> All sequence types (lists, tuples, or strings) can only use integers
> or slices for indexes. Dictionaries can use any immutable type
> (integers, strings, or tuples).


Yes.  One way we can see this is by trying:

###
>>> train_station = range(11)
>>> train_station
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> train_station[9.75]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: sequence index must be integer
###

It's very difficult to get to train_station Nine and Three Quarters
without magic...



From ignacio@openservices.net  Thu Sep 20 23:11:47 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Thu, 20 Sep 2001 18:11:47 -0400 (EDT)
Subject: SV: SV: [Tutor] Why use tuples?
In-Reply-To: <Pine.LNX.4.21.0109201456390.4057-100000@hkn.eecs.berkeley.edu>
Message-ID: <Pine.LNX.4.33.0109201810570.26328-100000@terbidium.openservices.net>

On Thu, 20 Sep 2001, Danny Yoo wrote:

> ###
> >>> train_station = range(11)
> >>> train_station
> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
> >>> train_station[9.75]
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: sequence index must be integer
> ###
>
> It's very difficult to get to train_station Nine and Three Quarters
> without magic...

Time to call Mr. Conductor!

(Sorry, I _had_ to say that ;) )

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From dyoo@hkn.eecs.berkeley.edu  Fri Sep 21 00:34:16 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 20 Sep 2001 16:34:16 -0700 (PDT)
Subject: [Tutor] How to spawn python appliation from C interface in Linux
In-Reply-To: <3BA9DEB0.B4DE6E83@ncoretech.com>
Message-ID: <Pine.LNX.4.21.0109201629370.6799-100000@hkn.eecs.berkeley.edu>

On Thu, 20 Sep 2001, Anne Ajaya Babu wrote:

> I want to spawn the Python GUI appliation from C in linux. I am very new
> to liux. What actually I want is I want to run the python appliation...,
> after successfully started that application I should get the control.
> How can I do this in linux.

Hmmm... will the C system() call be appropriate for this?  Try:

    man 3 system

at your command prompt, and documentation about the C system() call should
pop up.  I'm not sure if this is what you're looking for though.  
system() should allow you to run your Python program from C, and since
your program is graphical, you might want to run it in the "background".

On Unix, you can tell the system to run something in the background by
appending a '&' at the end of the command.  For example:

    $ do_hefty_processing &


One question: why do you want to run a Python program from C?


Good luck!



From dyoo@hkn.eecs.berkeley.edu  Fri Sep 21 00:39:08 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 20 Sep 2001 16:39:08 -0700 (PDT)
Subject: [Tutor] capturing 'print'ed output and manipulating it
In-Reply-To: <6971677.1000983594516.JavaMail.imail@pokemon.excite.com>
Message-ID: <Pine.LNX.4.21.0109201634240.6799-100000@hkn.eecs.berkeley.edu>

On Thu, 20 Sep 2001, Leona Euler wrote:

> I'm calling a function written by someone else. This function basically
> produces its output through a series of 'print' statements. I would like to
> capture this output and manipulate it. To this end, I have written a wrapper
> function that redirects stdout coming from the function into a StringIO
> object like so:
> 
> def funcwrap(foo, arg):
>     import sys, StringIO
>     saved_stdout = sys.stdout
>     sbuf = StringIO.StringIO()
>     sys.stdout = sbuf                   # redirect stdout to the stringio
> object
>     foo(arg)                            # call function. output should now
> go into sbuf
>     result = sbuf.getvalue() 
>     sys.stdout = saved_stdout           # clean up
>     sbuf.close()
>     return result
> 
> Is there a more efficient or direct way to do this?


Hmmm... I can't think of one offhand.  This wrapper looks good.  If we
want it to work on functions that can take multiple arguments, we can
generalize funcwrap() like this:

###
def funcwrap(foo, *args, **kwargs):
    import sys, StringIO
    saved_stdout = sys.stdout
    sbuf = StringIO.StringIO()
    sys.stdout = sbuf
    foo(*args, **kwargs)
    result = sbuf.getvalue() 
    sys.stdout = saved_stdout
    sbuf.close()
    return result
###



From fleet@teachout.org  Fri Sep 21 01:15:51 2001
From: fleet@teachout.org (fleet@teachout.org)
Date: Thu, 20 Sep 2001 20:15:51 -0400 (EDT)
Subject: [Tutor] poplib questions
Message-ID: <Pine.LNX.4.33.0109202014210.7990-100000@fleet1.paxp.com>

The pop3 mail retrieval module constructed from the example in poplib.py (see below) seems to
work REALLY well.  I have a couple of "newbie" type questions, though:

1. I need the mail to go to my /var/spool/mail/fleet file. (Linux RH 7.1)
Where should I open and close the file?  Open (for append) just before the
"for i in range" statement and close after "a.quit()" as I have it below?
Or should I open the file before the first getmail() call in the main
program and close it after the last one?  Does it make any difference?

2. Is there any reason for the three spaces before each line printed?

3. Do I have the "import" in the correct place or should it be in within
the function?

4. Are there any serious security concerns with this script (other than
the fact that the account names and passwords are in a text file)?

5. I've inserted some linefeeds, else the messages become one huge long
line in the "testbox"  file.  Is this going to mess up my procmail filter?

6. And, totally off topic, since there are no instructions activating
procmail in my fetchmail script, I'm assuming that procmail "guards" the
/var/spool/mail/fleet file and activates if anything shows up.  Am I
close?

7. Any suggestions to improve this would be greatly appreciated.

				- fleet -

++++++++++++++++++++++++++++++++++++++++++++
#! /usr/bin/python

import getpass, poplib

def getmail(MAILSERVER, USER, PASS):
   """Retrieves mail from pop3 servers"""

   a = poplib.POP3(MAILSERVER)
#   print a.getwelcome()
   a.user(USER)
   a.pass_(PASS)
   a.list()
   (numMsgs, totalSize) = a.stat()
   if numMsgs == 0:
      print "\nNo mail for "+USER+" at "+MAILSERVER
      return
   else:
      print "Retrieving "+`numMsgs`+" messages for "+USER+" at "+MAILSERVER
      f=open("testbox","a")
   for i in range(1, numMsgs + 1):
           (header, msg, octets) = a.retr(i)
           print "Message ", `i`, "("+`octets`+" octets)", ':'
           for line in msg:
                   f.write('   ' + line +"\n")
                   print ".",
#            dele(i)
#           f.write('\n-----------------------\n')
   a.quit()
   f.close()
   return

print "\n\n\n\n"
getmail("mail.server.com","fleet","secret")
getmail("mail.server.com","fleet1","secret")
getmail("mail.server.com","fleet2","secret")
getmail("mail.server.com","fleet3","secret")
getmail("mail.server.com","fleet4","secret")

++++++++++++++++++++++++++++++++++++++++++++++++++++++++



From ignacio@openservices.net  Fri Sep 21 01:36:07 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Thu, 20 Sep 2001 20:36:07 -0400 (EDT)
Subject: [Tutor] poplib questions
In-Reply-To: <Pine.LNX.4.33.0109202014210.7990-100000@fleet1.paxp.com>
Message-ID: <Pine.LNX.4.33.0109202024390.17299-100000@terbidium.openservices.net>

On Thu, 20 Sep 2001 fleet@teachout.org wrote:

> 1. I need the mail to go to my /var/spool/mail/fleet file. (Linux RH 7.1)
> Where should I open and close the file?  Open (for append) just before the
> "for i in range" statement and close after "a.quit()" as I have it below?
> Or should I open the file before the first getmail() call in the main
> program and close it after the last one?  Does it make any difference?

It doesn't matter as long as you expect to be the only program manipulating
it. See the answer to question 6 below.

> 2. Is there any reason for the three spaces before each line printed?

There shouldn't be.

> 3. Do I have the "import" in the correct place or should it be in within
> the function?

It's fine where it is.

> 4. Are there any serious security concerns with this script (other than
> the fact that the account names and passwords are in a text file)?

It accesses the mail file directly, so you could have a problem if more than
one program accesses it. See the answer to question 6 below.

> 5. I've inserted some linefeeds, else the messages become one huge long
> line in the "testbox"  file.  Is this going to mess up my procmail filter?

?

> 6. And, totally off topic, since there are no instructions activating
> procmail in my fetchmail script, I'm assuming that procmail "guards" the
> /var/spool/mail/fleet file and activates if anything shows up.  Am I
> close?

You're way, way off. When sendmail receives a message destined for a local
mailbox, it pipes it through procmail, and it's then procmail's job to open
the local mail file and dump the message into it.

> 7. Any suggestions to improve this would be greatly appreciated.

One thing that fetchmail as written by Eric S. Raymond does is that instead of
going through procmail, it dumps it to the local sendmail daemon. You might
want to look at using the smtplib module to do the same thing.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>




From SWidney@ci.las-vegas.nv.us  Fri Sep 21 02:42:00 2001
From: SWidney@ci.las-vegas.nv.us (Scott Widney)
Date: Thu, 20 Sep 2001 18:42:00 -0700
Subject: [Tutor] Copying file to multiple machines.
Message-ID: <D4EB5574F4A7D2119C9E00A0C9EA408D059F570F@sovereign.ci.las-vegas.nv.us>

> I am not sure if the other e-mail I wrote had gotten through 
> or not, so I try again. I would like to think I will only 
> have to do this once, but I doubt it. I am looking at the 
> shutil.py right now . I thought maybe something like this 
> could work, open and read src and write to dst?  
> 
> import sys
> import os
> 
> machines = [ " Machine Names " ]
> 
> source_file_path = sys.argv[1]
> dest_path = sys.argv[2]
> 
> source_file = open( source_file_path , "C:\\stuff\\remote.bat" )
> source_data = source_file.read()
> source_file.close()
> 
> for dest in machines :
>     dest_file = open( dest + "/" + dest_path , "\\C$\\Documents and
Settings\\All Users\\Start Menu\\Programs\\Startup" )
>     dest_file.write( source_data )
>     dest_file.close()
>  
> 
> The problem I am having is how to write a, I guess list and for loop for
the machines? I have the machine names already and I believe in Perl it
would be done like: 
> 
> for my $i (1..40) {
> 
>     my $machine = 'smbig0'. sprintf('2d,$i');
> 
>     #do copying and stuff
> 
> }
> 
>  
> 
> Thank you for your suggestions.
> 
>  
> 
> James

You're on the right track. Iterating over a list of machine names and
appending a pathname and filename is what I'd do....

I tend to do things from the Interactive Prompt, so I don't normally have an
argument list to read from; but here's my test run. Notice below that you
get the [list of machine names] in three lines that are very similar to the
three lines used to get your "source_data"....

src = 'C:\\stuff\\remote.bat'
machines = 'C:\\stuff\\list-of-names.txt'
# The machines file should have one name per line,
# including the leading double backslash
dest = '\\c$\\Documents and Settings\\All Users\\Start
Menu\\Programs\\Startup\\remote.bat'

# Read in the whole source file as one big string
src_file = open(src, 'r')
src_data = src_file.read()
src_file.close()

# Next, read in the whole machines file,
# returning each line as an item in a list
machine_file = open(machines, 'r')
machine_list = machine_file.readlines()
machines.close()

# Finally, iterate through your list,
# and create your target files
for eachPC in machine_list:
    # Create the file or overwrite an existing copy
    dest_file = open(eachPC[:-1] + dest, 'w')
    # The [:-1] slice operator eliminates the
    # newline character at the end of each item.
    # Then we append the destination to the name.
    dest_file.write(src_data)
    dest_file.close()

-----
Scott


From ajaya@ncoretech.com  Fri Sep 21 02:40:24 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Fri, 21 Sep 2001 07:10:24 +0530
Subject: FW: [Tutor] How to spawn python appliation from C interface in Linux
Message-ID: <000001c1423e$62c137c0$6501a8c0@ncoretech.com>

Thanks allot for your suggestions.

>>One question: why do you want to run a Python program from C?

I've earlier application..., for that I've added GUI. These two application
talk with each other using sockets. Here my Python application i client and
C is server..,

So I need to start C application first, After I go to the listen mode only I
want to start this python application...., It is for demo...to demonstrate
that I can write commmercial GUIs  in intime using Tkinter..,

Ok..., You may ask why cant python applicatin can be server...., Yes It can
be..,
But I am facing problem with python server mode..., Python select call is
not recognizing peersocket as a socket..it was giving exception. earlier
I've sent this to our mailing list.

My demo is today..., so I changed this for temparaly so that demo goes well.
But unfortunately...I've not got any answer for python select fucntin
problem.


Thanks allot for your great help.

with regards,
Ajaya






-----Original Message-----
From: Danny Yoo [mailto:dyoo@hkn.eecs.berkeley.edu]
Sent: Friday, September 21, 2001 5:04 AM
To: Anne Ajaya Babu
Cc: tutor@python.org
Subject: Re: [Tutor] How to spawn python appliation from C interface in
Linux


On Thu, 20 Sep 2001, Anne Ajaya Babu wrote:

> I want to spawn the Python GUI appliation from C in linux. I am very new
> to liux. What actually I want is I want to run the python appliation...,
> after successfully started that application I should get the control.
> How can I do this in linux.

Hmmm... will the C system() call be appropriate for this?  Try:

    man 3 system

at your command prompt, and documentation about the C system() call should
pop up.  I'm not sure if this is what you're looking for though.
system() should allow you to run your Python program from C, and since
your program is graphical, you might want to run it in the "background".

On Unix, you can tell the system to run something in the background by
appending a '&' at the end of the command.  For example:

    $ do_hefty_processing &


One question: why do you want to run a Python program from C?


Good luck!



From ramprasad@ncoretech.com  Fri Sep 21 07:32:14 2001
From: ramprasad@ncoretech.com (ramprasad)
Date: Fri, 21 Sep 2001 12:02:14 +0530
Subject: [Tutor] Re:sound in pyhton
Message-ID: <000e01c14267$27a7af10$e101a8c0@ncoretech.com>

This is a multi-part message in MIME format.

------=_NextPart_000_000B_01C14295.40AE9C70
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello All,

I want an sound module in pyhton. Is there any way that i can get the =
speaker sound in python. can anybody help or give some comments =
regarding this


Thanks in advance,
Ramprasad


------=_NextPart_000_000B_01C14295.40AE9C70
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello All,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I want&nbsp;an sound module in pyhton. =
Is there any=20
way that i can get the speaker sound in python. can anybody help or give =
some=20
comments regarding this</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks in advance,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Ramprasad</FONT></DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_000B_01C14295.40AE9C70--



From ignacio@openservices.net  Fri Sep 21 07:45:13 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Fri, 21 Sep 2001 02:45:13 -0400 (EDT)
Subject: [Tutor] Re:sound in pyhton
In-Reply-To: <000e01c14267$27a7af10$e101a8c0@ncoretech.com>
Message-ID: <Pine.LNX.4.33.0109210243190.21008-100000@terbidium.openservices.net>

On Fri, 21 Sep 2001, ramprasad wrote:

> I want an sound module in pyhton. Is there any way that i can get the speaker sound in python. can anybody help or give some comments regarding this

Under what operating system? There are different methods depending on whether
you're using Win32, Mac, or *nix.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From nidhi@ncoretech.com  Fri Sep 21 10:14:46 2001
From: nidhi@ncoretech.com (Sreenidhi.B.G)
Date: Fri, 21 Sep 2001 14:44:46 +0530
Subject: [Tutor] need some info on creating a Sound module
References: <Pine.LNX.4.21.0109192344250.23887-100000@hkn.eecs.berkeley.edu>
Message-ID: <3BAB0506.342DA926@ncoretech.com>

Hello All,

I want a sound module in pyhton. Is there any way in python , that using the
python builtins, i can produce sound.
can anybody help or give some comments regarding this


Thanks in advance,
sreenidhi,




From ramprasad@ncoretech.com  Fri Sep 21 10:52:35 2001
From: ramprasad@ncoretech.com (ramprasad)
Date: Fri, 21 Sep 2001 15:22:35 +0530
Subject: [Tutor] Re:sound in pyhton
References: <Pine.LNX.4.33.0109210243190.21008-100000@terbidium.openservices.net>
Message-ID: <000c01c14283$24188420$e101a8c0@ncoretech.com>

Hi Thanks,
I want sound for linux os can u find me one?
----- Original Message -----
From: Ignacio Vazquez-Abrams <ignacio@openservices.net>
To: <tutor@python.org>
Sent: Friday, September 21, 2001 12:15 PM
Subject: Re: [Tutor] Re:sound in pyhton


> On Fri, 21 Sep 2001, ramprasad wrote:
>
> > I want an sound module in pyhton. Is there any way that i can get the
speaker sound in python. can anybody help or give some comments regarding
this
>
> Under what operating system? There are different methods depending on
whether
> you're using Win32, Mac, or *nix.
>
> --
> Ignacio Vazquez-Abrams  <ignacio@openservices.net>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From nidhi@ncoretech.com  Fri Sep 21 11:23:13 2001
From: nidhi@ncoretech.com (Sreenidhi.B.G)
Date: Fri, 21 Sep 2001 15:53:13 +0530
Subject: [Tutor] Re:sound in pyhton
References: <Pine.LNX.4.33.0109210243190.21008-100000@terbidium.openservices.net> <000c01c14283$24188420$e101a8c0@ncoretech.com>
Message-ID: <3BAB1511.3A78E314@ncoretech.com>

Hi ,
is there a function equivavelent to beep in linux that will produce a beep

ramprasad wrote:

> Hi Thanks,
> I want sound for linux os can u find me one?
> ----- Original Message -----
> From: Ignacio Vazquez-Abrams <ignacio@openservices.net>
> To: <tutor@python.org>
> Sent: Friday, September 21, 2001 12:15 PM
> Subject: Re: [Tutor] Re:sound in pyhton
>
> > On Fri, 21 Sep 2001, ramprasad wrote:
> >
> > > I want an sound module in pyhton. Is there any way that i can get the
> speaker sound in python. can anybody help or give some comments regarding
> this
> >
> > Under what operating system? There are different methods depending on
> whether
> > you're using Win32, Mac, or *nix.
> >
> > --
> > Ignacio Vazquez-Abrams  <ignacio@openservices.net>
> >



From ramprasad@ncoretech.com  Fri Sep 21 12:53:57 2001
From: ramprasad@ncoretech.com (ramprasad)
Date: Fri, 21 Sep 2001 17:23:57 +0530
Subject: [Tutor] Re:sound with out sound card
Message-ID: <004d01c14294$1b89e720$e101a8c0@ncoretech.com>

This is a multi-part message in MIME format.

------=_NextPart_000_004A_01C142C2.326DF480
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello All,

I want to play sound in linux with out sound card. Is there any way that =
i can play the sound. We have SOUND AND NOSOUND  in dos in which we can =
specify frequency. do we have any such thing in linux. python supports =
sound in windows. wehave to import winsound and then we can play any =
wave files etc in that.Please can anybody help me out in solving  this =
problem.It will be of great help if i can getit ASAP

Thanks in advance,
Regards
Ramprasad

------=_NextPart_000_004A_01C142C2.326DF480
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello All,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I want to play sound in linux with out =
sound card.=20
Is there any way that i can play the sound. We have SOUND AND =
NOSOUND&nbsp; in=20
dos in which we can specify frequency. do we have any such thing in =
linux.=20
python supports sound in windows. wehave to import winsound and then we =
can play=20
any wave files etc in that.Please can anybody help me out in =
solving&nbsp; this=20
problem.It will be of great help if i can getit ASAP</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks in advance,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Regards</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Ramprasad</FONT></DIV></BODY></HTML>

------=_NextPart_000_004A_01C142C2.326DF480--



From alan.gauld@bt.com  Fri Sep 21 13:20:11 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 21 Sep 2001 13:20:11 +0100
Subject: [Tutor] poplib questions
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF92@mbtlipnt02.btlabs.bt.co.uk>

> Where should I open and close the file?  Open (for append) 
> just before the "for i in range" statement and close after 
> "a.quit()" as I have it below?

I'd leave it pretty much as is - definitely open outside 
any loops! But also add a try/finally block and call close 
inside the finally  section:


>    if numMsgs == 0:
>       print "\nNo mail for "+USER+" at "+MAILSERVER
>       return

coz you do a return here you don't really need the else:


>    else:
     
     try:
>       print "Retrieving "+`numMsgs`+" messages for "+USER+" 
> at "+MAILSERVER
>       f=open("testbox","a")
>       for i in range(1, numMsgs + 1):
>            (header, msg, octets) = a.retr(i)
>            print "Message ", `i`, "("+`octets`+" octets)", ':'
>            for line in msg:
>                    f.write('   ' + line +"\n")
>                    print ".",
> #            dele(i)
> #           f.write('\n-----------------------\n')
>        a.quit()
     finally:
	>    f.close()
>    return

Just a thought.

Alan G.


From dsh8290@rit.edu  Fri Sep 21 13:17:19 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 21 Sep 2001 08:17:19 -0400
Subject: [Tutor] Printing to a windows network printer
In-Reply-To: <NFBBKACIPKNFKAHLGHGBOECHCOAA.neilb@nbt.co.za>
References: <NFBBKACIPKNFKAHLGHGBOECHCOAA.neilb@nbt.co.za>
Message-ID: <20010921081719.A3167@hudson>

On Thu, Sep 20, 2001 at 10:37:53AM +0200, Neil Beattie wrote:
| Hi,
| I am a newbie to Python and am looking for a pointer to example code for
| printing from PythonWin 2.1.1  to a network printer from nt.

This probably isn't what you are looking for, but


printer = os.popen( "enscript //<host>/<printer>" )
printer.write( "Hello World" )
printer.close()
del printer


If you install the 'enscript' program you can print to windows
printers from the commandline, which also works from python via a
pipe.  I don't know any other way to programmatically print on a
windows system ( I don't think "copy /b <foo> LPT1" really counts )
but that is because I have no interest in windows programming and
haven't had the need yet.

-D



From dsh8290@rit.edu  Fri Sep 21 13:21:55 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 21 Sep 2001 08:21:55 -0400
Subject: [Tutor] os.system refuses to print from a script
In-Reply-To: <Pine.LNX.4.21.0109201444490.6939-100000@ecosse.net>
References: <Pine.LNX.4.21.0109201444490.6939-100000@ecosse.net>
Message-ID: <20010921082155.B3167@hudson>

On Thu, Sep 20, 2001 at 03:00:31PM +0400, Cerulean Rodent wrote:
| Some data is written to file as the script goes about its business.
| 
| Printing the file from command line with
| 
| lpr filename
| 
| works just fine. Invoke the interpreter from the command line, get a
| familiar prompt. Enter the following
| 
| import os
| os.system('lpr filename') 
| 
| the file gets printed without a glitch. 
| 
| do the same from the script, and I get
| 
| lpr: unable to print file: client-error-bad-request
| 
| change os.system('lpr filename') for os.system('pwd') to check whether I'm
| in the correct directory... I am. But lpr still returns an error when
| invoked from a script (and so does lp, for that matter). 

Hmm,  I'm not really certain on this, but I think that lpr may not be
setup quite right.  I use CUPS on my system, and I have found that
_sometimes_ I can use lp or lpr without specifying a destination and
other times it complains about it.  I haven't yet figured out how to
make it consistently default correctly (the config looks correct).  I
recommend researching lpr a bit to see what sort of conditions can
trigger that particular error message and then try and work back to
see how that condition was created in the script.

| PS By the by, just how does one dump the results of one's meek attempts at
| programming to Useless Python? Is it still available? All the links Google
| returns for "useless python" are as dead as Spandau Ballet. 

Send a mail to Rob Andrews.  He takes care of that.

HTH,
-D



From lumbricus@gmx.net  Fri Sep 21 16:11:01 2001
From: lumbricus@gmx.net (Joerg Woelke)
Date: Fri, 21 Sep 2001 17:11:01 +0200
Subject: [Tutor] Re:sound in pyhton
In-Reply-To: <3BAB1511.3A78E314@ncoretech.com>; from nidhi@ncoretech.com on Fri, Sep 21, 2001 at 03:53:13PM +0530
References: <Pine.LNX.4.33.0109210243190.21008-100000@terbidium.openservices.net> <000c01c14283$24188420$e101a8c0@ncoretech.com> <3BAB1511.3A78E314@ncoretech.com>
Message-ID: <20010921171101.A1490@Laplace.localdomain>

On Fri, Sep 21, 2001 at 03:53:13PM +0530, Sreenidhi.B.G wrote:
> Hi ,
> is there a function equivavelent to beep in linux that will produce a beep

print "\a"
?

HTH and Greets
J"o! :-)

-- 
You have the body of a 19 year old.  Please return it before it gets wrinkled.


From ignacio@openservices.net  Fri Sep 21 17:03:26 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Fri, 21 Sep 2001 12:03:26 -0400 (EDT)
Subject: [Tutor] Re:sound in pyhton
In-Reply-To: <000c01c14283$24188420$e101a8c0@ncoretech.com>
Message-ID: <Pine.LNX.4.33.0109211157270.2079-100000@terbidium.openservices.net>

On Fri, 21 Sep 2001, ramprasad wrote:

> Hi Thanks,
> I want sound for linux os can u find me one?

Go to

  http://www.vorbis.com/download_unix.psp

and get whatever copy of libao you feel comfortable with. NOTE: if you get the
binary RPM, then you also need to get the -devel RPM.

Then go to

  http://www.xiph.org/cvs.html

and follow the instructions to get the 'ao-python' module from CVS. The
download of ao-python available from the previous URL does not work with that
download of libao.

Install libao, then go to the directory where ao-python downloaded to and type
'python setup.py install'.

Then read the documentation and look at the code examples for both ao-python
and libao to learn how to use ao-python.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From dell2100@prodigy.net  Fri Sep 21 15:17:05 2001
From: dell2100@prodigy.net (David L. Lerner)
Date: Fri, 21 Sep 2001 14:17:05 -0000
Subject: [Tutor] IDLE Debug
References: <E15iRHt-0002HP-00@mail.python.org>
Message-ID: <004b01c142a8$1b630e20$18f163d8@pavilion>

Where can I get elementary info on IDLE Debug?  I mean, What is it, What
does it do, How do I use it, etc.?

I do not know how to use Go, Step, Over.  I've tried to use them, and I
don't know what I'm getting.

I looked for a basic intro on the web, and I can't find one.  I found an
intro to IDLE  by Danny Yoo,
http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html, but it is
incomplete.

Thank you.

David L. Lerner




From rob@jam.rr.com  Sat Sep 22 01:04:00 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Fri, 21 Sep 2001 19:04:00 -0500
Subject: [Tutor] Time Warner has bitten me fiercely.
Message-ID: <3BABD570.70900@jam.rr.com>

If anyone has sent email of any kind to Useless Python during the last 
week, please send it again.

Time Warner accidentally deleted my account during a nearly week-long 
outage in my area.

"Sorry, and we don't know how it happened, but your account was deleted, 
so all of your data is gone."

Woohoo, yippee,
Rob



From rmardo@yahoo.com  Sat Sep 22 09:11:58 2001
From: rmardo@yahoo.com (Rino Mardo)
Date: Sat, 22 Sep 2001 16:11:58 +0800
Subject: [Tutor] python newbie need help
Message-ID: <20010922161158.A296@amnesiac>

--XsQoSWH+UP9D9v3l
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

hi.  i have debian2.2r0 system with python-1.5.2 installed.  i went
thru the info doc of my python install and just can't seem to find out
why my code only runs in interactive mode and not from the shell.

Here is my code sample:

#! /usr/bin/python
# Euclid's method for finding a common factor of two numbers

 def faktor(a,b):
   while b !=3D 0:
       a, b =3D b, a % b
         return a


the code is named "test2.py" from the shell and i was able to import
it from the interactive python and was able to call and run it.  what
i want to do is run it from my shell.  what could i be missing?

thank you.

--=20
"If the only tool you have is a hammer, you tend to
see every problem as a nail." -- Abraham Maslow

--XsQoSWH+UP9D9v3l
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE7rEfO8JtvN2Ncyp0RAhGrAJ4vSOxd9ppqqcXa1DNKmYpzHAVAhQCeLq0Q
EevEYIuBC8kCVUMFxebdm+Y=
=/jSe
-----END PGP SIGNATURE-----

--XsQoSWH+UP9D9v3l--

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



From kalle@gnupung.net  Sat Sep 22 14:02:20 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Sat, 22 Sep 2001 15:02:20 +0200
Subject: [Tutor] python newbie need help
In-Reply-To: <20010922161158.A296@amnesiac>
References: <20010922161158.A296@amnesiac>
Message-ID: <20010922150220.A671@sverker.lysator.liu.se>

[Rino Mardo]
> hi.  i have debian2.2r0 system with python-1.5.2 installed.  i went
> thru the info doc of my python install and just can't seem to find out
> why my code only runs in interactive mode and not from the shell.
> 
> Here is my code sample:
> 
> #! /usr/bin/python
> # Euclid's method for finding a common factor of two numbers
> 
>  def faktor(a,b):
>    while b != 0:
>        a, b = b, a % b
>          return a

There are som indentation problems here:

def faktor(a,b):
    while b != 0:
        a, b = b, a % b
    return a

is probably what you want.

> the code is named "test2.py" from the shell and i was able to import
> it from the interactive python and was able to call and run it.  what
> i want to do is run it from my shell.  what could i be missing?

Have you set the executable bit (chmod +x test2.py)?  Otherwise I don't know.
What happens when you try to run it from the shell?

Peace,
  Kalle
-- 
[ Thought control, brought to you by the WIPO! ]
[ http://anti-dmca.org/ http://eurorights.org/ ]


From fleet@teachout.org  Sat Sep 22 17:46:18 2001
From: fleet@teachout.org (fleet@teachout.org)
Date: Sat, 22 Sep 2001 12:46:18 -0400 (EDT)
Subject: [Tutor] popmail script problem
Message-ID: <Pine.LNX.4.33.0109220953200.3995-100000@fleet1.paxp.com>

In my popmail script, the actual writing of the popmail message to a local
file occurs in the following code snippet.  In order to view progress of
the download, I wanted to "borrow" from the fetchmail program the idea of
"progress dots."  I was hoping to get a dot displayed on my monitor for
every line written to file, but it seems that the dots get stored until
the message transfer is completed, then they get dumped to the screen all
at once.

              for line in msg:
                      f.write('   ' + line +"\n")
                      print ".",

Would I have to open and close the file for each line in order to get what
I want?  Ie:

             for line in msg:
                     f=open("inbox","a")
                     f.write(line+"\n")
                     f.close
                     print ".",

This seems a bit harsh on the system somehow.




From alan.gauld@bt.com  Sat Sep 22 18:02:36 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sat, 22 Sep 2001 18:02:36 +0100
Subject: [Tutor] Printing to a windows network printer
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF93@mbtlipnt02.btlabs.bt.co.uk>

> pipe.  I don't know any other way to programmatically print on a
> windows system ( I don't think "copy /b <foo> LPT1" really counts )

You can use GDI to print in Windows for true WYSIWYG style output.
Thats how the Windows textbooks tell you to do it - wrap your normal 
screen onPaint method with a printer device context...

The winall MFC classes should provide all the support you need along 
with an MFC textbook but its horrid and nothing to do with Python 
its how Windows does printing thats horrible.

In practice I usually format my code an some markup type language 
and use os.system to print it:
in postscript using ghostscript
in pdf (using pdfgen) and adobe acrobat or ghostscript
in html using a browser
in RTF and using word or wordpad

HTML is easiest but least powerful. However its enough for most things.

Alan g


From alan.gauld@bt.com  Sat Sep 22 18:06:05 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sat, 22 Sep 2001 18:06:05 +0100
Subject: [Tutor] IDLE Debug
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF94@mbtlipnt02.btlabs.bt.co.uk>

> Where can I get elementary info on IDLE Debug?  I mean, What 
> is it, What
> does it do, How do I use it, etc.?

Unashamed plug coming up....

> I do not know how to use Go, Step, Over.  I've tried to use 
> them, and I don't know what I'm getting.

My book includes a chapter on debugging (as I have to admit 
do several others) :-)

http://www.crosswinds.net/~agauld

for pointers

Its one of the chapters not included on the web version(yet).

Alan g


From ignacio@openservices.net  Sat Sep 22 18:12:18 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Sat, 22 Sep 2001 13:12:18 -0400 (EDT)
Subject: [Tutor] popmail script problem
In-Reply-To: <Pine.LNX.4.33.0109220953200.3995-100000@fleet1.paxp.com>
Message-ID: <Pine.LNX.4.33.0109221311470.2924-100000@terbidium.openservices.net>

On Sat, 22 Sep 2001 fleet@teachout.org wrote:

> In my popmail script, the actual writing of the popmail message to a local
> file occurs in the following code snippet.  In order to view progress of
> the download, I wanted to "borrow" from the fetchmail program the idea of
> "progress dots."  I was hoping to get a dot displayed on my monitor for
> every line written to file, but it seems that the dots get stored until
> the message transfer is completed, then they get dumped to the screen all
> at once.

call system.stdout.flush() after each dot.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From lumbricus@gmx.net  Sat Sep 22 12:15:15 2001
From: lumbricus@gmx.net (Joerg Woelke)
Date: Sat, 22 Sep 2001 13:15:15 +0200
Subject: [Tutor] python newbie need help
In-Reply-To: <20010922161158.A296@amnesiac>; from rmardo@yahoo.com on Sat, Sep 22, 2001 at 04:11:58PM +0800
References: <20010922161158.A296@amnesiac>
Message-ID: <20010922131515.A2685@Laplace.localdomain>

On Sat, Sep 22, 2001 at 04:11:58PM +0800, Rino Mardo wrote:
> hi.  i have debian2.2r0 system with python-1.5.2 installed.  i went
> thru the info doc of my python install and just can't seem to find out
> why my code only runs in interactive mode and not from the shell.
> 
> Here is my code sample:
> 
> #! /usr/bin/python
> # Euclid's method for finding a common factor of two numbers
> 
>  def faktor(a,b):
>    while b != 0:
>        a, b = b, a % b
>          return a
> 
> 
> the code is named "test2.py" from the shell and i was able to import
> it from the interactive python and was able to call and run it.  what
> i want to do is run it from my shell.  what could i be missing?

You are missing the function main ;-)
Until now you defined a function (faktor) but you don't 
actually call it. add:

def main():
	# get arguments for faktor()
	# ...
	
	faktor(arg1,arg2)
	
	# print result or something
	# ...
	
# exec main
if __name__=="__main__":
	main()
	

PS:
Don't forget chmod(1) bzw. python <script>
:-)

> 
> thank you.
> 

HTH und Gruss
J"o!

-- 
If you wish to live wisely, ignore sayings -- including this one.


From ajaya@ncoretech.com  Sun Sep 23 12:42:27 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Sun, 23 Sep 2001 17:12:27 +0530
Subject: [Tutor] How to execute given script from the command line by just giving "python script.py" from different directories?
Message-ID: <000901c14424$d35c0860$6501a8c0@ncoretech.com>


Hi,

I am facing a small problem. I want to execute python script from any
directory in C: dirve..., I am working on both Linux and Windows. to test
this applications...

In linux I want to execute the python script which present in the directory
C:\python20\projects\VirtualHandset.. by  just typing
"python VirtualHandset.py" from the command line or from the process That I
start from the C routine...,

I am able to execute this script by giving obsolute path..., but If I try
from C:\python20 to execute this script it is giving python can not open
this file. I set the python.pth file path as
C:\python20\projects\VirtualHandset and also set the system environment
variable ...,

But it is telling still it can not open this file. Can any one suggest the
way I can  tell python interpretor that it should look the given directories
for the script file ?

Please give me some advise any help regarding would be great full to me...,

Thanks and Regards
Ajaya Babu



From ajaya@ncoretech.com  Sun Sep 23 12:52:23 2001
From: ajaya@ncoretech.com (Ajaya Babu)
Date: Sun, 23 Sep 2001 17:22:23 +0530
Subject: [Tutor] Probem using protocols ?? WM_DELETE_WINDOW
Message-ID: <000a01c14426$36181b00$6501a8c0@ncoretech.com>

Dear all great people,

Thanks allot for your continious help...,


I am facing a critical problem.  I am using Tkinter to create a GUI
application.., This GUI application talks to another application which
already tested.., using socket interface, When we press the destroy button
"x", on the top of the window
I would like to inform the other application running that I am exiting
(python application is exiting),,

For that I used protocol to trap the WM_DELETE_WINDOW message and doing
necessary clean up like this
    def Clenup(self):
        EventExit().Serialize(self.Pipe)
        self.Running = 0
        del self.Pipe
        self.root.destroy()

but this is not woking in Linux machine. Linux (7.1) and python 2.1, when I
do this the window simpy not going at all
insted it is getting hanged...only option I've is explicitly kill that
window..,

But when I more self.root.destroy  statement to the top of the function
suprisingly window is going immidiately..

What I am doing wrong. Please suggest some thing that I can fix this
problem...,

Thanks and Regards,
Ajaya Babu




From rmardo@yahoo.com  Sun Sep 23 17:17:00 2001
From: rmardo@yahoo.com (Rino Mardo)
Date: Mon, 24 Sep 2001 00:17:00 +0800
Subject: [Tutor] python newbie need help
In-Reply-To: <20010922125629.A3854@cruciatuz.de>
References: <20010922161158.A296@amnesiac> <20010922125629.A3854@cruciatuz.de>
Message-ID: <20010924001700.A372@amnesiac>

--VbJkn9YxBvnuCH5J
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sat, Sep 22, 2001 at 12:56:29PM -0400 or thereabouts, cruciatuz wrote:
>=20
<...snipped...>
> #!/usr/bin/env python
>=20
> def faktor(a,b):
>   while b !=3D 0:
>     a, b =3D b, a % b
>     return a
>=20
> if __name__ =3D=3D '__main__': # checks if the script is started as main
>   print faktor(13, 55)     # calls the function faktor(a, b)
> 					=09
thanks Stefan for that bit of info.  i have managed to make it work
and have actually moved on to accepting arguments from the command
line.

for my first actual python project i'm thinking of a utility to
archive my mails stored in a Maildir mailbox.  however, i'm finding it
difficult to find any reference as to what is the syntax should be for
most of python's modules.  take for example "os.system("cd "+dirName)"
the language reference nor the library has no mention of what the
syntax should for that command.  should i put a comma to separate the
arguments or no comma at all?  i think what i'm looking for something
similar to the syntax diagram of pascal.

is there something similar in python?

--=20
"GUIs normally make it simple to accomplish simple actions and impossible
to accomplish complex actions."   --Doug Gwyn  (22/Jun/91 in comp.unix.wiza=
rds)

--VbJkn9YxBvnuCH5J
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)

iD8DBQE7rgr88JtvN2Ncyp0RArWpAJ96nwTN4uEiCiv7CDin9U3kEHPw7ACfSSam
DssuYhCyx3wHYTyHY7fxcN0=
=xdxn
-----END PGP SIGNATURE-----

--VbJkn9YxBvnuCH5J--

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



From ignacio@openservices.net  Sun Sep 23 17:29:19 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Sun, 23 Sep 2001 12:29:19 -0400 (EDT)
Subject: [Tutor] python newbie need help
In-Reply-To: <20010924001700.A372@amnesiac>
Message-ID: <Pine.LNX.4.33.0109231225450.13319-100000@terbidium.openservices.net>

On Mon, 24 Sep 2001, Rino Mardo wrote:

> for my first actual python project i'm thinking of a utility to
> archive my mails stored in a Maildir mailbox.  however, i'm finding it
> difficult to find any reference as to what is the syntax should be for
> most of python's modules.  take for example "os.system("cd "+dirName)"
> the language reference nor the library has no mention of what the
> syntax should for that command.  should i put a comma to separate the
> arguments or no comma at all?  i think what i'm looking for something
> similar to the syntax diagram of pascal.

Well, here's the railroad diagram for os.system() if you really want it:

  ---<shell command>--->

os.system() actually runs its command in a subshell, so it may not be what
you're looking for. Try os.chdir() instead.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From alan.gauld@bt.com  Sun Sep 23 17:36:58 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sun, 23 Sep 2001 17:36:58 +0100
Subject: [Tutor] my web site
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF96@mbtlipnt02.btlabs.bt.co.uk>

Apologies to anyone trying to access my web tutor - Crosswinds' 
server has died again. Normal service will be resumed(*) ASAP.

Maybe sooner if I can get round to moving the site to a new
provider... but since I go on vacation tomorrow I doubt it!

Alan G

(*)Apparently they are going to reload FreeBSD. Dunno what 
they had been using but they seem distinctly unimpressed!


From ak@silmarill.org  Sun Sep 23 17:37:40 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Sun, 23 Sep 2001 12:37:40 -0400
Subject: [Tutor] python newbie need help
In-Reply-To: <20010924001700.A372@amnesiac>
References: <20010922161158.A296@amnesiac> <20010922125629.A3854@cruciatuz.de>
 <20010924001700.A372@amnesiac>
Message-ID: <20010923123740.A31375@sill.silmarill.org>

On Mon, Sep 24, 2001 at 12:17:00AM +0800, Rino Mardo wrote:
> On Sat, Sep 22, 2001 at 12:56:29PM -0400 or thereabouts, cruciatuz wrote:
> > 
> <...snipped...>
> > #!/usr/bin/env python
> > 
> > def faktor(a,b):
> >   while b != 0:
> >     a, b = b, a % b
> >     return a
> > 
> > if __name__ == '__main__': # checks if the script is started as main
> >   print faktor(13, 55)     # calls the function faktor(a, b)
> > 						
> thanks Stefan for that bit of info.  i have managed to make it work
> and have actually moved on to accepting arguments from the command
> line.
> 
> for my first actual python project i'm thinking of a utility to
> archive my mails stored in a Maildir mailbox.  however, i'm finding it
> difficult to find any reference as to what is the syntax should be for
> most of python's modules.  take for example "os.system("cd "+dirName)"
> the language reference nor the library has no mention of what the
> syntax should for that command.  should i put a comma to separate the
> arguments or no comma at all?  i think what i'm looking for something
> similar to the syntax diagram of pascal.
> 
> is there something similar in python?

Well, there are examples sprinkled throughout the docs, but this one
example that you give should be self-obvious: you pass the command to run
as an argument. Perhaps it would be easier to see if you made up the
string before passing it:

cmd = "ls " + dir
os.system(cmd)

If, on the other hand, it worked by taking in 2 arguments, one for the
command and the other one for arguments to that command, it would
explicitly say that it takes 2 arguments.

Some modules aren't documented much because info is readily available
elsewhere, for instance I'm looking through nntplib module and most
commands aren't explained in detail because they are covered in nntp rfc.

- Andrei 

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From runsun@bilbo.bio.purdue.edu  Mon Sep 24 18:24:47 2001
From: runsun@bilbo.bio.purdue.edu (runsun)
Date: Mon, 24 Sep 2001 12:24:47 -0500
Subject: [Tutor] Newbie (Argument; built-in modules)
In-Reply-To: <E15lYAO-0007Ja-00@mail.python.org>
Message-ID: <HEEGINKOFGFHODPACPPOCEMPCIAA.runsun@bilbo.bio.purdue.edu>

Hi All,

I am pretty new to python (only 2 days old). Can some one point some
directions for the following "puzzles" (to me they are :) ) :

1.

How can I pass arguments to a cgi from a browser url address box ?
For example, you type

	[..path..]/mypy.cgi?firstname=runsun&lastname=pan

I've tried a bit and managed to made a cgi:

http://expert.cc.purdue.edu/~runsun/python/argtest/argtestpy.cgi?A+Name:pan+
"test

but it has many limitions. For example, putting an "=" in the argument
disable the argument passing completely; and, some characters are
preceeded automatically during the argument passing with a "\" (for
example, http://...../~runsun is passed as http://...../\~runsun. Please
visit the above link for details.

2.

Where can I find a reference for all the built-in modules ?

Sincerely,
pan


======================================
      ~~ Be like water, be shapeless ~~
Runsun Pan, PhD, Biological Sci. Purdue Univ
Email: runsun@bilbo.bio.purdue.edu
Url : http://bilbo.bio.purdue.edu/~runsun
Tel : 765-496-4186(H), 765-494-4947 (O)
Fax : 775-665-1494 (USA) 094-656-8001 (Taiwan)
        (I can access both through my email)
======================================

 ] -----Original Message-----
 ] From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
 ] tutor-request@python.org
 ] Sent: Monday, September 24, 2001 11:01 AM
 ] To: tutor@python.org
 ] Subject: Tutor digest, Vol 1 #1105 - 4 msgs
 ]
 ]
 ] Send Tutor mailing list submissions to
 ] 	tutor@python.org
 ]
 ] 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@python.org
 ]
 ] You can reach the person managing the list at
 ] 	tutor-admin@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 newbie need help (Rino Mardo)
 ]    2. Re: python newbie need help (Ignacio Vazquez-Abrams)
 ]    3. my web site (alan.gauld@bt.com)
 ]    4. Re: python newbie need help (Andrei Kulakov)
 ]
 ] --__--__--
 ]
 ] Message: 1
 ] Date: Mon, 24 Sep 2001 00:17:00 +0800
 ] From: Rino Mardo <rmardo@yahoo.com>
 ] To: cruciatuz <sasoft@gmx.de>, tutor@python.org
 ] Subject: Re: [Tutor] python newbie need help
 ]
 ]
 ] --VbJkn9YxBvnuCH5J
 ] Content-Type: text/plain; charset=us-ascii
 ] Content-Disposition: inline
 ] Content-Transfer-Encoding: quoted-printable
 ]
 ] On Sat, Sep 22, 2001 at 12:56:29PM -0400 or thereabouts, cruciatuz wrote:
 ] >=20
 ] <...snipped...>
 ] > #!/usr/bin/env python
 ] >=20
 ] > def faktor(a,b):
 ] >   while b !=3D 0:
 ] >     a, b =3D b, a % b
 ] >     return a
 ] >=20
 ] > if __name__ =3D=3D '__main__': # checks if the script is
 ] started as main
 ] >   print faktor(13, 55)     # calls the function faktor(a, b)
 ] > 					=09
 ] thanks Stefan for that bit of info.  i have managed to make it work
 ] and have actually moved on to accepting arguments from the command
 ] line.
 ]
 ] for my first actual python project i'm thinking of a utility to
 ] archive my mails stored in a Maildir mailbox.  however, i'm finding it
 ] difficult to find any reference as to what is the syntax should be for
 ] most of python's modules.  take for example "os.system("cd "+dirName)"
 ] the language reference nor the library has no mention of what the
 ] syntax should for that command.  should i put a comma to separate the
 ] arguments or no comma at all?  i think what i'm looking for something
 ] similar to the syntax diagram of pascal.
 ]
 ] is there something similar in python?
 ]
 ] --=20
 ] "GUIs normally make it simple to accomplish simple actions and impossible
 ] to accomplish complex actions."   --Doug Gwyn  (22/Jun/91 in
 ] comp.unix.wiza=
 ] rds)
 ]
 ] --VbJkn9YxBvnuCH5J
 ] Content-Type: application/pgp-signature
 ] Content-Disposition: inline
 ]
 ] -----BEGIN PGP SIGNATURE-----
 ] Version: GnuPG v1.0.6 (GNU/Linux)
 ]
 ] iD8DBQE7rgr88JtvN2Ncyp0RArWpAJ96nwTN4uEiCiv7CDin9U3kEHPw7ACfSSam
 ] DssuYhCyx3wHYTyHY7fxcN0=
 ] =xdxn
 ] -----END PGP SIGNATURE-----
 ]
 ] --VbJkn9YxBvnuCH5J--
 ]
 ] _________________________________________________________
 ] Do You Yahoo!?
 ] Get your free @yahoo.com address at http://mail.yahoo.com
 ]
 ]
 ]
 ] --__--__--
 ]
 ] Message: 2
 ] Date: Sun, 23 Sep 2001 12:29:19 -0400 (EDT)
 ] From: Ignacio Vazquez-Abrams <ignacio@openservices.net>
 ] To: <tutor@python.org>
 ] Subject: Re: [Tutor] python newbie need help
 ]
 ] On Mon, 24 Sep 2001, Rino Mardo wrote:
 ]
 ] > for my first actual python project i'm thinking of a utility to
 ] > archive my mails stored in a Maildir mailbox.  however, i'm finding it
 ] > difficult to find any reference as to what is the syntax should be for
 ] > most of python's modules.  take for example "os.system("cd "+dirName)"
 ] > the language reference nor the library has no mention of what the
 ] > syntax should for that command.  should i put a comma to separate the
 ] > arguments or no comma at all?  i think what i'm looking for something
 ] > similar to the syntax diagram of pascal.
 ]
 ] Well, here's the railroad diagram for os.system() if you really want it:
 ]
 ]   ---<shell command>--->
 ]
 ] os.system() actually runs its command in a subshell, so it may
 ] not be what
 ] you're looking for. Try os.chdir() instead.
 ]
 ] --
 ] Ignacio Vazquez-Abrams  <ignacio@openservices.net>
 ]
 ]
 ]
 ] --__--__--
 ]
 ] Message: 3
 ] From: alan.gauld@bt.com
 ] To: tutor@python.org
 ] Date: Sun, 23 Sep 2001 17:36:58 +0100
 ] Subject: [Tutor] my web site
 ]
 ] Apologies to anyone trying to access my web tutor - Crosswinds'
 ] server has died again. Normal service will be resumed(*) ASAP.
 ]
 ] Maybe sooner if I can get round to moving the site to a new
 ] provider... but since I go on vacation tomorrow I doubt it!
 ]
 ] Alan G
 ]
 ] (*)Apparently they are going to reload FreeBSD. Dunno what
 ] they had been using but they seem distinctly unimpressed!
 ]
 ]
 ] --__--__--
 ]
 ] Message: 4
 ] Date: Sun, 23 Sep 2001 12:37:40 -0400
 ] From: Andrei Kulakov <sill@optonline.net>
 ] Subject: Re: [Tutor] python newbie need help
 ] To: tutor@python.org
 ] Reply-to: ak@silmarill.org
 ]
 ] On Mon, Sep 24, 2001 at 12:17:00AM +0800, Rino Mardo wrote:
 ] > On Sat, Sep 22, 2001 at 12:56:29PM -0400 or thereabouts,
 ] cruciatuz wrote:
 ] > >
 ] > <...snipped...>
 ] > > #!/usr/bin/env python
 ] > >
 ] > > def faktor(a,b):
 ] > >   while b != 0:
 ] > >     a, b = b, a % b
 ] > >     return a
 ] > >
 ] > > if __name__ == '__main__': # checks if the script is started as main
 ] > >   print faktor(13, 55)     # calls the function faktor(a, b)
 ] > >
 ] > thanks Stefan for that bit of info.  i have managed to make it work
 ] > and have actually moved on to accepting arguments from the command
 ] > line.
 ] >
 ] > for my first actual python project i'm thinking of a utility to
 ] > archive my mails stored in a Maildir mailbox.  however, i'm finding it
 ] > difficult to find any reference as to what is the syntax should be for
 ] > most of python's modules.  take for example "os.system("cd "+dirName)"
 ] > the language reference nor the library has no mention of what the
 ] > syntax should for that command.  should i put a comma to separate the
 ] > arguments or no comma at all?  i think what i'm looking for something
 ] > similar to the syntax diagram of pascal.
 ] >
 ] > is there something similar in python?
 ]
 ] Well, there are examples sprinkled throughout the docs, but this one
 ] example that you give should be self-obvious: you pass the command to run
 ] as an argument. Perhaps it would be easier to see if you made up the
 ] string before passing it:
 ]
 ] cmd = "ls " + dir
 ] os.system(cmd)
 ]
 ] If, on the other hand, it worked by taking in 2 arguments, one for the
 ] command and the other one for arguments to that command, it would
 ] explicitly say that it takes 2 arguments.
 ]
 ] Some modules aren't documented much because info is readily available
 ] elsewhere, for instance I'm looking through nntplib module and most
 ] commands aren't explained in detail because they are covered in nntp rfc.
 ]
 ] - Andrei
 ]
 ] --
 ] Cymbaline: intelligent learning mp3 player - python, linux, console.
 ] get it at: cy.silmarill.org
 ]
 ]
 ]
 ] --__--__--
 ]
 ] _______________________________________________
 ] Tutor maillist  -  Tutor@python.org
 ] http://mail.python.org/mailman/listinfo/tutor
 ]
 ]
 ] End of Tutor Digest
 ]



From ak@silmarill.org  Mon Sep 24 18:35:50 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Mon, 24 Sep 2001 13:35:50 -0400
Subject: [Tutor] Newbie (Argument; built-in modules)
In-Reply-To: <HEEGINKOFGFHODPACPPOCEMPCIAA.runsun@bilbo.bio.purdue.edu>
References: <E15lYAO-0007Ja-00@mail.python.org>
 <HEEGINKOFGFHODPACPPOCEMPCIAA.runsun@bilbo.bio.purdue.edu>
Message-ID: <20010924133550.A4139@sill.silmarill.org>

On Mon, Sep 24, 2001 at 12:24:47PM -0500, runsun wrote:
> Hi All,
> 
> I am pretty new to python (only 2 days old). Can some one point some
> directions for the following "puzzles" (to me they are :) ) :
> 
> 1.
> 
> How can I pass arguments to a cgi from a browser url address box ?
> For example, you type
> 
> 	[..path..]/mypy.cgi?firstname=runsun&lastname=pan
> 
> I've tried a bit and managed to made a cgi:
> 
> http://expert.cc.purdue.edu/~runsun/python/argtest/argtestpy.cgi?A+Name:pan+
> "test
> 
> but it has many limitions. For example, putting an "=" in the argument
> disable the argument passing completely; and, some characters are
> preceeded automatically during the argument passing with a "\" (for
> example, http://...../~runsun is passed as http://...../\~runsun. Please
> visit the above link for details.
> 
> 2.
> 
> Where can I find a reference for all the built-in modules ?

http://python.org/doc/current/lib/lib.html

Also, since you're new, do read all of the tutorial:

http://python.org/doc/current/tut/tut.html

- Andrei 

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From shalehperry@home.com  Mon Sep 24 18:41:20 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Mon, 24 Sep 2001 10:41:20 -0700 (PDT)
Subject: [Tutor] Newbie (Argument; built-in modules)
In-Reply-To: <HEEGINKOFGFHODPACPPOCEMPCIAA.runsun@bilbo.bio.purdue.edu>
Message-ID: <XFMail.20010924104120.shalehperry@home.com>

On 24-Sep-2001 runsun wrote:
> Hi All,
> 
> I am pretty new to python (only 2 days old). Can some one point some
> directions for the following "puzzles" (to me they are :) ) :
> 
> 1.
> 
> How can I pass arguments to a cgi from a browser url address box ?
> For example, you type
> 

better stated "how do cgi's work?".  Do a web search (www.google.com is your
friend) there are plenty of cgi docs out there.  Every language handles them in
mostly the same way.  There are also a python module or two for cgi handling.

> 
> 2.
> 
> Where can I find a reference for all the built-in modules ?
> 

On www.python.org in the Documentation area.  If you use UNIX there is also the
Info docs.  Another place for help is to actually look at the python modules
installed on your system.  Under linux they should be in /usr/lib/python...
I have a /usr/lib/python1.5/cgi.py on my system.  Reading these .py files can
also help you understand python better.


From phil.bertram@clear.net.nz  Mon Sep 24 19:46:47 2001
From: phil.bertram@clear.net.nz (Phil Bertram)
Date: Tue, 25 Sep 2001 06:46:47 +1200
Subject: [Tutor] Mime content types. Can you access this info from the os
Message-ID: <000901c14529$5da05990$d99ca7cb@pf05nt.bayernz.co.nz>

This is a multi-part message in MIME format.

------=_NextPart_000_0004_01C1458D.D8B04320
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi,

I am playing around with MimeWriter.py

Is ther any way to access the content type of a binary file (Windows =
NT4) that is being added to a MIME message as an attachment so the =
header can be created correctly.

e.g. 'application/vnd.ms-word' etc

Regards
Phil Bertram

------=_NextPart_000_0004_01C1458D.D8B04320
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Dwindows-1252">
<META content=3D"MSHTML 5.50.4134.600" name=3DGENERATOR></HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>Hi,</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>I am playing around with MimeWriter.py</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Is ther any way to access the content type of a =
binary file=20
(Windows NT4) that is being added to a MIME message as an attachment so =
the=20
header can be created correctly.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>e.g. 'application/vnd.ms-word' etc</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Regards</FONT></DIV>
<DIV><FONT size=3D2>Phil Bertram</FONT></DIV></BODY></HTML>

------=_NextPart_000_0004_01C1458D.D8B04320--



From arcege@speakeasy.net  Mon Sep 24 21:38:33 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Mon, 24 Sep 2001 16:38:33 -0400
Subject: [Tutor] Mime content types. Can you access this info from the os
In-Reply-To: <000901c14529$5da05990$d99ca7cb@pf05nt.bayernz.co.nz>; from phil.bertram@clear.net.nz on Tue, Sep 25, 2001 at 06:46:47AM +1200
References: <000901c14529$5da05990$d99ca7cb@pf05nt.bayernz.co.nz>
Message-ID: <20010924163833.A982@speakeasy.net>

On Tue, Sep 25, 2001 at 06:46:47AM +1200, Phil Bertram wrote:
>    I am playing around with MimeWriter.py
> 
>    Is ther any way to access the content type of a binary file (Windows
>    NT4) that is being added to a MIME message as an attachment so the
>    header can be created correctly.
> 
> 
> 
>    e.g. 'application/vnd.ms-word' etc

You will want to look into the mimetypes module.  I doubt there will be
included entries for Micros**t file types since Python tries to be
uniform across computers.  It handles somewhere between 60-80 different
types that are commonly used.  The module can also read in other files
with MIME type definitions.

  -Arcege

PS: There are some other (better) modules to use instead of MimeWriter,
including mimelib and my own mimecntl.



From wilson@visi.com  Tue Sep 25 04:02:29 2001
From: wilson@visi.com (Timothy Wilson)
Date: Mon, 24 Sep 2001 22:02:29 -0500 (CDT)
Subject: [Tutor] printing special characters
Message-ID: <Pine.GSO.4.21.0109242200250.3487-100000@isis.visi.com>

Hi everyone,

Is there a cross-platform way to print special characters such as the degree
symbol in a Python program?

-Tim

--
Tim Wilson      |   Visit Sibley online:   | Check out:
Henry Sibley HS |  http://www.isd197.org   | http://www.zope.com
W. St. Paul, MN |                          | http://slashdot.org
wilson@visi.com |  <dtml-var pithy_quote>  | http://linux.com



From ehenry@imt.net  Tue Sep 25 06:32:11 2001
From: ehenry@imt.net (Eric Henry)
Date: Mon, 24 Sep 2001 23:32:11 -0600
Subject: [Tutor] A couple beginner questions.
Message-ID: <3BB016DB.6080501@imt.net>

Hi there everyone.  I decided work on a small project to sort of get my 
feet wet in python and programming in general.  I've got a couple of 
quick questions for you all.  First, is there a built in way to apply 
some operation to each item in a list?  For example adding 2 to [1,2,3], 
and getting [3,4,5].

Second, I need to store some information from a table.  Each row has 3 
values.  Somewhat like this:

[1, 3, 4]
[2, 4, 5]
[3, 1, 1]

 From what I understand, a dictionary would let me assign each of those 
sets of information a key and retrieve them, but what I need to do is 
give it say 3 in the second column(the numbers aren't duplicated 
anywhere in each column) and have it return one or four.  I don't know 
how clear that all was, but hopefully someone has some idea what I'm 
talking aobut.

I guess that's it for now.  Anyway, if someone could give me some ideas 
on how to do these two things, I'd really appreciate it.  Thanks.

--

Eric Henry



From shalehperry@home.com  Tue Sep 25 06:56:09 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Mon, 24 Sep 2001 22:56:09 -0700 (PDT)
Subject: [Tutor] A couple beginner questions.
In-Reply-To: <3BB016DB.6080501@imt.net>
Message-ID: <XFMail.20010924225609.shalehperry@home.com>

On 25-Sep-2001 Eric Henry wrote:
> Hi there everyone.  I decided work on a small project to sort of get my 
> feet wet in python and programming in general.  I've got a couple of 
> quick questions for you all.  First, is there a built in way to apply 
> some operation to each item in a list?  For example adding 2 to [1,2,3], 
> and getting [3,4,5].
> 

this one is straight from the tutorials.

[1,2,3] is a list in python.  There are two handy functions in python for
lists:

map(func,list) -- every item in list is passed to func() as an argument this is
equivalent to 'for i in list: func(i)'

reduce(func, list) -- starting with the first two elements, pass two elements
to func and keep a cumalitive result.  This is the same as 'total =
func(list[0], list[1]); for i in list[2:]: total = func(total, i)'
 
> Second, I need to store some information from a table.  Each row has 3 
> values.  Somewhat like this:
> 
> [1, 3, 4]
> [2, 4, 5]
> [3, 1, 1]
> 
>  From what I understand, a dictionary would let me assign each of those 
> sets of information a key and retrieve them, but what I need to do is 
> give it say 3 in the second column(the numbers aren't duplicated 
> anywhere in each column) and have it return one or four.  I don't know 
> how clear that all was, but hopefully someone has some idea what I'm 
> talking aobut.
> 

Hmmm, sounds like a homework problem (-:  Consider making the middle element
the key and the each list the data.  So dict[3] -> [1,3,4].  Of course this
only works when the keys are not dups.


From ignacio@openservices.net  Tue Sep 25 07:03:44 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Tue, 25 Sep 2001 02:03:44 -0400 (EDT)
Subject: [Tutor] A couple beginner questions.
In-Reply-To: <3BB016DB.6080501@imt.net>
Message-ID: <Pine.LNX.4.33.0109250159590.23392-100000@terbidium.openservices.net>

On Mon, 24 Sep 2001, Eric Henry wrote:

> Hi there everyone.  I decided work on a small project to sort of get my
> feet wet in python and programming in general.  I've got a couple of
> quick questions for you all.  First, is there a built in way to apply
> some operation to each item in a list?  For example adding 2 to [1,2,3],
> and getting [3,4,5].

map(lambda x: x+2, [1, 2, 3])

> Second, I need to store some information from a table.  Each row has 3
> values.  Somewhat like this:
>
> [1, 3, 4]
> [2, 4, 5]
> [3, 1, 1]
>
>  From what I understand, a dictionary would let me assign each of those
> sets of information a key and retrieve them, but what I need to do is
> give it say 3 in the second column(the numbers aren't duplicated
> anywhere in each column) and have it return one or four.  I don't know
> how clear that all was, but hopefully someone has some idea what I'm
> talking aobut.

You weren't clear on which 1 or 4 you wanted...

---
t=[[1, 3, 4], [2, 4, 5], [3, 1, 1]]

for i in t:
  if i[1]==3:
    print i

idx=t[0].index(3)

for i in t[1:]:
  print i[idx]
---

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>




From ignacio@openservices.net  Tue Sep 25 07:08:02 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Tue, 25 Sep 2001 02:08:02 -0400 (EDT)
Subject: [Tutor] A couple beginner questions.
In-Reply-To: <XFMail.20010924225609.shalehperry@home.com>
Message-ID: <Pine.LNX.4.33.0109250204480.23392-100000@terbidium.openservices.net>

On Mon, 24 Sep 2001, Sean 'Shaleh' Perry wrote:

> [1,2,3] is a list in python.  There are two handy functions in python for
> lists:
>
> map(func,list) -- every item in list is passed to func() as an argument this is
> equivalent to 'for i in list: func(i)'
>
> reduce(func, list) -- starting with the first two elements, pass two elements
> to func and keep a cumalitive result.  This is the same as 'total =
> func(list[0], list[1]); for i in list[2:]: total = func(total, i)'

Actually, there are three:

filter(func, list) -- returns in a list each element of the list the
func(element) returns true for:

filter(lambda x: x!=3, [1, 2, 3, 4, 5]) returns [1, 2, 4, 5]

Also, map() returns a list containing the results of the function applied to
the elements.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From hnowak@cuci.nl  Tue Sep 25 08:51:08 2001
From: hnowak@cuci.nl (Hans Nowak)
Date: Tue, 25 Sep 2001 09:51:08 +0200
Subject: [Tutor] A couple beginner questions.
Message-ID: <3BB140E2@twigger.nl>

>===== Original Message From Eric Henry <ehenry@imt.net> =====
>Hi there everyone.  I decided work on a small project to sort of get my
>feet wet in python and programming in general.  I've got a couple of
>quick questions for you all.  First, is there a built in way to apply
>some operation to each item in a list?  For example adding 2 to [1,2,3],
>and getting [3,4,5].

As people already pointed out, you can use map:

  x = map(lambda x: x+2, [1, 2, 3])

or without the lambda:

  def f(x): return x+2
  x = map(f, [1, 2, 3])

...but you can also use a list comprehension:

  x = [x+2 for x in [1, 2, 3])

Which one is to be used is largely a matter of preference (although reduce() 
has no equivalent with list comprehensions).

HTH,

--Hans Nowak



From cerulean_rodent@yahoo.co.uk  Tue Sep 25 12:36:13 2001
From: cerulean_rodent@yahoo.co.uk (Cerulean Rodent)
Date: Tue, 25 Sep 2001 15:36:13 +0400
Subject: [Tutor] lost mail
Message-ID: <E15lqVZ-0006Wl-00@ecosse.net>

So sorry. Some of the mail from this list went to /dev/null several days 
ago, so if someone posted a reply to whatever it was that I was asking 
about, it never got through. So it wasn't me being rude (I reserve that 
part for dealing with customers whenever it's my turn to do tech 
support). Ah well. This email is a waste of bandwidth, anyway. -----------------------------------------------------
 
 " Well you can take your reincarnation, 
   Transubstantiation and your papal kiss
   Cause I'm with the beast in beastly bliss
   And all I want is good old-fashioned copulation. "
  
    --David Tibet, "Crowleymass Unveiled"

-----------------------------------------------------


PM XXIII 

-----------------------------------------------------
 
 " Well you can take your reincarnation, 
   Transubstantiation and your papal kiss
   Cause I'm with the beast in beastly bliss
   And all I want is good old-fashioned copulation. "
  
    --David Tibet, "Crowleymass Unveiled"

-----------------------------------------------------


From cerulean_rodent@yahoo.co.uk  Tue Sep 25 13:54:54 2001
From: cerulean_rodent@yahoo.co.uk (Cerulean Rodent)
Date: Tue, 25 Sep 2001 16:54:54 +0400
Subject: [Tutor] cyrus interaction
Message-ID: <E15lrji-0006ZJ-00@ecosse.net>

So this time I'm trying to automate the process of adding users to the Cyrus server. 
A sample script that doesn't work: 

x = os.popen("cyradm -user mailadmin localhost")

x.write("mypassword")

So I can't even make it log on to cyradm. All I get in response is the following 
message: 

application-specific initialization failed: error flushing "file1": broken pipe

Now where is the heinously idiotic mistake that I'm not aware of making? Ideas, 
anyone?

Cheerio, 

PM XXIII

PS sorry for duplicating the signature in my previous post - quite unintentional. 

-----------------------------------------------------
 
 


From csmith@blakeschool.org  Tue Sep 25 14:42:12 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Tue, 25 Sep 2001 08:42:12 -0500
Subject: [Tutor] Re: printing special characters
In-Reply-To: <E15lqVO-0007HP-00@mail.python.org>
References: <E15lqVO-0007HP-00@mail.python.org>
Message-ID: <fc.004c4b6b007c65d33b9aca004732d96a.7c6682@blakeschool.org>

tutor@python.org writes:
>Subject: [Tutor] printing special characters
>
>Hi everyone,
>
>Is there a cross-platform way to print special characters such as the
>degree
>symbol in a Python program?
>
>-Tim
>
I'm working on 2 solutions: 1) find a common font to both systems (like
symbol or chemsyn for the pc/mac) 2) convert what I need to be seen to
html and view it on any system using a browser.  For the latter purpose I
have been testing TtH by Andrew Treverrow, author of OzTeX for the mac.

I'm just getting into this, but it seems to me that there are a few issues:

1) the code in the text

2) the translation being used (e.g., latin-1; unicode.com has a list of
these as pdf files)

3) the font that will be used to represent the translated text code (which
may not have the desired translation of the code in the specified
translation table).

I'm hoping to hearing some good advice on this matter.

/c



From arcege@speakeasy.net  Tue Sep 25 15:02:56 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Tue, 25 Sep 2001 10:02:56 -0400
Subject: [Tutor] cyrus interaction
In-Reply-To: <E15lrji-0006ZJ-00@ecosse.net>; from cerulean_rodent@yahoo.co.uk on Tue, Sep 25, 2001 at 04:54:54PM +0400
References: <E15lrji-0006ZJ-00@ecosse.net>
Message-ID: <20010925100256.C982@speakeasy.net>

On Tue, Sep 25, 2001 at 04:54:54PM +0400, Cerulean Rodent wrote:
> So this time I'm trying to automate the process of adding users to the Cyrus server. 
> A sample script that doesn't work: 
> 
> x = os.popen("cyradm -user mailadmin localhost")
> 
> x.write("mypassword")
> 
> So I can't even make it log on to cyradm. All I get in response is the following 
> message: 
> 
> application-specific initialization failed: error flushing "file1": broken pipe
> 
> Now where is the heinously idiotic mistake that I'm not aware of making? Ideas, 

It is not a mistake really, just a misunderstanding of how passwords
are read from most programs.  I see two possibilities here, I'll go over
the simplier one first.

If the cyradm program reads from standard input (which is uncommon for
programs), then you will want to open the popen for writing.
  x = os.popen("cyradm -user mailadmin localhost", "w")

If you need the output as well, you might look into the other pipe
functionality, the "popen2" module.  From there, you can get two file
objects, one for reading and one for writing.


But since passwords need to be secure, most programs read directly from
the terminal (/dev/tty), not from standard input.  Here you will need
something between your program and the "secure" program (like passwd(1)
and su(1)).  This "something" will opening a new pseudo-terminal that
fakes the program into thinking it is talking to a terminal, and not to
a program.

Expect is best known for this and there are Expect-like extensions written
for Python out there.  There is also the pty module which uses similar
underlying technology as Expect, but you have to do everything manually.

Hopefully the first will work for you, but for security sake, it would
be better if cyradm didn't get the password from stdin.

  -Arcege

PS: You might also look to see if the cyradm program can take the
password on the command-line.  Some do that, but it is even less secure
than reading from stdin (the password could be seen in a process listing).



From wilson@visi.com  Tue Sep 25 15:44:19 2001
From: wilson@visi.com (Timothy Wilson)
Date: Tue, 25 Sep 2001 09:44:19 -0500 (CDT)
Subject: [Tutor] Re: printing special characters
In-Reply-To: <fc.004c4b6b007c65d33b9aca004732d96a.7c6682@blakeschool.org>
Message-ID: <Pine.GSO.4.21.0109250943070.24056-100000@isis.visi.com>

On Tue, 25 Sep 2001, Christopher Smith wrote:

> I'm working on 2 solutions: 1) find a common font to both systems (like
> symbol or chemsyn for the pc/mac) 2) convert what I need to be seen to
> html and view it on any system using a browser.  For the latter purpose I
> have been testing TtH by Andrew Treverrow, author of OzTeX for the mac.

I'm just trying to get the symbols to print for my students' next project, a
simple temp converter. (see
http://www.isd197.org/sibley/cs/icp/assignments/temp_html)

-Tim

--
Tim Wilson      |   Visit Sibley online:   | Check out:
Henry Sibley HS |  http://www.isd197.org   | http://www.zope.com
W. St. Paul, MN |                          | http://slashdot.org
wilson@visi.com |  <dtml-var pithy_quote>  | http://linux.com



From lkvam@venix.com  Tue Sep 25 16:22:54 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Tue, 25 Sep 2001 11:22:54 -0400
Subject: [Tutor] Re: printing special characters
References: <Pine.GSO.4.21.0109250943070.24056-100000@isis.visi.com>
Message-ID: <3BB0A14E.E7ABBCAB@venix.com>

print chr(186)

Will work for some fonts (at least under Windows...)

Timothy Wilson wrote:
> 
> On Tue, 25 Sep 2001, Christopher Smith wrote:
> 
> > I'm working on 2 solutions: 1) find a common font to both systems (like
> > symbol or chemsyn for the pc/mac) 2) convert what I need to be seen to
> > html and view it on any system using a browser.  For the latter purpose I
> > have been testing TtH by Andrew Treverrow, author of OzTeX for the mac.
> 
> I'm just trying to get the symbols to print for my students' next project, a
> simple temp converter. (see
> http://www.isd197.org/sibley/cs/icp/assignments/temp_html)
> 
> -Tim
> 
> --
> Tim Wilson      |   Visit Sibley online:   | Check out:
> Henry Sibley HS |  http://www.isd197.org   | http://www.zope.com
> W. St. Paul, MN |                          | http://slashdot.org
> wilson@visi.com |  <dtml-var pithy_quote>  | http://linux.com
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582


From csmith@blakeschool.org  Tue Sep 25 16:32:00 2001
From: csmith@blakeschool.org (Christopher Smith)
Date: Tue, 25 Sep 2001 10:32:00 -0500
Subject: [Tutor] Re: printing special characters
In-Reply-To: <Pine.GSO.4.21.0109250943070.24056-100000@isis.visi.com>
References: <Pine.GSO.4.21.0109250943070.24056-100000@isis.visi.com>
Message-ID: <fc.004c4b6b007c6c6c3b9aca004732d96a.7c6da4@blakeschool.org>

wilson@visi.com writes:
>On Tue, 25 Sep 2001, Christopher Smith wrote:
>
>> I'm working on 2 solutions: 1) find a common font to both systems (lik=
e
>> symbol or chemsyn for the pc/mac) 2) convert what I need to be seen to
>> html and view it on any system using a browser.  For the latter purpos=
e
>I
>> have been testing TtH by Andrew Treverrow, author of OzTeX for the mac.
>
>I'm just trying to get the symbols to print for my students' next
>project, a
>simple temp converter. (see
>http://www.isd197.org/sibley/cs/icp/assignments/temp_html)

OK, that's easier.

-find out the code to the character on all target systems
-when running the script, determine your system and=20
 select the appropriate code

On the mac it's code 161 (\xa1).

>>> import sys
>>> sys.platform #find out what you are running on
'mac'
>>> ord('=B0')  #if you can type it, you can find the decimal code
161
>>> chr(161)  #repr will give the hex code
'\xa1'
>>> print chr(161) #str will give the proper symbol
=B0                  # on the mac I see a degree symbol=20
>>> deg=3D'\xa1'     # assign the hex code to a variable
>>> print deg+'F'  # concatenate at will
=B0F                 # here I see degree symbol followed by F

Note:  I checked the extended latin-1 unicode table
http://www.unicode.org/charts/PDF/U0080.pdf
and it lists the degree as \xb0 and \xa1 as the inverted
exclamation mark, so apparently I am looking at the wrong
unicode table or else the mac is not using latin-1 translation.

Hmmm...Skip just posted something about someone else's
problem with a rogue character.  Maybe that's useful for
us here:

>>> d=3Du'\N{DEGREE SIGN}'  #tell u the name of the character
>>> d

u'\xb0'
>>> d.encode('mac-latin2') #encode it for the system

'\xa1'
>>>=20

SO...look up the name of the symbol that you want in the unicode table
(in this case the name is DEGREE SIGN) and use the unicode string feature
to give you the code which you then can encode into the appropriate
hex code with the encode() operator.  Of course, you still need to find
out what system you are on since I doubt you will want to use mac-latin
for windows.

HTH,

/c



From dsh8290@rit.edu  Tue Sep 25 17:31:18 2001
From: dsh8290@rit.edu (dman)
Date: Tue, 25 Sep 2001 12:31:18 -0400
Subject: [Tutor] Re: printing special characters
In-Reply-To: <fc.004c4b6b007c65d33b9aca004732d96a.7c6682@blakeschool.org>; from csmith@blakeschool.org on Tue, Sep 25, 2001 at 08:42:12AM -0500
References: <E15lqVO-0007HP-00@mail.python.org> <fc.004c4b6b007c65d33b9aca004732d96a.7c6682@blakeschool.org>
Message-ID: <20010925123118.F14011@harmony.cs.rit.edu>

[...]
| Is there a cross-platform way to print special characters such as
| the degree symbol in a Python program?

If you can use Unicode, the degree symbol is character is 00B0.  I
used that recently in a small java/swing program I had to write.  It
does, of course, depend on the environment the user has.  If the
environment is "archaic"[1] then you probably can't print any special
symbols like that.

With python 1.5.2 on a Debian Woody system running in gnome-terminal
version 1.4.0 and the fonts I have installed, 
    print chr( 0xB0 )
works just fine.  (hmm, 1.5.2 doesn't even have unicode.  Maybe that
character is in iso8859 too?)

-D


[1]  By "archaic" I mean a system that can only handle pure-ASCII
     (7 bits).  I think these systems are all too common these days.
     The conversion to unicode is quite slow.


From rnd@onego.ru  Tue Sep 25 19:41:42 2001
From: rnd@onego.ru (Roman Suzi)
Date: Tue, 25 Sep 2001 22:41:42 +0400 (MSD)
Subject: [Tutor] python newbie need help
In-Reply-To: <20010923123740.A31375@sill.silmarill.org>
Message-ID: <Pine.LNX.4.30.0109252236010.13302-100000@rnd.onego.ru>

>On Mon, Sep 24, 2001 at 12:17:00AM +0800, Rino Mardo wrote:
>> On Sat, Sep 22, 2001 at 12:56:29PM -0400 or thereabouts, cruciatuz wrote:

>> for my first actual python project i'm thinking of a utility to
>> archive my mails stored in a Maildir mailbox.  however, i'm finding it
>> difficult to find any reference as to what is the syntax should be for
>> most of python's modules.  take for example "os.system("cd "+dirName)"
>> the language reference nor the library has no mention of what the
>> syntax should for that command.  should i put a comma to separate the
>> arguments or no comma at all?  i think what i'm looking for something
>> similar to the syntax diagram of pascal.
>>
>> is there something similar in python?

I am not sure why syntax diagram is needed in case of os.system, but if
you insist, you can look at the Python Grammar in the Grammar/Grammar file
of the source Python distribution.

But usually after two hours of moving around in Python people understand
its grammar by heart.

Sincerely yours, Roman Suzi
-- 
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd@onego.ru _/
_/ Tuesday, September 25, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ ""How to Catch Worms" by Earl E. Bird" _/



From runsun@bilbo.bio.purdue.edu  Tue Sep 25 20:54:39 2001
From: runsun@bilbo.bio.purdue.edu (runsun)
Date: Tue, 25 Sep 2001 14:54:39 -0500
Subject: [Tutor] How to import my own module
In-Reply-To: <E15ludw-0000BH-00@mail.python.org>
Message-ID: <HEEGINKOFGFHODPACPPOCENKCIAA.runsun@bilbo.bio.purdue.edu>

How can I import my own module and use the
functions/classes/variables that are defined in
that module ?

Should I put it in the /usr/local/bin/python folder?
Should I be a root in order to do so ? Or I can put
it in the same folder in which the calling cgi resides?

I've looked all over the net and couldn't find anything 
on this.

Oh, btw, thx to all those people who responded to my
previous question.

pan

======================================
      ~~ Be like water, be shapeless ~~
Runsun Pan, PhD, Biological Sci. Purdue Univ
Email: runsun@bilbo.bio.purdue.edu
Url : http://bilbo.bio.purdue.edu/~runsun
Tel : 765-496-4186(H), 765-494-4947 (O)
Fax : 775-665-1494 (USA) 094-656-8001 (Taiwan)
        (I can access both through my email)
======================================


From ignacio@openservices.net  Tue Sep 25 21:13:07 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Tue, 25 Sep 2001 16:13:07 -0400 (EDT)
Subject: [Tutor] How to import my own module
In-Reply-To: <HEEGINKOFGFHODPACPPOCENKCIAA.runsun@bilbo.bio.purdue.edu>
Message-ID: <Pine.LNX.4.33.0109251610380.24103-100000@terbidium.openservices.net>

On Tue, 25 Sep 2001, runsun wrote:

> How can I import my own module and use the
> functions/classes/variables that are defined in
> that module ?
>
> Should I put it in the /usr/local/bin/python folder?
> Should I be a root in order to do so ? Or I can put
> it in the same folder in which the calling cgi resides?
>
> I've looked all over the net and couldn't find anything
> on this.

It should be in $(PREFIX)/lib/pythonX.Y/site-packages.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>




From urnerk@qwest.net  Tue Sep 25 22:36:11 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Tue, 25 Sep 2001 14:36:11 -0700
Subject: [Tutor] Broken os.system() in Windoze
In-Reply-To: <Pine.LNX.4.33.0109251610380.24103-100000@terbidium.openser
 vices.net>
References: <HEEGINKOFGFHODPACPPOCENKCIAA.runsun@bilbo.bio.purdue.edu>
Message-ID: <4.2.0.58.20010925143507.017d8990@pop3.norton.antivirus>

I'm one of those people who wanted WinMe to boot
in real DOS mode enroute to Windows, giving me
the ability to not boot Windows at all if I don't
want to.

I think making this change must have broken os.system(),
as now even os.system("notepad") tells me "this program
runs in MS DOS mode, real mode, which this version of
Windows does not support..." blah blah.

Somewhere I saw mention of a special workaround, for
people using COMMAND.COM -- but I don't find it
documented and can't remember where I saw the note.

Or maybe I'm just dreamin'.

Any help/pointers welcome.

Kirby



From urnerk@qwest.net  Tue Sep 25 22:59:59 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Tue, 25 Sep 2001 14:59:59 -0700
Subject: [Tutor] Broken os.system() in Windoze
In-Reply-To: <4.2.0.58.20010925143507.017d8990@pop3.norton.antivirus>
References: <Pine.LNX.4.33.0109251610380.24103-100000@terbidium.openser vices.net>
 <HEEGINKOFGFHODPACPPOCENKCIAA.runsun@bilbo.bio.purdue.edu>
Message-ID: <4.2.0.58.20010925145550.00a642a0@pop3.norton.antivirus>

>
>Or maybe I'm just dreamin'.
>
>Any help/pointers welcome.
>
>Kirby

Note:  If I go to a DOS box and boot the Python
shell in DOS vs. in GUI IDLE (blech), then I'm
able to import os, os.system("notepad") just fine.

Somehow +already+ being in DOS solves the problem,
but trying to run os.system("notepad") from within
the Windows shell results in an error message and
an exit code of 65413

Kirby

PS:  it's not really notepad I'm interested in --
just using this as an example.



From dyoo@hkn.eecs.berkeley.edu  Tue Sep 25 23:14:02 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 25 Sep 2001 15:14:02 -0700 (PDT)
Subject: [Tutor] python newbie need help
In-Reply-To: <Pine.LNX.4.30.0109252236010.13302-100000@rnd.onego.ru>
Message-ID: <Pine.LNX.4.21.0109251503280.2968-100000@hkn.eecs.berkeley.edu>

On Tue, 25 Sep 2001, Roman Suzi wrote:

> >> for my first actual python project i'm thinking of a utility to
> >> archive my mails stored in a Maildir mailbox.  however, i'm finding it

Very cool.  I have some source code that demonstrates Python's Mailbox
module if you're interested.


> difficult to find any reference as to what is the syntax should be for
> most of python's modules.  take for example "os.system("cd "+dirName)"
> the language reference nor the library has no mention of what the
> syntax should for that command.  should i put a comma to separate the
> arguments or no comma at all?  i think what i'm looking for something

Yes, we place commas between arguments to functions.  Modules shouldn't
have too weird of a syntax --- if you can give us examples of strange
looking modules, we can give examples to show how to use them.


In the particular call to os.system:

    os.system("cd " + dirName)

what's being passed is a single argument --- it doesn't look like it
initially because our eyes are sensitive to symbols like '+', but it's
just a single expression:

    "cd " + dirName

which is a string "concatenation": we're gluing together the string " cd "
with another string called 'dirName'.  I haven't touched Pascal in a LONG
LONG time, so I don't know if Pascal allows casual string concatenation.  
Does it?


> >> similar to the syntax diagram of pascal.
> >>
> >> is there something similar in python?
> 
> I am not sure why syntax diagram is needed in case of os.system, but
> if you insist, you can look at the Python Grammar in the
> Grammar/Grammar file of the source Python distribution.

By the way, cruciatuz, it does sounds like you're familiar with a
Pascal-like programming language, so you may find the official Python
tutorial really helpful in getting you get up to speed:

    http://www.python.org/doc/current/tut/tut.html

If you go through the tutorial once, you should pick up enough of the
grammar to use Python effectively.  Of course, you always have us too.  
*grin*

If you have more questions, please feel free to ask.



From dyoo@hkn.eecs.berkeley.edu  Tue Sep 25 23:19:56 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 25 Sep 2001 15:19:56 -0700 (PDT)
Subject: [Tutor] How to import my own module
In-Reply-To: <HEEGINKOFGFHODPACPPOCENKCIAA.runsun@bilbo.bio.purdue.edu>
Message-ID: <Pine.LNX.4.21.0109251514570.2968-100000@hkn.eecs.berkeley.edu>

On Tue, 25 Sep 2001, runsun wrote:

> How can I import my own module and use the
> functions/classes/variables that are defined in
> that module ?
> 
> Should I put it in the /usr/local/bin/python folder?
> Should I be a root in order to do so ? Or I can put
> it in the same folder in which the calling cgi resides?

It depends; if you want everyone on your system to be able to easily
access your module, putting it in the site-packages directory as Ignacio
suggests is a good choice.  You'll probably need to be root to move the
files there.

Putting the file in the same directory as the calling CGI will also work,
and is probably a very good choice for CGI programs.


If your module is for more personal use, you can also stuff it in a
private directory, and add that directory to your PYTHONPATH environment
variable.  I don't know how much experience you have in the Unix
environment, but if you'd like an example, I can cook one up.  This
approach may not be suitable for CGI's, but they're quite nice for one's
own personal library.

Good luck to you!



From dyoo@hkn.eecs.berkeley.edu  Wed Sep 26 00:10:07 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 25 Sep 2001 16:10:07 -0700 (PDT)
Subject: [Tutor] How to import my own module (fwd)
Message-ID: <Pine.LNX.4.21.0109251605480.4475-100000@hkn.eecs.berkeley.edu>

Hello!

Sure, I'd be happy to show how to do this.

At the moment, I'm frantically catching up on lost time.  (I've been in
Canada the past weekend!  Very nice place.)  Let me forward this to the
rest of the tutor list first, and I'll try answering when I have more
time.

Someone else on the list may be able to help you before I get to your
question, but that's a good thing too... *grin*


---------- Forwarded message ----------
Date: Tue, 25 Sep 2001 17:43:59 -0500
From: runsun <runsun@bilbo.bio.purdue.edu>
To: Danny Yoo <dyoo@hkn.eecs.berkeley.edu>
Subject: RE: [Tutor] How to import my own module

Hi Danny,

Thx for your reply. I just started python 4 days ago and
I am trying to build some libraries for personal use. I want
to put all my modules into one folder, and have them
accessible from some other py's in different folders.

I don't know much about unix, only some basic telnet, ls
emac, ftp, ch, mkdir, cat ....... these very basic commands.
I am also capable of editing the .cshrc, .login .. files, and
source them. Could you pls show me how / where to set
the PYTHONPATH ? Or, if it's not a hassle, some example
like you mentioned will be of great help. Thx.

pan

======================================
      ~~ Be like water, be shapeless ~~
Runsun Pan, PhD, Biological Sci. Purdue Univ
Email: runsun@bilbo.bio.purdue.edu
Url : http://bilbo.bio.purdue.edu/~runsun
Tel : 765-496-4186(H), 765-494-4947 (O)
Fax : 775-665-1494 (USA) 094-656-8001 (Taiwan)
        (I can access both through my email)
======================================

 ] -----Original Message-----
 ] From: Danny Yoo [mailto:dyoo@hkn.eecs.berkeley.edu]
 ] Sent: Tuesday, September 25, 2001 5:20 PM
 ] To: runsun
 ] Cc: tutor@python.org
 ] Subject: Re: [Tutor] How to import my own module
 ]
 ]
 ] On Tue, 25 Sep 2001, runsun wrote:
 ]
 ] > How can I import my own module and use the
 ] > functions/classes/variables that are defined in
 ] > that module ?
 ] >
 ] > Should I put it in the /usr/local/bin/python folder?
 ] > Should I be a root in order to do so ? Or I can put
 ] > it in the same folder in which the calling cgi resides?
 ]
 ] It depends; if you want everyone on your system to be able to easily
 ] access your module, putting it in the site-packages directory as Ignacio
 ] suggests is a good choice.  You'll probably need to be root to move the
 ] files there.
 ]
 ] Putting the file in the same directory as the calling CGI will also work,
 ] and is probably a very good choice for CGI programs.
 ]
 ]
 ] If your module is for more personal use, you can also stuff it in a
 ] private directory, and add that directory to your PYTHONPATH environment
 ] variable.  I don't know how much experience you have in the Unix
 ] environment, but if you'd like an example, I can cook one up.  This
 ] approach may not be suitable for CGI's, but they're quite nice for one's
 ] own personal library.
 ]
 ] Good luck to you!
 ]
 ]



From ak@silmarill.org  Wed Sep 26 00:51:46 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Tue, 25 Sep 2001 19:51:46 -0400
Subject: [Tutor] How to import my own module (fwd)
In-Reply-To: <Pine.LNX.4.21.0109251605480.4475-100000@hkn.eecs.berkeley.edu>
References: <Pine.LNX.4.21.0109251605480.4475-100000@hkn.eecs.berkeley.edu>
Message-ID: <20010925195145.A14325@sill.silmarill.org>

On Tue, Sep 25, 2001 at 04:10:07PM -0700, Danny Yoo wrote:
> Hello!
> 
> Sure, I'd be happy to show how to do this.
> 
> At the moment, I'm frantically catching up on lost time.  (I've been in
> Canada the past weekend!  Very nice place.)  Let me forward this to the
> rest of the tutor list first, and I'll try answering when I have more
> time.
> 
> Someone else on the list may be able to help you before I get to your
> question, but that's a good thing too... *grin*
> 
> 
> ---------- Forwarded message ----------
> Date: Tue, 25 Sep 2001 17:43:59 -0500
> From: runsun <runsun@bilbo.bio.purdue.edu>
> To: Danny Yoo <dyoo@hkn.eecs.berkeley.edu>
> Subject: RE: [Tutor] How to import my own module
> 
> Hi Danny,
> 
> Thx for your reply. I just started python 4 days ago and
> I am trying to build some libraries for personal use. I want
> to put all my modules into one folder, and have them
> accessible from some other py's in different folders.
> 
> I don't know much about unix, only some basic telnet, ls
> emac, ftp, ch, mkdir, cat ....... these very basic commands.
> I am also capable of editing the .cshrc, .login .. files, and
> source them. Could you pls show me how / where to set
> the PYTHONPATH ? Or, if it's not a hassle, some example
> like you mentioned will be of great help. Thx.

Let's say your username is pan. Your home dir is then /home/pan/.
First, you should make a dir for your modules:
$ cd
$ mkdir .my_modules

Now you have to edit your .bashrc file:
$ pico .bashrc
(or .cshrc)

I'm not exactly sure if the format for .cshrc is the same, but for
.bashrc you'd have to add this line:
export PYTHONPATH=/home/pan/.my_modules

and then do:
$ source .bashrc

Next time you log in, it'll be automatically loaded.

Hope this helps,

- Andrei 

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From dsh8290@rit.edu  Wed Sep 26 01:53:55 2001
From: dsh8290@rit.edu (dman)
Date: Tue, 25 Sep 2001 20:53:55 -0400
Subject: [Tutor] Broken os.system() in Windoze
In-Reply-To: <4.2.0.58.20010925145550.00a642a0@pop3.norton.antivirus>; from urnerk@qwest.net on Tue, Sep 25, 2001 at 02:59:59PM -0700
References: <HEEGINKOFGFHODPACPPOCENKCIAA.runsun@bilbo.bio.purdue.edu> <4.2.0.58.20010925143507.017d8990@pop3.norton.antivirus> <4.2.0.58.20010925145550.00a642a0@pop3.norton.antivirus>
Message-ID: <20010925205355.A2458@harmony.cs.rit.edu>

On Tue, Sep 25, 2001 at 02:59:59PM -0700, Kirby Urner wrote:
| >
| >Or maybe I'm just dreamin'.

This is usually true when using windows <0.5 wink>.

| >Any help/pointers welcome.
| >
| >Kirby
| 
| Note:  If I go to a DOS box and boot the Python
| shell in DOS vs. in GUI IDLE (blech), then I'm
| able to import os, os.system("notepad") just fine.
| 
| Somehow +already+ being in DOS solves the problem,
| but trying to run os.system("notepad") from within
| the Windows shell results in an error message and
| an exit code of 65413

Check your PATH, make sure that whatever the DOS box is is in your
PATH. (eg command.com)  You should be able to find environment
variables in the Control Panel somewhere.  NT/2k has them under
System, then under the Advanced tab in the System dialog.  I haven't
looked close enough at my brother's system to know about ME.

-D



From sburr@mac.com  Wed Sep 26 03:07:35 2001
From: sburr@mac.com (Steven Burr)
Date: Tue, 25 Sep 2001 19:07:35 -0700
Subject: [Tutor] How to import my own module (fwd)
In-Reply-To: <20010925195145.A14325@sill.silmarill.org>
Message-ID: <20010926020354.LHXD7629.femail26.sdc1.sfba.home.com@localhost>

On Tuesday, September 25, 2001, at 04:51 PM, Andrei Kulakov wrote:
>
> I'm not exactly sure if the format for .cshrc is the same, but for
> .bashrc you'd have to add this line:
> export PYTHONPATH=/home/pan/.my_modules
>

I can't believe I even know this, but for a C shell (such as tcsh, which 
is the default on Mac OS X), the appropriate shell script command would 
be:

setenv PYTHONPATH <path-to-home-directory>/<module-directory>

Steve Jobs is truly a miracle worker.  He's turned a middle-aged lawyer 
into a Unix geek.


From dsh8290@rit.edu  Wed Sep 26 03:09:33 2001
From: dsh8290@rit.edu (dman)
Date: Tue, 25 Sep 2001 22:09:33 -0400
Subject: [Tutor] How to execute given script from the command line by just
 giving "python script.py" from different directories?
In-Reply-To: <000901c14424$d35c0860$6501a8c0@ncoretech.com>
References: <000901c14424$d35c0860$6501a8c0@ncoretech.com>
Message-ID: <20010925220933.A2038@hudson>

On Sun, Sep 23, 2001 at 05:12:27PM +0530, Ajaya Babu wrote:
| 
| 
| Hi,
| 
| I am facing a small problem. I want to execute python script from any
| directory in C: dirve..., I am working on both Linux and Windows. to test
| this applications...
| 
| In linux I want to execute the python script which present in the directory
| C:\python20\projects\VirtualHandset.. by  just typing

This is a bit confusing because it is impossible to have a directory
called 'C:\python20\projects\VirtualHandset' in Linux.  

| "python VirtualHandset.py" from the command line or from the process That I
| start from the C routine...,

You can only do this if the script is in the PATH, and then you
execute the script directly.

| I am able to execute this script by giving obsolute path..., but If I try
| from C:\python20 to execute this script it is giving python can not open
| this file. I set the python.pth file path as
| C:\python20\projects\VirtualHandset and also set the system environment
| variable ...,

That is only used for imports, not for executing a script.  Python
simply tries to open the file given as an argument and execute it.
The .pth and PYTHONPATH stuff is used only for import statements.

| But it is telling still it can not open this file. Can any one suggest the
| way I can  tell python interpretor that it should look the given directories
| for the script file ?

For Unix-type systems put the .py file in a directory in the PATH,
such as /usr/bin, /usr/local/bin or ~/bin.  Also make sure the script
is executable and has the #! line at the beginning.  You can then type
    
    VirtualHandset.py

at the prompt and the shell will locate the script in the PATH and
execute it.  If you name the file 'VirtualHandset' instead of
'VirtualHandset.py' then you can simply type

    VirtualHandset

to run it.  Any other modules must have the .py extension though.

It is much the same on Windows, excpet that there really aren't any
standard directories in the PATH that I am aware of.

HTH,
-D




From ehenry@imt.net  Wed Sep 26 07:21:51 2001
From: ehenry@imt.net (Eric Henry)
Date: Wed, 26 Sep 2001 00:21:51 -0600
Subject: [Tutor] A couple beginner questions.
References: <XFMail.20010924225609.shalehperry@home.com>
Message-ID: <3BB173FF.7020602@imt.net>

Sean 'Shaleh' Perry wrote:

> this one is straight from the tutorials.
> 
> [1,2,3] is a list in python.  There are two handy functions in python for
> lists:
> 
> map(func,list) -- every item in list is passed to func() as an argument this is
> equivalent to 'for i in list: func(i)'
> 
> reduce(func, list) -- starting with the first two elements, pass two elements
> to func and keep a cumalitive result.  This is the same as 'total =


Ah, ok.  Thanks, that was exactly what I needed.  :)

> Hmmm, sounds like a homework problem (-:  Consider making the middle element
> the key and the each list the data.  So dict[3] -> [1,3,4].  Of course this
> only works when the keys are not dups.


Hmm.  I'm not sure that will do what I need.  I'm not always gonna know 
what the number in the middle column is.  Sometimes I'll need to give it 
the number in the first column, and get the value from the second 
column, other times the value in the third column, and get back both the 
first and second column values.

Oh, and actually it's not homework.  :)  I'm a sociology student, just 
trying to learn a bit about programming by doing some stuff to solve 
some problems I come across a lot, basically just statistics related 
stuff.  Usually I just open up SPSS and do it, but I needed something to 
work on while I'm learning, so I'm duplicating a bunch of stuff. 
Probably pretty badly too.  ;)

Thanks again.

Eric Henry



From lkvam@venix.com  Wed Sep 26 12:59:57 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Wed, 26 Sep 2001 07:59:57 -0400
Subject: [Tutor] A couple beginner questions.
References: <XFMail.20010924225609.shalehperry@home.com> <3BB173FF.7020602@imt.net>
Message-ID: <3BB1C33D.ADAB5FB8@venix.com>

The book "Python Programming on Win32" by Hammond & Robinson includes some sample classes for processing data. (Chapter 13 on databases.)  While the sample code includes windows paths and windows ODBC config info, it is actually quite portable.

They use a class, DataSet which loads data from an sql database as a list of rows.  The fieldnames are stored as a seperate list.  They provide sample methods for manipulating DataSet's.

I have found this a very useful starting point for my statistical processing.  The sample code is here:
http://starship.python.net/crew/mhammond/ppw32/index.html

If you are working in a Windows environment, this book is EXTREMELY helpful.

Eric Henry wrote:
> 
> Sean 'Shaleh' Perry wrote:
> 
> > this one is straight from the tutorials.
> >
> > [1,2,3] is a list in python.  There are two handy functions in python for
> > lists:
> >
> > map(func,list) -- every item in list is passed to func() as an argument this is
> > equivalent to 'for i in list: func(i)'
> >
> > reduce(func, list) -- starting with the first two elements, pass two elements
> > to func and keep a cumalitive result.  This is the same as 'total =
> 
> Ah, ok.  Thanks, that was exactly what I needed.  :)
> 
> > Hmmm, sounds like a homework problem (-:  Consider making the middle element
> > the key and the each list the data.  So dict[3] -> [1,3,4].  Of course this
> > only works when the keys are not dups.
> 
> Hmm.  I'm not sure that will do what I need.  I'm not always gonna know
> what the number in the middle column is.  Sometimes I'll need to give it
> the number in the first column, and get the value from the second
> column, other times the value in the third column, and get back both the
> first and second column values.
> 
> Oh, and actually it's not homework.  :)  I'm a sociology student, just
> trying to learn a bit about programming by doing some stuff to solve
> some problems I come across a lot, basically just statistics related
> stuff.  Usually I just open up SPSS and do it, but I needed something to
> work on while I'm learning, so I'm duplicating a bunch of stuff.
> Probably pretty badly too.  ;)
> 
> Thanks again.
> 
> Eric Henry
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582


From runsun@bilbo.bio.purdue.edu  Wed Sep 26 20:23:04 2001
From: runsun@bilbo.bio.purdue.edu (runsun)
Date: Wed, 26 Sep 2001 14:23:04 -0500
Subject: [Tutor] Strange cgi behavior
In-Reply-To: <E15mH8V-0002mw-00@mail.python.org>
Message-ID: <HEEGINKOFGFHODPACPPOIEOCCIAA.runsun@bilbo.bio.purdue.edu>

I am writing a simple cgi counter in python as a learning exercise:
http://expert.cc.purdue.edu/~runsun/python/counter/simplecounter.cgi

This counter loads countdata.txt (which contains only one
integer), increases that number by one and adds it back.
The code is as following:
--------------------------------------------------------[ Start ]
#!/usr/local/bin/python
print "Content-type: text/html\n\n"
datafile="countdata.txt"

f = open(datafile,"r")
hitlist=f.read()
hitlist = str(int(hitlist)+1)
print hitlist    # <============ the 1st print command
f.close()

f = open(datafile,"w")
f.write(hitlist)
f.close()

print hitlist   # <=========== the 2nd print command
------------------------------------------------------ [ end ] 

When this cgi is execusted by typing simplecounter.cgi
in the command prompt of unix, it returns both print results:

27
27

Another execution does the work : increasing the number 
by one.

28
28

Now, I try to call this cgi from the url address bar of my 
browser. Strange behaviors are :

[1] The result of the 2nd print command never shows up;
[2] A [reload] or [refresh] click to execute the cgi the second
or more times DOES NOT increase the number. This happened
in both IE 5.5 and NS4.03. 

Can someone tell me what's going on ?? thx in advance.

pan

======================================
      ~~ Be like water, be shapeless ~~
Runsun Pan, PhD, Biological Sci. Purdue Univ
Email: runsun@bilbo.bio.purdue.edu
Url : http://bilbo.bio.purdue.edu/~runsun
Tel : 765-496-4186(H), 765-494-4947 (O)
Fax : 775-665-1494 (USA) 094-656-8001 (Taiwan)
        (I can access both through my email)
======================================
 


From ignacio@openservices.net  Wed Sep 26 20:36:40 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Wed, 26 Sep 2001 15:36:40 -0400 (EDT)
Subject: [Tutor] Strange cgi behavior
In-Reply-To: <HEEGINKOFGFHODPACPPOIEOCCIAA.runsun@bilbo.bio.purdue.edu>
Message-ID: <Pine.LNX.4.33.0109261535510.24213-100000@terbidium.openservices.net>

On Wed, 26 Sep 2001, runsun wrote:

> [2] A [reload] or [refresh] click to execute the cgi the second
> or more times DOES NOT increase the number. This happened
> in both IE 5.5 and NS4.03.

This is due to the browser's cache. Use Shift+[Reload] and Ctrl+[Refresh]
instead.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From urnerk@qwest.net  Wed Sep 26 22:46:39 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Wed, 26 Sep 2001 14:46:39 -0700
Subject: [Tutor] Broken os.system() in Windoze
In-Reply-To: <20010925205355.A2458@harmony.cs.rit.edu>
References: <4.2.0.58.20010925145550.00a642a0@pop3.norton.antivirus>
 <HEEGINKOFGFHODPACPPOCENKCIAA.runsun@bilbo.bio.purdue.edu>
 <4.2.0.58.20010925143507.017d8990@pop3.norton.antivirus>
 <4.2.0.58.20010925145550.00a642a0@pop3.norton.antivirus>
Message-ID: <4.2.0.58.20010926144407.013dc9d0@pop3.norton.antivirus>

>
>Check your PATH, make sure that whatever the DOS box is is in your
>PATH. (eg command.com)  You should be able to find environment
>variables in the Control Panel somewhere.  NT/2k has them under
>System, then under the Advanced tab in the System dialog.  I haven't
>looked close enough at my brother's system to know about ME.
>
>-D

I can check the path via Python itself:

   >>> os.environ['PATH']
   'C:\\PROGRA~1\\SYMANTEC\\PCANYW~1\\;C:\\WINDOWS;C:\\WINDOWS\\COMMAND;
   C:\\UTILS;D:\\JBUILDER\\JDK1.3.1\\BIN'

Apparently that's not the problem.  Turns out
r = os.popen('notepad') is working, so I'm able to
get by with that option.  So far a mystery as to
why os.system() would die.  Not positive it has
to do with making WinME boot differently.

Thanks for offering a pointer/clue.

Kirby




From dyoo@hkn.eecs.berkeley.edu  Thu Sep 27 02:04:39 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Wed, 26 Sep 2001 18:04:39 -0700 (PDT)
Subject: FW: [Tutor] How to spawn python appliation from C interface in
 Linux
In-Reply-To: <000001c1423e$62c137c0$6501a8c0@ncoretech.com>
Message-ID: <Pine.LNX.4.21.0109261800540.4317-100000@hkn.eecs.berkeley.edu>

On Fri, 21 Sep 2001, Ajaya Babu wrote:

> Ok..., You may ask why cant python applicatin can be server...., Yes
> It can be.., But I am facing problem with python server mode...,
> Python select call is not recognizing peersocket as a socket..it was
> giving exception. earlier I've sent this to our mailing list.
> 
> My demo is today..., so I changed this for temparaly so that demo goes
> well. But unfortunately...I've not got any answer for python select
> fucntin problem.

Just checking up on this --- have you found out yet why it's giving an
exception?  To tell the truth, I've never played with select(), so I can't
help on this one.

You might want to talk with the main comp.lang.python newsgroup --- the
people there are often very experienced at this sort of stuff, and may be
able to help you better.

Good luck!



From jessefw@loop.com  Thu Sep 27 03:08:17 2001
From: jessefw@loop.com (Jesse F. W)
Date: Wed, 26 Sep 2001 19:08:17 -0700
Subject: [Tutor] A couple beginner questions.
In-Reply-To: <3BB016DB.6080501@imt.net>
Message-ID: <3BB227A1.10072.29A92035@localhost>

Dear Eric,
	Below I have enclosed something which might serve for your needs.  The 
doc strings should make it clear how it works.
						Jesse W

Eric Henry wrote:
> Second, I need to store some information from a table.  Each 
> row has 3
> values.  Somewhat like this:
> 
> [1, 3, 4]
> [2, 4, 5]
> [3, 1, 1]

class Table:
    def __init__(self, table):
        """Create a table object.  Take a list of lists, which must include
        at least one row with the desired number of items in it.  Other rows can
        be added later.

            The provided list of rows is translated into a list of columns and
        saved to self.table."""
        self.table=[ [] for x in table[0] ]
        for item in table:
            for pos in range(len(table[0])):
                self.table[pos].append(item[pos])
    def add_row(self, row):
        """Add a row to the table.  Take a list of items.

            This checks if the row has the proper number of items, then appends
            each item in the row to the appropriete list in self.table"""
        if len(row) != len(self.table):
            return 'Error!'
        for pos in range(len(self.table)):
            self.table[pos].append(row[pos])
    def get(self, value, col_number):
        """Return a column, when given a value in that column, and the column
        number(starting from zero).

        If the given value is in the list representing the given column, return
        that list, else return None."""
        if value in self.table[col_number]:
            return self.table[col_number]
        return None


From nidhi@ncoretech.com  Thu Sep 27 05:22:12 2001
From: nidhi@ncoretech.com (Sreenidhi.B.G)
Date: Thu, 27 Sep 2001 09:52:12 +0530
Subject: [Tutor] Need some info on time module
References: <Pine.LNX.4.33.0109261535510.24213-100000@terbidium.openservices.net>
Message-ID: <3BB2A974.97301F3D@ncoretech.com>

Hi all,

I need some info on how to get system time and keep track of that, say for
example , time required to execute a set of instructions,
i'm using ctime from the time module, but i need a resolution in millisecs,
can you help me,

thanks and regards,
-sreenidhi.



From ignacio@openservices.net  Thu Sep 27 05:40:14 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Thu, 27 Sep 2001 00:40:14 -0400 (EDT)
Subject: [Tutor] Need some info on time module
In-Reply-To: <3BB2A974.97301F3D@ncoretech.com>
Message-ID: <Pine.LNX.4.33.0109270039060.27586-100000@terbidium.openservices.net>

On Thu, 27 Sep 2001, Sreenidhi.B.G wrote:

> I need some info on how to get system time and keep track of that, say for
> example , time required to execute a set of instructions,
> i'm using ctime from the time module, but i need a resolution in millisecs,
> can you help me,

ti=time.time()
dosomething()
tf=time.time()
elapsed=tf-ti

No guarantee that you'll get microseconds though...

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From dell2100@prodigy.net  Thu Sep 27 02:17:20 2001
From: dell2100@prodigy.net (David L. Lerner)
Date: Thu, 27 Sep 2001 01:17:20 -0000
Subject: [Tutor] Turning a string into a tuple?
References: <E15j0px-0007Xt-00@mail.python.org>
Message-ID: <001801c146f2$33f4dd80$0ef163d8@pavilion>

I need to turn a string:

"['Alda', 11, 9, 6, 'Trey', 10, 12]"

into a tuple:

['Alda', 11, 9, 6, 'Trey', 10, 12]

This seems like it should be simple, sort of  the reverse of  string (), but
I can't find how to do it.  I tried:

>>> tuple ("['Alda', 11, 9, 6, 'Trey', 10, 12]")

and I got:

('[', "'", 'A', 'l', 'd', 'a', "'", ',', ' ', '1', '1', ',', ' ', '9', ',',
' ', '6', ',', ' ', "'", 'T', 'r', 'e', 'y', "'", ',', ' ', '1', '0', ',', '
', '1', '2', ']')


Thank you
David L. Lerner
dell2100@prodigy.net
He's a great artist, but genuine greatness involves great risk. One doesn't
get recognized as great from following a safe path already taken and
approved by others. And risks don't always produce positive results. That's
why they're called risks.
- Scoopy (http://scoopy.net/)



From ignacio@openservices.net  Thu Sep 27 06:40:19 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Thu, 27 Sep 2001 01:40:19 -0400 (EDT)
Subject: [Tutor] Turning a string into a tuple?
In-Reply-To: <001801c146f2$33f4dd80$0ef163d8@pavilion>
Message-ID: <Pine.LNX.4.33.0109270139210.27586-100000@terbidium.openservices.net>

On Thu, 27 Sep 2001, David L. Lerner wrote:

> I need to turn a string:
>
> "['Alda', 11, 9, 6, 'Trey', 10, 12]"
>
> into a tuple:
>
> ['Alda', 11, 9, 6, 'Trey', 10, 12]
>
> This seems like it should be simple, sort of  the reverse of  string (), but
> I can't find how to do it.  I tried:
>
> >>> tuple ("['Alda', 11, 9, 6, 'Trey', 10, 12]")
>
> and I got:
>
> ('[', "'", 'A', 'l', 'd', 'a', "'", ',', ' ', '1', '1', ',', ' ', '9', ',',
> ' ', '6', ',', ' ', "'", 'T', 'r', 'e', 'y', "'", ',', ' ', '1', '0', ',', '
> ', '1', '2', ']')

Use eval() to turn the string into a list, then use tuple() to turn the list
into a tuple.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From nidhi@ncoretech.com  Thu Sep 27 06:34:19 2001
From: nidhi@ncoretech.com (Sreenidhi.B.G)
Date: Thu, 27 Sep 2001 11:04:19 +0530
Subject: [Tutor] Need some info on time module
References: <Pine.LNX.4.33.0109270039060.27586-100000@terbidium.openservices.net>
Message-ID: <3BB2BA5B.63B2BE91@ncoretech.com>

thanks for your response,
but i would like to know if there is an equivalent of the function clock() in
python.
regards,
-sreenidhi,


Ignacio Vazquez-Abrams wrote:

> On Thu, 27 Sep 2001, Sreenidhi.B.G wrote:
>
> > I need some info on how to get system time and keep track of that, say for
> > example , time required to execute a set of instructions,
> > i'm using ctime from the time module, but i need a resolution in millisecs,
> > can you help me,
>
> ti=time.time()
> dosomething()
> tf=time.time()
> elapsed=tf-ti
>
> No guarantee that you'll get microseconds though...
>
> --
> Ignacio Vazquez-Abrams  <ignacio@openservices.net>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor



From ignacio@openservices.net  Thu Sep 27 06:45:49 2001
From: ignacio@openservices.net (Ignacio Vazquez-Abrams)
Date: Thu, 27 Sep 2001 01:45:49 -0400 (EDT)
Subject: [Tutor] Need some info on time module
In-Reply-To: <3BB2BA5B.63B2BE91@ncoretech.com>
Message-ID: <Pine.LNX.4.33.0109270143560.27586-100000@terbidium.openservices.net>

On Thu, 27 Sep 2001, Sreenidhi.B.G wrote:

> thanks for your response,
> but i would like to know if there is an equivalent of the function clock() in
> python.

Um, would time.clock() do it for you? Please read the documentation before
asking questions like this.

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>



From dell2100@prodigy.net  Thu Sep 27 02:57:36 2001
From: dell2100@prodigy.net (David L. Lerner)
Date: Thu, 27 Sep 2001 01:57:36 -0000
Subject: [Tutor] Turning a string into a tuple?
References: <E15i6Zh-0002jQ-00@mail.python.org>
Message-ID: <000c01c146f7$cc386940$0ef163d8@pavilion>

The eval() statement!!!

 eval ("['Alda', 11, 9, 6, 'Trey', 10, 12]")

gives me:

['Alda', 11, 9, 6, 'Trey', 10, 12]

I found this five minutes after asking.  Thank you for your time.

Is there a searchable index to the python tutor list?


>I need to turn a string:

>"['Alda', 11, 9, 6, 'Trey', 10, 12]"

>into a tuple:

>['Alda', 11, 9, 6, 'Trey', 10, 12]

>This seems like it should be simple, sort of  the reverse of  string (),
but
>I can't find how to do it.  I tried:

>>>> tuple ("['Alda', 11, 9, 6, 'Trey', 10, 12]")

>and I got:

>('[', "'", 'A', 'l', 'd', 'a', "'", ',', ' ', '1', '1', ',', ' ', '9', ',',
>' ', '6', ',', ' ', "'", 'T', 'r', 'e', 'y', "'", ',', ' ', '1', '0', ',',
'
>', '1', '2', ']')


Thank you
David L. Lerner
dell2100@prodigy.net
He's a great artist, but genuine greatness involves great risk. One doesn't
get recognized as great from following a safe path already taken and
approved by others. And risks don't always produce positive results. That's
why they're called risks.
- Scoopy (http://scoopy.net/)



From jyothi@ncoretech.com  Thu Sep 27 08:26:32 2001
From: jyothi@ncoretech.com (jyothi Guruprasanna)
Date: Thu, 27 Sep 2001 12:56:32 +0530
Subject: [Tutor] Regarding Directory listing display
Message-ID: <NEBBKOPMNKJCOCOBFDKPKEKGCCAA.jyothi@ncoretech.com>

Hi,

	I want to display the directory listings on PmwScrollList. Is there any
Tkinter widget which will just show this or any Pmw, which can do this. It
should work just like windows explorer.

I looked into
 http://www.handshake.de/~dieter/pyprojects/treewidget.html
But i couldn't get the correct picture of implementing using this. Is there
any examples, using this TreeWidget classes..

Thanks and Regards,
Jyothi.



From d_coughlan@altavista.com  Thu Sep 27 11:35:31 2001
From: d_coughlan@altavista.com (Damian Coughlan)
Date: 27 Sep 2001 03:35:31 -0700
Subject: [Tutor] executing python script
Message-ID: <20010927103531.4.cpmta@c012.sfo.cp.net>

This is a multi-part message in MIME format...

------------=_1001586931-29377-0
Content-Type: text/plain
Content-Disposition: inline

Hi, 
   attached u will find a script called lotto1.py. When I run the script using __main__ 
the interpreter does nothing and does not execute the function play. Please explain 

Thanks 
 
 


Find the best deals on the web at AltaVista Shopping!
http://www.shopping.altavista.com

------------=_1001586931-29377-0
Content-Type: application/octet-stream; name="lotto1.py"
Content-Disposition: attachment; filename="lotto1.py"
Content-Transfer-Encoding: base64

IyB0byBnZW5lcmF0ZSBxdWljayBwaWNrIGxvdHRvIG51bWJlcnMNCiMgYXV0
aG9yIDogRGFtaWVuIENvdWdobGFuICAgIC0gRGF0ZSAyNS85LzAxDQppbXBv
cnQgcmFuZG9tDQoNCmRlZiBsb3R0bygpIDoNCiAgICBhID0gcmFuZ2UoNDIp
DQogICAgcmFuZG9tLnNodWZmbGUoYSkNCiAgICBwcmludCBhWzo2XQ0KDQog
ICANCiAgICBkZWYgcGxheSgpOg0KICAgICAgICBjb21wbGV0ZWQ9MA0KICAg
ICAgICB3aGlsZSBub3QgY29tcGxldGVkOg0KICAgICAgICAgICAgdHJ5OiB4
PXJhd19pbnB1dCgnXG5wcmVzcyBlbnRlciBmb3IgbG90dG8gcXVpY2sgcGlj
ayAoRSB0byBleGl0KS4gJykNCiAgICAgICAgICAgIGV4Y2VwdCBFT0ZFcnJv
cjoNCiAgICAgICAgICAgICAgICB4ID0gJ2UnDQogICAgICAgICAgICAgICAg
aWYgeCBhbmQgKHhbMF0gPT0gJ2UnIG9yIHhbMF0gPT0gJ0UnKToNCiAgICAg
ICAgICAgICAgICAgICAgY29tcGxldGVkID0gMQ0KICAgICAgICAgICAgICAg
ICAgICBwcmludCAnY29tcGxldGVkJw0KICAgICAgICAgICAgICAgIGVsc2U6
DQogICAgICAgICAgICAgICAgICAgIHByaW50IGxvdHRvKCkNCg0KDQoNCiAg
ICBpZiBfX25hbWVfXyA9PSAnX19tYWluX18nIDoNCiAgICAgICAgcGxheSgp
DQogICAgZWxzZSA6DQogICAgICAgICAgICBwcmludCAiIE1vZHVsZSByYW5k
b20gaW1wb3J0ZWQgXG4iDQogICAgICAgICAgICBwcmludCAiIHRvIHBsYXkg
dHlwZSBsb3R0bzEucGxheSgpIFxuIg0KICAgICAgICAgICAgcHJpbnQgIiBU
byByZWxvYWQgdHlwZSA6IHJlbG9hZC5sb3R0bzEgXG4iDQo=

------------=_1001586931-29377-0--


From scarblac@pino.selwerd.nl  Thu Sep 27 11:53:49 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 27 Sep 2001 12:53:49 +0200
Subject: [Tutor] executing python script
In-Reply-To: <20010927103531.4.cpmta@c012.sfo.cp.net>; from d_coughlan@altavista.com on Thu, Sep 27, 2001 at 03:35:31AM -0700
References: <20010927103531.4.cpmta@c012.sfo.cp.net>
Message-ID: <20010927125349.A4269@pino.selwerd.nl>

On  0, Damian Coughlan <d_coughlan@altavista.com> wrote:
> Hi, 
>    attached u will find a script called lotto1.py. When I run the script using __main__ 
> the interpreter does nothing and does not execute the function play. Please explain 

The way it's written, the 'if __name__ == "__main__":' line is part of the
function you defined, because it's still indented, so part of the def block.

Move that line and the lines after it back one level of indentation, and it
should work.

-- 
Remco Gerlich


From jyothi@ncoretech.com  Thu Sep 27 13:28:01 2001
From: jyothi@ncoretech.com (jyothi Guruprasanna)
Date: Thu, 27 Sep 2001 17:58:01 +0530
Subject: [Tutor] Regarding drives....
Message-ID: <NEBBKOPMNKJCOCOBFDKPKEKICCAA.jyothi@ncoretech.com>

Hi,

	Is there any function which gives the drive information like how many
drives are there and what are they???

Thanks and Regards,
Jyothi.



From ak@silmarill.org  Thu Sep 27 14:09:45 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Thu, 27 Sep 2001 09:09:45 -0400
Subject: [Tutor] Regarding drives....
In-Reply-To: <NEBBKOPMNKJCOCOBFDKPKEKICCAA.jyothi@ncoretech.com>
References: <NEBBKOPMNKJCOCOBFDKPKEKICCAA.jyothi@ncoretech.com>
Message-ID: <20010927090945.A21614@sill.silmarill.org>

On Thu, Sep 27, 2001 at 05:58:01PM +0530, jyothi Guruprasanna wrote:
> Hi,
> 
> 	Is there any function which gives the drive information like how many
> drives are there and what are they???
> 
> Thanks and Regards,
> Jyothi.

On windows? You can use:
for letter in string.letters:
    drive = letter + ":\"
    if os.path.exists(drive):
        drives.append(drive)

Not tested!

- Andrei 

> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From bill-bell@bill-bell.hamilton.on.ca  Thu Sep 27 14:34:51 2001
From: bill-bell@bill-bell.hamilton.on.ca (Bill Bell)
Date: Thu, 27 Sep 2001 09:34:51 -0400
Subject: [Tutor] Re: Regarding drives....
In-Reply-To: <E15mb0I-0004rL-00@mail.python.org>
Message-ID: <3BB2F2BB.12556.441FC09@localhost>

Andrei Kulakov <sill@optonline.net> wrote, in part:
> On Thu, Sep 27, 2001 at 05:58:01PM +0530, jyothi Guruprasanna wrote:
> Is there any function which gives the drive information like
> how many drives are there and what are they???
> 
> On windows? You can use:
> for letter in string.letters:
>     drive = letter + ":\"
>     if os.path.exists(drive):
>         drives.append(drive)
> 
> Not tested!

First of all, Andrei, I enjoyed reading your code!

Here is the code again, slightly refined and corrected (and tried on 
one computer):

>>> import string
>>> import os
>>> drives = []
>>> for letter in string.uppercase:
... 	drive = letter + ":\\"
... 	if os.path.exists(drive):
... 		drives.append(letter)
... 		
>>> drives
['A', 'C', 'D', 'E', 'F']
>>> len ( drives )
5

Notes:
1. Using 'uppercase', rather than letters, avoids having drive 
availability checked twice. => 'len' can be used to determine number 
of drives, which was part of the original statement of the problem.
2. String literal corrected in code.

Bill

Bill Bell, MSc, Software Developer


From urnerk@qwest.net  Thu Sep 27 15:38:36 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Thu, 27 Sep 2001 07:38:36 -0700
Subject: [Tutor] Turning a string into a tuple?
In-Reply-To: <000c01c146f7$cc386940$0ef163d8@pavilion>
References: <E15i6Zh-0002jQ-00@mail.python.org>
Message-ID: <4.2.0.58.20010927073640.00c4a750@pop3.norton.antivirus>

>asking.  Thank you for your time.
>
>Is there a searchable index to the python tutor list?

The various Python lists (including this one)
are archived at ActiveState (as well as Python.org)
and in the former case, are searchable by key word(s):
http://aspn.activestate.com/ASPN/Python/Mail

Not always easy to find your topic of course, e.g.
doesn't help to search on "string" :-D.

Kirby



From toodles@yifan.net  Thu Sep 27 15:42:53 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Thu, 27 Sep 2001 22:42:53 +0800
Subject: [Tutor] Re: Regarding drives....
References: <3BB2F2BB.12556.441FC09@localhost>
Message-ID: <003901c14762$b193dff0$0300a8c0@sun>

Who likes list comprehensions? I know I do.

import string,os
drives=['%s:\\'%letter for letter in string.uppercase if
os.path.exists('%s:\\'%letter)]

*grin*
Andrew

> Here is the code again, slightly refined and corrected (and tried on
> one computer):
>
> >>> import string
> >>> import os
> >>> drives = []
> >>> for letter in string.uppercase:
> ... drive = letter + ":\\"
> ... if os.path.exists(drive):
> ... drives.append(letter)
> ...
> >>> drives
> ['A', 'C', 'D', 'E', 'F']
> >>> len ( drives )
> 5
>
> Notes:
> 1. Using 'uppercase', rather than letters, avoids having drive
> availability checked twice. => 'len' can be used to determine number
> of drives, which was part of the original statement of the problem.
> 2. String literal corrected in code.
>
> Bill
>
> Bill Bell, MSc, Software Developer
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From dyoo@hkn.eecs.berkeley.edu  Thu Sep 27 17:33:10 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 27 Sep 2001 09:33:10 -0700 (PDT)
Subject: [Tutor] Turning a string into a tuple?
In-Reply-To: <000c01c146f7$cc386940$0ef163d8@pavilion>
Message-ID: <Pine.LNX.4.21.0109270933060.21656-100000@hkn.eecs.berkeley.edu>

On Thu, 27 Sep 2001, David L. Lerner wrote:

> The eval() statement!!!
> 
>  eval ("['Alda', 11, 9, 6, 'Trey', 10, 12]")
> 
> gives me:
> 
> ['Alda', 11, 9, 6, 'Trey', 10, 12]
> 
> I found this five minutes after asking.  Thank you for your time.
> 
> Is there a searchable index to the python tutor list?
> 
> 
> >I need to turn a string:
> 
> >"['Alda', 11, 9, 6, 'Trey', 10, 12]"
> 
> >into a tuple:
> 
> >['Alda', 11, 9, 6, 'Trey', 10, 12]
> 
> >This seems like it should be simple, sort of  the reverse of  string (),
> but
> >I can't find how to do it.  I tried:
> 
> >>>> tuple ("['Alda', 11, 9, 6, 'Trey', 10, 12]")
> 
> >and I got:
> 
> >('[', "'", 'A', 'l', 'd', 'a', "'", ',', ' ', '1', '1', ',', ' ', '9', ',',
> >' ', '6', ',', ' ', "'", 'T', 'r', 'e', 'y', "'", ',', ' ', '1', '0', ',',
> '
> >', '1', '2', ']')
> 
> 
> Thank you
> David L. Lerner
> dell2100@prodigy.net
> He's a great artist, but genuine greatness involves great risk. One doesn't
> get recognized as great from following a safe path already taken and
> approved by others. And risks don't always produce positive results. That's
> why they're called risks.
> - Scoopy (http://scoopy.net/)
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 



From ak@silmarill.org  Thu Sep 27 17:42:01 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Thu, 27 Sep 2001 12:42:01 -0400
Subject: [Tutor] Turning a string into a tuple?
In-Reply-To: <Pine.LNX.4.21.0109270933060.21656-100000@hkn.eecs.berkeley.edu>
References: <000c01c146f7$cc386940$0ef163d8@pavilion>
 <Pine.LNX.4.21.0109270933060.21656-100000@hkn.eecs.berkeley.edu>
Message-ID: <20010927124201.A23008@sill.silmarill.org>

On Thu, Sep 27, 2001 at 09:33:10AM -0700, Danny Yoo wrote:
> On Thu, 27 Sep 2001, David L. Lerner wrote:
> 
> > The eval() statement!!!
> > 
> >  eval ("['Alda', 11, 9, 6, 'Trey', 10, 12]")
> > 
> > gives me:
> > 
> > ['Alda', 11, 9, 6, 'Trey', 10, 12]
> > 
> > I found this five minutes after asking.  Thank you for your time.
> > 
> > Is there a searchable index to the python tutor list?

By the way, it's not a tuple, it's a list. Lists are enclosed in square
brackets, tuples in parenthesis: (1,2,3) - a tuple.

- Andrei 

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From james2dope@yahoo.com  Thu Sep 27 18:26:33 2001
From: james2dope@yahoo.com (james middendorff)
Date: Thu, 27 Sep 2001 10:26:33 -0700 (PDT)
Subject: [Tutor] help
Message-ID: <20010927172633.89473.qmail@web13908.mail.yahoo.com>

--0-2050051091-1001611593=:88664
Content-Type: text/plain; charset=us-ascii


Hello, 

I am just learning to program, and I am using "Learn to Program using Python" written by Alan Gauld, which is helping me alot, but I wanted to try my own program instead of one thats in the book, so I am actually making a program that will read text documents, and as time goes on and I learn more on how to program maybe I will use it to modify text documents. Right now I have it set so that it will open any text document but I am having a hard time trying to figure out how to make a GUI environment for it, is there any easy way to practice making little GUI programs or something that might help me?

thanks

 


"I would kill everyone in this room
    for a drop of sweet beer."
     ----Homer Simpson----


---------------------------------
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone with Yahoo! by Phone.
--0-2050051091-1001611593=:88664
Content-Type: text/html; charset=us-ascii

<P>Hello, </P>
<P>I am just learning to program, and I am using "Learn to Program using Python" written by Alan Gauld, which is helping me alot, but I wanted to try my own program instead of one thats in the book, so I am actually making a program that will read text documents, and as time goes on and I learn more on how to program maybe I will use it to modify text documents. Right now I have it set so that it will open any text document but I am having a hard time trying to figure out how to make a GUI environment for it, is there any easy way to practice making little GUI programs or something that might help me?</P>
<P>thanks</P>
<P>&nbsp;</P><BR><BR>"I would kill everyone in this room<br>    for a drop of sweet beer."<br>     ----Homer Simpson----<p><br><hr size=1><b>Do You Yahoo!?</b><br>
Listen to your Yahoo! Mail messages from any phone with <a
href="http://rd.yahoo.com/mail_us/tag/?http://phone.yahoo.com/?.refer=mailinsideymail">Yahoo! by Phone</a>.
--0-2050051091-1001611593=:88664--


From DavidCraig@pia.ca.gov  Fri Sep 28 00:24:20 2001
From: DavidCraig@pia.ca.gov (DavidCraig@pia.ca.gov)
Date: Thu, 27 Sep 2001 16:24:20 -0700
Subject: [Tutor] How do I kill this program?
Message-ID: <OFE494D0EA.BB564FBB-ON88256AD4.007FF9F4@PIA.CA.GOV>

I am doing exercises in Lutz's Programming Python.

#config-button.py

from Tkinter import *
widget=Button(text='Spam', padx=10, pady=10)
widget.pack(padx=20, pady=20)
widget.config(cursor='gumby')
widget.config(bd=8, relief=RAISED)
widget.config(bg='dark green', fg='white')
widget.config(font=('helvetica', 20, 'underline italic'))
mainloop()

The program runs fine.  I use IDLE for my editor.  The problem is when I
finish I get the following message:

The program is still running.  Do you want to kill it?  I say yes, but the
program will not close and I am unable to close the IDLE environment
without doing a three fingered salute.

Help!!

TIA

Dave
D. H. Craig, CSM



From urnerk@qwest.net  Fri Sep 28 01:02:05 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Thu, 27 Sep 2001 17:02:05 -0700
Subject: [Tutor] How do I kill this program?
In-Reply-To: <OFE494D0EA.BB564FBB-ON88256AD4.007FF9F4@PIA.CA.GOV>
Message-ID: <4.2.0.58.20010927165957.00beaa20@pop3.norton.antivirus>

In many cases, IDLE is not a good place to develop
Tk programs.

However, in this case, you can have it work.

Paste the code below into a Window and or pull it
up from a file.  Do Ctrl-F5 in that window (code
window) to start the Tk program (nice 'Spam' BTW).

Now, here's the important part:  resist the temptation
to hit the windows close box (x) in the upper right.
Instead, click on the Tk icon on the left, and choose
close.  This will return you to the IDLE shell prompt,
no three-fingers necessary.

Kirby

At 04:24 PM 9/27/2001 -0700, DavidCraig@pia.ca.gov wrote:
>I am doing exercises in Lutz's Programming Python.
>
>#config-button.py
>
>from Tkinter import *
>widget=Button(text='Spam', padx=10, pady=10)
>widget.pack(padx=20, pady=20)
>widget.config(cursor='gumby')
>widget.config(bd=8, relief=RAISED)
>widget.config(bg='dark green', fg='white')
>widget.config(font=('helvetica', 20, 'underline italic'))
>mainloop()
>
>The program runs fine.  I use IDLE for my editor.  The problem is when I
>finish I get the following message:
>
>The program is still running.  Do you want to kill it?  I say yes, but the
>program will not close and I am unable to close the IDLE environment
>without doing a three fingered salute.
>
>Help!!
>
>TIA
>
>Dave
>D. H. Craig, CSM
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor



From urnerk@qwest.net  Fri Sep 28 01:06:45 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Thu, 27 Sep 2001 17:06:45 -0700
Subject: [Tutor] How do I kill this program?
In-Reply-To: <OFE494D0EA.BB564FBB-ON88256AD4.007FF9F4@PIA.CA.GOV>
Message-ID: <4.2.0.58.20010927170435.00c87d00@pop3.norton.antivirus>

Alas, I spoke to soon.  I saw the cursor returning
to the shell, but the shell was dead at this point.

IDLE just isn't a good environment for playing with Tk.

So boot Python in a DOS box (blech) and run it from
there,

     e.g. c:\python22\>python .\mystuff\testing.py

Exit using the Tk icon, as mentioned.

Sorry to give you (and me) false hope.

Kirby



From pobrien@orbtech.com  Fri Sep 28 02:16:05 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Thu, 27 Sep 2001 20:16:05 -0500
Subject: [Tutor] How do I kill this program?
In-Reply-To: <OFE494D0EA.BB564FBB-ON88256AD4.007FF9F4@PIA.CA.GOV>
Message-ID: <NBBBIOJPGKJEKIECEMCBAEEEKMAA.pobrien@orbtech.com>

Works fine from the PyCrust shell
(http://sourceforge.net/projects/pycrust/):

Welcome To PyCrust 0.6.1 - The Flakiest Python Shell
Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
Startup script executed: C:\Code\.pythonrc.py
>>> from Tkinter import *
>>> widget=Button(text='Spam', padx=10, pady=10)
>>> widget.pack(padx=20, pady=20)
>>> widget.config(cursor='gumby')
>>> widget.config(bd=8, relief=RAISED)
>>> widget.config(bg='dark green', fg='white')
>>> widget.config(font=('helvetica', 20, 'underline italic'))
>>> mainloop()
>>> dir(widget)
['_name', '_w', 'children', 'master', 'tk', 'widgetName']
>>> widget.__doc__
'Button widget.'
>>>

---
Patrick K. O'Brien
Orbtech (http://www.orbtech.com)
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
DavidCraig@pia.ca.gov
Sent: Thursday, September 27, 2001 6:24 PM
To: tutor@python.org
Subject: [Tutor] How do I kill this program?

I am doing exercises in Lutz's Programming Python.

#config-button.py

from Tkinter import *
widget=Button(text='Spam', padx=10, pady=10)
widget.pack(padx=20, pady=20)
widget.config(cursor='gumby')
widget.config(bd=8, relief=RAISED)
widget.config(bg='dark green', fg='white')
widget.config(font=('helvetica', 20, 'underline italic'))
mainloop()

The program runs fine.  I use IDLE for my editor.  The problem is when I
finish I get the following message:

The program is still running.  Do you want to kill it?  I say yes, but the
program will not close and I am unable to close the IDLE environment
without doing a three fingered salute.

Help!!

TIA

Dave
D. H. Craig, CSM


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From dsh8290@rit.edu  Fri Sep 28 05:04:41 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 28 Sep 2001 00:04:41 -0400
Subject: [Tutor] Broken os.system() in Windoze
In-Reply-To: <4.2.0.58.20010926144407.013dc9d0@pop3.norton.antivirus>
References: <4.2.0.58.20010925145550.00a642a0@pop3.norton.antivirus>
 <HEEGINKOFGFHODPACPPOCENKCIAA.runsun@bilbo.bio.purdue.edu>
 <4.2.0.58.20010925143507.017d8990@pop3.norton.antivirus>
 <4.2.0.58.20010925145550.00a642a0@pop3.norton.antivirus>
 <4.2.0.58.20010926144407.013dc9d0@pop3.norton.antivirus>
Message-ID: <20010928000441.C3808@hudson>

On Wed, Sep 26, 2001 at 02:46:39PM -0700, Kirby Urner wrote:
| dman wrote : 
| >Check your PATH, make sure that whatever the DOS box is is in your
| >PATH. (eg command.com)  You should be able to find environment
| >variables in the Control Panel somewhere.  NT/2k has them under
| >System, then under the Advanced tab in the System dialog.  I haven't
| >looked close enough at my brother's system to know about ME.
| 
| I can check the path via Python itself:
| 
|   >>> os.environ['PATH']
|   'C:\\PROGRA~1\\SYMANTEC\\PCANYW~1\\;C:\\WINDOWS;C:\\WINDOWS\\COMMAND;
|   C:\\UTILS;D:\\JBUILDER\\JDK1.3.1\\BIN'
| 
| Apparently that's not the problem.  Turns out
| r = os.popen('notepad') is working, so I'm able to
| get by with that option.  So far a mystery as to
| why os.system() would die.  Not positive it has
| to do with making WinME boot differently.

Now you need to try `type notepad` and `which notepad` <wink>.
 
| Thanks for offering a pointer/clue.

You're welcome.

-D



From koen@behindthesofa.dhs.org  Fri Sep 28 06:45:01 2001
From: koen@behindthesofa.dhs.org (Koen Bossers)
Date: Fri, 28 Sep 2001 07:45:01 +0200
Subject: [Tutor] help
References: <20010927172633.89473.qmail@web13908.mail.yahoo.com>
Message-ID: <3BB40E5D.6040508@behindthesofa.dhs.org>

james middendorff wrote:

> Hello,
> 
> I am just learning to program, and I am using "Learn to Program using 
> Python" written by Alan Gauld, which is helping me alot, but I wanted to 
> try my own program instead of one thats in the book, so I am actually 
> making a program that will read text documents, and as time goes on and 
> I learn more on how to program maybe I will use it to modify text 
> documents. Right now I have it set so that it will open any text 
> document but I am having a hard time trying to figure out how to make a 
> GUI environment for it, is there any easy way to practice making little 
> GUI programs or something that might help me?
> 



Take a loot at the Tkinter documentation at:

http://www.pythonware.com/library/tkinter/introduction/index.htm


> thanks


You're welcome.


Cheers, Koen Bossers
-- 

Python@BehindTheSofa

home of mapselect.py,
dailycomic.py and others.

http://behindthesofa.dhs.org
-------------------------------



From dyoo@hkn.eecs.berkeley.edu  Fri Sep 28 07:12:08 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 27 Sep 2001 23:12:08 -0700 (PDT)
Subject: [Tutor] Turning a string into a tuple?  (Without eval?)
In-Reply-To: <4.2.0.58.20010927073640.00c4a750@pop3.norton.antivirus>
Message-ID: <Pine.LNX.4.21.0109270933140.21656-100000@hkn.eecs.berkeley.edu>

On Thu, 27 Sep 2001, Kirby Urner wrote:

> >asking.  Thank you for your time.
> >
> >Is there a searchable index to the python tutor list?
> 
> The various Python lists (including this one) are archived at
> ActiveState (as well as Python.org) and in the former case, are
> searchable by key word(s):
> http://aspn.activestate.com/ASPN/Python/Mail
> 
> Not always easy to find your topic of course, e.g. doesn't help to
> search on "string" :-D.

David's question is a very good one --- What happens if we want to avoid
using eval()?  We've always encouraged people to avoid it like the plague
because eval() is just way too powerful for normal use.


It would be nice if someone could write a small "parser" that translated a
string made up of:

    lists, strings, and numbers

into a Python data structure.

If we put on our "wishing makes it so" hat, we could imagine doing
something like this:

###
>>> parse("[1, 2, 'three']")
[1, 2, "three"]
>>> parse("[   1.0    , [[2]]  ]")
[1.0, [[2]]]
###

It would be cool if it could handle nested lists, as our imaginary parse()
does.  It's not a requirement, but it would be quite nice...

I haven't written this program yet, but it sounds like it might be really
useful for people who want to avoid the dangers of eval().  Does anyone
want a crack at it first?  *grin*



From jyothi@ncoretech.com  Fri Sep 28 13:47:26 2001
From: jyothi@ncoretech.com (jyothi Guruprasanna)
Date: Fri, 28 Sep 2001 18:17:26 +0530
Subject: [Tutor] Regarding Toplevel widget display
Message-ID: <NEBBKOPMNKJCOCOBFDKPEEKKCCAA.jyothi@ncoretech.com>

Hi,

	Is there a way to embed toplevel widget in some other Tkinter widgets, so
that it appears just like Frame embedded in another widget instead of an
independent window.
I used screen option of Toplevel widget but i am getting an error "couldn't
connect to display ".21103212".  what does this error mean generally...

Thanks and Regards,
Jyothi.





From arcege@speakeasy.net  Fri Sep 28 13:59:50 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Fri, 28 Sep 2001 08:59:50 -0400
Subject: [Tutor] Regarding Toplevel widget display
In-Reply-To: <NEBBKOPMNKJCOCOBFDKPEEKKCCAA.jyothi@ncoretech.com>; from jyothi@ncoretech.com on Fri, Sep 28, 2001 at 06:17:26PM +0530
References: <NEBBKOPMNKJCOCOBFDKPEEKKCCAA.jyothi@ncoretech.com>
Message-ID: <20010928085950.A1495@speakeasy.net>

On Fri, Sep 28, 2001 at 06:17:26PM +0530, jyothi Guruprasanna wrote:
> 	Is there a way to embed toplevel widget in some other Tkinter widgets, so
> that it appears just like Frame embedded in another widget instead of an
> independent window.
> I used screen option of Toplevel widget but i am getting an error "couldn't
> connect to display ".21103212".  what does this error mean generally...

You cannot embed a Toplevel widget into anything, but is sounds like
you need the Frame widget itself.  Except for the window decorations
(close buttons, minimize, etc.), and an additional way that menus can
be attached (but do not need to be), there is not difference between
the Toplevel and Frame widgets.

The "screen" in the windowing system relates to which monitor/display/
desktop to show the window on.  In some systems, an application can
send different windows to different monitors (possibily on different
computers).

For what purpose are your trying to get the Toplevel embedded into
another widget?

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |
| Ailment info: http://www.speakeasy.org/~arcege/michaelwatch.html     |


From urnerk@qwest.net  Fri Sep 28 18:00:41 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Fri, 28 Sep 2001 10:00:41 -0700
Subject: [Tutor] Turning a string into a tuple?  (Without eval?)
In-Reply-To: <Pine.LNX.4.21.0109270933140.21656-100000@hkn.eecs.berkeley
 .edu>
References: <4.2.0.58.20010927073640.00c4a750@pop3.norton.antivirus>
Message-ID: <4.2.0.58.20010928095556.00c8ad20@pop3.norton.antivirus>

>
>It would be cool if it could handle nested lists, as our imaginary parse()
>does.  It's not a requirement, but it would be quite nice...
>
>I haven't written this program yet, but it sounds like it might be really
>useful for people who want to avoid the dangers of eval().  Does anyone
>want a crack at it first?  *grin*

Here's a first pass that handles only the very
restrictive case David shared in his example:
a quoted list of strings and integers needing to
be turned into a real list.

Danny proposed this be done sans eval (which useful
function I *don't* avoid like the plague):

  >>> def parse(input):
         """
         Converts quoted list of strings, integers to list
         sans any use of eval
         """
          terms = input.split(",")
          terms[0]  = terms[0][1:]
          terms[-1] = terms[-1][:-1]
          output = []
          for t in terms:
            try:
               nt = int(t)
               output.append(nt)
            except:
                if t.find("'")>-1:
                    t = t[t.find("'")+1:]
                    t = t[:t.find("'")]
                    output.append(t)
          return output

  >>> parse("['Alda', 11, 9, 6, 'Trey', 10, 12]")
  ['Alda', 11, 9, 6, 'Trey', 10, 12]

Kirby



From pobrien@orbtech.com  Fri Sep 28 18:47:19 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Fri, 28 Sep 2001 12:47:19 -0500
Subject: [Tutor] Turning a string into a tuple?  (Without eval?)
In-Reply-To: <4.2.0.58.20010928095556.00c8ad20@pop3.norton.antivirus>
Message-ID: <NBBBIOJPGKJEKIECEMCBAEFMKMAA.pobrien@orbtech.com>

While I admire this effort, it seems to me that we could easily end up with
one heck of a complex program trying to avoid eval(). I suppose you could
look for '[' and ']' as the first and last characters of the input string as
a way to avoid eval()ing something that wouldn't result in a list. But I'm
not sure that would avoid all the potential evils of eval(). Makes for an
interesting problem, though, that's for sure.

---
Patrick K. O'Brien
Orbtech (http://www.orbtech.com)
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Kirby Urner
Sent: Friday, September 28, 2001 12:01 PM
To: Danny Yoo
Cc: David L. Lerner; tutor@python.org
Subject: Re: [Tutor] Turning a string into a tuple? (Without eval?)


>
>It would be cool if it could handle nested lists, as our imaginary parse()
>does.  It's not a requirement, but it would be quite nice...
>
>I haven't written this program yet, but it sounds like it might be really
>useful for people who want to avoid the dangers of eval().  Does anyone
>want a crack at it first?  *grin*

Here's a first pass that handles only the very
restrictive case David shared in his example:
a quoted list of strings and integers needing to
be turned into a real list.

Danny proposed this be done sans eval (which useful
function I *don't* avoid like the plague):

  >>> def parse(input):
         """
         Converts quoted list of strings, integers to list
         sans any use of eval
         """
          terms = input.split(",")
          terms[0]  = terms[0][1:]
          terms[-1] = terms[-1][:-1]
          output = []
          for t in terms:
            try:
               nt = int(t)
               output.append(nt)
            except:
                if t.find("'")>-1:
                    t = t[t.find("'")+1:]
                    t = t[:t.find("'")]
                    output.append(t)
          return output

  >>> parse("['Alda', 11, 9, 6, 'Trey', 10, 12]")
  ['Alda', 11, 9, 6, 'Trey', 10, 12]

Kirby


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor



From blakew@sonainnovations.com  Fri Sep 28 19:14:51 2001
From: blakew@sonainnovations.com (Blake Winton)
Date: Fri, 28 Sep 2001 14:14:51 -0400
Subject: [Tutor] Turning a string into a tuple?  (Without eval?)
References: <NBBBIOJPGKJEKIECEMCBAEFMKMAA.pobrien@orbtech.com>
Message-ID: <002f01c14849$85fe1bc0$d6d35fd8@quintessential>

> While I admire this effort, it seems to me that we could easily end up
with
> one heck of a complex program trying to avoid eval(). I suppose you could
> look for '[' and ']' as the first and last characters of the input string
as
> a way to avoid eval()ing something that wouldn't result in a list. But I'm
> not sure that would avoid all the potential evils of eval(). Makes for an
> interesting problem, though, that's for sure.

And indeed, I've been working on it for a few hours, and I've got a horribly
complex program...  :)

On the other hand, I'm just about done ironing out the last bugs, and then
I'll post it to the list, where the Useless Python people can grab it...

Later,
Blake.





From blakew@sonainnovations.com  Fri Sep 28 19:39:12 2001
From: blakew@sonainnovations.com (Blake Winton)
Date: Fri, 28 Sep 2001 14:39:12 -0400
Subject: [Tutor] Turning a string into a tuple?  (Without eval?)
References: <NBBBIOJPGKJEKIECEMCBAEFMKMAA.pobrien@orbtech.com>
Message-ID: <004c01c1484c$ebd39170$d6d35fd8@quintessential>

> While I admire this effort, it seems to me that we could easily end up
with
> one heck of a complex program trying to avoid eval().

And here is my overly complex program...  :)
But first, some descriptions of what it does.

> I suppose you could look for '[' and ']' as the first and last characters
> of the input string as a way to avoid eval()ing something that wouldn't
> result in a list. But I'm not sure that would avoid all the potential
> evils of eval().

I agree with you, so what I did was to write my own parser for the various
things I wanted to handle.  Those being lists, strings, numbers, and None.
Each item is parsed in its own function, and some of the functions call
others.  I've used the "int", "long", and "float" functions to handle
the numbers, cause it makes my life a lot easier.

An example of how to use it:
-------------------------------------------------------------
>>> parse.parse( '123' ) # An integer.
123
>>> parse.parse( '"abc"' ) # A string.
'abc'
>>> parse.parse( 'None' ) # Nothing.
>>> print parse.parse( 'None' ) # Nothing.
None
>>> parse.parse( '123456789101112' ) # A long integer.
123456789101112L
>>> parse.parse( '1.234' ) # A float.
1.234
>>> parse.parse( '-1.234' ) # I handle negative numbers too.
-1.234
>>> parse.parse( '[]' ) # And finally, lists...
[]
>>> parse.parse( '[[None, "abc"],[ -1, "ab\\"d" ], -4972.]' ) # And lists
containing lists containg stuff...
[[None, 'abc'], [-1, 'ab"d'], -4972.0]
>>> parse.parse( '[   [     None,  "abc"  ]  ,   "   "]' ) # I ignore spaces
sometimes...
[[None, 'abc'], '   ']
-------------------------------------------------------------
So there you go.

Finally, the code in all its ugliness.  I put in some comments,
and the functions are reasonably named, I think.  As long as you
start from parse(), you should be okay.
-------------------------------------------------------------
# parse.py.  Like eval, but safer.

# Utility functions for treating strings like lists.

def peek( input ):
    return input[0]

def pull( input ):
    if input == "":
        return "\0", ""
    return input[0], input[1:]

def push( char, input ):
    if char == "\0":
        return input
    return char + input


# Functions that handle the types I want to.
#   Which is to say, Strings, None, Lists, and Numbers.
#   And, of course, Expressions, which could be any of them.

def parseString( input ):
    if peek( input ) != "\"":
        raise Exception( "Failed!  Next character isn't \"!  Input: '%s'." %
(input,) )

    # Remove the " char...
    switchChar, input = pull( input )

    result = ""
    while( 1 ):
        switchChar, input = pull( input )

        if switchChar == "\"":
            break
        elif switchChar == "\\":
            addChar, input = pull( input )
            result = result + addChar
        else:
            result = result + switchChar
    return result, input

def parseNone( input ):
    if input[:4] != "None":
        raise Exception( "Failed!  Next four characters aren't 'None'!
Input: '%s'." % (input,) )
    return None, input[4:]

def parseList( input ):
    if peek(input) != "[":
        raise Exception( "Failed!  Next character isn't '['!  Input: '%s'."
% (input) )

    switchChar, input = pull(input)
    result = [];

    input = input.lstrip()
    if peek(input) == "]":
        # We've got the empty list.
        closeBracket, input = pull(input)
        return result, input

    #otherwise, we've got >=1 expression.
    item, input = parseExpr( input )
    result.append( item )
    input = input.lstrip()

    switchChar, input = pull( input )
    while switchChar == ",":
        # we've got more elements.
        input = input.lstrip()
        item, input = parseExpr( input )
        result.append( item )
        input = input.lstrip()
        switchChar, input = pull( input )

    # Okay,that's all the elements.  Now we better have a ].
    if switchChar != "]":
        push( switchChar, input )
        print switchChar
        raise Exception( "Failed!  Next character isn't ']'!  Input: '%s'."
% (input) )

    return result, input

def parseNum( input ):
    result = ""

    while( 1 ):
        switchChar, input = pull( input )

        if (switchChar == "+") or (switchChar == "-") or
switchChar.isdigit() or (switchChar == "."):
            result = result + switchChar
        else:
            input = push( switchChar, input )
            break

    # Great, now we've got our number, let's try converting it!
    # First, try an int.  If that fails, try a long.  If that fails, try a
float.
    try:
        result = int( result )
    except ValueError:
        try:
            result = long( result )
        except ValueError:
            result = float( result )

    return result, input

def parseExpr( input ):
    switchChar = input[0]
    if switchChar == "\"":
        result, input = parseString( input )
    elif switchChar == "N":
        result, input = parseNone( input )
    elif switchChar == "[":
        result, input = parseList( input )
    elif (switchChar == "+") or (switchChar == "-") or switchChar.isdigit()
or (switchChar == "."):
        result, input = parseNum( input )
    else:
        raise Exception( "Failed!  Next character isn't 'N' or \" or '[' or
[0-9] or '+' or '-'!  Input: '%s'." % (input) )

    return result, input

# The main entry point.  And a main, in case someone wants to run us
directly.

def parse( input ):
    input = input.lstrip()
    result, input = parseExpr( input )
    input = input.lstrip()
    if input != "":
        raise Exception( "Garbage at the end of the input!  Result: %s
Input: '%s'." % (result, input) )
    return result

def main( args ):
    for arg in args:
        x = parse( arg )
        print x

if __name__ == "__main__":
    import sys
    main( sys.argv )
-------------------------------------------------------------

Later,
Blake.





From lha2@columbia.edu  Fri Sep 28 22:24:19 2001
From: lha2@columbia.edu (Lloyd Hugh Allen)
Date: Fri, 28 Sep 2001 17:24:19 -0400
Subject: [Tutor] How do I kill this program?
Message-ID: <3BB4EA83.A0894C79@mail.verizon.net>

Sorry. Too lazy to cut and paste the original code snippets.

IDLE gets mad when you start a second main loop. Don't mainloop() when
running Tk stuff from IDLE (IDLE itself is driven by Tkinter--mainloop()
has already been invoked). IIRC.

Good luck.

-LHA


From dell2100@prodigy.net  Fri Sep 28 19:42:20 2001
From: dell2100@prodigy.net (David L. Lerner)
Date: Fri, 28 Sep 2001 18:42:20 -0000
Subject: [Tutor] Turning a string into a tuple?  (Without eval?)
References: <4.2.0.58.20010927073640.00c4a750@pop3.norton.antivirus> <4.2.0.58.20010928095556.00c8ad20@pop3.norton.antivirus>
Message-ID: <000d01c1484d$4f885160$18f163d8@pavilion>

<snip>

>I haven't written this program yet, but it sounds like it might be really
 >useful for people who want to avoid the dangers of eval().

What dangers?

Thank you
David L. Lerner
dell2100@prodigy.net
He's a great artist, but genuine greatness involves great risk. One doesn't
get recognized as great from following a safe path already taken and
approved by others. And risks don't always produce positive results. That's
why they're called risks.
- Scoopy (http://scoopy.net/)



From runsun@bilbo.bio.purdue.edu  Fri Sep 28 23:43:51 2001
From: runsun@bilbo.bio.purdue.edu (runsun)
Date: Fri, 28 Sep 2001 17:43:51 -0500
Subject: [Tutor] Verification of variable input
Message-ID: <HEEGINKOFGFHODPACPPOKEPECIAA.runsun@bilbo.bio.purdue.edu>

Hi all,

How do I make sure the values been passed into a variable is valid?
For example:

[1] a variable "isBoldface" will take:
     "true", "True", "1", "5" ===> valid
     "false", "fALSE", "0", anyother type ===> invalid

[2] a variable "borderWidth" will take:
     "2", "2.5", 3 ====> valid
     "a", any other type =====> invalid

[3] a variable "align" will take
     "center", "CENTER", "Center", "Left", "right" ... ==> valid
     any other values ===> invalid

I have written two functions for [1] and [2] and both work fine.
Just thinking if there's any builtin function that I can use.

For [1]:

def returnBoolean(b):
        ''' Reutrn 1 if b = "True", "tRue", "TRUE", "1", and any integer
other than 0 .....
            Return 0 if b= 0, 0.00, 5.5, "false", "False", "FALSE", integer
0 ....
        '''
       if type(b)==type(1):            # If b is an integer
                if b!=0: return 1       # anythong other than 0 will set b
to true
        elif type(b)==type("a"):        # if b is a string
                if b.strip().upper()=="TRUE":   return 1
                else return 0

For [2]

def returnInt(x):
        try:
            x=int(x)            #"3", "-4", 3.5, -1 ...
            return x
        except:
            try:
                x=float(x)      #for cases like "3.5"
                return int(x)
            except:
                return 0        # "a", or any other data type

======================================
      ~~ Be like water, be shapeless ~~
Runsun Pan, PhD, Biological Sci. Purdue Univ
Email: runsun@bilbo.bio.purdue.edu
Url : http://bilbo.bio.purdue.edu/~runsun
Tel : 765-496-4186(H), 765-494-4947 (O)
Fax : 775-665-1494 (USA) 094-656-8001 (Taiwan)
        (I can access both through my email)
======================================



From urnerk@qwest.net  Sat Sep 29 00:02:57 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Fri, 28 Sep 2001 16:02:57 -0700
Subject: [Tutor] Turning a string into a tuple?  (Without eval?)
In-Reply-To: <004c01c1484c$ebd39170$d6d35fd8@quintessential>
References: <NBBBIOJPGKJEKIECEMCBAEFMKMAA.pobrien@orbtech.com>
Message-ID: <4.2.0.58.20010928155921.00be6170@pop3.norton.antivirus>

Very impressive Blake!

But does it handle:
�


From dyoo@hkn.eecs.berkeley.edu  Sat Sep 29 00:04:59 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 28 Sep 2001 16:04:59 -0700 (PDT)
Subject: [Tutor] Beware eval()
In-Reply-To: <000d01c1484d$4f885160$18f163d8@pavilion>
Message-ID: <Pine.LNX.4.21.0109281549100.30267-100000@hkn.eecs.berkeley.edu>

On Fri, 28 Sep 2001, David L. Lerner wrote:

> <snip>
> 
> >I haven't written this program yet, but it sounds like it might be really
>  >useful for people who want to avoid the dangers of eval().
> 
> What dangers?


###
>>> some_input = """[1, 2,
...     __import__(\"os\").system("echo 'If they knew what I knew...'"),
...      3, 4]"""
>>> eval(some_input)
If they knew what I knew...
[1, 2, 0, 3, 4]
###
                
Notice that we just called the underlying os.system() here.  The "echo"
command is very innoculous here... but if we put ourselves in a dark mood,
we can imagine Really Bad Things happening.

I have to admit that I feel very uncomfortable talking about this --- this
is not the sort of thing I want to think about.  But we have to know that
the possibility of abuse does exist.

If we're taking strings from the "outside", we need to be careful when
eval()ing those strings. eval() gives the outside world as much Python
power as the original programmer.  This is a great thing if the use is
casual for one's private libraries... but akin to the touch of death in a
CGI script.



From ak@silmarill.org  Sat Sep 29 00:01:32 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Fri, 28 Sep 2001 19:01:32 -0400
Subject: [Tutor] Verification of variable input
In-Reply-To: <HEEGINKOFGFHODPACPPOKEPECIAA.runsun@bilbo.bio.purdue.edu>
References: <HEEGINKOFGFHODPACPPOKEPECIAA.runsun@bilbo.bio.purdue.edu>
Message-ID: <20010928190132.A29040@sill.silmarill.org>

On Fri, Sep 28, 2001 at 05:43:51PM -0500, runsun wrote:
> Hi all,
> 
> How do I make sure the values been passed into a variable is valid?
> For example:
> 
> [1] a variable "isBoldface" will take:
>      "true", "True", "1", "5" ===> valid
>      "false", "fALSE", "0", anyother type ===> invalid

I guess you'll just have to test for it:

if isBoldFace not in ("true", "True", "1", "5"):
    print "Error!"

> 
> [2] a variable "borderWidth" will take:
>      "2", "2.5", 3 ====> valid
>      "a", any other type =====> invalid
> 
> [3] a variable "align" will take
>      "center", "CENTER", "Center", "Left", "right" ... ==> valid
>      any other values ===> invalid
> 
> I have written two functions for [1] and [2] and both work fine.
> Just thinking if there's any builtin function that I can use.
> 
> For [1]:
> 
> def returnBoolean(b):
>         ''' Reutrn 1 if b = "True", "tRue", "TRUE", "1", and any integer
> other than 0 .....
>             Return 0 if b= 0, 0.00, 5.5, "false", "False", "FALSE", integer
> 0 ....
>         '''
>        if type(b)==type(1):            # If b is an integer
>                 if b!=0: return 1       # anythong other than 0 will set b
> to true
>         elif type(b)==type("a"):        # if b is a string
>                 if b.strip().upper()=="TRUE":   return 1
>                 else return 0
> 
> For [2]
> 
> def returnInt(x):
>         try:
>             x=int(x)            #"3", "-4", 3.5, -1 ...
>             return x
>         except:
>             try:
>                 x=float(x)      #for cases like "3.5"
>                 return int(x)
>             except:
>                 return 0        # "a", or any other data type
> 
> ======================================
>       ~~ Be like water, be shapeless ~~
> Runsun Pan, PhD, Biological Sci. Purdue Univ
> Email: runsun@bilbo.bio.purdue.edu
> Url : http://bilbo.bio.purdue.edu/~runsun
> Tel : 765-496-4186(H), 765-494-4947 (O)
> Fax : 775-665-1494 (USA) 094-656-8001 (Taiwan)
>         (I can access both through my email)
> ======================================
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From urnerk@qwest.net  Sat Sep 29 00:24:39 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Fri, 28 Sep 2001 16:24:39 -0700
Subject: [Tutor] Turning a string into a tuple?  (Without eval?)
Message-ID: <4.2.0.58.20010928162242.00a66100@pop3.norton.antivirus>

Very impressive Blake!

But does it handle:

[why did it cut off before, will it do so again...?]

=====

   >>> f = lambda x: x*x
   >>> qlist = "[f]"
   >>> eval(qlist)
   [<function <lambda> at 00B2C61C>]

=====

?  :-D

I think eval(x) isn't so bad if its arg isn't wholly
left up to some remote user via cgi or something (cite
Danny's comments).  That'd be sloppy programming style.

But eval() can be insulated, and many (most) programs
don't have anything to do with remote users with a
malicious bent (including ones you download).

All worthy interpreted languages have something similar,
no?

Kirby




From ak@silmarill.org  Sat Sep 29 00:27:37 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Fri, 28 Sep 2001 19:27:37 -0400
Subject: [Tutor] Turning a string into a tuple?  (Without eval?)
In-Reply-To: <4.2.0.58.20010928162242.00a66100@pop3.norton.antivirus>
References: <4.2.0.58.20010928162242.00a66100@pop3.norton.antivirus>
Message-ID: <20010928192737.A29296@sill.silmarill.org>

On Fri, Sep 28, 2001 at 04:24:39PM -0700, Kirby Urner wrote:
> 
> Very impressive Blake!
> 
> But does it handle:
> 
> [why did it cut off before, will it do so again...?]
> 
> =====
> 
>   >>> f = lambda x: x*x
>   >>> qlist = "[f]"
>   >>> eval(qlist)
>   [<function <lambda> at 00B2C61C>]
> 
> =====
> 
> ?  :-D
> 
> I think eval(x) isn't so bad if its arg isn't wholly
> left up to some remote user via cgi or something (cite
> Danny's comments).  That'd be sloppy programming style.
> 
> But eval() can be insulated, and many (most) programs
> don't have anything to do with remote users with a
> malicious bent (including ones you download).
> 
> All worthy interpreted languages have something similar,
> no?
> 
> Kirby

Yeah, I would even go as far as saying that this isn't about eval per se
but about accepting untrusted user input. You just have to look at what
your program does with this input, and it may be eval or just argument to
os.system, and so you check the input for illegal contents.


[snip]

- Andrei 

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From arcege@speakeasy.net  Sat Sep 29 00:55:19 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Fri, 28 Sep 2001 19:55:19 -0400
Subject: [Tutor] Beware eval()
In-Reply-To: <Pine.LNX.4.21.0109281549100.30267-100000@hkn.eecs.berkeley.edu>; from dyoo@hkn.eecs.berkeley.edu on Fri, Sep 28, 2001 at 04:04:59PM -0700
References: <000d01c1484d$4f885160$18f163d8@pavilion> <Pine.LNX.4.21.0109281549100.30267-100000@hkn.eecs.berkeley.edu>
Message-ID: <20010928195519.A971@speakeasy.net>

On Fri, Sep 28, 2001 at 04:04:59PM -0700, Danny Yoo wrote:
> ###
> >>> some_input = """[1, 2,
> ...     __import__(\"os\").system("echo 'If they knew what I knew...'"),
> ...      3, 4]"""
> >>> eval(some_input)
> If they knew what I knew...
> [1, 2, 0, 3, 4]
> ###
>                 
> Notice that we just called the underlying os.system() here.  The "echo"
> command is very innoculous here... but if we put ourselves in a dark mood,
> we can imagine Really Bad Things happening.

That is why you can just pass empty namespaces:

>>> eval(some_input, {'__builtins__': {}}, {})
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "<string>", line 0, in ?
NameError: __import__
>>>

And since it is an eval, you cannot call statements; only expressions
are allowed.  That leaves anything that is not an unqualified name (value,
function, class, instance, module, etc.).  That's fairly safe, I'd say.

  -Arcege

Incidently, Python has a "parser" module to parse Python code, including
expressions given to eval().

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |
| Ailment info: http://www.speakeasy.org/~arcege/michaelwatch.html     |


From runsun@bilbo.bio.purdue.edu  Sat Sep 29 08:08:14 2001
From: runsun@bilbo.bio.purdue.edu (runsun)
Date: Sat, 29 Sep 2001 02:08:14 -0500
Subject: [Tutor] Import multiple classes from one module
Message-ID: <HEEGINKOFGFHODPACPPOOEPGCIAA.runsun@bilbo.bio.purdue.edu>

I have a module containing several classes, say,
c1, c2, c3.

It seems that I have to import each class one by one like:

from mymodule import c1
from mymodule import c2
from mymodule import c3

What if there are 30 classes in that module that
I wanna import ? Should I make 30 imports or 
there's a better way to do it ?

pan

======================================
      ~~ Be like water, be shapeless ~~
Runsun Pan, PhD, Biological Sci. Purdue Univ
Email: runsun@bilbo.bio.purdue.edu
Url : http://bilbo.bio.purdue.edu/~runsun
Tel : 765-496-4186(H), 765-494-4947 (O)
Fax : 775-665-1494 (USA) 094-656-8001 (Taiwan)
        (I can access both through my email)
======================================


From reto@codedculture.com  Sat Sep 29 12:26:51 2001
From: reto@codedculture.com (Reto M. Kiefer)
Date: Sat, 29 Sep 2001 13:26:51 +0200
Subject: WG: [Tutor] Import multiple classes from one module
Message-ID: <NEBBLGGNNBJKPDCBALPLEEHHEFAA.reto@codedculture.com>

> I have a module containing several classes, say,
> c1, c2, c3.
>
> It seems that I have to import each class one by one like:
>
> from mymodule import c1
> from mymodule import c2
> from mymodule import c3
>
> What if there are 30 classes in that module that
> I wanna import ? Should I make 30 imports or
> there's a better way to do it ?

The way :

from mymodule import *

doesn't work?

HTH and CU,

Reto

--
Reto M. Kiefer | New Media Solutions
Email:  reto@codedculture.com
Web:    http://www.codedculture.com 


From noticias@iberosoft.com  Sat Sep 29 14:27:51 2001
From: noticias@iberosoft.com (Informacion de Iberosoft.com)
Date: Sat, 29 Sep 2001 13:27:51
Subject: [Tutor] Nueva web corporativa de Iberosoft.com
Message-ID: <E15nIK7-0007iD-00@mail.python.org>

Estimado amigo,

nos complace comunicarte que Iberosoft, lider de soluciones software e implantaciones de portales interactivos en Español, ha cambiado su web corporativa.

Visitanos en http://www.iberosoft.com/ y disfruta de nuestros exclusivos servicios Gratuitos.

-Traceador Visual (VisualRoute Server en Espalo, Unico en el mundo en nustro idioma!!)
-VisualPulse, monitor de tiempos de latencia de IPs, servidores, etc.
-Webmail
-Foros

Y muchas mas....

Esperamos contar pronto con tu visita y te agradecemos todo tipo de comentarios

noticias@iberosoft.com


From arcege@speakeasy.net  Sat Sep 29 12:31:33 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Sat, 29 Sep 2001 07:31:33 -0400
Subject: [Tutor] Import multiple classes from one module
In-Reply-To: <HEEGINKOFGFHODPACPPOOEPGCIAA.runsun@bilbo.bio.purdue.edu>; from runsun@bilbo.bio.purdue.edu on Sat, Sep 29, 2001 at 02:08:14AM -0500
References: <HEEGINKOFGFHODPACPPOOEPGCIAA.runsun@bilbo.bio.purdue.edu>
Message-ID: <20010929073133.C971@speakeasy.net>

On Sat, Sep 29, 2001 at 02:08:14AM -0500, runsun wrote:
> I have a module containing several classes, say,
> c1, c2, c3.
> 
> It seems that I have to import each class one by one like:
> 
> from mymodule import c1
> from mymodule import c2
> from mymodule import c3
> 
> What if there are 30 classes in that module that
> I wanna import ? Should I make 30 imports or 
> there's a better way to do it ?

If you have that many, then it might be better to import the module
itself (not the classes) and reference the classes through the module.

  import mymodule

  c1inst = mymodule.c1()
  class c2subclass(mymodule.c2):
    def __init__(self, arg):
      mymodule.c2.__init__(self)
      self.arg = arg

Also, if you have a "few" names to import, you can separate them with
commas.

  from mymodule import c1, c2, c3

Good Luck,
  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |
| Ailment info: http://www.speakeasy.org/~arcege/michaelwatch.html     |


From ak@silmarill.org  Sat Sep 29 17:06:42 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Sat, 29 Sep 2001 12:06:42 -0400
Subject: WG: [Tutor] Import multiple classes from one module
In-Reply-To: <NEBBLGGNNBJKPDCBALPLEEHHEFAA.reto@codedculture.com>
References: <NEBBLGGNNBJKPDCBALPLEEHHEFAA.reto@codedculture.com>
Message-ID: <20010929120642.A645@sill.silmarill.org>

On Sat, Sep 29, 2001 at 01:26:51PM +0200, Reto M. Kiefer wrote:
> > I have a module containing several classes, say,
> > c1, c2, c3.
> >
> > It seems that I have to import each class one by one like:
> >
> > from mymodule import c1
> > from mymodule import c2
> > from mymodule import c3
> >
> > What if there are 30 classes in that module that
> > I wanna import ? Should I make 30 imports or
> > there's a better way to do it ?
> 
> The way :
> 
> from mymodule import *
> 
> doesn't work?

If you use this method, you should know of it's dangers: it becomes rather
hard to tell where the module or function came from. Consider:

from mymod import *
from mymod2 import *

stuff()

Is stuff a builtin, did it come from mymod or mymod2 or is it defined
somewhere in the file? You can tell right after you wrote it, but will you
be able to tell 2 years later? What about someone else who has to maintain
or modify your code? Also, you can't reload modules if they're imported
like this.

In some cases it's acceptable but you have to be aware of these hiccups..

> 
> HTH and CU,
> 
> Reto
> 
> --
> Reto M. Kiefer | New Media Solutions
> Email:  reto@codedculture.com
> Web:    http://www.codedculture.com 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From printers@sendme.cz  Sat Sep 29 20:10:54 2001
From: printers@sendme.cz (A)
Date: Sat, 29 Sep 2001 21:10:54 +0200
Subject: [Tutor] How can I access a variable outside a class definition?
Message-ID: <3BB638DE.20838.53CAAE@localhost>

Hi,
How can I access a variable defined in one class outside this class 
? For example

I have two classes like below

#############################
class Complex:
 def __init__(self, realpart1,imagpart1,realpart2,imagpart2):
   self.r1 = realpart1
   self.i1 = imagpart1
   self.r2 = realpart2
   self.i2 = imagpart2
 def Add(self,r1,i1,r2,i2):
   self.sum=self.i1+self.i2
   ImSum=self.sum
   return ImSum
###########################
###########################
class Outside
 def MyFunction(self,ImSum)
  ...
  ...

########################

Is it possible to access,in the Outside class, a value of
the ImSum
that was return by 
Add function in that Complex class?


Thank you for help.
Ladislav




From ak@silmarill.org  Sat Sep 29 20:32:32 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Sat, 29 Sep 2001 15:32:32 -0400
Subject: [Tutor] How can I access a variable outside a class definition?
In-Reply-To: <3BB638DE.20838.53CAAE@localhost>
References: <3BB638DE.20838.53CAAE@localhost>
Message-ID: <20010929153232.A1306@sill.silmarill.org>

On Sat, Sep 29, 2001 at 09:10:54PM +0200, A wrote:
> Hi,
> How can I access a variable defined in one class outside this class 
> ? For example
> 
> I have two classes like below
> 
> #############################
> class Complex:
>  def __init__(self, realpart1,imagpart1,realpart2,imagpart2):
>    self.r1 = realpart1
>    self.i1 = imagpart1
>    self.r2 = realpart2
>    self.i2 = imagpart2
>  def Add(self,r1,i1,r2,i2):
>    self.sum=self.i1+self.i2
>    ImSum=self.sum
>    return ImSum
> ###########################
> ###########################
> class Outside
>  def MyFunction(self,ImSum)
>   ...
>   ...
> 
> ########################
> 
> Is it possible to access,in the Outside class, a value of
> the ImSum
> that was return by 
> Add function in that Complex class?

Certainly, you just instantiate that class:

complex = Complex(a,b,c,d)
class Outside:
    def myfunc(self):
        var = complex.Add(e,f,g,h)

[snip]

 - Andrei


-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org


From dyoo@hkn.eecs.berkeley.edu  Sat Sep 29 20:48:35 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sat, 29 Sep 2001 12:48:35 -0700 (PDT)
Subject: [Tutor] Mirror for Alan Gauld's web site?
Message-ID: <Pine.LNX.4.21.0109291246450.15923-100000@hkn.eecs.berkeley.edu>

Hi everyone,

It looks like Alan Gauld's web site disappeared; does anyone know of
mirrors for it?  I haven't been able to get in touch with Alan yet; it
appears he's on vacation.



From riddlebox@vitalogy.org  Sat Sep 29 20:48:48 2001
From: riddlebox@vitalogy.org (RIDDLE BOX)
Date: Sat, 29 Sep 2001 12:48:48 -0700
Subject: [Tutor] help
Message-ID: <200109291948.MAA32511@mail12.bigmailbox.com>

I am just learning how to program and there is an application that I have in mind, but I am not sure how to build the GUI frame for it, is there some examples of like small text readers or something like that, that I could look at and see how they are made?
thanks 



------------------------------------------------------------
This Email Is Provided Free Of Charge Thanks To http://www.vitalogy.org
Sponsored by: http://www.iminteractive.net Internet Solutions, web host & more!


From wilson@visi.com  Sat Sep 29 22:44:30 2001
From: wilson@visi.com (Timothy Wilson)
Date: Sat, 29 Sep 2001 16:44:30 -0500 (CDT)
Subject: [Tutor] Mirror for Alan Gauld's web site?
In-Reply-To: <Pine.LNX.4.21.0109291246450.15923-100000@hkn.eecs.berkeley.edu>
Message-ID: <Pine.GSO.4.21.0109291644150.6686-100000@isis.visi.com>

On Sat, 29 Sep 2001, Danny Yoo wrote:

> It looks like Alan Gauld's web site disappeared; does anyone know of
> mirrors for it?  I haven't been able to get in touch with Alan yet; it
> appears he's on vacation.

I should be in google's cache.

-Tim

--
Tim Wilson      |   Visit Sibley online:   | Check out:
Henry Sibley HS |  http://www.isd197.org   | http://www.zope.com
W. St. Paul, MN |                          | http://slashdot.org
wilson@visi.com |  <dtml-var pithy_quote>  | http://linux.com



From dyoo@hkn.eecs.berkeley.edu  Sat Sep 29 22:44:02 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sat, 29 Sep 2001 14:44:02 -0700 (PDT)
Subject: [Tutor] help
In-Reply-To: <200109291948.MAA32511@mail12.bigmailbox.com>
Message-ID: <Pine.LNX.4.21.0109291437010.17023-100000@hkn.eecs.berkeley.edu>

On Sat, 29 Sep 2001, RIDDLE BOX wrote:

> I am just learning how to program and there is an application that I
> have in mind, but I am not sure how to build the GUI frame for it, is
> there some examples of like small text readers or something like that,
> that I could look at and see how they are made? thanks

Hello!  If you're doing GUIs, it sounds like the Tkinter module is what
you're looking for.  Tkinter is a GUI interface for Python.  I'm not sure
if you've learned about modules yet, but it can't hurt to show a small
example.  Here's an example with some comments on the side:

###
from Tkinter import *            ## This tells Python to let us play
                                 ## with Tkinter stuff.

root = Tk()                      ## This makes a main window.  We'll be
                                 ## able to stuff things like text boxes
                                 ## and buttons in here.  Let's put in a
                                 ## label.

label = Label(root, "Hello, this is a label.")
                                 ## First, we make a label...
label.pack()                     ## ... and then stuff or "pack" it in.
###


Tkinter is a large topic, so there's a separate part of the web site
dedicated to Tkinter graphics programming:

    http://python.org/topics/tkinter/

You can find tutorials and docs there, but you can also ask questions
here.  We'll be happy to help you get your application running.


Good luck!



From dyoo@hkn.eecs.berkeley.edu  Sat Sep 29 22:51:56 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sat, 29 Sep 2001 14:51:56 -0700 (PDT)
Subject: [Tutor] How can I access a variable outside a class definition?
In-Reply-To: <3BB638DE.20838.53CAAE@localhost>
Message-ID: <Pine.LNX.4.21.0109291233010.15923-100000@hkn.eecs.berkeley.edu>

On Sat, 29 Sep 2001, A wrote:

> How can I access a variable defined in one class outside this class ?
> For example
> 
> I have two classes like below
> 
> #############################
> class Complex:
>  def __init__(self, realpart1,imagpart1,realpart2,imagpart2):
>    self.r1 = realpart1
>    self.i1 = imagpart1
>    self.r2 = realpart2
>    self.i2 = imagpart2
>  def Add(self,r1,i1,r2,i2):
>    self.sum=self.i1+self.i2
>    ImSum=self.sum
>    return ImSum

Side note: I'm a little unfamiliar with this definition of complex
numbers.  Can you explain a little more what this class represents?


> ###########################
> ###########################
> class Outside
>  def MyFunction(self,ImSum)
>   ...
>   ...
> 
> ########################
> 
> Is it possible to access,in the Outside class, a value of the ImSum
> that was return by Add function in that Complex class?

It's possible for Outside to call methods of Complex, as long as you give
Outside an instance of that Complex class.


Here's an example that might help:

###
class EchoEcho:
    """An EchoEcho person always repeats the same thing."""
    def __init__(self, what_to_say):
        self.what_to_say = what_to_say

    def speak(self):
        return self.what_to_say


def reverse(s):
    """Reverses a string."""
    s_as_list = list(s)
    s_as_list.reverse()
    return ''.join(s_as_list)


class Esrever:
    """An Esrever is someone who listens to a target, and reverses
    whatever that person says..."""
    def __init__(self, mimiced_target):
        self.mimiced_target = mimiced_target

    def speak(self):
        """We get our target to say something, and then we reverse
        whatever they say."""
        speech = self.mimiced_target.speak()
        return reverse(speech)
###



Let's take a look at how this works:

###
>>> jane = EchoEcho("Hi, I'm Jane.")
>>> jane.speak()
"Hi, I'm Jane."
>>> john = Esrever(jane)
>>> john.speak()
".enaJ m'I ,iH"
###


So as long as the "outside" can hold onto an instance of your class, it
can call all of its methods too.

Please feel free to ask more questions on this; OOP programming isn't too
hard, but it does have some concepts that take getting used to.  Hope this
helps!



From urnerk@qwest.net  Sat Sep 29 22:51:07 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Sat, 29 Sep 2001 14:51:07 -0700
Subject: [Tutor] How can I access a variable outside a class
 definition?
In-Reply-To: <3BB638DE.20838.53CAAE@localhost>
Message-ID: <4.2.0.58.20010929143303.00c829e0@pop3.norton.antivirus>

>
>Is it possible to access,in the Outside class, a value of
>the ImSum
>that was return by
>Add function in that Complex class?

Classes have access to variables defined outside of them, e.g.

  >>> c = 10  # defined outside (e.g. returned by yr Complex.Add())

  >>> class C:
          def func(a,b):
             return a+b+c
          func =staticmethod(func)


  >>> C.func(1,2)
  13


is legal in 2.2 (the staticmethod syntax allows C to not
have a self -- a new breed of soulless classes is afoot).

If you're seriously wanting to do stuff with complex numbers,
please realize that they're already built in:

   >>> z1 = complex(1,2)
   >>> z2 = complex(3,4)
   >>> z3 = z1 + z2
   >>> z3
   (4+6j)
   >>> z3.real
   4.0
   >>> z3.imag
   6.0

-- all without even importing the cmath module.

Kirby





From informacion.general@lideralia.com  Sun Sep 30 12:17:11 2001
From: informacion.general@lideralia.com (Informacion General)
Date: Sun, 30 Sep 2001 11:17:11
Subject: [Tutor] Informacion de Interes
Message-ID: <E15nchU-0003J4-00@mail.python.org>

 Estimado amigo,

nos complace comunicarte que Iberosoft, líder de soluciones software e implantaciones de portales interactivos en Español, ha cambiado su web corporativa.

Visitanos en http://www.iberosoft.com/ y disfruta de nuestros exclusivos servicios Gratuitos.

-Traceador Visual (VisualRoute Server en Español, Único en el mundo en nuestro idioma!!)
-VisualPulse, monitor de tiempos de latencia de IPs, servidores, etc.
-Webmail
-Chat
-Foros
-Noticias.

Y muchas mas....

Esperamos contar pronto con tu visita y te agradecemos todo tipo de comentarios
Así mismo te expresamos nuestro interés en conocer tu opinión sobre nuestras actividades.
¿quieres trabajar con nosotros? Envíanos tu CV lo mas detallado posible a rrhh@iberosoft.com 

Recibe un saludo del equipo de Iberosoft.com
noticias@iberosoft.com




From oktay_safak@yahoo.com  Sun Sep 30 21:27:52 2001
From: oktay_safak@yahoo.com (Oktay Safak)
Date: Sun, 30 Sep 2001 13:27:52 -0700 (PDT)
Subject: [Tutor] How to make IDLE show turkish characters properly
In-Reply-To: <3BB4EA83.A0894C79@mail.verizon.net>
Message-ID: <20010930202752.62246.qmail@web20710.mail.yahoo.com>

Hi all,

I am on win98 and use Python version 2.1.1

Does anybody know how to make IDLE show Turkish(or
German or French etc.) characters properly? I change
the defaultencoding by sitecustomize.py, end when I do
sys.getdefaultencoding(), it gives the correct
encoding for Turkish but when I type the special
characters they aren't shown as they should. The
console window gets it right, and also, within IDLE,
when I save some strings containing those characters
to a text file and then inspect the file with Notepad
I see that they are written correctly to the file. So
IDLE actually does the right thing but it covers it up
very well! I tried to change the font in the
configuration file that IDLE uses but that doesn't
help; I think I can't get the name of the font right
this time since it changes from courier to something
like Arial.

Any ideas?

Thanks,

Oktay Safak 

__________________________________________________
Do You Yahoo!?
Listen to your Yahoo! Mail messages from any phone.
http://phone.yahoo.com


From  Kerim Borchaev \( WarKiD \) " <warkid@storm.ru  Tue Sep 11 09:55:51 2001
From:  Kerim Borchaev \( WarKiD \) " <warkid@storm.ru ( Kerim Borchaev ( WarKiD ) )
Date: Tue, 11 Sep 2001 12:55:51 +0400
Subject: [Tutor] PythonWin and tabs
Message-ID: <18538.010911@storm.ru>

Hello ,

      Recently I've found a bad thing about PythonWin - even if
      "insert spaces" option is checked it still uses tabs - in
      interactive window. It happended a couple of times before but I
      thought I just don't get Python.
      So be careful cut'n'pasting code from PW.
      
      And if it is a bug someone please report it to ActiveState...

Best regards,
 Kerim                          mailto:warkid@storm.ru


_______________________________________________
ActivePython mailing list
ActivePython@listserv.ActiveState.com
http://listserv.ActiveState.com/mailman/listinfo/activepython


From alan.gauld@bt.com  Tue Sep 11 17:51:49 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 11 Sep 2001 17:51:49 +0100
Subject: [Tutor] PythonWin and tabs
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66BF40@mbtlipnt02.btlabs.bt.co.uk>

>       Recently I've found a bad thing about PythonWin - even if
>       "insert spaces" option is checked it still uses tabs - in

What version are you using?
I had that on the version I downloaded with 1.5.1 but the 
version that comes with Python 2.0 doesn't do that anymore 
- at least I've not seen it...

Alan G
_______________________________________________
ActivePython mailing list
ActivePython@listserv.ActiveState.com
http://listserv.ActiveState.com/mailman/listinfo/activepython


From printers@sendme.cz  Sat Sep 29 20:10:54 2001
From: printers@sendme.cz (A)
Date: Sat, 29 Sep 2001 21:10:54 +0200
Subject: [Tutor] How can I access a variable outside a class definition?
Message-ID: <3BB638DE.20838.53CAAE@localhost>

Hi,
How can I access a variable defined in one class outside this class 
? For example

I have two classes like below

#############################
class Complex:
 def __init__(self, realpart1,imagpart1,realpart2,imagpart2):
   self.r1 = realpart1
   self.i1 = imagpart1
   self.r2 = realpart2
   self.i2 = imagpart2
 def Add(self,r1,i1,r2,i2):
   self.sum=self.i1+self.i2
   ImSum=self.sum
   return ImSum
###########################
###########################
class Outside
 def MyFunction(self,ImSum)
  ...
  ...

########################

Is it possible to access,in the Outside class, a value of
the ImSum
that was return by 
Add function in that Complex class?


Thank you for help.
Ladislav


_______________________________________________
ActivePython mailing list
ActivePython@listserv.ActiveState.com
http://listserv.ActiveState.com/mailman/listinfo/activepython


From dyoo@hkn.eecs.berkeley.edu  Sat Sep 29 22:51:56 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sat, 29 Sep 2001 14:51:56 -0700 (PDT)
Subject: [Tutor] How can I access a variable outside a class definition?
In-Reply-To: <3BB638DE.20838.53CAAE@localhost>
Message-ID: <Pine.LNX.4.21.0109291233010.15923-100000@hkn.eecs.berkeley.edu>

On Sat, 29 Sep 2001, A wrote:

> How can I access a variable defined in one class outside this class ?
> For example
> 
> I have two classes like below
> 
> #############################
> class Complex:
>  def __init__(self, realpart1,imagpart1,realpart2,imagpart2):
>    self.r1 = realpart1
>    self.i1 = imagpart1
>    self.r2 = realpart2
>    self.i2 = imagpart2
>  def Add(self,r1,i1,r2,i2):
>    self.sum=self.i1+self.i2
>    ImSum=self.sum
>    return ImSum

Side note: I'm a little unfamiliar with this definition of complex
numbers.  Can you explain a little more what this class represents?


> ###########################
> ###########################
> class Outside
>  def MyFunction(self,ImSum)
>   ...
>   ...
> 
> ########################
> 
> Is it possible to access,in the Outside class, a value of the ImSum
> that was return by Add function in that Complex class?

It's possible for Outside to call methods of Complex, as long as you give
Outside an instance of that Complex class.


Here's an example that might help:

###
class EchoEcho:
    """An EchoEcho person always repeats the same thing."""
    def __init__(self, what_to_say):
        self.what_to_say = what_to_say

    def speak(self):
        return self.what_to_say


def reverse(s):
    """Reverses a string."""
    s_as_list = list(s)
    s_as_list.reverse()
    return ''.join(s_as_list)


class Esrever:
    """An Esrever is someone who listens to a target, and reverses
    whatever that person says..."""
    def __init__(self, mimiced_target):
        self.mimiced_target = mimiced_target

    def speak(self):
        """We get our target to say something, and then we reverse
        whatever they say."""
        speech = self.mimiced_target.speak()
        return reverse(speech)
###



Let's take a look at how this works:

###
>>> jane = EchoEcho("Hi, I'm Jane.")
>>> jane.speak()
"Hi, I'm Jane."
>>> john = Esrever(jane)
>>> john.speak()
".enaJ m'I ,iH"
###


So as long as the "outside" can hold onto an instance of your class, it
can call all of its methods too.

Please feel free to ask more questions on this; OOP programming isn't too
hard, but it does have some concepts that take getting used to.  Hope this
helps!

_______________________________________________
ActivePython mailing list
ActivePython@listserv.ActiveState.com
http://listserv.ActiveState.com/mailman/listinfo/activepython


From carlosdsousa@hotmail.com  Mon Sep 24 12:33:07 2001
From: carlosdsousa@hotmail.com (carlos sousa)
Date: Mon, 24 Sep 2001 12:33:07 +0100
Subject: [Tutor] [tutor]Newby!!!!
Message-ID: <OE421m7YDopT5kZ1pvH000040d7@hotmail.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0005_01C144F5.10971E60
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

hello to everyone
this my first program using python.
I am building a webpage, and I use python to manipulate a Postgresql =
database.
My problem is that i would like create a function similar in =
functionality to the HTML "checkbox" in witch the number of check inputs =
is variable (the number of check inputs depends from a parameter 'names' =
witch contains a list of names).

thanks for your time and sorry for my bad english


------=_NextPart_000_0005_01C144F5.10971E60
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>hello to everyone</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>this my first program using =
python.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I am building a webpage, and I use =
python to=20
manipulate a Postgresql database.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>My problem is that i would like create =
a function=20
similar in functionality to the HTML "checkbox" in witch the number of =
check=20
inputs is variable (the number of check inputs depends from a parameter =
'names'=20
witch contains a list of names).</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>thanks for your time and sorry for my =
bad=20
english</FONT></DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_0005_01C144F5.10971E60--