From lha2@columbia.edu  Thu Nov  1 00:20:08 2001
From: lha2@columbia.edu (Lloyd Hugh Allen)
Date: Wed, 31 Oct 2001 19:20:08 -0500
Subject: [Tutor] [Fwd: Nigerian investment scam]
Message-ID: <3BE09538.470F894C@mail.verizon.net>

In reference to that spam earlier:

-------- Original Message --------
From: (edited) @oag.state.md.us>
Subject: Nigerian investment scam
To: (edited)

Mr. Allen:
     The investment opportunity you received falls within the genre of
"Nigerian bank letter scams."  Millions of dollars are promised for
helping to transfer millions more out of Nigeria and into a US account. 
It is, of course, a scam.  Those who have provided their personal or
business account info have seen their accounts depleted.  I will forward
this letter to the US Secret Service, which has a taskforce attempting
to halt the operation.

(edited)
Assistant Attorney General
Securities Division
200 St. Paul Place
Baltimore,  MD  21202
410/576-6950


From david.jay.jackson@wcox.com  Thu Nov  1 03:25:40 2001
From: david.jay.jackson@wcox.com (Jackson)
Date: Wed, 31 Oct 2001 20:25:40 -0700
Subject: [Tutor] Using re/search with dictionaries
Message-ID: <200110312025.AA377815166@wcox.com>

Kirby --
Thanks for your reply. It fit the bill perfectly for what I need.

David




---------- Original Message ----------------------------------
From: Kirby Urner <urnerk@qwest.net>
Date: Wed, 31 Oct 2001 09:24:56 -0800

>
>Regular expressions search strings, not lists, so you
>can't use d.keys() as an arg to re.search() -- would have
>to do some conversion to/from to make this approach work.
>
>But regular expressions might be overkill if you're just
>wanting to find keys with embedded strings, nothing much
>fancier.  Simpler string functions will do that job.
>
>Defining dictionary d as per your setup script, the
>function below lists all key/value pairs where the
>passed pattern (e.g. "blue") is found in the key:
>
>   >>> def getmatches(pattern, thedict):
>            keys = [i for i in thedict.keys() if i.find(pattern)>=0]
>            for k in keys:
>               print "%s = %s" % (k,thedict[k])
>
>
>   >>> getmatches("blue",d)
>   blue-003 = ['blueberry muffins']
>   blue-002 = ['blueberry cobbler']
>   blue-001 = ['blueberry pie']
>   blueberry = ['muffins']
>   bluebird = ['feathered friend']
>
>You could modify the above to work with regular expressions,
>but it'd search each key, one at a time.  Again, if simple
>string functions will do the job, they're faster.
>
>Kirby
>
>At 10:04 AM 10/31/2001 -0700, Jackson wrote:
>>Greetings --
>>How do I search dict keys? and return the records that go along with them? 
>>It seems as if it should be something along this line:
>>
>># we're looking for keys/records with blue* in them.
>>m=rd.search("\w[blue]+",d.keys())
>>if m: print repr(m.group(0))
>>    and the output should be:
>>
>>[blue-001"]=["blueberry pie"]
>>["blue-002"]=["blueberry cobbler"]
>>["blue-003"]=["blueberry muffins"]
>>...
>>....
>>
>>
>>Thanks for you time
>>David Jackson
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>


From dsh8290@rit.edu  Thu Nov  1 03:28:08 2001
From: dsh8290@rit.edu (dman)
Date: Wed, 31 Oct 2001 22:28:08 -0500
Subject: [Tutor] help
In-Reply-To: <20011031164127.A11972@sill.silmarill.org>; from sill@optonline.net on Wed, Oct 31, 2001 at 04:41:27PM -0500
References: <20011031204128.46041.qmail@web13903.mail.yahoo.com> <20011031164127.A11972@sill.silmarill.org>
Message-ID: <20011031222807.A18297@harmony.cs.rit.edu>

On Wed, Oct 31, 2001 at 04:41:27PM -0500, Andrei Kulakov wrote:
| On Wed, Oct 31, 2001 at 12:41:28PM -0800, james middendorff wrote:
| > 
| > hello,
| > 
| > could someone please tell me how to display a text file, and then be able to type more information into that file?
| > 
| > thanks
| 
| Not exactly sure what you mean by that, but this would work:
| 
| import os
| os.system("vim file")

<wide grin>  I like that approach :-).


To display (though maybe not usefully)

    f = open( "filename" , "r" )
    print f.read()
    f.close()
    del f

To add more text at the end :

    f = open( "filename" , "a" )
    f.write( "some more text" )
    f.close()
    del f


I agree with Andrei that if you want to edit files in an arbitrary
way, you should use a text editor.  Alternatively use a GUI that
proivdes a multi-line text entry ; read the text into the widget, then
write it all back out when an event occurs.

HTH,
-D



From pythonpython@hotmail.com  Thu Nov  1 07:07:35 2001
From: pythonpython@hotmail.com (Hy Python)
Date: Thu, 01 Nov 2001 07:07:35 +0000
Subject: [Tutor] How to install JapaneseCodecs without cl.exe?
Message-ID: <F115nx8dyDd3OJXsNQp00001e4a@hotmail.com>

Does anyone know how to to install JapaneseCodecs without cl.exe?
I kept running into cl.exe-not-found errors when I was trying to install the 
codecs.


Thank you very much


Hy

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp



From vulpine@pobox.com  Thu Nov  1 08:08:51 2001
From: vulpine@pobox.com (Kit O'Connell)
Date: Thu, 1 Nov 2001 02:08:51 -0600 (CST)
Subject: [Tutor] Confused about functions
Message-ID: <Pine.LNX.4.33.0111010204030.16331-100000@bermuda.io.com>

I am working my way through Learning Python (from O'Reilly). I am reading
about functions and how they interact with variables (on built-in, global,
and local levels). The following example code is given:

def changer (x,y):
	x = 2
	y[0] = 'spam'

X = 1
L = [1, 2]
changer (X, L)

at the end of the code, the value of X remains 1, because x is only set to
2 on a local level within the function. However, L has chaned to ['spam',
2].

I am confused. Why does L change, but X doesn't? I hope someone can
explain this for me a bit.

Also, does anyone have an opinion on the Python Essential Referance from
New Riders? How does it compare to O'Reilly's Programming Python or their
Standard Library book?

Thanks!
Kit

-- 
 * Bring to me a handful of stardust,  *    Kit O'Connell
* that I can cast into my darkest night *   vulpine@pobox.com
 *	-Dream Trybe, "Come Down"      *    http://www.dreamspeakers.net/
*       http://www.dreamtrybe.com/      *   Austin, Texas, Planet Earth
			'finger vulpine@io.com' for PGP key



From scarblac@pino.selwerd.nl  Thu Nov  1 08:40:10 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 1 Nov 2001 09:40:10 +0100
Subject: [Tutor] Confused about functions
In-Reply-To: <Pine.LNX.4.33.0111010204030.16331-100000@bermuda.io.com>; from vulpine@pobox.com on Thu, Nov 01, 2001 at 02:08:51AM -0600
References: <Pine.LNX.4.33.0111010204030.16331-100000@bermuda.io.com>
Message-ID: <20011101094010.A1978@pino.selwerd.nl>

On  0, Kit O'Connell <vulpine@pobox.com> wrote:
> I am working my way through Learning Python (from O'Reilly). I am reading
> about functions and how they interact with variables (on built-in, global,
> and local levels). The following example code is given:
> 
> def changer (x,y):
> 	x = 2
> 	y[0] = 'spam'
> 
> X = 1
> L = [1, 2]
> changer (X, L)
> 
> at the end of the code, the value of X remains 1, because x is only set to
> 2 on a local level within the function. However, L has chaned to ['spam',
> 2].
> 
> I am confused. Why does L change, but X doesn't? I hope someone can
> explain this for me a bit.
  
The difference is between

x = 2

and

y[0] = 'spam'

The first makes the local name x refer to the integer 2. No objects are
changed, and nothing outside the function is influenced.

The second changes something *inside* the object y refers to; y[0] refers to
'spam', but y still refers to the same object. So the object is changed, and
everything else that referred to that object (like L) will also show the
change.

So what looks like the same operation is really quite different - make a
local name for something or actually change an object.

Not all objects can be changed, they can be 'immutable', for instance you
would have gotten an error if L had been the tuple (1, 2) instead.

I hope i've cleared up the confusion a bit. If not, someone will try to
explain it with different words :)

> Also, does anyone have an opinion on the Python Essential Referance from
> New Riders? How does it compare to O'Reilly's Programming Python or their
> Standard Library book?

I don't have these books, I use the online documentation.

-- 
Remco Gerlich


From koen@behindthesofa.dhs.org  Thu Nov  1 11:06:04 2001
From: koen@behindthesofa.dhs.org (Koen Bossers)
Date: Thu, 01 Nov 2001 12:06:04 +0100
Subject: [Tutor] [Q] Tkinter
References: <009a01c16250$b7eea2a0$95757e82@visit2>
Message-ID: <3BE12C9C.7070601@behindthesofa.dhs.org>

Young-Jin Lee wrote:


> 
> from Tkinter import *
> 
> class App:
> 
>     def __init__(self, master):
> 
>         frame = Frame(master)
>         frame.pack()
> 
>         self.button = Button(frame, text="QUIT", fg="red", command=frame.quit)


Use "command=master.quit" instead


> root = Tk()
> 
> app = App(root)
> 
> root.mainloop()
> 
> How can I make this test application to quit instead of Python shell 
> itself? When I click the quit button, the IDLE itself quits. This is not 
> what I wanted. I want to close only this application. How can I do this?
> 
> Thanks.
> 


Cheers, Koen

-- 

Python@BehindTheSofa

home of mapselect.py,
dailycomic.py and others.

http://behindthesofa.dhs.org
-------------------------------



From david.jay.jackson@wcox.com  Thu Nov  1 11:24:36 2001
From: david.jay.jackson@wcox.com (Jackson)
Date: Thu,  1 Nov 2001 04:24:36 -0700
Subject: [Tutor] os.system(mysql) (Was help)
Message-ID: <200111010424.AA382271800@wcox.com>

This reply got me wondering about running mysql threw the backdoor?

>| 
>| import os
>| os.system("vim file")
>
><wide grin>  I like that approach :-).

I installed Python and Mysql from binaries on a Sun E6500 at work,
but for some reason when ever I try to compile any thing I get an gcc error message math.h or iso/math.h not found( GCC was installed from binary also)?

>From the shell we can exicute one following to pass a sql script
to mysql:

mysql dbmame -u -p -e sql_script_file
mysql dbname -u -p < sql_script_file


What I want to do is:

------------- Python script -----------
#!/usr/bin/python
import os

hostname = raw_input("Enter hostname: ")
ipaddr = raw_input("Enter IP address: ")

query="insert into text(hostname,ipaddr)
                valuess('hostname','ipaddr')"
os.system(" mysql dbname -u -p -e query)

-----------------

Does that make any sense *grin*

David








From alan.gauld@bt.com  Thu Nov  1 11:49:04 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 1 Nov 2001 11:49:04 -0000
Subject: [Tutor] help
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C055@mbtlipnt02.btlabs.bt.co.uk>

------_=_NextPart_001_01C162CB.34A53550
Content-type: text/plain; charset="ISO-8859-1"

could someone please tell me how to display a text file, and then be able to
type more information into that file? 

Try this:

inf = open("test.txt", "r+")
for l in inf.readlines():
   print l
for i in range(3):
   inf.write("New stuff\n")
nf.close()

For explanation of whats going on read my file 
handling topic at:

http://www.freenetpages.co.uk/hp/alan.gauld/
<http://www.freenetpages.co.uk/hp/alan.gauld/> 

With the additional info that a mode of "r+" passed 
to open()allows you to read and write - use it with 
caution!

Alan g.


------_=_NextPart_001_01C162CB.34A53550
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>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; PADDING-LEFT: 5px">
  <P>could someone please tell me how to display a text file, and then be able 
  to type more information into that file?<FONT color=#0000ff face="Courier New" 
  size=2><SPAN class=790484611-01112001>&nbsp;</SPAN></FONT></P></BLOCKQUOTE>
<P><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=790484611-01112001>Try this:</SPAN></FONT></P>
<P><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=790484611-01112001>inf = open("test.txt", "r+")<BR>for l in 
inf.readlines():<BR>&nbsp;&nbsp; print l<BR>for i in range(3):<BR>&nbsp;&nbsp; 
inf.write("New stuff\n")<BR>nf.close()</SPAN></FONT></P>
<P><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=790484611-01112001>For explanation of whats going on read my file 
<BR></SPAN></FONT><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=790484611-01112001>handling topic at:</SPAN></FONT></P>
<P><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=790484611-01112001><A 
href="http://www.freenetpages.co.uk/hp/alan.gauld/">http://www.freenetpages.co.uk/hp/alan.gauld/</A></SPAN></FONT></P>
<P><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=790484611-01112001>With the additional info that a mode of "r+" passed 
<BR>to open()allows </SPAN></FONT><FONT color=#0000ff face="Courier New" 
size=2><SPAN class=790484611-01112001>you to read and write -&nbsp;use it 
</SPAN></FONT><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=790484611-01112001>with <BR>caution!</SPAN></FONT></P>
<P><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=790484611-01112001>Alan g.</SPAN></FONT></P></BODY></HTML>

------_=_NextPart_001_01C162CB.34A53550--


From kalle@gnupung.net  Thu Nov  1 12:02:48 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Thu, 1 Nov 2001 13:02:48 +0100
Subject: [Tutor] Confused about functions
In-Reply-To: <Pine.LNX.4.33.0111010204030.16331-100000@bermuda.io.com>
References: <Pine.LNX.4.33.0111010204030.16331-100000@bermuda.io.com>
Message-ID: <20011101130247.A27919@sandra.lysator.liu.se>

[Kit O'Connell]
> def changer (x,y):
> 	x = 2
> 	y[0] = 'spam'
> 
> X = 1
> L = [1, 2]
> changer (X, L)

> I am confused. Why does L change, but X doesn't? I hope someone can
> explain this for me a bit.

This is a nice example of how things that look very similar can be very
different...  The key thing to notice here is that
y[0] = 'spam'
isn't an assignment in the same way that
x = 2
is.
The ordinary assignment operator works by binding a name, 'x' in this
case, to an object, here the integer object '2'.  These names are available in
different namespaces and scopes which I suppose Learning Python discusses.

y[0] = 2 isn't really an assignment, it's more like a method call.  This can
be illustrated if we substitute instances of a pointless little class for the
variables in the example:

### begin ###
class A:
    stuff = "Not set!"
    def __setitem__(self, key, val):
        self.stuff = (key, val)
    def __str__(self):
        return "Instance of class A: %s" % self.stuff

a, b = A(), A()
print a, b
a = 2
b[0] = 2
print a, b
### end ###

When run, this will result in:

Instance of class A: 'Not set!' Instance of class A: Not set!
2 Instance of class A: (0, 2)

'a' has been rebound to an integer, 'b' is still the same object, but the
special method __setitem__ has been called.
Nice, eh?

Peace,
  Kalle
-- 
[ Thought control, brought to you by the WIPO! ]
[ http://anti-dmca.org/ http://eurorights.org/ ]


From dsh8290@rit.edu  Thu Nov  1 12:43:38 2001
From: dsh8290@rit.edu (dman)
Date: Thu, 1 Nov 2001 07:43:38 -0500
Subject: [Tutor] os.system(mysql) (Was help)
In-Reply-To: <200111010424.AA382271800@wcox.com>; from david.jay.jackson@wcox.com on Thu, Nov 01, 2001 at 04:24:36AM -0700
References: <200111010424.AA382271800@wcox.com>
Message-ID: <20011101074338.A20739@harmony.cs.rit.edu>

On Thu, Nov 01, 2001 at 04:24:36AM -0700, Jackson wrote:
| This reply got me wondering about running mysql threw the backdoor?
| 
| >| 
| >| import os
| >| os.system("vim file")
| >
| ><wide grin>  I like that approach :-).
| 
| I installed Python and Mysql from binaries on a Sun E6500 at work,
| but for some reason when ever I try to compile any thing I get an
| gcc error message math.h or iso/math.h not found( GCC was installed
| from binary also)?
| 
| >From the shell we can exicute one following to pass a sql script
| to mysql:
| 
| mysql dbmame -u -p -e sql_script_file
| mysql dbname -u -p < sql_script_file
| 
| 
| What I want to do is:
| 
| ------------- Python script -----------
| #!/usr/bin/python
| import os
| 
| hostname = raw_input("Enter hostname: ")
| ipaddr = raw_input("Enter IP address: ")
| 
| query="insert into text(hostname,ipaddr)
|                 valuess('hostname','ipaddr')"
| os.system(" mysql dbname -u -p -e query)
| 
| -----------------
| 
| Does that make any sense *grin*

It is doable, though likely not optimal.  As far as performance is
concerned, you are starting two more processes (a shell and mysql).
More importantly, you have the potential for quoting issues.  When you
call os.system() a shell (probably /bin/sh on *nix systems and
command.com or cmd.exe on win*) is started and it is passed the string
as a commend.  The shell then has to interpret that string, so any
special characters (backslashes, spaces, quotes, etc.) must be escaped
or quoted such that the shell interprets them correctly.  Then the
shell executes the command, and it interprets any arguments passed to
it.  Thus if you wanted to insert the string "\" (a single backslash)
into your db, you'd have to write something like
    "\\\\\\\\"
The reason is, you have to escape each backslash for python.  Thus you
have \\.  Then you have to escape each of those backslashes for the
shell, \\\\.  Then, I assume, mysql will require the backslash to be
escaped, so you need 2 backslashes going into mysql (double what went
into the shell).

So, while what you proposed above is doable, I'd recommend using the
programmatic API instead.  The main difference between accessing a db
and editing a file is that db's have APIs while most text editors
don't.  You could write a text editor, but why?

HTH,
-D



From ak@silmarill.org  Thu Nov  1 14:47:05 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Thu, 01 Nov 2001 09:47:05 -0500
Subject: [Tutor] Confused about functions
In-Reply-To: <Pine.LNX.4.33.0111010204030.16331-100000@bermuda.io.com>
References: <Pine.LNX.4.33.0111010204030.16331-100000@bermuda.io.com>
Message-ID: <20011101094704.A15104@sill.silmarill.org>

On Thu, Nov 01, 2001 at 02:08:51AM -0600, Kit O'Connell wrote:
> I am working my way through Learning Python (from O'Reilly). I am reading
> about functions and how they interact with variables (on built-in, global,
> and local levels). The following example code is given:
> 
> def changer (x,y):
> 	x = 2
> 	y[0] = 'spam'
> 
> X = 1
> L = [1, 2]
> changer (X, L)
> 
> at the end of the code, the value of X remains 1, because x is only set to
> 2 on a local level within the function. However, L has chaned to ['spam',
> 2].
> 
> I am confused. Why does L change, but X doesn't? I hope someone can
> explain this for me a bit.

Consider this:

def changer(x, y):
    x = 1
    y = [1,2]

X = 2
Y = [3,4]
changer(X, Y)
print X, Y # prints 2, [3,4]

Parts of lists can be changed, on the fly. In your code, that's precisely 
what you do. Lists can often be quite large (millions of items) and you
often want to change just one item (or a few) of that list, instead of
making a copy. Imagine how much more expensive it'd be to make a new copy
of a million-item list and change stuff in the new copy, and keep the old
one unchanged!

Now you're probably thinking, well, why doesn't the integer here behave
consistently with a list, then? The reason is encapsulation of data -
in a solid program, you want to pass some stuff into a function and get
results. For instance:

def mult(x, y):
  return x * y

Now, if you're thinking at the place in the code where you call this
function, you'll see this:

result = mult(val1, val2)

You shouldn't need to look at the function to be sure that val1 and val2
don't change. If mult changed val1, for instance, that'd be bad because
when you look at the line above, it looks like you just pass two values
in and get a result. This makes for a much more clearer program: if you
look through code and try to figure out the flow of logic, you don't have
to constantly jump to that functions code to check whether it modified
a variable or not.

These behaviours are only the reasonable defaults, you can override both.

This would change X outside the function:

def changer(x, y):
  global X
  X = 1

This would keep Y list unchanged:

def changer(x, y):
  z = y[:]  # make a copy of y list
  z[0] = "spam"

But, you know, I'm not sure what I said here is exactly right.. if you know
otherwise, please correct me!

  
> 
> Also, does anyone have an opinion on the Python Essential Referance from
> New Riders? How does it compare to O'Reilly's Programming Python or their
> Standard Library book?
> 
> Thanks!
> Kit
> 
> -- 
>  * Bring to me a handful of stardust,  *    Kit O'Connell
> * that I can cast into my darkest night *   vulpine@pobox.com
>  *	-Dream Trybe, "Come Down"      *    http://www.dreamspeakers.net/
> *       http://www.dreamtrybe.com/      *   Austin, Texas, Planet Earth
> 			'finger vulpine@io.com' for PGP key
> 
> 
> _______________________________________________
> 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 david.jay.jackson@wcox.com  Thu Nov  1 16:27:07 2001
From: david.jay.jackson@wcox.com (Jackson)
Date: Thu,  1 Nov 2001 09:27:07 -0700
Subject: [Tutor] os.system(mysql) (Was help)
Message-ID: <200111010927.AA113967406@wcox.com>




D --
Dare I raise the spector of Emacs,which does have a sql-mysql
mode. Although I'm not sure if that qualifies as an API.

David

>
>So, while what you proposed above is doable, I'd recommend using the
>programmatic API instead.  The main difference between accessing a db
>and editing a file is that db's have APIs while most text editors
>don't.  You could write a text editor, but why?
>
>HTH,
>-D
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>


From kimtitu@yahoo.com  Thu Nov  1 18:01:13 2001
From: kimtitu@yahoo.com (Titu Kim)
Date: Thu, 1 Nov 2001 10:01:13 -0800 (PST)
Subject: [Tutor] Confused about functions
In-Reply-To: <20011101094704.A15104@sill.silmarill.org>
Message-ID: <20011101180113.8926.qmail@web14704.mail.yahoo.com>

I am making these statement without refering to the
source. If i am wrong, please correct me. 
    To explain the behaviour in changer(), i believe
python by default passes changer a copy of x, but an
object reference to the list L. Thus, changer makes
change on the copy of x but changes the original list
L. 
--- Andrei Kulakov <sill@optonline.net> wrote:
> On Thu, Nov 01, 2001 at 02:08:51AM -0600, Kit
> O'Connell wrote:
> > I am working my way through Learning Python (from
> O'Reilly). I am reading
> > about functions and how they interact with
> variables (on built-in, global,
> > and local levels). The following example code is
> given:
> > 
> > def changer (x,y):
> > 	x = 2
> > 	y[0] = 'spam'
> > 
> > X = 1
> > L = [1, 2]
> > changer (X, L)
> > 
> > at the end of the code, the value of X remains 1,
> because x is only set to
> > 2 on a local level within the function. However, L
> has chaned to ['spam',
> > 2].
> > 
> > I am confused. Why does L change, but X doesn't? I
> hope someone can
> > explain this for me a bit.
> 
> Consider this:
> 
> def changer(x, y):
>     x = 1
>     y = [1,2]
> 
> X = 2
> Y = [3,4]
> changer(X, Y)
> print X, Y # prints 2, [3,4]
> 
> Parts of lists can be changed, on the fly. In your
> code, that's precisely 
> what you do. Lists can often be quite large
> (millions of items) and you
> often want to change just one item (or a few) of
> that list, instead of
> making a copy. Imagine how much more expensive it'd
> be to make a new copy
> of a million-item list and change stuff in the new
> copy, and keep the old
> one unchanged!
> 
> Now you're probably thinking, well, why doesn't the
> integer here behave
> consistently with a list, then? The reason is
> encapsulation of data -
> in a solid program, you want to pass some stuff into
> a function and get
> results. For instance:
> 
> def mult(x, y):
>   return x * y
> 
> Now, if you're thinking at the place in the code
> where you call this
> function, you'll see this:
> 
> result = mult(val1, val2)
> 
> You shouldn't need to look at the function to be
> sure that val1 and val2
> don't change. If mult changed val1, for instance,
> that'd be bad because
> when you look at the line above, it looks like you
> just pass two values
> in and get a result. This makes for a much more
> clearer program: if you
> look through code and try to figure out the flow of
> logic, you don't have
> to constantly jump to that functions code to check
> whether it modified
> a variable or not.
> 
> These behaviours are only the reasonable defaults,
> you can override both.
> 
> This would change X outside the function:
> 
> def changer(x, y):
>   global X
>   X = 1
> 
> This would keep Y list unchanged:
> 
> def changer(x, y):
>   z = y[:]  # make a copy of y list
>   z[0] = "spam"
> 
> But, you know, I'm not sure what I said here is
> exactly right.. if you know
> otherwise, please correct me!
> 
>   
> > 
> > Also, does anyone have an opinion on the Python
> Essential Referance from
> > New Riders? How does it compare to O'Reilly's
> Programming Python or their
> > Standard Library book?
> > 
> > Thanks!
> > Kit
> > 
> > -- 
> >  * Bring to me a handful of stardust,  *    Kit
> O'Connell
> > * that I can cast into my darkest night *  
> vulpine@pobox.com
> >  *	-Dream Trybe, "Come Down"      *   
> http://www.dreamspeakers.net/
> > *       http://www.dreamtrybe.com/      *  
> Austin, Texas, Planet Earth
> > 			'finger vulpine@io.com' for PGP key
> > 
> > 
> > _______________________________________________
> > 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
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com


From gbcs1978@hotmail.com  Thu Nov  1 18:15:58 2001
From: gbcs1978@hotmail.com (Glauco Silva)
Date: Thu, 1 Nov 2001 16:15:58 -0200
Subject: [Tutor] Help - Create dll
Message-ID: <OE71fweDY4aCQSpZmPS0000d5fd@hotmail.com>

This is a multi-part message in MIME format.

------=_NextPart_000_00A1_01C162F0.7DDD1B00
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi ,
How can i create a dll file ( C dynamic library) from windows to be =
imported by python .


------=_NextPart_000_00A1_01C162F0.7DDD1B00
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.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi ,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>How can i create a dll file (&nbsp;C =
dynamic=20
library) from windows to be imported by python .</FONT></DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_00A1_01C162F0.7DDD1B00--


From vulpine@pobox.com  Thu Nov  1 18:15:07 2001
From: vulpine@pobox.com (Kit O'Connell)
Date: Thu, 1 Nov 2001 12:15:07 -0600 (CST)
Subject: [Tutor] Confused about functions
In-Reply-To: <E15zLDP-0006GM-00@mail.python.org>
Message-ID: <Pine.LNX.4.33.0111011214380.29741-100000@bermuda.io.com>

Thanks to everyone who answered my question about functions. I have a much
better grasp on what is going on now.

Cheers,
Kit

-- 
 * Bring to me a handful of stardust,  *    Kit O'Connell
* that I can cast into my darkest night *   vulpine@pobox.com
 *	-Dream Trybe, "Come Down"      *    http://www.dreamspeakers.net/
*       http://www.dreamtrybe.com/      *   Austin, Texas, Planet Earth
			'finger vulpine@io.com' for PGP key



From alan.gauld@bt.com  Thu Nov  1 18:17:22 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 1 Nov 2001 18:17:22 -0000
Subject: [Tutor] Confused about functions
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C05D@mbtlipnt02.btlabs.bt.co.uk>

> X = 1
> L = [1, 2]
> changer (X, L)
> 
> at the end of the code, the value of X remains 1, 
> because x is only set to 2 on a local level within 
> the function. However, L has chaned to ['spam',2].

No. L has not changed at all. L is a reference to 
a list object. The list object itself is still 
the same list, what has changed is the contents 
of the list.

Now redefine changer() slightly:

>>> def changer(x,y):
...   x = 2
...   y = [3,4] #<-- try to assign a new list
...
>>> changer(X,L)
>>> X,L
(42, ['foo', 2])

Now what happens is function changer() tries to assign 
a new list to y which is representing L. But it can't 
change L so it creates a new local L referencing the 
new list. This then gets lost when the function returns 
and the global L retains its original list.

> Also, does anyone have an opinion on the Python Essential 
> Referance from New Riders? 

The best Python reference book around bar the online 
manuals - which you can also get in print...

> How does it compare to O'Reilly's Programming 
> Python 

Different kind of book. PP explains how/why Python works, 
Essential Python just tells you what it does and how to 
use it. I'd recommend both of these books.

> Standard Library book?

More like EP but not as good IMHO - more like a cookbook 
of handy tips and examples etc.

Alan G.


From scarblac@pino.selwerd.nl  Thu Nov  1 18:19:20 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 1 Nov 2001 19:19:20 +0100
Subject: [Tutor] Confused about functions
In-Reply-To: <20011101180113.8926.qmail@web14704.mail.yahoo.com>; from kimtitu@yahoo.com on Thu, Nov 01, 2001 at 10:01:13AM -0800
References: <20011101094704.A15104@sill.silmarill.org> <20011101180113.8926.qmail@web14704.mail.yahoo.com>
Message-ID: <20011101191919.A2919@pino.selwerd.nl>

On  0, Titu Kim <kimtitu@yahoo.com> wrote:
> I am making these statement without refering to the
> source. If i am wrong, please correct me. 
>     To explain the behaviour in changer(), i believe
> python by default passes changer a copy of x, but an
> object reference to the list L. Thus, changer makes
> change on the copy of x but changes the original list
> L. 

That's not true. Python always passes a reference of every object.

so in a function:

def func(x, y):
   x = 3
   y[0] = 3
   
a = 2
b = [2]

func(a,b)


In this function, x and y initially refer to the same objects as a and b,
since their references are passed to the function.

However, after 'x = 2', the local variable refers to a new object, 3. a is
unchanged, since it still refers to the old object, 2.

After 'y[0] = 3' however, y still refers to the same list, but the inside of
the list is changed. So b is also changed - it's the same list.

It's really the difference between letting a local name refer to a new
object, and changing an object.

-- 
Remco Gerlich


From alan.gauld@bt.com  Thu Nov  1 18:26:20 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 1 Nov 2001 18:26:20 -0000
Subject: [Tutor] os.system(mysql) (Was help)
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C05E@mbtlipnt02.btlabs.bt.co.uk>

> I installed Python and Mysql from binaries on a Sun E6500 

You don't say but I assume you installed the binaries on 
to another Sun? Otherwise it probably won't work!

Even if it was another Sun I'd still advise getting 
the source and rebuilding or if not a Sun find binaries 
for your platform.

Alan G.


From toodles@yifan.net  Thu Nov  1 18:34:10 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Fri, 2 Nov 2001 02:34:10 +0800
Subject: [Tutor] Confused about functions
References: <20011101180113.8926.qmail@web14704.mail.yahoo.com>
Message-ID: <000d01c16303$cd62a3d0$0300a8c0@sun>

> I am making these statement without refering to the
> source. If i am wrong, please correct me.
>     To explain the behaviour in changer(), i believe
> python by default passes changer a copy of x, but an
> object reference to the list L. Thus, changer makes
> change on the copy of x but changes the original list
> L.

In section 4.6 Defining Functions of the Python tutorial:
"The actual parameters (arguments) to a function call are introduced in the
local symbol table of the called function when it is called; thus, arguments
are passed using call by value (where the value is always an object
reference, not the value of the object)."

The objects are both passed in by reference. The difference is (as Remco,
Kalle and Andrei pointed out) in the use of the assignment operator and the
fact that "x" refers to a name and y[0] refers directly to an object.

In the case of
    x=1
the integer 1 is given an alias of "x", but only in the local namespace.
Think of it this way: "X" is in the global namespace, referring to the
integer 2. When X is passed to changer, a reference is created and bound to
the alias "x" in the local namespace. When "x=1" is evaluated, rather than
assigning 1 to the value of "x" it is rebinds "x" to refer to the integer 1.
Given that the object reference was changed and the value of the object "x"
was originally referring to wasn't changed, the value of "X" will remain the
same in the global namespace.

In the case of
    y[0]='spam'
because y[0] is not a name but an object, the value of object that y and Y
will change.

ERGH that sounds really bad I hope you can understand me...

Regards,
Andrew

> --- Andrei Kulakov <sill@optonline.net> wrote:
> > On Thu, Nov 01, 2001 at 02:08:51AM -0600, Kit
> > O'Connell wrote:
> > > I am working my way through Learning Python (from
> > O'Reilly). I am reading
> > > about functions and how they interact with
> > variables (on built-in, global,
> > > and local levels). The following example code is
> > given:
> > >
> > > def changer (x,y):
> > > x = 2
> > > y[0] = 'spam'
> > >
> > > X = 1
> > > L = [1, 2]
> > > changer (X, L)
> > >
> > > at the end of the code, the value of X remains 1,
> > because x is only set to
> > > 2 on a local level within the function. However, L
> > has chaned to ['spam',
> > > 2].
> > >
> > > I am confused. Why does L change, but X doesn't? I
> > hope someone can
> > > explain this for me a bit.
> >
> > Consider this:
> >
> > def changer(x, y):
> >     x = 1
> >     y = [1,2]
> >
> > X = 2
> > Y = [3,4]
> > changer(X, Y)
> > print X, Y # prints 2, [3,4]
> >
> > Parts of lists can be changed, on the fly. In your
> > code, that's precisely
> > what you do. Lists can often be quite large
> > (millions of items) and you
> > often want to change just one item (or a few) of
> > that list, instead of
> > making a copy. Imagine how much more expensive it'd
> > be to make a new copy
> > of a million-item list and change stuff in the new
> > copy, and keep the old
> > one unchanged!
> >
> > Now you're probably thinking, well, why doesn't the
> > integer here behave
> > consistently with a list, then? The reason is
> > encapsulation of data -
> > in a solid program, you want to pass some stuff into
> > a function and get
> > results. For instance:
> >
> > def mult(x, y):
> >   return x * y
> >
> > Now, if you're thinking at the place in the code
> > where you call this
> > function, you'll see this:
> >
> > result = mult(val1, val2)
> >
> > You shouldn't need to look at the function to be
> > sure that val1 and val2
> > don't change. If mult changed val1, for instance,
> > that'd be bad because
> > when you look at the line above, it looks like you
> > just pass two values
> > in and get a result. This makes for a much more
> > clearer program: if you
> > look through code and try to figure out the flow of
> > logic, you don't have
> > to constantly jump to that functions code to check
> > whether it modified
> > a variable or not.
> >
> > These behaviours are only the reasonable defaults,
> > you can override both.
> >
> > This would change X outside the function:
> >
> > def changer(x, y):
> >   global X
> >   X = 1
> >
> > This would keep Y list unchanged:
> >
> > def changer(x, y):
> >   z = y[:]  # make a copy of y list
> >   z[0] = "spam"
> >
> > But, you know, I'm not sure what I said here is
> > exactly right.. if you know
> > otherwise, please correct me!
> >
> >
> > >
> > > Also, does anyone have an opinion on the Python
> > Essential Referance from
> > > New Riders? How does it compare to O'Reilly's
> > Programming Python or their
> > > Standard Library book?
> > >
> > > Thanks!
> > > Kit
> > >
> > > --
> > >  * Bring to me a handful of stardust,  *    Kit
> > O'Connell
> > > * that I can cast into my darkest night *
> > vulpine@pobox.com
> > >  * -Dream Trybe, "Come Down"      *
> > http://www.dreamspeakers.net/
> > > *       http://www.dreamtrybe.com/      *
> > Austin, Texas, Planet Earth
> > > 'finger vulpine@io.com' for PGP key
> > >
> > >
> > > _______________________________________________
> > > 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
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
>
>
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.yahoo.com
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From vulpine@pobox.com  Thu Nov  1 18:44:55 2001
From: vulpine@pobox.com (Kit O'Connell)
Date: Thu, 1 Nov 2001 12:44:55 -0600 (CST)
Subject: Python books (was: RE: [Tutor] Confused about functions)
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66C05D@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <Pine.LNX.4.33.0111011239090.29741-100000@bermuda.io.com>

> No. L has not changed at all. L is a reference to
> a list object. The list object itself is still
> the same list, what has changed is the contents
> of the list.

Ah, that is a detail I had thought about. Thanks for pointing this out.

> The best Python reference book around bar the online
> manuals - which you can also get in print...

Thanks. I do like to have a printed manual, though I also make extensive
use of the online documentation. Besides, it's got an introduction from
Guido, which makes it even cooler. :)

It looks like the book I have here is the first edition. Do you think it
would still be useful to an aspiring python hacker, or should I wait until
I can get a copy of the second edition?

> > How does it compare to O'Reilly's Programming
> > Python
>
> Different kind of book. PP explains how/why Python works,
> Essential Python just tells you what it does and how to
> use it. I'd recommend both of these books.

Great. I'll keep an eye out for PP at the used bookstore where I work.

> > Standard Library book?
>
> More like EP but not as good IMHO - more like a cookbook
> of handy tips and examples etc.

Thanks again for your thoughts on these books.

-- 
 * Bring to me a handful of stardust,  *    Kit O'Connell
* that I can cast into my darkest night *   vulpine@pobox.com
 *	-Dream Trybe, "Come Down"      *    http://www.dreamspeakers.net/
*       http://www.dreamtrybe.com/      *   Austin, Texas, Planet Earth
			'finger vulpine@io.com' for PGP key



From david.jay.jackson@wcox.com  Thu Nov  1 18:48:56 2001
From: david.jay.jackson@wcox.com (Jackson)
Date: Thu,  1 Nov 2001 11:48:56 -0700
Subject: O.T : [Tutor] os.system(mysql) (Was help)
Message-ID: <200111011148.AA399048988@wcox.com>

Alan ---

I didn't install the Linux binaries on the E6500 :)
I downloaded the binaries for Solaris 2.8 from
http://www.sunfreeware.com/

And needless to say they both work. My problem is, when ever
I try to compile anything I get "math.h or iso/maith.h" not found. Another gentleman suggest I need to run "fix_includes"
and recompile gcc from source. Which leads the question?
Can I compile gcc with the existing gcc install gives the above
errors.


---------- Original Message ----------------------------------
From: alan.gauld@bt.com
Date: Thu, 1 Nov 2001 18:26:20 -0000

>> I installed Python and Mysql from binaries on a Sun E6500 
>
>You don't say but I assume you installed the binaries on 
>to another Sun? Otherwise it probably won't work!
>
>Even if it was another Sun I'd still advise getting 
>the source and rebuilding or if not a Sun find binaries 
>for your platform.
>
>Alan G.
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
>


From lkvam@venix.com  Thu Nov  1 19:03:57 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Thu, 01 Nov 2001 14:03:57 -0500
Subject: [Tutor] Confused about functions
References: <Pine.LNX.4.33.0111010204030.16331-100000@bermuda.io.com>
Message-ID: <3BE19C9D.7040603@venix.com>

I keep a local copy of the html file
http://www.brunningonline.net/simon/python/quick-ref2_0.html
Python 2.0 Quick Reference

It is searchable and covers enough to be quite useful.

My bookshelf has:
	Hammond & Robinson
		Python Programming on Win32
		This book is essential for Windows programming

	Chun
		Core Python Programming
		I don't really like it, but it is reasonably accurate

	Lutz
		Programming Python
		Broad coverage of different areas of using Python
		Some of the examples do not use best techniques

	Lund?? (lent it out)
		Python Standard Libraries
		I like the examples, short but not too trivial
	
Kit O'Connell wrote:
....

 > Also, does anyone have an opinion on the Python Essential Referance from
 > New Riders? How does it compare to O'Reilly's Programming Python or their
 > Standard Library book?
 >
 > Thanks!
 > Kit
 >
 >


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

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




From gary@stokeson.freeserve.co.uk  Thu Nov  1 19:06:56 2001
From: gary@stokeson.freeserve.co.uk (gary)
Date: Thu, 1 Nov 2001 19:06:56 -0000
Subject: [Tutor] Creating a path for Python to walk along
Message-ID: <004801c16308$619dbc20$100f883e@oemcomputer>

This is a multi-part message in MIME format.

------=_NextPart_000_0045_01C16308.604E0AA0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi, I am new to python AND to proggramming languages as the forgoing =
will show. I need to create a path to the system files (?) to create =
ext. programmes(?).I have Python version 2.0.1 Python is in =
C:\WINDOWS\Start Menu\Programs\Python 2.0 . Am I even on the right =
path?In essence I need to know without a doubt how to create paths and =
not blunder along causing more harm than good. Thank you, who ever you =
are for being willing to help me. I just can't wait to write that killer =
script: 'Hello, World!' :-)
below is my system info ( in case it is usefully required?)
Microsoft Windows 98 4.10.1998 =20
Clean install using OEM Preinstall Kit /T:C:\WININST0.400 =
/SrcDir=3DC:\WINDOWS\OPTIONS\CABS /IS /IW /IQ /ID /IV /IZ /II /NR /II /C =
 /U:xxxxxxxxxxxxxxxxx
IE 5 5.50.4807.2300
Uptime: 0:00:08:50
Normal mode
On "OEMCOMPUTER" as "Gary"
Time Computers
AuthenticAMD AMD-K6(tm) 3D processor Intel MMX(TM) Technology
64MB RAM
59% system resources free
Windows-managed swap file on drive C (10139MB free)
Available space on drive C: 10139MB of 12405MB (FAT32)


------=_NextPart_000_0045_01C16308.604E0AA0
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.4807.2300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>
<DIV><FONT face=3DArial size=3D2>Hi, I am new to python AND to =
proggramming=20
languages&nbsp;as the forgoing will show. I need&nbsp;to create a path =
to the=20
system files (?) to create&nbsp;ext. programmes(?).I have Python version =
2.0.1=20
Python is in C:\WINDOWS\Start Menu\Programs\Python 2.0 . Am I even on =
the right=20
path?In essence I need to know without a doubt how to create paths and =
not=20
blunder along causing more harm than good. Thank you, who ever you are =
for being=20
willing to help me. I&nbsp;just can't wait to write that killer script: =
'Hello,=20
World!'&nbsp;:-)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>below is my system info ( in case it is =
usefully=20
required?)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Microsoft Windows 98 4.10.1998&nbsp; =
<BR>Clean=20
install using OEM Preinstall Kit /T:C:\WININST0.400=20
/SrcDir=3DC:\WINDOWS\OPTIONS\CABS /IS /IW /IQ /ID /IV /IZ /II /NR /II =
/C&nbsp;=20
/U:xxxxxxxxxxxxxxxxx<BR>IE 5 5.50.4807.2300<BR>Uptime: =
0:00:08:50<BR>Normal=20
mode<BR>On "OEMCOMPUTER" as "Gary"<BR>Time Computers<BR>AuthenticAMD =
AMD-K6(tm)=20
3D processor Intel MMX(TM) Technology<BR>64MB RAM<BR>59% system =
resources=20
free<BR>Windows-managed swap file on drive C (10139MB free)<BR>Available =
space=20
on drive C: 10139MB of 12405MB=20
(FAT32)<BR></FONT></DIV></FONT></DIV></BODY></HTML>

------=_NextPart_000_0045_01C16308.604E0AA0--



From ylee12@uiuc.edu  Thu Nov  1 19:24:54 2001
From: ylee12@uiuc.edu (Young-Jin Lee)
Date: Thu, 1 Nov 2001 13:24:54 -0600
Subject: [Tutor] [Q] from Python Tkinter programming
Message-ID: <007201c1630a$e30edf30$95757e82@visit2>

This is a multi-part message in MIME format.

------=_NextPart_000_006F_01C162D8.97E04580
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi, I'm trying to learn Python programming and I ran into an odd =
problem.
I was reading the sample chapter of "Python and Tkinter programming" to =
learn how to use Tkinter in Python.
I downloaded the sample code and tried to run them in IDLE.=20
For some reason, I couldn't run them in IDLE with the following error.

Traceback (innermost last)
  File "c:\yjlee\worx\dissertation\python-related\python and tkinter =
programming\grayson\examples\chapter11\plot.py", line 404, in ?
    graph.draw(graphObject, 'automatic', 'automatic')
  File "c:\yjlee\worx\dissertation\python-related\python and tkinter =
programming\grayson\examples\chapter11\plot.py", line 226, in draw
    xticks =3D self._ticks(xaxis[0], xaxis[1])
  File "c:\yjlee\worx\dissertation\python-related\python and tkinter =
programming\grayson\examples\chapter11\plot.py", line 363, in _ticks
    ticks.append(t, format % (t,))
TypeError: append() takes exactly 1 argument (2 given)

Program disconnected.

The example seems to provide wrong number of argument and I wanted to =
look up the append() method of Python List. But I don't know where I to =
look up. Is there on-line document for all the methods in Python?
According to the error message, the example code was wrong, but it is =
hard to believe. I think a lot of people already read this article and =
if so, it should have been updated a long time ago, shouldn't it?

Thanks.=20

------=_NextPart_000_006F_01C162D8.97E04580
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.3315.2870" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi, I'm trying to learn Python =
programming and I=20
ran into an odd problem.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I was reading the sample chapter of =
"Python and=20
Tkinter programming" to learn how to use Tkinter in Python.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I downloaded the sample code and tried =
to run them=20
in IDLE. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>For some reason, I couldn't run them in =
IDLE with=20
the following error.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Traceback (innermost last)<BR>&nbsp; =
File=20
"c:\yjlee\worx\dissertation\python-related\python and tkinter=20
programming\grayson\examples\chapter11\plot.py", line 404, in=20
?<BR>&nbsp;&nbsp;&nbsp; graph.draw(graphObject, 'automatic',=20
'automatic')<BR>&nbsp; File =
"c:\yjlee\worx\dissertation\python-related\python=20
and tkinter programming\grayson\examples\chapter11\plot.py", line 226, =
in=20
draw<BR>&nbsp;&nbsp;&nbsp; xticks =3D self._ticks(xaxis[0], =
xaxis[1])<BR>&nbsp;=20
File "c:\yjlee\worx\dissertation\python-related\python and tkinter=20
programming\grayson\examples\chapter11\plot.py", line 363, in=20
_ticks<BR>&nbsp;&nbsp;&nbsp; ticks.append(t, format % =
(t,))<BR>TypeError:=20
append() takes exactly 1 argument (2 given)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Program disconnected.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>The example seems to provide wrong =
number of=20
argument and I wanted to look up the append() method of Python List. But =
I don't=20
know where I to look up. Is there on-line document for all the methods =
in=20
Python?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>According to the error message, the =
example code=20
was wrong, but it is hard to believe. I think a lot of people already =
read this=20
article and if so, it should have been updated a long time ago, =
shouldn't=20
it?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks. </FONT></DIV></BODY></HTML>

------=_NextPart_000_006F_01C162D8.97E04580--



From lkvam@venix.com  Thu Nov  1 19:44:24 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Thu, 01 Nov 2001 14:44:24 -0500
Subject: [Tutor] Creating a path for Python to walk along
References: <004801c16308$619dbc20$100f883e@oemcomputer>
Message-ID: <3BE1A618.2080908@venix.com>

http://downloads.ActiveState.com/ActivePython/windows/2.1/ActivePython-2.1.1.msi

This is the easiest source of Python for someone who doesn't know their 
way around Windows configuration.  It will setup shortcut icons for 
running pythonwin.exe which provides a more Windows style program 
interface.  This is a less portable approach to Python, but could make 
it easier to get started.

gary wrote:

> Hi, I am new to python AND to proggramming languages as the forgoing 
> will show. I need to create a path to the system files (?) to 
> create ext. programmes(?).I have Python version 2.0.1 Python is in 
> C:\WINDOWS\Start Menu\Programs\Python 2.0 . Am I even on the right 
> path?In essence I need to know without a doubt how to create paths and 
> not blunder along causing more harm than good. Thank you, who ever you 
> are for being willing to help me. I just can't wait to write that killer 
> script: 'Hello, World!' :-)
> 
> below is my system info ( in case it is usefully required?)
> 
> Microsoft Windows 98 4.10.1998 
> Clean install using OEM Preinstall Kit /T:C:\WININST0.400 
> /SrcDir=C:\WINDOWS\OPTIONS\CABS /IS /IW /IQ /ID /IV /IZ /II /NR /II /C  
> /U:xxxxxxxxxxxxxxxxx
> IE 5 5.50.4807.2300
> Uptime: 0:00:08:50
> Normal mode
> On "OEMCOMPUTER" as "Gary"
> Time Computers
> AuthenticAMD AMD-K6(tm) 3D processor Intel MMX(TM) Technology
> 64MB RAM
> 59% system resources free
> Windows-managed swap file on drive C (10139MB free)
> Available space on drive C: 10139MB of 12405MB (FAT32)
> 


-- 
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  Thu Nov  1 20:10:39 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 1 Nov 2001 12:10:39 -0800 (PST)
Subject: [Tutor] Help - Create dll
In-Reply-To: <OE71fweDY4aCQSpZmPS0000d5fd@hotmail.com>
Message-ID: <Pine.LNX.4.21.0111011206160.9396-100000@hkn.eecs.berkeley.edu>

On Thu, 1 Nov 2001, Glauco Silva wrote:

> How can i create a dll file ( C dynamic library) from windows to be
> imported by python .

Dear Glauco,

I haven't used Windows for Python programming yet, so I'm not too familiar
with the process of making DLL's.  There's a small section in the
"Extending and Embedding" document that talks about making DLLs:

    http://www.python.org/doc/current/ext/win-dlls.html

You might want to talk with the folks in the main comp.lang.python
newsgroup as well; I'm sure that people there could give pointers on
writing extension modules in Windows.

Anyway, hope things work well.  Good luck!



From dyoo@hkn.eecs.berkeley.edu  Thu Nov  1 20:22:01 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 1 Nov 2001 12:22:01 -0800 (PST)
Subject: [Tutor] [Q] from Python Tkinter programming
In-Reply-To: <007201c1630a$e30edf30$95757e82@visit2>
Message-ID: <Pine.LNX.4.21.0111011210570.9396-100000@hkn.eecs.berkeley.edu>

Hello Young Jin,


On Thu, 1 Nov 2001, Young-Jin Lee wrote:

> Hi, I'm trying to learn Python programming and I ran into an odd
> problem. I was reading the sample chapter of "Python and Tkinter
> programming" to learn how to use Tkinter in Python. I downloaded the

Let's take a look!


> sample code and tried to run them in IDLE.  For some reason, I
> couldn't run them in IDLE with the following error.
> 
> Traceback (innermost last)
>   File "c:\yjlee\worx\dissertation\python-related\python and tkinter programming\grayson\examples\chapter11\plot.py", line 404, in ?
>     graph.draw(graphObject, 'automatic', 'automatic')
>   File "c:\yjlee\worx\dissertation\python-related\python and tkinter programming\grayson\examples\chapter11\plot.py", line 226, in draw
>     xticks = self._ticks(xaxis[0], xaxis[1])
>   File "c:\yjlee\worx\dissertation\python-related\python and tkinter programming\grayson\examples\chapter11\plot.py", line 363, in _ticks
>     ticks.append(t, format % (t,))
> TypeError: append() takes exactly 1 argument (2 given)


Ah!  Do you have the page number where this code is?  That looks like a
typo to me; I would have expected:

    ticks.append( (t, format % (t,)) )

because the append() method of lists only take in a single argument.


> The example seems to provide wrong number of argument and I wanted to
> look up the append() method of Python List. But I don't know where I
> to look up. Is there on-line document for all the methods in Python?


Yes, you'll want to look at:

    http://www.python.org/doc/lib/typesseq-mutable.html

Actually, the problem you found with append() is explained in Footnote 1
of the link.  Python used to allow append() to have multiple arguments,
but the designers saw this as a design flaw, so they fixed it so that it
only takes one.



> According to the error message, the example code was wrong, but it is
> hard to believe. I think a lot of people already read this article and
> if so, it should have been updated a long time ago, shouldn't it?

Yes.  It may already be corrected in the author's Errata at,

    http://www.manning.com/Grayson/Errata.html

If you can tell us the page number, we can see if it's already been
corrected by the author, and if not, we should inform the author to
fix his code.


Good luck to you!



From dyoo@hkn.eecs.berkeley.edu  Thu Nov  1 20:49:19 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 1 Nov 2001 12:49:19 -0800 (PST)
Subject: [Tutor] MySQLdb saga continues :(
In-Reply-To: <200110312239.f9VMdpZ08488@smtp4.fas.harvard.edu>
Message-ID: <Pine.LNX.4.21.0111011233310.9396-100000@hkn.eecs.berkeley.edu>

On Wed, 31 Oct 2001, Pijus Virketis wrote:

> well, my helpfull ISP admin sent me this message:
> 
> --------------------- error message ----------------------
> OK, I downloaded Disutils and followed the install instructions and got the 
> following error:
> 
> python setup.py install
> 
> Error in %s at %d: %s ('setup.cfg', 21, "'[bdist_rpm]\\012'")
> Error in %s at %d: %s ('setup.cfg', 24, "'doc_files = CHANGES.txt\\012'")
> Traceback (innermost last):
>    File "setup.py", line 13, in ?
>      setup (name = "Distutils",
>    File "distutils/core.py", line 110, in setup
>      dist.parse_config_files()
>    File "distutils/dist.py", line 323, in parse_config_files
>      parser.read(filename)
>    File "/usr/lib/python1.5/ConfigParser.py", line 154, in read
>      self.__read(fp)
>    File "/usr/lib/python1.5/ConfigParser.py", line 232, in __read
>      cursect = cursect[optname] + '\n ' + value
> TypeError: expected integer index
> --------------------- end error message ----------------------
> 
> Sorry to bother you with this, but this is really what I know nothing about
> in Python. Any ideas as to how to do this thing?


Yikes.  It looks like Distutils doesn't work well with Python 1.51.  I
just took a closer look at MySQLdb's README, and there are disheartening
words:

"""Prerequisites:

Python 1.5.2 or higher
-- http://www.python.org/
-- Versions lower than 1.5.2 WON'T WORK.
-- All versions from 1.5.2 should work. 1.6.x versions have not been
   tested. 2.0.1, 2.1.1, and 2.2a3 have all been tested.
...
"""

Is there any way you can convince your ISP to install a newer version of
Python?



From kimtitu@yahoo.com  Thu Nov  1 22:31:49 2001
From: kimtitu@yahoo.com (Titu Kim)
Date: Thu, 1 Nov 2001 14:31:49 -0800 (PST)
Subject: [Tutor] Confused about functions
In-Reply-To: <000d01c16303$cd62a3d0$0300a8c0@sun>
Message-ID: <20011101223149.71812.qmail@web14704.mail.yahoo.com>

So, can i conclude that in local namespace of
changer(), object reference of 'x' is altered to point
to integer 1, while object reference of 'X' in global
namespace still points to integer 2? If i define my
changer as 'changer(X,Y)', changer() still behaves the
same way because 'X' in changer() and 'X' in global
reside at different momory location(although same
name) but they point to same memory location of
integer '2'. Once i changer laters object reference of
local 'X' to point to integer '1', then at this point
two 'X's refer to different memory locations. Am
thinking in right direction? Please correct me.

Regards,
Kim Titu.
--- Andrew Wilkins <toodles@yifan.net> wrote:
> > I am making these statement without refering to
> the
> > source. If i am wrong, please correct me.
> >     To explain the behaviour in changer(), i
> believe
> > python by default passes changer a copy of x, but
> an
> > object reference to the list L. Thus, changer
> makes
> > change on the copy of x but changes the original
> list
> > L.
> 
> In section 4.6 Defining Functions of the Python
> tutorial:
> "The actual parameters (arguments) to a function
> call are introduced in the
> local symbol table of the called function when it is
> called; thus, arguments
> are passed using call by value (where the value is
> always an object
> reference, not the value of the object)."
> 
> The objects are both passed in by reference. The
> difference is (as Remco,
> Kalle and Andrei pointed out) in the use of the
> assignment operator and the
> fact that "x" refers to a name and y[0] refers
> directly to an object.
> 
> In the case of
>     x=1
> the integer 1 is given an alias of "x", but only in
> the local namespace.
> Think of it this way: "X" is in the global
> namespace, referring to the
> integer 2. When X is passed to changer, a reference
> is created and bound to
> the alias "x" in the local namespace. When "x=1" is
> evaluated, rather than
> assigning 1 to the value of "x" it is rebinds "x" to
> refer to the integer 1.
> Given that the object reference was changed and the
> value of the object "x"
> was originally referring to wasn't changed, the
> value of "X" will remain the
> same in the global namespace.
> 
> In the case of
>     y[0]='spam'
> because y[0] is not a name but an object, the value
> of object that y and Y
> will change.
> 
> ERGH that sounds really bad I hope you can
> understand me...
> 
> Regards,
> Andrew
> 
> > --- Andrei Kulakov <sill@optonline.net> wrote:
> > > On Thu, Nov 01, 2001 at 02:08:51AM -0600, Kit
> > > O'Connell wrote:
> > > > I am working my way through Learning Python
> (from
> > > O'Reilly). I am reading
> > > > about functions and how they interact with
> > > variables (on built-in, global,
> > > > and local levels). The following example code
> is
> > > given:
> > > >
> > > > def changer (x,y):
> > > > x = 2
> > > > y[0] = 'spam'
> > > >
> > > > X = 1
> > > > L = [1, 2]
> > > > changer (X, L)
> > > >
> > > > at the end of the code, the value of X remains
> 1,
> > > because x is only set to
> > > > 2 on a local level within the function.
> However, L
> > > has chaned to ['spam',
> > > > 2].
> > > >
> > > > I am confused. Why does L change, but X
> doesn't? I
> > > hope someone can
> > > > explain this for me a bit.
> > >
> > > Consider this:
> > >
> > > def changer(x, y):
> > >     x = 1
> > >     y = [1,2]
> > >
> > > X = 2
> > > Y = [3,4]
> > > changer(X, Y)
> > > print X, Y # prints 2, [3,4]
> > >
> > > Parts of lists can be changed, on the fly. In
> your
> > > code, that's precisely
> > > what you do. Lists can often be quite large
> > > (millions of items) and you
> > > often want to change just one item (or a few) of
> > > that list, instead of
> > > making a copy. Imagine how much more expensive
> it'd
> > > be to make a new copy
> > > of a million-item list and change stuff in the
> new
> > > copy, and keep the old
> > > one unchanged!
> > >
> > > Now you're probably thinking, well, why doesn't
> the
> > > integer here behave
> > > consistently with a list, then? The reason is
> > > encapsulation of data -
> > > in a solid program, you want to pass some stuff
> into
> > > a function and get
> > > results. For instance:
> > >
> > > def mult(x, y):
> > >   return x * y
> > >
> > > Now, if you're thinking at the place in the code
> > > where you call this
> > > function, you'll see this:
> > >
> > > result = mult(val1, val2)
> > >
> > > You shouldn't need to look at the function to be
> > > sure that val1 and val2
> > > don't change. If mult changed val1, for
> instance,
> > > that'd be bad because
> > > when you look at the line above, it looks like
> you
> > > just pass two values
> > > in and get a result. This makes for a much more
> > > clearer program: if you
> > > look through code and try to figure out the flow
> of
> > > logic, you don't have
> > > to constantly jump to that functions code to
> check
> > > whether it modified
> > > a variable or not.
> > >
> > > These behaviours are only the reasonable
> defaults,
> > > you can override both.
> > >
> > > This would change X outside the function:
> > >
> > > def changer(x, y):
> > >   global X
> > >   X = 1
> > >
> > > This would keep Y list unchanged:
> > >
> > > def changer(x, y):
> > >   z = y[:]  # make a copy of y list
> > >   z[0] = "spam"
> > >
> > > But, you know, I'm not sure what I said here is
> > > exactly right.. if you know
> > > otherwise, please correct me!
> > >
> > >
> > > >
> > > > Also, does anyone have an opinion on the
> Python
> > > Essential Referance from
> > > > New Riders? How does it compare to O'Reilly's
> > > Programming Python or their
> > > > Standard Library book?
> > > >
> > > > Thanks!
> > > > Kit
> > > >
> > > > --
> > > >  * Bring to me a handful of stardust,  *   
> Kit
> > > O'Connell
> > > > * that I can cast into my darkest night *
> > > vulpine@pobox.com
> > > >  * -Dream Trybe, "Come Down"      *
> > > http://www.dreamspeakers.net/
> > > > *       http://www.dreamtrybe.com/      *
> > > Austin, Texas, Planet Earth
> > > > 'finger vulpine@io.com' for PGP key
> > > >
> > > >
> 
=== message truncated ===


__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com


From dsh8290@rit.edu  Thu Nov  1 23:22:54 2001
From: dsh8290@rit.edu (dman)
Date: Thu, 1 Nov 2001 18:22:54 -0500
Subject: [Tutor] os.system(mysql) (Was help)
In-Reply-To: <200111010927.AA113967406@wcox.com>; from david.jay.jackson@wcox.com on Thu, Nov 01, 2001 at 09:27:07AM -0700
References: <200111010927.AA113967406@wcox.com>
Message-ID: <20011101182254.A23634@harmony.cs.rit.edu>

On Thu, Nov 01, 2001 at 09:27:07AM -0700, Jackson wrote:
 
| D --
|
| >So, while what you proposed above is doable, I'd recommend using the
| >programmatic API instead.  The main difference between accessing a db
| >and editing a file is that db's have APIs while most text editors
| >don't.  You could write a text editor, but why?
| 
| Dare I raise the spector of Emacs,

No <wink>.

| which does have a sql-mysql mode. 

interesting ...

| Although I'm not sure if that qualifies as an API.

Is it a shell-like thing, or is it a set of functions that can be
called programmatically?  PostgreSQL comes with a shell, 'psql', that
can be run and used to interactively execute SQL statements.  An API
is an Application Programming Interface -- an interface for
applications, not people, to use.

-D



From ylee12@uiuc.edu  Thu Nov  1 23:49:20 2001
From: ylee12@uiuc.edu (Young-Jin Lee)
Date: Thu, 1 Nov 2001 17:49:20 -0600
Subject: [Tutor] [Q] IDLE setting
Message-ID: <00d601c1632f$d3ca5570$95757e82@visit2>

This is a multi-part message in MIME format.

------=_NextPart_000_00D3_01C162FD.8920A330
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi, I'm a newbie trying to learn Python.
I have a problem using IDLE. I think IDLE import modules only from the =
sys.path, but I don't know how to change the sys.path in IDLE (or =
outside a IDLE). I tried to run a wxPython demo code after loading the =
file into IDLE, but IDLE failed to load it. But I could run it on the =
command window of windows 2000 os.=20

Thanks in advance.

YJ

------=_NextPart_000_00D3_01C162FD.8920A330
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.3315.2870" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi, I'm a newbie trying to learn=20
Python.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have a problem using IDLE. I think =
IDLE import=20
modules only from the sys.path, but I don't know how to change the =
sys.path in=20
IDLE (or outside a IDLE). I tried to run a wxPython demo code after =
loading the=20
file into IDLE, but IDLE failed to load it. But I&nbsp;could run it on =
the=20
command window of windows 2000 os. </FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks in advance.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>YJ</FONT></DIV></BODY></HTML>

------=_NextPart_000_00D3_01C162FD.8920A330--



From lkvam@venix.com  Fri Nov  2 00:10:21 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Thu, 01 Nov 2001 19:10:21 -0500
Subject: [Tutor] Confused about functions
References: <20011101223149.71812.qmail@web14704.mail.yahoo.com>
Message-ID: <3BE1E46D.4000400@venix.com>

Here's my mental image (for better or worse).

X = 1
Python creates a "bucket of bits" where the bits represent a one.  Then 
Python writes an X on a sticky label.  Finaly the label is stuck on the 
bucket.

In C (or VB or COBOL or Fortran ...)
X = 1
C takes the bits that represent 1 and sticks them in a bucket labeled X. 
  The programmer must have created that bucket by declaring X.  (int X;, 
or  DIM X AS Integer, etc.)

L = [1,2]
Python again creates a "bucket of bits" and sticks in bits for a one and 
a two.  A sticky label of L is attached.  This bucket is different.  It 
is mutable.  You can change the bits in the bucket.

L[0] = 3
Python finds the bucket with the L label, takes out the bits at the zero 
postion and replaces them with bits that represent three.

X = 3
Python creates a new bit bucket with bits representing three in the 
bucket.  Then it finds the X label, peels it off the old bucket and 
sticks it on the new bucket.  If the old bucket has no labels it is 
recycled (garbage collection).

Y = X
Python finds the Y label (or creates a new label for Y) and then sticks 
it on the bucket that already has an X label.  Buckets can have many labels.


I hope that helps.  While Python programs do not necessarily look so 
very different from C or Java programs, the underlying variable handling 
is different.  For most situations, Python's immutable "buckets" are a 
big improvement.

Titu Kim wrote:

> So, can i conclude that in local namespace of
> changer(), object reference of 'x' is altered to point
> to integer 1, while object reference of 'X' in global
> namespace still points to integer 2? If i define my
> changer as 'changer(X,Y)', changer() still behaves the
> same way because 'X' in changer() and 'X' in global
> reside at different momory location(although same
> name) but they point to same memory location of
> integer '2'. Once i changer laters object reference of
> local 'X' to point to integer '1', then at this point
> two 'X's refer to different memory locations. Am
> thinking in right direction? Please correct me.
> 
> Regards,
> Kim Titu.
> --- Andrew Wilkins <toodles@yifan.net> wrote:
> 
>>>I am making these statement without refering to
>>>
>>the
>>
>>>source. If i am wrong, please correct me.
>>>    To explain the behaviour in changer(), i
>>>
>>believe
>>
>>>python by default passes changer a copy of x, but
>>>
>>an
>>
>>>object reference to the list L. Thus, changer
>>>
>>makes
>>
>>>change on the copy of x but changes the original
>>>
>>list
>>
>>>L.
>>>
>>In section 4.6 Defining Functions of the Python
>>tutorial:
>>"The actual parameters (arguments) to a function
>>call are introduced in the
>>local symbol table of the called function when it is
>>called; thus, arguments
>>are passed using call by value (where the value is
>>always an object
>>reference, not the value of the object)."
>>
>>The objects are both passed in by reference. The
>>difference is (as Remco,
>>Kalle and Andrei pointed out) in the use of the
>>assignment operator and the
>>fact that "x" refers to a name and y[0] refers
>>directly to an object.
>>
>>In the case of
>>    x=1
>>the integer 1 is given an alias of "x", but only in
>>the local namespace.
>>Think of it this way: "X" is in the global
>>namespace, referring to the
>>integer 2. When X is passed to changer, a reference
>>is created and bound to
>>the alias "x" in the local namespace. When "x=1" is
>>evaluated, rather than
>>assigning 1 to the value of "x" it is rebinds "x" to
>>refer to the integer 1.
>>Given that the object reference was changed and the
>>value of the object "x"
>>was originally referring to wasn't changed, the
>>value of "X" will remain the
>>same in the global namespace.
>>
>>In the case of
>>    y[0]='spam'
>>because y[0] is not a name but an object, the value
>>of object that y and Y
>>will change.
>>
>>ERGH that sounds really bad I hope you can
>>understand me...
>>
>>Regards,
>>Andrew
>>
>>
>>>--- Andrei Kulakov <sill@optonline.net> wrote:
>>>
>>>>On Thu, Nov 01, 2001 at 02:08:51AM -0600, Kit
>>>>O'Connell wrote:
>>>>
>>>>>I am working my way through Learning Python
>>>>>
>>(from
>>
>>>>O'Reilly). I am reading
>>>>
>>>>>about functions and how they interact with
>>>>>
>>>>variables (on built-in, global,
>>>>
>>>>>and local levels). The following example code
>>>>>
>>is
>>
>>>>given:
>>>>
>>>>>def changer (x,y):
>>>>>x = 2
>>>>>y[0] = 'spam'
>>>>>
>>>>>X = 1
>>>>>L = [1, 2]
>>>>>changer (X, L)
>>>>>
>>>>>at the end of the code, the value of X remains
>>>>>
>>1,
>>
>>>>because x is only set to
>>>>
>>>>>2 on a local level within the function.
>>>>>
>>However, L
>>
>>>>has chaned to ['spam',
>>>>
>>>>>2].
>>>>>
>>>>>I am confused. Why does L change, but X
>>>>>
>>doesn't? I
>>
>>>>hope someone can
>>>>
>>>>>explain this for me a bit.
>>>>>
>>>>Consider this:
>>>>
>>>>def changer(x, y):
>>>>    x = 1
>>>>    y = [1,2]
>>>>
>>>>X = 2
>>>>Y = [3,4]
>>>>changer(X, Y)
>>>>print X, Y # prints 2, [3,4]
>>>>
>>>>Parts of lists can be changed, on the fly. In
>>>>
>>your
>>
>>>>code, that's precisely
>>>>what you do. Lists can often be quite large
>>>>(millions of items) and you
>>>>often want to change just one item (or a few) of
>>>>that list, instead of
>>>>making a copy. Imagine how much more expensive
>>>>
>>it'd
>>
>>>>be to make a new copy
>>>>of a million-item list and change stuff in the
>>>>
>>new
>>
>>>>copy, and keep the old
>>>>one unchanged!
>>>>
>>>>Now you're probably thinking, well, why doesn't
>>>>
>>the
>>
>>>>integer here behave
>>>>consistently with a list, then? The reason is
>>>>encapsulation of data -
>>>>in a solid program, you want to pass some stuff
>>>>
>>into
>>
>>>>a function and get
>>>>results. For instance:
>>>>
>>>>def mult(x, y):
>>>>  return x * y
>>>>
>>>>Now, if you're thinking at the place in the code
>>>>where you call this
>>>>function, you'll see this:
>>>>
>>>>result = mult(val1, val2)
>>>>
>>>>You shouldn't need to look at the function to be
>>>>sure that val1 and val2
>>>>don't change. If mult changed val1, for
>>>>
>>instance,
>>
>>>>that'd be bad because
>>>>when you look at the line above, it looks like
>>>>
>>you
>>
>>>>just pass two values
>>>>in and get a result. This makes for a much more
>>>>clearer program: if you
>>>>look through code and try to figure out the flow
>>>>
>>of
>>
>>>>logic, you don't have
>>>>to constantly jump to that functions code to
>>>>
>>check
>>
>>>>whether it modified
>>>>a variable or not.
>>>>
>>>>These behaviours are only the reasonable
>>>>
>>defaults,
>>
>>>>you can override both.
>>>>
>>>>This would change X outside the function:
>>>>
>>>>def changer(x, y):
>>>>  global X
>>>>  X = 1
>>>>
>>>>This would keep Y list unchanged:
>>>>
>>>>def changer(x, y):
>>>>  z = y[:]  # make a copy of y list
>>>>  z[0] = "spam"
>>>>
>>>>But, you know, I'm not sure what I said here is
>>>>exactly right.. if you know
>>>>otherwise, please correct me!
>>>>
>>>>
>>>>
>>>>>Also, does anyone have an opinion on the
>>>>>
>>Python
>>
>>>>Essential Referance from
>>>>
>>>>>New Riders? How does it compare to O'Reilly's
>>>>>
>>>>Programming Python or their
>>>>
>>>>>Standard Library book?
>>>>>
>>>>>Thanks!
>>>>>Kit
>>>>>
>>>>>--
>>>>> * Bring to me a handful of stardust,  *   
>>>>>
>>Kit
>>
>>>>O'Connell
>>>>
>>>>>* that I can cast into my darkest night *
>>>>>
>>>>vulpine@pobox.com
>>>>
>>>>> * -Dream Trybe, "Come Down"      *
>>>>>
>>>>http://www.dreamspeakers.net/
>>>>
>>>>>*       http://www.dreamtrybe.com/      *
>>>>>
>>>>Austin, Texas, Planet Earth
>>>>
>>>>>'finger vulpine@io.com' for PGP key
>>>>>
>>>>>
>>>>>
> === message truncated ===
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.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 scarblac@pino.selwerd.nl  Fri Nov  2 00:10:03 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Fri, 2 Nov 2001 01:10:03 +0100
Subject: [Tutor] Confused about functions
In-Reply-To: <20011101223149.71812.qmail@web14704.mail.yahoo.com>; from kimtitu@yahoo.com on Thu, Nov 01, 2001 at 02:31:49PM -0800
References: <000d01c16303$cd62a3d0$0300a8c0@sun> <20011101223149.71812.qmail@web14704.mail.yahoo.com>
Message-ID: <20011102011003.A3353@pino.selwerd.nl>

On  0, Titu Kim <kimtitu@yahoo.com> wrote:
> So, can i conclude that in local namespace of
> changer(), object reference of 'x' is altered to point
> to integer 1, while object reference of 'X' in global
> namespace still points to integer 2? If i define my
> changer as 'changer(X,Y)', changer() still behaves the
> same way because 'X' in changer() and 'X' in global
> reside at different momory location(although same
> name) but they point to same memory location of
> integer '2'. Once i changer laters object reference of
> local 'X' to point to integer '1', then at this point
> two 'X's refer to different memory locations. Am
> thinking in right direction? Please correct me.

As far as I can see at the moment (it's rather late at night) this is
completely correct.

-- 
Remco Gerlich


From scarblac@pino.selwerd.nl  Fri Nov  2 00:12:09 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Fri, 2 Nov 2001 01:12:09 +0100
Subject: [Tutor] Confused about functions
In-Reply-To: <3BE19C9D.7040603@venix.com>; from lkvam@venix.com on Thu, Nov 01, 2001 at 02:03:57PM -0500
References: <Pine.LNX.4.33.0111010204030.16331-100000@bermuda.io.com> <3BE19C9D.7040603@venix.com>
Message-ID: <20011102011209.B3353@pino.selwerd.nl>

On  0, Lloyd Kvam <lkvam@venix.com> wrote:
> 	Lund?? (lent it out)
> 		Python Standard Libraries
> 		I like the examples, short but not too trivial

The name is Fredrik Lundh, aka effbot. He's one of the most useful posters
on comp.lang.python ever.

-- 
Remco Gerlich


From davej@theporch.pickledbeans.com  Fri Nov  2 00:39:23 2001
From: davej@theporch.pickledbeans.com (David Jackson)
Date: Thu, 1 Nov 2001 17:39:23 -0700
Subject: [Tutor] os.system(mysql) (Was help)
In-Reply-To: <20011101182254.A23634@harmony.cs.rit.edu>; from dsh8290@rit.edu on Thu, Nov 01, 2001 at 06:22:54PM -0500
References: <200111010927.AA113967406@wcox.com> <20011101182254.A23634@harmony.cs.rit.edu>
Message-ID: <20011101173923.A16023@theporch>

-D
I'm going to say shell, because opens up buffer with mysql >> prompt in it,
but only Richard Stallings and God knows for sure....and God would probley deferr to RMS on this one *grin*


DJJ

> | 
> | Dare I raise the spector of Emacs,
> 
> No <wink>.
> 
> | Although I'm not sure if that qualifies as an API.
> 
> Is it a shell-like thing, or is it a set of functions that can be
> called programmatically?  PostgreSQL comes with a shell, 'psql', that
> can be run and used to interactively execute SQL statements.  An API
> is an Application Programming Interface -- an interface for
> applications, not people, to use.
> 
> -D
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 


From toodles@yifan.net  Fri Nov  2 00:58:06 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Fri, 2 Nov 2001 08:58:06 +0800
Subject: [Tutor] [Q] IDLE setting
References: <00d601c1632f$d3ca5570$95757e82@visit2>
Message-ID: <002b01c16339$7076e3d0$0300a8c0@sun>

This is a multi-part message in MIME format.

------=_NextPart_000_0028_01C1637C.7D284450
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi Young-Jin

You're quite right in thinking that Python works with sys.path. All you =
need to do is append the directory to sys.path that contains the =
program. sys.path.append("directory")
Example:

####
>>> import sys
>>> sys.path
['C:\\Python21\\Tools\\idle', 'C:\\Python21', 'C:\\Python21\\DLLs', =
'C:\\Python21\\lib', 'C:\\Python21\\lib\\plat-win', =
'C:\\Python21\\lib\\lib-tk']
>>> import monkey
Traceback (most recent call last):
  File "<pyshell#3>", line 1, in ?
    import monkey
ImportError: No module named monkey
>>> sys.path.append('c:\\monkey')
>>> import monkey
His nature was - IRREPRESSIBLE!
###

Regards,
Andrew

  ----- Original Message -----=20
  From: Young-Jin Lee=20
  To: tutor@python.org=20
  Sent: Friday, November 02, 2001 7:49 AM
  Subject: [Tutor] [Q] IDLE setting


  Hi, I'm a newbie trying to learn Python.
  I have a problem using IDLE. I think IDLE import modules only from the =
sys.path, but I don't know how to change the sys.path in IDLE (or =
outside a IDLE). I tried to run a wxPython demo code after loading the =
file into IDLE, but IDLE failed to load it. But I could run it on the =
command window of windows 2000 os.=20

  Thanks in advance.

  YJ

------=_NextPart_000_0028_01C1637C.7D284450
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#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi Young-Jin</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>You're quite right in thinking that =
Python works=20
with sys.path. All you need to do is append the directory to sys.path =
that=20
contains the program. sys.path.append("directory")</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Example:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>####</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&gt;&gt;&gt; import sys</FONT><FONT =
face=3DArial=20
size=3D2><BR>&gt;&gt;&gt; sys.path<BR>['C:\\Python21\\Tools\\idle',=20
'C:\\Python21', 'C:\\Python21\\DLLs', 'C:\\Python21\\lib',=20
'C:\\Python21\\lib\\plat-win', 'C:\\Python21\\lib\\lib-tk']</FONT><FONT=20
face=3DArial size=3D2><BR>&gt;&gt;&gt; import monkey<BR>Traceback (most =
recent call=20
last):<BR>&nbsp; File "&lt;pyshell#3&gt;", line 1, in =
?<BR>&nbsp;&nbsp;&nbsp;=20
import monkey<BR>ImportError: No module named monkey<BR>&gt;&gt;&gt;=20
sys.path.append('c:\\monkey')<BR>&gt;&gt;&gt; import monkey<BR>His =
nature was -=20
IRREPRESSIBLE!</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>###</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Regards,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Andrew</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A title=3Dylee12@uiuc.edu href=3D"mailto:ylee12@uiuc.edu">Young-Jin =
Lee</A>=20
</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A title=3Dtutor@python.org =

  href=3D"mailto:tutor@python.org">tutor@python.org</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Friday, November 02, 2001 =
7:49=20
  AM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Tutor] [Q] IDLE =
setting</DIV>
  <DIV><BR></DIV>
  <DIV><FONT face=3DArial size=3D2>Hi, I'm a newbie trying to learn=20
  Python.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>I have a problem using IDLE. I think =
IDLE import=20
  modules only from the sys.path, but I don't know how to change the =
sys.path in=20
  IDLE (or outside a IDLE). I tried to run a wxPython demo code after =
loading=20
  the file into IDLE, but IDLE failed to load it. But I&nbsp;could run =
it on the=20
  command window of windows 2000 os. </FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>Thanks in advance.</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial =
size=3D2>YJ</FONT></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0028_01C1637C.7D284450--



From virketis@fas.harvard.edu  Fri Nov  2 00:57:55 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Thu, 1 Nov 2001 19:57:55 -0500
Subject: [Tutor] [Q] IDLE setting
In-Reply-To: <00d601c1632f$d3ca5570$95757e82@visit2>
References: <00d601c1632f$d3ca5570$95757e82@visit2>
Message-ID: <200111020057.fA20vFA29997@smtp3.fas.harvard.edu>

Hi YJ,

> I have a problem using IDLE. I think IDLE import modules only from the
> sys.path, but I don't know how to change the sys.path in IDLE (or outside a
> IDLE). 

I am not sure, but this seems to be a "feature", rather than a "problem" :) 
In any case, it is easy to resove. Just type:

>>> import sys
>>> sys.path()

# Python prints out your curren path ... After inspecting it, type

>>> sys.path.append("/your/path/")
>>> sys.path()

# Python prints out the modified path

N.B. These changes will be session-specific, i.e., you'll need to add the 
path again when you close and reopen Python.

Cheers, 

Pijus


From shalehperry@home.com  Fri Nov  2 04:15:14 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Thu, 01 Nov 2001 20:15:14 -0800 (PST)
Subject: Python books (was: RE: [Tutor] Confused about functions)
In-Reply-To: <Pine.LNX.4.33.0111011239090.29741-100000@bermuda.io.com>
Message-ID: <XFMail.20011101201514.shalehperry@home.com>

> 
> It looks like the book I have here is the first edition. Do you think it
> would still be useful to an aspiring python hacker, or should I wait until
> I can get a copy of the second edition?
> 

I am not directly familiar with the book, that said the biggest change from 1.4
and earlier to 1.5.x was exceptions were now supposeed to be classes instead of
strings.  If you look through the standard lib of 1.5 you can see both (NNTP is
strings for instance).  The 2.x series of python added some new features which
are cool but are also not in 1.5.x which is still the most common version. 
1.5.x python code still works without problems in 2.x.


From charlie@begeistert.org  Fri Nov  2 13:53:31 2001
From: charlie@begeistert.org (Charlie Clark)
Date: Fri, 02 Nov 2001 14:53:31 +0100
Subject: [Tutor] Problem parsing an HTML-Website: SGML Parser error
Message-ID: <20011102135916.C9D3737D91@mx04.nexgo.de>

Dear all,

I've currently got a bunch of scripts all running and collecting data from various websites. The inevitable has happened and I've now got a website which cannot be 
parsed at all. The pages seem to written in Microsoft word by hand.

The error generated is 
File "C:\Python21\lib\sgmllib.py", line 91, in feed
    self.goahead(0)
  File "C:\Python21\lib\sgmllib.py", line 158, in goahead
    k = self.parse_declaration(i)
  File "C:\Python21\lib\sgmllib.py", line 238, in parse_declaration
    raise SGMLParseError(
SGMLParseError: unexpected char in declaration: '<

An example can be found at

http://www.royal-muenchen.de/archiv/f_012836.htm

What I need to know is what is the best way of finding out what is wrong in the source so that I can try and remove it before sending it to the parser.

A response to me directly would be appreciated. Many thanx for your help.

Charlie

Charlie Clark
Helmholtzstr. 20
Düsseldorf
40215
Tel: +49-178-782-6226 




From shalehperry@home.com  Fri Nov  2 18:23:56 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Fri, 02 Nov 2001 10:23:56 -0800 (PST)
Subject: [Tutor] Problem parsing an HTML-Website: SGML Parser error
In-Reply-To: <20011102135916.C9D3737D91@mx04.nexgo.de>
Message-ID: <XFMail.20011102102356.shalehperry@home.com>

> 
> What I need to know is what is the best way of finding out what is wrong in
> the source so that I can try and remove it before sending it to the parser.
> 
> A response to me directly would be appreciated. Many thanx for your help.
> 

My guess is the embedded xml is killing it.  Perhaps you could convince
SGMLParser that anything between <xml></xml> should be ignored.

That is some amazingly ugly html code.


From kaffeen@mac.com  Fri Nov  2 21:52:12 2001
From: kaffeen@mac.com (Chris Scott)
Date: Fri, 02 Nov 2001 16:52:12 -0500
Subject: [Tutor] Tkinter question
Message-ID: <B8087FBC.37F%kaffeen@mac.com>

I'm going through (well, was going through 'til I stalled) the Tkinter
introduction and am wondering what I'm doing wrong regarding keyboard input.
I took the mouse-button binding example and thought to adapt it (very
simply) to a keyboard event. I'm just not understanding this... here's the
program as I've changed it:

# file bind1.py

from Tkinter import *

root = Tk()
def testPrint(event):
    print "pressed key"
    
frame = Frame(root, width=200, height=200)
frame.bind("<Return>", testPrint)
frame.pack()

root.mainloop()

It's pretty much the same as the one printed, except I've swapped the
<Button-1> reference for a <Return> reference (have tried with and without
<>) but I don't get any output in the window when I press the return key. It
worked with the mouse button. Am I just typing it in wrong? The
documentation isn't very helpful to me. I appreciate any help, thanks.

- Chris



From arcege@speakeasy.net  Fri Nov  2 22:56:05 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Fri, 2 Nov 2001 17:56:05 -0500
Subject: [Tutor] Tkinter question
In-Reply-To: <B8087FBC.37F%kaffeen@mac.com>; from kaffeen@mac.com on Fri, Nov 02, 2001 at 04:52:12PM -0500
References: <B8087FBC.37F%kaffeen@mac.com>
Message-ID: <20011102175605.B1028@speakeasy.net>

On Fri, Nov 02, 2001 at 04:52:12PM -0500, Chris Scott wrote:
> frame = Frame(root, width=200, height=200)
> frame.bind("<Return>", testPrint)
> frame.pack()
> 
> root.mainloop()
> 
> It's pretty much the same as the one printed, except I've swapped the
> <Button-1> reference for a <Return> reference (have tried with and without
> <>) but I don't get any output in the window when I press the return key. It
> worked with the mouse button. Am I just typing it in wrong? The
> documentation isn't very helpful to me. I appreciate any help, thanks.

The key to remember is that the mouse and the keyboard are two different
input device and that the windowing system doesn't always assume that
both will go to the same window, at the same time.

You need to change the keyboard focus to the new window.  Before you
run the mainloop, also call the focus() method.

frame.bind("<Return>", testPrint)
frame.focus()  # change keyboard input to this window
frame.pack()

root.mainloop() # frame.mainloop() would also work - why?

Good luck.
  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |
| Ailment info: http://www.speakeasy.org/~arcege/michaelwatch.html     |


From charlie@begeistert.org  Sat Nov  3 12:49:40 2001
From: charlie@begeistert.org (Charlie Clark)
Date: Sat, 03 Nov 2001 13:49:40 +0100
Subject: [Tutor] Problem parsing an HTML-Website: SGML Parser error
Message-ID: <20011103125524.E0FAB37B5F@mx04.nexgo.de>

Am 02.11.2001 19:23:56, schrieb "Sean 'Shaleh' Perry" <shalehperry@home.com>:

>> 
>> What I need to know is what is the best way of finding out what is wrong in
>> the source so that I can try and remove it before sending it to the parser.
>> 
>> A response to me directly would be appreciated. Many thanx for your help.
>> 
>
>My guess is the embedded xml is killing it.  Perhaps you could convince
>SGMLParser that anything between <xml></xml> should be ignored.
>
>That is some amazingly ugly html code.
>
You're right there. I ran a few of the pages through the w3c vaidator and it choked as well. I managed to find the culprit by printing the rawdata. My hunch was that the 
embedded "if" statements would be the problem and it seems to be the exclamation marks in them which are not allowed.

<![if !supportEmptyParas]> will cause the SGML-parser to choke but
<!--[if gte mso 9]> is okay.

I've taken the easy way out initially and just eliminated the "!". I think it would be better to remove all of the [...] tags using a regular expression, at least I think that's 
where re's can be used. It's not really my area so I'd appreciate help there, too. What I'm doing is fairly sisyphian but it can't be helped.

Charlie



From dsh8290@rit.edu  Sat Nov  3 14:43:00 2001
From: dsh8290@rit.edu (dman)
Date: Sat, 3 Nov 2001 09:43:00 -0500
Subject: [Tutor] Problem parsing an HTML-Website: SGML Parser error
In-Reply-To: <20011103125524.E0FAB37B5F@mx04.nexgo.de>; from charlie@begeistert.org on Sat, Nov 03, 2001 at 01:49:40PM +0100
References: <20011103125524.E0FAB37B5F@mx04.nexgo.de>
Message-ID: <20011103094300.A642@harmony.cs.rit.edu>

On Sat, Nov 03, 2001 at 01:49:40PM +0100, Charlie Clark wrote:
| Am 02.11.2001 19:23:56, schrieb "Sean 'Shaleh' Perry" <shalehperry@home.com>:
| 
| >> 
| >> What I need to know is what is the best way of finding out what is wrong in
| >> the source so that I can try and remove it before sending it to the parser.
| >> 
| >> A response to me directly would be appreciated. Many thanx for your help.
| >> 
| >
| >My guess is the embedded xml is killing it.  Perhaps you could convince
| >SGMLParser that anything between <xml></xml> should be ignored.
| >
| >That is some amazingly ugly html code.
|
| You're right there. I ran a few of the pages through the w3c
| vaidator and it choked as well. I managed to find the culprit by
| printing the rawdata. My hunch was that the embedded "if" statements
| would be the problem and it seems to be the exclamation marks in
| them which are not allowed.
| 
| <![if !supportEmptyParas]> will cause the SGML-parser to choke but
| <!--[if gte mso 9]> is okay.
| 
| I've taken the easy way out initially and just eliminated the "!". I
| think it would be better to remove all of the [...] tags using a
| regular expression, at least I think that's where re's can be used.
| It's not really my area so I'd appreciate help there, too. 

Try :

<!\[([^\]]|\][^>])*\]>

The idea is find "<![" followed by any number of characters that
aren't "]" or are "]" but not followed by "*", and those characters
are followed by "]>".

This is much like matching C comments.

-D



From charlie@begeistert.org  Sat Nov  3 14:51:48 2001
From: charlie@begeistert.org (Charlie Clark)
Date: Sat, 03 Nov 2001 15:51:48 +0100
Subject: [Tutor] Strange behaviour in a list
Message-ID: <20011103145735.60CE537B93@mx04.nexgo.de>

Dear list,

I've just noted rather strange behaviour when running through a list. I've got a script that collects URLs from a web page and then systematically calls each URL 
individually. This is an extract from the script

src = urllib.urlopen(src)
articles += munig.get_articles(src)  # a direct assign would be nicer
for article in articles:
		src = urllib.urlopen(base_url + article['link'])
		print "getting ", article['headline']
		place = munig.party(src)
		place['headline'] = article['headline']
		places.append(place)
		src.close()
		articles.remove(article)  #currently necessary

I noticed that when I run this script inside another loop the inner loop seems to step through "articles" two entries at a time. This is the output generated while I check 
this.

[{'link': 'index.phtml?Source=adressen&Kathegorie=Gastronomie&nr=3', 'headline': 'Adria'},
 {'link': 'index.phtml?Source=adressen&Kathegorie=Gastronomie&nr=7', 'headline': 'Aficionado'}, 
{'link': 'index.phtml?Source=adressen&Kathegorie=Gastronomie&nr=16', 'headline': 'Alte Post'}, 
{'link': 'index.phtml?Source=adressen&Kathegorie=Gastronomie&nr=17', 'headline': 'Alter Simpel'},
 {'link': 'index.phtml?Source=adressen&Kathegorie=Gastronomie&nr=18', 'headline': 'Alter Wirt'}, 
{'link': 'index.phtml?Source=adressen&Kathegorie=Gastronomie&nr=315', 'headline': 'Alter Wirt Forstenried'}, 
{'link': 'index.phtml?Source=adressen&Kathegorie=Gastronomie&nr=321', 'headline': 'Alter Wirt Ramersdorf'}, 
....
getting  Adria
address at 27373
getting  Alte Post
address at 27373
no description
getting  Alter Wirt
address at 27373
no description
getting  Alter Wirt Ramersdorf
address at 27373
no description
....

Any ideas why this is happening and how it's best to correct?
Charlie

Charlie Clark
Helmholtzstr. 20
Düsseldorf
40215
Tel: +49-178-782-6226 




From dsh8290@rit.edu  Sat Nov  3 15:09:01 2001
From: dsh8290@rit.edu (dman)
Date: Sat, 3 Nov 2001 10:09:01 -0500
Subject: [Tutor] Strange behaviour in a list
In-Reply-To: <20011103145735.60CE537B93@mx04.nexgo.de>; from charlie@begeistert.org on Sat, Nov 03, 2001 at 03:51:48PM +0100
References: <20011103145735.60CE537B93@mx04.nexgo.de>
Message-ID: <20011103100900.A743@harmony.cs.rit.edu>

On Sat, Nov 03, 2001 at 03:51:48PM +0100, Charlie Clark wrote:
| Dear list,
| 
| I've just noted rather strange behaviour when running through a list. I've got a script that collects URLs from a web page and then systematically calls each URL 
| individually. This is an extract from the script
| 
| src = urllib.urlopen(src)
| articles += munig.get_articles(src)  # a direct assign would be nicer
  print articles
| for article in articles:
		print article
| 		articles.remove(article)  #currently necessary
                ^^^^^^^^^^^^^^^^^^^^^^^^

The way the for loop works in python is an invisible counter is
created, then that counter is used to index the list until it gets an
IndexError.  When you remove the current item from the list you are
changing the indices of all the remaining items, thus the for loop
will get messed up.  The solution is to not modify the list that the
loop is iterating over.  Alternatively you could do :

while len( articles ) > 0 :
    article = articles[0]
    print article
    articles.remove( article )

HTH,
-D



From toodles@yifan.net  Sat Nov  3 15:29:19 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Sat, 3 Nov 2001 23:29:19 +0800
Subject: [Tutor] Strange behaviour in a list
References: <20011103145735.60CE537B93@mx04.nexgo.de>
Message-ID: <003601c1647c$512a8d30$0300a8c0@sun>

Hi Charlie

> src = urllib.urlopen(src)
> articles += munig.get_articles(src)  # a direct assign would be nicer
> for article in articles:
> src = urllib.urlopen(base_url + article['link'])
> print "getting ", article['headline']
> place = munig.party(src)
> place['headline'] = article['headline']
> places.append(place)
> src.close()
> articles.remove(article)  #currently necessary
>
> I noticed that when I run this script inside another loop the inner loop
seems to step through "articles" two entries at a time. This is the output
generated while I check
> this.

This has to do with the removing of the article. I'll cut 'n' paste what I
posted in another thread a while ago.
####

"for" goes through the indices 0..len(factor_range)
As you remove each item it decreases the size of factor_range, and the index
that for points to next will contain something else.

Example:

>>> test_range=range(10)
>>> for i in test_range:
           print i,test_range
           test_range.remove(i)

0 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
2 [1, 2, 3, 4, 5, 6, 7, 8, 9]
4 [1, 3, 4, 5, 6, 7, 8, 9]
6 [1, 3, 5, 6, 7, 8, 9]
8 [1, 3, 5, 7, 8, 9]

So as you can see in the 2nd iteration it is pointing to index 1 as it
should be, but this now points to "2".

>>> test=range(10)
>>> count=test[:]
>>> for i in count:
            print i,test
            test.remove(i)

0 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
1 [1, 2, 3, 4, 5, 6, 7, 8, 9]
2 [2, 3, 4, 5, 6, 7, 8, 9]
3 [3, 4, 5, 6, 7, 8, 9]
4 [4, 5, 6, 7, 8, 9]
5 [5, 6, 7, 8, 9]
6 [6, 7, 8, 9]
7 [7, 8, 9]
8 [8, 9]
9 [9]

HTH
Andrew



>
> [{'link': 'index.phtml?Source=adressen&Kathegorie=Gastronomie&nr=3',
'headline': 'Adria'},
>  {'link': 'index.phtml?Source=adressen&Kathegorie=Gastronomie&nr=7',
'headline': 'Aficionado'},
> {'link': 'index.phtml?Source=adressen&Kathegorie=Gastronomie&nr=16',
'headline': 'Alte Post'},
> {'link': 'index.phtml?Source=adressen&Kathegorie=Gastronomie&nr=17',
'headline': 'Alter Simpel'},
>  {'link': 'index.phtml?Source=adressen&Kathegorie=Gastronomie&nr=18',
'headline': 'Alter Wirt'},
> {'link': 'index.phtml?Source=adressen&Kathegorie=Gastronomie&nr=315',
'headline': 'Alter Wirt Forstenried'},
> {'link': 'index.phtml?Source=adressen&Kathegorie=Gastronomie&nr=321',
'headline': 'Alter Wirt Ramersdorf'},
> ....
> getting  Adria
> address at 27373
> getting  Alte Post
> address at 27373
> no description
> getting  Alter Wirt
> address at 27373
> no description
> getting  Alter Wirt Ramersdorf
> address at 27373
> no description
> ....
>
> Any ideas why this is happening and how it's best to correct?
> Charlie
>
> Charlie Clark
> Helmholtzstr. 20
> Düsseldorf
> 40215
> Tel: +49-178-782-6226
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From gncuster@firehead.org  Sat Nov  3 19:18:51 2001
From: gncuster@firehead.org (Nate Custer)
Date: 03 Nov 2001 13:18:51 -0600
Subject: [Tutor] Souce Debuger
Message-ID: <1004815131.28222.8.camel@gncuster>

Hey all,

Is there anything comprable to gdb for python? I want to step through a
large program, and cutting and pasting into the interp is a lot of work.

--Nate Custer



From boud@rempt.xs4all.nl  Sat Nov  3 19:24:13 2001
From: boud@rempt.xs4all.nl (Boudewijn Rempt)
Date: Sat, 3 Nov 2001 20:24:13 +0100 (CET)
Subject: [Tutor] Souce Debuger
In-Reply-To: <1004815131.28222.8.camel@gncuster>
Message-ID: <Pine.LNX.4.33.0111032020490.489-100000@calcifer.valdyas.org>

On 3 Nov 2001, Nate Custer wrote:

> Hey all,
>
> Is there anything comprable to gdb for python? I want to step through a
> large program, and cutting and pasting into the interp is a lot of work.
>

There's an almost exact equivalent included: pdb. Of course, it's
horrible to use, being a command-line debugger. You might want to
try eric, the debugger that's included with PyQt. That one has the
advantage that it knows where to stop - i.e., it doesn't try to
step into the standard modules. Likewise, BlackAdder, Pythonwin,
Pythonworks, Wing IDE, Komodo and perhaps Idle (I'm not sure about
Idle) all include nice debuggers. DDD can be used as a frontend to
pdb, but I haven't had much success with it. And I've used pydebug
for a long time. I don't know where that script went to, but The
Vaults of Parnassus might know.

Finally, there's not much that a well-placed print statement cannot
tell you :-).


Boudewijn Rempt  | http://www.valdyas.org



From lha2@columbia.edu  Sat Nov  3 21:32:30 2001
From: lha2@columbia.edu (Lloyd Hugh Allen)
Date: Sat, 03 Nov 2001 16:32:30 -0500
Subject: [Tutor] Souce Debuger
References: <Pine.LNX.4.33.0111032020490.489-100000@calcifer.valdyas.org>
Message-ID: <3BE4626E.C011AAF2@mail.verizon.net>

IDLE includes a debugger that works reasonably well. You'll want to
"step" into functions that you have written and to "over" functions that
are internal to Python (there's no need to see how "print" works for
most people--usually it's just confusing).

Boudewijn Rempt wrote:
> 
> On 3 Nov 2001, Nate Custer wrote:
> 
> > Hey all,
> >
> > Is there anything comprable to gdb for python? I want to step through a
> > large program, and cutting and pasting into the interp is a lot of work.
> >
> 
> There's an almost exact equivalent included: pdb. Of course, it's
> horrible to use, being a command-line debugger. You might want to
> try eric, the debugger that's included with PyQt. That one has the
> advantage that it knows where to stop - i.e., it doesn't try to
> step into the standard modules. Likewise, BlackAdder, Pythonwin,
> Pythonworks, Wing IDE, Komodo and perhaps Idle (I'm not sure about
> Idle) all include nice debuggers. DDD can be used as a frontend to
> pdb, but I haven't had much success with it. And I've used pydebug
> for a long time. I don't know where that script went to, but The
> Vaults of Parnassus might know.
> 
> Finally, there's not much that a well-placed print statement cannot
> tell you :-).
> 
> Boudewijn Rempt  | http://www.valdyas.org
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


From dsh8290@rit.edu  Sat Nov  3 23:03:41 2001
From: dsh8290@rit.edu (dman)
Date: Sat, 3 Nov 2001 18:03:41 -0500
Subject: [Tutor] Souce Debuger
In-Reply-To: <Pine.LNX.4.33.0111032020490.489-100000@calcifer.valdyas.org>; from boud@rempt.xs4all.nl on Sat, Nov 03, 2001 at 08:24:13PM +0100
References: <1004815131.28222.8.camel@gncuster> <Pine.LNX.4.33.0111032020490.489-100000@calcifer.valdyas.org>
Message-ID: <20011103180341.A2902@harmony.cs.rit.edu>

On Sat, Nov 03, 2001 at 08:24:13PM +0100, Boudewijn Rempt wrote:
| On 3 Nov 2001, Nate Custer wrote:
| 
| > Hey all,
| >
| > Is there anything comprable to gdb for python? I want to step through a
| > large program, and cutting and pasting into the interp is a lot of work.
| >
| 
| There's an almost exact equivalent included: pdb. Of course, it's
| horrible to use, being a command-line debugger. You might want to

The gui frontends to gdb (DDD and GVD) are supposed to work with pdb
as well.  I've only used them to debug C++ though.

-D



From dyoo@hkn.eecs.berkeley.edu  Sat Nov  3 23:19:19 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sat, 3 Nov 2001 15:19:19 -0800 (PST)
Subject: [Tutor] Souce Debuger
In-Reply-To: <Pine.LNX.4.33.0111032020490.489-100000@calcifer.valdyas.org>
Message-ID: <Pine.LNX.4.21.0111031443400.32066-100000@hkn.eecs.berkeley.edu>

On Sat, 3 Nov 2001, Boudewijn Rempt wrote:

> > Is there anything comprable to gdb for python? I want to step through a
> > large program, and cutting and pasting into the interp is a lot of work.
> >
> 
> Finally, there's not much that a well-placed print statement cannot
> tell you :-).


Also, the Python interpreter itself is wonderful when you want to debug
something --- you don't have to cut and paste!  You can "import" your
program as if it were a module, and then test out your functions
individually.  As you make changes to your source code, you can ask Python
to "reload()" your code.


For example, let's say we were debugging a program that tries to figure
out if a word sounds like Klingon or not:

###
## klingon.py
def isSoundingLikeKlingon(name):
    ## If the suffix of the word is guttural, it's probably Klingon.
    if name[-2:] in ('gh', 'pu'):
        return 1
    return 0
###


How can we test this function out?  We can import it:

###
>>> import klingon
>>> klingon.isSoundingLikeKlingon("qa'vIn")
0
>>> klingon.isSoundingLikeKlingon("pagh")
1
###

Ok, this is certainly not accurate at all --- it doesn't even recognize
that "qa'vIn" stands for the word "coffee"!  If we modify klingon.py:


###
def isSoundingLikeKlingon(name):
    ## If the suffix of the word is guttural, it's probably Klingon.
    if name[-2:] in ('gh', 'pu'):
        return 1
    if name[-3:] in ('vIn'):
        return 1
    return 0
###


and save the file, we can go back to where we left off on the interpreter:


###
>>> reload(klingon)
<module 'klingon' from 'klingon.pyc'>
>>> reload(klingon)
<module 'klingon' from 'klingon.py'>
>>> klingon.isSoundingLikeKlingon("qa'vIn")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "klingon.py", line 5, in isSoundingLikeKlingon
    if name[-3:] in ('vIn'):
TypeError: 'in <string>' requires character as left operand
###


Ooops!  I forgot that "('vIn')" doesn't look like a tuple of one element
to Python --- instead, to Python, those parens are there for precedence
sake.  Let me fix that bug:

###
def isSoundingLikeKlingon(name):
    ## If the suffix of the word is guttural, it's probably Klingon.
    if name[-2:] in ('gh', 'pu'):
        return 1
    if name[-3:] in ('vIn',):       ## The trailing comma convinces
                                    ## python to treat ('vIn',) as a
                                    ## tuple of one element.
        return 1
    return 0
###

and try again:

###
>>> reload(klingon)
<module 'klingon' from 'klingon.py'>
>>> klingon.isSoundingLikeKlingon("qa'vIn")
1
###


That's better.  Now I'm going out for a little bit of qa'vIn.  *grin*



From Charlie@begeistert.org  Sun Nov  4 22:44:13 2001
From: Charlie@begeistert.org (Charlie Clark)
Date: Sun, 04 Nov 2001 23:44:13 +0100
Subject: [Tutor] Strange behaviour in a list
In-Reply-To: <003601c1647c$512a8d30$0300a8c0@sun>
Message-ID: <1004913853_PM_BeOS.Charlie@begeistert.org>

>This has to do with the removing of the article. I'll cut 'n' paste 
what I 
>posted in another thread a while ago. 
>#### 
> 
>"for" goes through the indices 0..len(factor_range) 
>As you remove each item it decreases the size of factor_range, and the 
index 
>that for points to next will contain something else. 
> 
>Example: 
> 
>>>> test_range=range(10) 
>>>> for i in test_range: 
>           print i,test_range 
>           test_range.remove(i) 
> 
>0 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 
>2 [1, 2, 3, 4, 5, 6, 7, 8, 9] 
>4 [1, 3, 4, 5, 6, 7, 8, 9] 
>6 [1, 3, 5, 6, 7, 8, 9] 
>8 [1, 3, 5, 7, 8, 9] 
> 
>So as you can see in the 2nd iteration it is pointing to index 1 as it 
>should be, but this now points to "2". 
Ah, thanx for pointing this out. Yes, it is logical but also easy to get 
caught out on.

Charlie




From alan.gauld@bt.com  Sun Nov  4 22:56:39 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sun, 4 Nov 2001 22:56:39 -0000
Subject: [Tutor] Souce Debuger
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C06E@mbtlipnt02.btlabs.bt.co.uk>

> Is there anything comprable to gdb for python? 

No, but there are several feeble minded debuggers that you
can use. However none come even close to gdb's power.

Python includes the pdb module from which you can run
your program, set breakpoints, watches and step thru'

IDLE includes a GUI front end but with some limitations
in functionality.

Pythonwin provides a fdfferent and IMHO superior debugger 
if you are on windows.

THe other IDEs likely do likewise.

My beginners book (not the web pages yet) has a chapter 
on debugging Python and Programming Python by Lutz had 
a similar chapter (at least in the first edition!)

> large program, and cutting and pasting into the interp is a 
> lot of work.

You should be able to import the program and then create 
objects, call functions/methods etc that way - provided 
you used the 

if __name__ == "__main__": 

trick.

Alan G


From alan.gauld@bt.com  Sun Nov  4 23:08:15 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sun, 4 Nov 2001 23:08:15 -0000
Subject: [Tutor] Souce Debuger
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C06F@mbtlipnt02.btlabs.bt.co.uk>

> There's an almost exact equivalent included: pdb. Of course, it's
> horrible to use, being a command-line debugger. 

At this point I feel I must stand up in defense of 
command line debuggers.

For serious debugging they are far more powerful than 
any gui debugger I've ever seen - and that's a lot! Few 
gui debuggers allow serious scripting of the debugger 
or recording of sessions for later replay. Also the 
ability to combine commands and define macros(*) is 
extremely useful, especially when dealing with deeply 
nested data structures.

Now I agree a GUI front end makes basic level debugging
easier, but they do have a habit of encouraging lazy 
debugging by just stepping thru the code. 
Slow and inefficient...

The extra work(typing) required to drive a command line 
debugger means  you think harder about the fastest way 
to get to the required code - using conditional 
breakpoints and watches etc.

And after all of that I have to add that pdb falls far 
short of being a good commandline debugger, or even a 
good debugger! But combined with the interpreter it is 
probably just adequate

Reluctance to use commandline debuggers is one of 
my "hot buttons" with our new graduates... :-)

Alan g

(*)In fairness a few modern Windows debuggers are 
starting to include macros and scripting capability.


From dlapolla@mediaone.net  Sun Nov  4 23:44:06 2001
From: dlapolla@mediaone.net (Dominic)
Date: Sun, 4 Nov 2001 15:44:06 -0800
Subject: [Tutor] Setting a path
Message-ID: <000a01c1658a$97a5c400$6501a8c0@Desktop>

This is a multi-part message in MIME format.

------=_NextPart_000_0007_01C16547.89457B00
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I'm running windows 2000 pro and I'm trying to set the path for python =
so that I can just go to the command prompt and type python script.py  =
as of now I have to go to the c prompt and go to the python directory ( =
which is in on the root directory) I also have to save all my scripts to =
the python directory to be able to do that. Is there an easier way. Are =
there any other tips for setting up in win2000 pro.
                                                                    =
Dominic

------=_NextPart_000_0007_01C16547.89457B00
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.3315.2870" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>I'm running windows 2000 pro and I'm =
trying to set=20
the path for python so that I can just go to the command prompt and type =
python=20
script.py&nbsp; as of now I have to go to the c prompt and go to the =
python=20
directory ( which is in on the root directory) I also have to save all =
my=20
scripts to the python directory to be able to do that. Is there an =
easier way.=20
Are there any other tips for setting up in win2000 pro.</FONT></DIV>
<DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
Dominic</FONT></DIV></BODY></HTML>

------=_NextPart_000_0007_01C16547.89457B00--



From jean9t@hotmail.com  Mon Nov  5 00:01:33 2001
From: jean9t@hotmail.com (anneke joubert)
Date: Mon, 05 Nov 2001 02:01:33 +0200
Subject: [Tutor] (no subject)
Message-ID: <F63pbKWZfEAkqBiBsbr00004b5d@hotmail.com>

<html><div style='background-color:'><DIV>I am starting to learn python. I am using alan gauld's book.Is there anybody out there willing to answer real stupid questions in plain english (american)</DIV>
<DIV>thanks </DIV>
<DIV>jeannine</DIV></div><br clear=all><hr>Get your FREE download of MSN Explorer at <a href='http://go.msn.com/bql/hmtag_itl_EN.asp'>http://explorer.msn.com</a><br></html>


From rob@jam.rr.com  Mon Nov  5 00:23:00 2001
From: rob@jam.rr.com (Rob Andrews)
Date: Sun, 4 Nov 2001 18:23:00 -0600
Subject: [Tutor] (no subject)
References: <F63pbKWZfEAkqBiBsbr00004b5d@hotmail.com>
Message-ID: <000d01c16590$0cebf1d0$721caa18@TESTWIN1>

----- Original Message -----
From: "anneke joubert" <jean9t@hotmail.com>
To: <tutor@python.org>
Sent: Sunday, November 04, 2001 6:01 PM
Subject: [Tutor] (no subject)


> I am starting to learn python. I am using alan gauld's book.Is there
anybody out there willing to answer real stupid questions in plain english
(american)
> thanks
> jeannine

One of the first things you'll learn on the Tutor list is that your
questions are most likely not "stupid" at all. And using Alan Gauld's book
won't make you any enemies here, either.

Rob




From kalle@gnupung.net  Mon Nov  5 00:23:56 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Mon, 5 Nov 2001 01:23:56 +0100
Subject: [Tutor] (no subject)
In-Reply-To: <F63pbKWZfEAkqBiBsbr00004b5d@hotmail.com>
References: <F63pbKWZfEAkqBiBsbr00004b5d@hotmail.com>
Message-ID: <20011105012356.A13198@sandra.lysator.liu.se>

[anneke joubert, asks if anyone is willing to answer stupid questions]

Yes, no question is stupid on this list.  Feel free to ask anything you wonder
about, we'll try to find helpful answers.  Sometimes, this answer might be a
suggestion that you read a certain part of the documentation, and you will
have to be prepared to do some reading for yourself.  As long as this doesn't
scare you, you'll find some excellent help here, I'm sure.

It would be appreciated if you try to make your email client send plain text
messages instead of HTML, though.  I'm not sure how this is done on Hotmail,
but I think it is possible.  This will remove all fancy formatting, but make
sure I and others with similar email software can read your messages too.

Peace,
  Kalle
-- 
[ Thought control, brought to you by the WIPO! ]
[ http://anti-dmca.org/ http://eurorights.org/ ]


From dsh8290@rit.edu  Mon Nov  5 00:42:35 2001
From: dsh8290@rit.edu (dman)
Date: Sun, 4 Nov 2001 19:42:35 -0500
Subject: [Tutor] Setting a path
In-Reply-To: <000a01c1658a$97a5c400$6501a8c0@Desktop>; from dlapolla@mediaone.net on Sun, Nov 04, 2001 at 03:44:06PM -0800
References: <000a01c1658a$97a5c400$6501a8c0@Desktop>
Message-ID: <20011104194234.A8907@harmony.cs.rit.edu>

On Sun, Nov 04, 2001 at 03:44:06PM -0800, Dominic wrote:
| I'm running windows 2000 pro and I'm trying to set the path for
| python so that I can just go to the command prompt and type python
| script.py 

Start->Settings->Control Panel

System

Advanced (tab)

Environment Variables (button)


In the environment variables dialog find the PATH variable and add the
python installation directory to it (preceded by a semicolon).  If the
variable does not exist yet, create it (the semicolon is not needed in
this case).

-D



From python.tutor@atrixnet.com  Mon Nov  5 06:48:00 2001
From: python.tutor@atrixnet.com (Tommy Butler)
Date: Sun, 4 Nov 2001 22:48:00 -0800
Subject: [Tutor] New Python scoping
In-Reply-To: <E160Qdu-0005mE-00@mail.python.org>
Message-ID: <MABBJNNKNGCCADBAELCHGEBPDAAA.python.tutor@atrixnet.com>

One of the reasons I haven't really used Python a lot in the past is beca=
use of
the difficulty in creating enforced capsulation of both variables and met=
hods in
Python objects.

Forgive me for not really understanding what the philosophy behind this p=
aradigm
really is.  I am very curious about why this is so, and if the new scopin=
g rules
for the latest version of Python change this in any way.

The discussion of these new rules in the release notes at Python.org left=
 me a
bit confused.  I'm sure that  my lack of substantial experience with Pyth=
on has
much to do with that.

So my questions are thus--

   a)  what ways can one create encapsulated, private
       routines and/or variables in a Python object...

   b)  Is such a thing really even necessary?

   c)  Wouldn't namespace conflicts arise?  Do you have
       to make a new object every time you need a new
       namespace?

   d)  Has a new reasoning been adopted within the Python
       community about scoping issues? Is this the driving
       factor behind the changes?

   e)  Do Python's new scoping rules change the design
       paradigm and coding methodologies for OO
       programming in Python?  If yes, how so?

   f)  Can someone explain Python scoping rules in general
       for me, taking into account these new changes?


    Tommy Butler
    Internet Strategies, Inc.   Everything is Possible

      web     http://www.istrat.com
      email   mailto:tommy@istrat.com
      tel     214=B7393=B71000  ext 207
      fax     800=B7307=B78105

    2200 North Lamar, Suite 307      Dallas, TX  75202






From urnerk@qwest.net  Mon Nov  5 04:56:11 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Sun, 04 Nov 2001 20:56:11 -0800
Subject: [Tutor] New Python scoping
In-Reply-To: <MABBJNNKNGCCADBAELCHGEBPDAAA.python.tutor@atrixnet.com>
References: <E160Qdu-0005mE-00@mail.python.org>
Message-ID: <4.2.0.58.20011104204402.00c71910@pop3.norton.antivirus>

    f)  Can someone explain Python scoping rules in general
        for me, taking into account these new changes?

Hi Tommy --

Not entirely sure if I understand your confusions, but the
new scoping rules are more intuitive, what people would
expect, so it's best, if new to Python, to not even remember
the old ways.  If old to Python, forget 'em as well.

However, the scoping rules don't have a lot to do with
classes and objects per se.  What other languages have you
experience with?  Python is simpler than Java in its
approach, is only starting to have something like
abstract classes for example, where you don't need to
instantiate an instance in order to use class methods.

And class variables aren't particularly private.  There's
a way to suggest privacy, but it's not ironclad or anything.

  >>> class A:
  	 def method1(self):
	    print "Howdy!"
	 def __method2(self):
	    print "I'm private!"

	
  >>> a = A()
  >>> dir(a)
  ['_A__method2', '__doc__', '__module__', 'method1']

You see, method2, given the double-underline prefix, has
had its name "mangled" by the interpreter, and is known
internally as _A__method2 -- the class name, and an
underline prefix, have been pre-pended.  So you can't
invoke __method2 directly:

   >>> a.__method2()
   Traceback (most recent call last):
     File "<pyshell#9>", line 1, in ?
       a.__method2()
   AttributeError: A instance has no attribute '__method2'
   >>> a._A__method2()
   I'm private!

Ah, but I *did* invoke it, because I know how the mangling
works, as does any Python programmer.

Really, the private methods and variables technique is
fairly obscure and not used in 99% of Python programs.
Python assumes a collegial environment where people know
what they're doing in a civilized atmosphere.  That context
keeps things simple, straightforward, workaday.

If you're assuming everyone has their heart set on being
malicious and breaking stuff, then you need a more secure
language, like maybe Java.

Kirby

PS:

Note:  even with mangling, you can use the double underline
name as-is *internally* to the class -- which is most
likely, as what's the point of a private method except
to serve some other methods that need it:

  >>> class A:
	 def method1(self):
	    print "Howdy!"
	 def __method2(self):
	    print "I'm private!"
	 def method3(self):
	    self.__method2()

	
  >>> a = A()
  >>> a.method3
  <bound method A.method3 of <__main__.A instance at 0x00D011B0>>
  >>> a.method3()
  I'm private!

Kirby




From MAILER-DAEMON@spf1.hk5.outblaze.com  Mon Nov  5 06:08:04 2001
From: MAILER-DAEMON@spf1.hk5.outblaze.com (Mail Delivery Subsystem)
Date: Mon, 5 Nov 2001 06:08:04 GMT
Subject: [Tutor] Returned mail: see transcript for details
Message-ID: <200111050608.fA5684v29408@spf1.hk5.outblaze.com>

This is a MIME-encapsulated message

--fA5684v29408.1004940484/spf1.hk5.outblaze.com

The original message was received at Mon, 5 Nov 2001 06:07:53 GMT
from adsl-156-58-205.asm.bellsouth.net [66.156.58.205]

   ----- The following addresses had permanent fatal errors -----
<clutching2@ireland.com>
    (reason: 550 sorry, no such user here)

   ----- Transcript of session follows -----
... while talking to mta1.hk2.outblaze.com.:
>>> RCPT To:<clutching2@ireland.com>
<<< 550 sorry, no such user here
550 5.1.1 <clutching2@ireland.com>... User unknown

--fA5684v29408.1004940484/spf1.hk5.outblaze.com
Content-Type: message/delivery-status

Reporting-MTA: dns; spf1.hk5.outblaze.com
Received-From-MTA: DNS; adsl-156-58-205.asm.bellsouth.net
Arrival-Date: Mon, 5 Nov 2001 06:07:53 GMT

Final-Recipient: RFC822; clutching2@ireland.com
Action: failed
Status: 5.1.1
Remote-MTA: DNS; mta1.hk2.outblaze.com
Diagnostic-Code: SMTP; 550 sorry, no such user here
Last-Attempt-Date: Mon, 5 Nov 2001 06:08:04 GMT

--fA5684v29408.1004940484/spf1.hk5.outblaze.com
Content-Type: text/rfc822-headers

Return-Path: <tutor@python.org>
Received: from SERVER1 (adsl-156-58-205.asm.bellsouth.net [66.156.58.205])
	by spf1.hk5.outblaze.com (8.11.2/8.11.2) with SMTP id fA567rv29244
	for <clutching2@ireland.com>; Mon, 5 Nov 2001 06:07:53 GMT
Date: Mon, 5 Nov 2001 06:07:53 GMT
Message-Id: <200111050607.fA567rv29244@spf1.hk5.outblaze.com>
From: <tutor@python.org>
Subject: Get Personal with Everyone.net!
MIME-Version: 1.0
Content-Type: multipart/related;
	type="multipart/alternative";
	boundary="====_ABC123456j7890DEF_===="
X-Priority: 3
X-MSMail-Priority: Normal
X-Unsent: 1

--fA5684v29408.1004940484/spf1.hk5.outblaze.com--



From specialoffers@specialoffers.onvia.com  Mon Nov  5 06:16:18 2001
From: specialoffers@specialoffers.onvia.com (Onvia)
Date: Sun, 04 Nov 2001 22:16:18 -0800 (PST)
Subject: [Tutor] Thank you for your feedback
Message-ID: <JbYAAAAAA=3be62eb2@specialoffers.onvia.com>

--------------JbYAAAAAA=00
Content-Type: multipart/alternative;
 boundary="------------JbYAAAAAA=01"

--------------JbYAAAAAA=01
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit


THIS IS AN AUTOMATED RESPONSE -- PLEASE DO NOT REPLY TO THIS MESSAGE

You have received this message because you are a customer of
Onvia.com and have opted to receive information via email.

If you have any questions about the message you received, or any of
our products, please visit:
http://www.onvia.com
Thank you

If you do not wish to receive any further emails from Onvia, please
follow the instructions found at the bottom of the original message
you received or reply to this message with "REMOVE" as the subject.

Thank you

Onvia
http://www.onvia.com


--------------JbYAAAAAA=01
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: 7bit

<HTML><PRE><BODY BGCOLOR="#FFFFFF">
<B>THIS IS AN AUTOMATED RESPONSE -- PLEASE DO NOT REPLY TO THIS MESSAGE</B>

You have received this message because you are a customer of
Onvia.com and have opted to receive information via email.

If you have any questions about the message you received, or any of
our products, please <A HREF="http://www.onvia.com">click here</A>.
Thank you

If you do not wish to receive any further emails from Onvia, please
follow the instructions found at the bottom of the original message
you received or reply to this message with "REMOVE" as the subject.

Thank you

<A HREF="http://www.onvia.com">Onvia</A>


</body></PRE></HTML>


--------------JbYAAAAAA=01--
--------------JbYAAAAAA=00--



From kromag@nsacom.net  Mon Nov  5 08:55:48 2001
From: kromag@nsacom.net (kromag@nsacom.net)
Date: Mon, 5 Nov 2001 00:55:48 -0800 (PST)
Subject: [Tutor] changing mutable object from within a class
Message-ID: <200111050855.fA58tmg02032@pop.nsacom.net>

Howdy folks!

I am having difficulty understanding whether or not I can make a global 
object mutable from within a class.

The script is a 'citadel' bbs clone. Citadel's read and enter messages into 
messagebases called rooms. My rooms consist of pickled dictionaries full of 
lists:

roomname.room -> {1: username, time of entry, post}

Citadels traditionally start from the 'lobby'. That means I need to load and 
read the lobby first by default, then read from other rooms I 'jump' to.

The problem is: I can't for the life of me figure out how to pass the 
new 'roomname' to the command prompt after I choose it!

I think my problem is that the __init__ function is only reading the initial 
global declaration of 'roomname'.

I have painted myself into a corner! Throw some turpentine on me! :-)

---------------at least I know this works!-------------------

>>> def room_namer(roomname=None):
        if roomname is None:
                roomname='lobby'
        return roomname

>>> roomname=room_namer()
>>> roomname
'lobby'

roomname=room_namer('new')
>>> roomname
'new'


--------------script----------------------------

def get_roomlist():
        roomlistsuck=glob.glob('*.room')
        roomlist=[]
        for all in roomlistsuck:
                roomlist.append(all[:-5])
        return roomlist

def room_namer(roomname=None):
        if roomname is None:
                roomname='lobby'
        return roomname

roomname=room_namer()

'''This is the meat of the matter
all commands (and their helpfiles) are
located here. There are some extra
underscores floating around ignore
them please! I think I have plans....'''

class Jabulon(cmd.Cmd):

        def __init__(self):

#fire up that command prompt!

                self.prompt='%s ('M' for menu, Help): '%(room_namer
(roomname))
                self.post={}

        def help_m(self):
                print 'Prints a handy menu.'
        def do_m(self, _):
                print '*'*50
                print '(R)ead New Messages, (E)nter Message'
                #print '(S)kip This Room (G)o to Next Room '
                print '(L)ist Rooms (C)reate New Room.'
                print '(T)erminate Connection'
                print 'Help (letter) for short explaination.'
                print '*'*50


#List rooms.
        def help_l(self):
                print 'Prints the roomlist'
        def do_l(self,_):
                roomlist=get_roomlist()
                print 'n%sn%snn%sn' %('Roomlist','='*8,roomlist)

#Jump to another room.

        def help_j(self):
                print 'Jumps to another room.'
        def do_j(self,_):
                roomlist=get_roomlist()
                next_room=raw_input('Jump to which room? : ')
                if next_room in roomlist:
                        roomname=room_namer(next_room)
                else:
                        print '%s not found.'%(next_room)

#bring the noise!

if __name__=='__main__':
        jab=Jabulon()
        jab.cmdloop()

---------------------end script-----------------------



From zhangsc@neusoft.com  Mon Nov  5 07:51:00 2001
From: zhangsc@neusoft.com (=?gb2312?B?1cXJ2bPb?=)
Date: Mon, 05 Nov 2001 15:51:00 +0800
Subject: [Tutor] help
Message-ID: <014701c165ce$a039b790$4301010a@sky>

This is a multi-part message in MIME format.

--Boundary_(ID_QS6it3QBclAVjXxe7vw6pA)
Content-type: text/plain; charset=gb2312
Content-transfer-encoding: 7BIT

I want to extending python, so I write a program. My purpose is return a buff from my program,so I can receive the buff in Python,the buff's type is char buff[MAXLINE] .I don't know whether Python's extending support char buff[MAXLINE] type?

My programs is follows,named 'ddd.c':
#include <stdio.h>
#include <error.h>
#include <sys/types.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <linux/ioctl.h>
#include <linux/if_ether.h>
#include <linux/if_arp.h>

#define MAXLINE 4096
ssize_t n;
union {
  unsigned int addr;
  unsigned char ip[4];
}saddr,daddr;

char  * mysock()
{
  int listenfd;
  char buff[MAXLINE];
  if((listenfd=socket(AF_INET,SOCK_PACKET,htons(ETH_P_IP)))<0)
  {
    perror("create socket(SOCK_PACKET)\n");
    exit(-1);
  }
  if ((n=recv(listenfd,buff,MAXLINE,0))>0)
    return buff;
 
}

#include "Python.h"

static PyObject * my_mysock(PyObject *self,PyObject *args)
{
  int num;
  if(!PyArg_ParseTuple(args,"i",&num))
    return NULL;
  return (PyObject *)Py_BuildValue("s",mysock());
}   

static PyMethodDef myMethods[]={
 {"mysock",my_mysock,METH_VARARGS},
 {NULL,NULL},
};

void initmy()
{
  Py_InitModule("reads",myMethods);
}   

My extending steps are followed:
$gcc ddd.c -c -I /usr/include/python1.5
$ld -share -o mymodule.so ddd.o
$python
>>>import my
__main__:1: RuntimeWarning:Python C API version mismatch for module reads:
Python has API version 1011,module reads has version 1007.
  File "<stdin>",line 1,in ?
SystemError:_PyImport_FixupExtension: module my not loaded

How to correct? The return value 'char buff[MAXLINE]' is very important for me, it will affect 
my next work,Would you help me?
                Thank you very much!!! 

--Boundary_(ID_QS6it3QBclAVjXxe7vw6pA)
Content-type: text/html; charset=gb2312
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=gb2312">
<META content="MSHTML 6.00.2600.0" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2>
<DIV><FONT size=2>I want to extending python, so I write&nbsp;a program. My 
purpose is return a buff from my program,so I can receive the buff in Python,the 
buff's type is <FONT color=#0000ff>char buff[MAXLINE]</FONT> .I don't know 
whether Python's extending support char buff[MAXLINE] type?</FONT></DIV>
<DIV><FONT size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>My programs is follows,named 'ddd.c':</FONT></DIV>
<DIV><FONT color=#0000ff size=2>#include &lt;stdio.h&gt;<BR>#include 
&lt;error.h&gt;<BR>#include &lt;sys/types.h&gt;<BR>#include 
&lt;netinet/ip.h&gt;<BR>#include &lt;netinet/tcp.h&gt;<BR>#include 
&lt;netinet/udp.h&gt;<BR>#include &lt;linux/ioctl.h&gt;<BR>#include 
&lt;linux/if_ether.h&gt;<BR>#include &lt;linux/if_arp.h&gt;</FONT></DIV>
<DIV><FONT color=#0000ff></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff size=2>#define MAXLINE 4096<BR>ssize_t n;<BR>union 
{<BR>&nbsp; unsigned int addr;<BR>&nbsp; unsigned char 
ip[4];<BR>}saddr,daddr;</FONT></DIV>
<DIV><FONT color=#0000ff></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff size=2>char&nbsp; * mysock()<BR>{<BR>&nbsp; int 
listenfd;<BR>&nbsp; char buff[MAXLINE];<BR>&nbsp; 
if((listenfd=socket(AF_INET,SOCK_PACKET,htons(ETH_P_IP)))&lt;0)<BR>&nbsp; 
{<BR>&nbsp;&nbsp;&nbsp; perror("create 
socket(SOCK_PACKET)\n");<BR>&nbsp;&nbsp;&nbsp; exit(-1);<BR>&nbsp; }<BR>&nbsp; 
if ((n=recv(listenfd,buff,MAXLINE,0))&gt;0)<BR>&nbsp;&nbsp;&nbsp; return 
buff;<BR>&nbsp;<BR>}</FONT></DIV>
<DIV><FONT color=#0000ff></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff size=2>#include "Python.h"</FONT></DIV>
<DIV><FONT color=#0000ff></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff size=2>static PyObject * my_mysock(PyObject 
*self,PyObject *args)<BR>{<BR>&nbsp; int num;<BR>&nbsp; 
if(!PyArg_ParseTuple(args,"i",&amp;num))<BR>&nbsp;&nbsp;&nbsp; return 
NULL;<BR>&nbsp; return (PyObject *)Py_BuildValue("s",mysock());<BR>}&nbsp;&nbsp; 
</FONT></DIV>
<DIV><FONT color=#0000ff></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff size=2>static PyMethodDef 
myMethods[]={<BR>&nbsp;{"mysock",my_mysock,METH_VARARGS},<BR>&nbsp;{NULL,NULL},<BR>};</FONT></DIV>
<DIV><FONT color=#0000ff></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff size=2>void initmy()<BR>{<BR>&nbsp; 
Py_InitModule("reads",myMethods);<BR>}&nbsp;&nbsp;&nbsp;<BR><FONT 
color=#000000></FONT></FONT></DIV>
<DIV><FONT color=#0000ff size=2><FONT color=#000000>My extending steps are 
followed:</FONT></FONT></DIV>
<DIV><FONT color=#0000ff size=2>$gcc ddd.c -c -I 
/usr/include/python1.5</FONT></DIV>
<DIV><FONT color=#0000ff size=2>$ld -share -o mymodule.so ddd.o</FONT></DIV>
<DIV><FONT color=#0000ff size=2>$python</FONT></DIV>
<DIV><FONT color=#ff0000 size=2>&gt;&gt;&gt;import my</FONT></DIV>
<DIV><FONT color=#ff0000 size=2>__main__:1: RuntimeWarning:Python C API version 
mismatch for module reads:</FONT></DIV>
<DIV><FONT color=#ff0000 size=2>Python has API version 1011,module reads has 
version 1007.</FONT></DIV>
<DIV><FONT color=#ff0000 size=2>&nbsp; File "&lt;stdin&gt;",line 1,in 
?</FONT></DIV>
<DIV><FONT color=#ff0000 size=2>SystemError:_PyImport_FixupExtension: module my 
not loaded</FONT></DIV>
<DIV><FONT color=#ff0000 size=2></FONT>&nbsp;</DIV>
<DIV><FONT size=2>How to correct? The return value&nbsp;'<FONT 
color=#0000ff>char buff[MAXLINE]' </FONT><FONT color=#000000>is very important 
for me, it will affect </FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#000000>my next work,Would you help 
me?</FONT></FONT></DIV>
<DIV><FONT 
size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
Thank you&nbsp;very much!!!</FONT>&nbsp;</DIV></FONT></DIV></BODY></HTML>

--Boundary_(ID_QS6it3QBclAVjXxe7vw6pA)--


From alan.gauld@bt.com  Mon Nov  5 10:48:17 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 5 Nov 2001 10:48:17 -0000
Subject: [Tutor] (no subject)
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C070@mbtlipnt02.btlabs.bt.co.uk>

------_=_NextPart_001_01C165E7.60D7A300
Content-type: text/plain; charset="ISO-8859-1"

I am starting to learn python. I am using alan gauld's book.Is there anybody
out there willing to answer real stupid questions in plain english
(american) 
 

I'm not too good on American but if British English 
will suffice I'll have a go :-) 
 
Have you checked the errata page for the book BTW?
A lot of typos got thru' the review/edit process.
 
http://www.freenetpages.co.uk/hp/alan.gauld/book/
<http://www.freenetpages.co.uk/hp/alan.gauld/book/> 
 
Alan Gauld.

------_=_NextPart_001_01C165E7.60D7A300
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>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; PADDING-LEFT: 5px">
  <DIV>
  <DIV>I am starting to learn python. I am using alan gauld's book.Is there 
  anybody out there willing to answer real stupid questions in plain english 
  (american)<FONT color=#0000ff face="Courier New" size=2><SPAN 
  class=330094810-05112001>&nbsp;</SPAN></FONT></DIV>
  <DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
  class=330094810-05112001></SPAN></FONT>&nbsp;</DIV></DIV></BLOCKQUOTE>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=330094810-05112001>I'm not too good on American but if British English 
</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=330094810-05112001>will suffice I'll have a go 
:-)&nbsp;</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=330094810-05112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=330094810-05112001>Have you checked the errata page for the book 
BTW?</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=330094810-05112001>A lot of typos got thru' the review/edit 
process.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=330094810-05112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=330094810-05112001><A 
href="http://www.freenetpages.co.uk/hp/alan.gauld/book/">http://www.freenetpages.co.uk/hp/alan.gauld/book/</A></SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=330094810-05112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=330094810-05112001>Alan Gauld.</SPAN></FONT></DIV></BODY></HTML>

------_=_NextPart_001_01C165E7.60D7A300--


From alan.gauld@bt.com  Mon Nov  5 11:03:42 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 5 Nov 2001 11:03:42 -0000
Subject: [Tutor] New Python scoping
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C071@mbtlipnt02.btlabs.bt.co.uk>

> One of the reasons I haven't really used Python a lot in the 
> past is because of the difficulty in creating enforced 
> capsulation of both variables and methods in
> Python objects.

Encapsulation means keeping them together as a single 
entity - an object. Python does that just fine.
Some people in recent years have started to declare
that encapsulation should also mean making data 
members inaccessible from outside the object except 
through function members(aka methods). This is 
frankly bizarre but several OO languages do it.

Python provides limited support for this with 
the _name syntax.

This is really part of Information Hiding, a useful
but unrelated charateristic to data/method encapsulation.

> Forgive me for not really understanding what the philosophy 
> behind this paradigm

If you don't understand the paradigm why is it an issue?

> the new scoping rules for the latest version of 
> Python change this in any way.

I don't think the scoping rules affect the name 
visibility rules in any way. But I'm open to correction.

> So my questions are thus--
>    a)  what ways can one create encapsulated, private
>        routines and/or variables in a Python object...

Encapsulated methods are the normal Python class 
definition syntax.

Private methods use a naming convention - single 
underscore I think? I never use it...

>    b)  Is such a thing really even necessary?

Encapsulation is for OO - its almost the definition of 
an Object! Visibility controls are sometimes nice to have
but not necessary - Lisp, Delphi, Python and many other 
OO languages don't put a lot of stress on this..

>    c)  Wouldn't namespace conflicts arise?  

Only if you try to use the same name for different things 
within a class hierarchy. Bad practice anyway. Otherwise 
all class names are contained within the class scope so 
there is no conflict.

>        to make a new object every time you need a new
>        namespace?

No, but a new object does create a new namespace. But 
modules have a namespace and indeed classes themselves 
provide a namespace similar to C++/Java's static feature.

>    d)  Has a new reasoning been adopted within the Python
>        community about scoping issues? Is this the driving
>        factor behind the changes?

No. I don't think so.

>    e)  Do Python's new scoping rules change the design
>        paradigm and coding methodologies for OO
>        programming in Python?  If yes, how so?

OO programming is almost language independant.
There are issues in the detail around dynamic vv static 
typing etc. The latter makes design much more constrained 
and usually requires many more classes. But the design 
paradigm of creating abstract frameworks of classes 
and then providing concrete implementations of those 
remains constant. A good book on this is Robert Martin's 
OOD book.

>    f)  Can someone explain Python scoping rules in general
>        for me, taking into account these new changes?

I'll leave that to somebody else :-)


Alan G.


From gary@stokeson.freeserve.co.uk  Mon Nov  5 11:40:52 2001
From: gary@stokeson.freeserve.co.uk (gary)
Date: Mon, 5 Nov 2001 11:40:52 -0000
Subject: [Tutor] Re
Message-ID: <000101c165f0$37d2c1c0$2cc8193e@oemcomputer>

This is a multi-part message in MIME format.

------=_NextPart_000_002E_01C165EE.B9604340
Content-Type: text/plain;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

CONFIRM 876210

------=_NextPart_000_002E_01C165EE.B9604340
Content-Type: text/html;
	charset="Windows-1252"
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.4807.2300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>CONFIRM =
876210</FONT></DIV></BODY></HTML>

------=_NextPart_000_002E_01C165EE.B9604340--



From arcege@speakeasy.net  Mon Nov  5 13:22:35 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Mon, 5 Nov 2001 08:22:35 -0500
Subject: [Tutor] help
In-Reply-To: <014701c165ce$a039b790$4301010a@sky>; from zhangsc@neusoft.com on Mon, Nov 05, 2001 at 03:51:00PM +0800
References: <014701c165ce$a039b790$4301010a@sky>
Message-ID: <20011105082235.E1067@speakeasy.net>

On Mon, Nov 05, 2001 at 03:51:00PM +0800, =D5=C5=C9=D9=B3=DB wrote:
>=20
>    I want to extending python, so I write a program. My purpose is retu=
rn
>    a buff from my program,so I can receive the buff in Python,the buff'=
s
>    type is char buff[MAXLINE] .I don't know whether Python's extending
>    support char buff[MAXLINE] type?
>=20
>    My programs is follows,named 'ddd.c':
>    #include <stdio.h>
>    #include <error.h>
>    #include <sys/types.h>
>    #include <netinet/ip.h>
>    #include <netinet/tcp.h>
>    #include <netinet/udp.h>
>    #include <linux/ioctl.h>
>    #include <linux/if_ether.h>
>    #include <linux/if_arp.h>
>=20
>    #define MAXLINE 4096
>    ssize_t n;
>    union {
>      unsigned int addr;
>      unsigned char ip[4];
>    }saddr,daddr;
>=20
>    char  * mysock()
>    {
>      int listenfd;
>      char buff[MAXLINE];
>      if((listenfd=3Dsocket(AF_INET,SOCK_PACKET,htons(ETH_P_IP)))<0)
>      {
>        perror("create socket(SOCK_PACKET)\n");
>        exit(-1);
>      }
>      if ((n=3Drecv(listenfd,buff,MAXLINE,0))>0)
>        return buff;
>=20
>    }
>=20
>    #include "Python.h"
>=20
>    static PyObject * my_mysock(PyObject *self,PyObject *args)
>    {
>      int num;
>      if(!PyArg_ParseTuple(args,"i",&num))
>        return NULL;
>      return (PyObject *)Py_BuildValue("s",mysock());
>    }
>=20
>    static PyMethodDef myMethods[]=3D{
>     {"mysock",my_mysock,METH_VARARGS},
>     {NULL,NULL},
>    };
>=20
>    void initmy()
>    {
>      Py_InitModule("reads",myMethods);
>    }
>    My extending steps are followed:
>    $gcc ddd.c -c -I /usr/include/python1.5
>    $ld -share -o mymodule.so ddd.o
>    $python
>    >>>import my
>    __main__:1: RuntimeWarning:Python C API version mismatch for module
>    reads:
>    Python has API version 1011,module reads has version 1007.
>      File "<stdin>",line 1,in ?
>    SystemError:_PyImport_FixupExtension: module my not loaded
>=20
>    How to correct? The return value 'char buff[MAXLINE]' is very
>    important for me, it will affect
>    my next work,Would you help me?

Hi,  there is one important thing to remember: character buffers are
not like character strings.  Character strings stop after the first null
character ('\000'), even if there is data later.  Character buffers have
an associated length.  The data returned by the recv(2) C function is
stored in a character buffer, the length is the functions return value.
Network data can easily include null characters, and not be terminated
by them.

In your, mysock() function, you do not return the length,
which you will need.  Then once you have the length, you can use the
  Py_BuildValue("s#", buff, buflen);

Secondly, it looks like you are building against Python 1.5.x and using
the module with Python 2.x.  You need to build against the version of
Python you will be using it with.

At that point, you will have the real data returned by the socket.

  -Arcege

PS: Also, local variables should not be returned from a function, the
next function called may overwrite the data (even tho the context is not
on the stack, the data is stored there, and the next functions context
will be laid on top of it).

--=20
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From nhytro-python@web.de  Mon Nov  5 13:27:21 2001
From: nhytro-python@web.de (Sharriff Aina)
Date: Mon, 5 Nov 2001 14:27:21 +0100
Subject: [Tutor] Invoking the internet explorer intkinter?
Message-ID: <200111051327.fA5DRLu12260@mailgate5.cinetic.de>

My tkinter application works now, thanks to help from this list and others, to finish things off I would like to have a link in the menu to documentation in form of HTML files. I can invoke any program using:

##

def foo():
....os.system( 'start foo.exe')
##

but trying this:

def foo2():
....os.sys('start index.html') #crude example

causes my tkinter application to hang, when I close the "dead" application via the taskmanager, voila! the html page pops up. Can some one tell me how to invoke local HTML pages on a local disk without being python platform specific? I would like to code a version of this application also for Linux.


Thanks in advance

Sharriff  

________________________________________________________________
Lotto online tippen! Egal zu welcher Zeit, egal von welchem Ort.
Mit dem WEB.DE Lottoservice. http://tippen2.web.de/?x=13




From adind@telkom.net  Tue Nov  6 15:26:49 2001
From: adind@telkom.net (Adinda Praditya)
Date: Tue, 6 Nov 2001 22:26:49 +0700
Subject: [Tutor] really stange behaviour
Message-ID: <002001c166d7$75efb4d0$0101a8c0@baitullah>

This is a multi-part message in MIME format.

------=_NextPart_000_001D_01C16712.20B06D30
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Take a look at this:
=3D=3D=3D
>>> import os
>>> user =3D os.getenv('USER')
>>> print user
dida
>>> group =3D os.system('set -- `groups $USER`; echo $3')
staff
>>> print group
0
=3D=3D=3D

How did this happened? The reason i create this is for managing users. I =
run python in my environment. How can i take the (os.system...) value?


------=_NextPart_000_001D_01C16712.20B06D30
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#ffffff>
<DIV><FONT size=3D2>Take a look at this:<BR>=3D=3D=3D<BR>&gt;&gt;&gt; =
import=20
os<BR>&gt;&gt;&gt; user =3D os.getenv('USER')<BR>&gt;&gt;&gt; print=20
user<BR>dida<BR>&gt;&gt;&gt; group =3D os.system('set -- `groups $USER`; =
echo=20
$3')<BR>staff<BR>&gt;&gt;&gt; print group<BR>0<BR>=3D=3D=3D</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>How did this happened? The reason i create this is =
for=20
managing users. I run python in my environment. How can i take the=20
(os.system...) value?<BR></FONT></DIV></BODY></HTML>

------=_NextPart_000_001D_01C16712.20B06D30--



From lonetwin@yahoo.com  Mon Nov  5 15:56:21 2001
From: lonetwin@yahoo.com (lonetwin)
Date: Mon, 5 Nov 2001 21:26:21 +0530
Subject: [Tutor] really stange behaviour
In-Reply-To: <002001c166d7$75efb4d0$0101a8c0@baitullah>
References: <002001c166d7$75efb4d0$0101a8c0@baitullah>
Message-ID: <01110521262100.10893@mercury.worli>

On Tuesday 06 November 2001 20:56, Adinda wrote:
> ....<snip>.........
> ...How can i take the (os.system...) value?

from the standard lib. docs.:

system(command)
  .....The return value is the exit status of the process encoded in the
  format specified for wait()....

This means that os.system() returns a value that reflects the success or 
faliure of the command that it executes, not the output of the command. It's 
a common mistake to assume otherwise. To get the output of a particular 
command you could use the commands module.

like so:
====================================================
>>> import commands
>>> op = commands.getoutput('echo foo')
>>> op
'foo'
>>> op = commands.getstatusoutput('echo foo')
>>> op
(0, 'foo')
>>>
=====================================================
hope that helps,

Peace
Steve

P.S: I know all you gurus would suggest something like a popen, I just wanted 
to make a mention of the "commands" module, which is a nice lil' thing 
specifically meant for these kinda problems ....*I Think* :)
----------------------------------------------
Every oak tree started out as a 
couple of nuts who stood their ground.
                                    Anonymous
----------------------------------------------



From robin@alldunn.com  Mon Nov  5 16:42:00 2001
From: robin@alldunn.com (Robin Dunn)
Date: Mon, 5 Nov 2001 08:42:00 -0800
Subject: [Tutor] Re: [wxPython] really stange behaviour
References: <002001c166d7$75efb4d0$0101a8c0@baitullah>
Message-ID: <10f201c16618$cb72a120$0100a8c0@Rogue>

> Take a look at this:
> ===
> >>> import os
> >>> user = os.getenv('USER')
> >>> print user
> dida
> >>> group = os.system('set -- `groups $USER`; echo $3')
> staff
> >>> print group
> 0
> ===
>
> How did this happened? The reason i create this is for managing
> users. I run python in my environment. How can i take the
> (os.system...) value?


1. This has nothing to do with wxPython.

2. What did you expect?  (See the docs for os.system)

3. You probably wanted os.popen.

--
Robin Dunn
Software Craftsman
robin@AllDunn.com       Java give you jitters?
http://wxPython.org      Relax with wxPython!






From alan.gauld@bt.com  Mon Nov  5 17:33:08 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 5 Nov 2001 17:33:08 -0000
Subject: [Tutor] really stange behaviour
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C077@mbtlipnt02.btlabs.bt.co.uk>

> >>> import commands
> >>> op = commands.getoutput('echo foo')

> P.S: I know all you gurus would suggest something like a 
> popen, I just wanted to make a mention of the "commands" 
> module, which is a nice 

Very nice thanks for pointing it out, I certainly 
didn't realize it existed! Once again Python surprises 
me with its completeness. (Mind you I cant get it to 
work on win98 but thats probably a popen issue in Win32.)

Alan g.



From ylee12@uiuc.edu  Mon Nov  5 18:42:26 2001
From: ylee12@uiuc.edu (Young-Jin Lee)
Date: Mon, 5 Nov 2001 12:42:26 -0600
Subject: [Tutor] [Q] Looking for drawing toolkit in Tkinter
Message-ID: <004501c16629$9dc10710$95757e82@visit2>

This is a multi-part message in MIME format.

------=_NextPart_000_0042_01C165F7.52F28EC0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi, I'm looking for a drawing toolkit in Tkinter.
I asked the similar question a week ago and I was told to check DIA. But =
DIA does not provide a API and I want to find one in Tkinter because of =
cross-platform issue.

wxPython provides Object Graphics Library (OGL) to support the creation =
and manipulation of simple and complex graphic images on a canvas. But =
wxPython is not available in Mac. Is there anything equivalent to OGL of =
wxPython in Tkinter?

I hope to get some answer here. Thanks in advance.

YJ

------=_NextPart_000_0042_01C165F7.52F28EC0
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.3315.2870" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi, I'm looking for a drawing toolkit =
in=20
Tkinter.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I asked the similar question a week ago =
and I was=20
told to check DIA. But DIA does not provide a API and I want to find one =
in=20
Tkinter because of cross-platform issue.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>wxPython provides Object Graphics =
Library=20
(OGL)&nbsp;to support the creation and manipulation of simple and =
complex=20
graphic images on a canvas. But wxPython is not available in Mac. Is =
there=20
anything equivalent to OGL&nbsp;of wxPython in Tkinter?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I hope to get some answer here. Thanks =
in=20
advance.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>YJ</FONT></DIV></BODY></HTML>

------=_NextPart_000_0042_01C165F7.52F28EC0--



From boud@valdyas.org  Mon Nov  5 18:55:31 2001
From: boud@valdyas.org (Boudewijn Rempt)
Date: Mon, 5 Nov 2001 19:55:31 +0100 (CET)
Subject: [Tutor] Souce Debuger
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66C06F@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <Pine.LNX.4.33.0111051945540.30190-100000@calcifer.valdyas.org>

On Sun, 4 Nov 2001 alan.gauld@bt.com wrote:

> > There's an almost exact equivalent included: pdb. Of course, it's
> > horrible to use, being a command-line debugger.
>
> At this point I feel I must stand up in defense of
> command line debuggers.
>
<... snip ...>
>
> Reluctance to use commandline debuggers is one of
> my "hot buttons" with our new graduates... :-)
>

I tend to be a very light user of debuggers. I learnt programming on the
ZX-Spectrum, and obviously had to do without one. I rather like stepping
through my code, though - it's one of the simple meditation exercises
that help to rest my mind, like neatly indenting source :-). It's just
an alternative for looking out of the window. Besides, when you just start
programming, visually stepping through code might teach you to get some
insight into what I like to call 'the geography of code' - the flow of
execution like some kind of speedy river through your code. You don't
get that easily with command-line debuggers.

As for debugging techiques, as I said near the end of my list of available
debuggers, there's little a well-placed print statement can't handle.

Boudewijn Rempt  | http://www.valdyas.org



From ylee12@uiuc.edu  Mon Nov  5 21:25:33 2001
From: ylee12@uiuc.edu (Young-Jin Lee)
Date: Mon, 5 Nov 2001 15:25:33 -0600
Subject: [Tutor] [Q] how to use more than one source file.
Message-ID: <00f801c16640$67153df0$95757e82@visit2>

This is a multi-part message in MIME format.

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

Hi, all.
I have a question on how to use more than one file creating a Python =
application.
Most example code uses only one file, but it is not realistic. I want to =
separate codes into multiple files and use them.
For instance, suppose that I created a main python module in the =
mainApp.py and I created a separate mainFrame.py which will be called =
from mainApp.py. In this situation, how can I run the whole application =
package? Once I checked everything works as I expected, how can I =
created one executable file out of these two files?
Thanks in advance.

YJ

------=_NextPart_000_00F5_01C1660E.1C657130
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.3315.2870" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>Hi, all.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>I have a question on how to use more =
than one file=20
creating a Python application.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Most example code uses only one file, =
but it is not=20
realistic. I want to separate codes into multiple files and use=20
them.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>For instance, suppose that I created a =
main python=20
module in the mainApp.py and I created a separate mainFrame.py which =
will be=20
called from mainApp.py. In this situation, how can I run the whole =
application=20
package? Once I checked everything works as I expected, how can I =
created one=20
executable file out of these two files?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Thanks in advance.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>YJ</FONT></DIV></FONT></DIV></BODY></HTML>

------=_NextPart_000_00F5_01C1660E.1C657130--



From ken@ksp26.co.uk  Mon Nov  5 21:39:58 2001
From: ken@ksp26.co.uk (ken@ksp26.co.uk)
Date: Mon, 5 Nov 2001 21:39:58 -0000
Subject: [Tutor] What's The Quickest & Easiest Way For You To Succeed On The Internet?
Message-ID: <E160rTt-0007Or-00@mail.python.org>

<P ALIGN="CENTER"><A HREF="http://www.host4income.com/show.cgi/KSP26/home.html"><IMG
SRC="http://www.host4income.com/images/banner2.gif"WIDTH="468"HEIGHT="60"
ALIGN="BOTTOM" BORDER="0"></A>


From discuss@sendme.cz  Mon Nov  5 21:59:16 2001
From: discuss@sendme.cz (A)
Date: Mon, 5 Nov 2001 22:59:16 +0100
Subject: [Tutor] How to ?
Message-ID: <3BE719C4.26077.693A1B@localhost>

Hi,
I have a program that uses( reads) some data from a text file. How 
can I prevent users from seeing the content of this text file?
Thank you for reply.
Ladislav



From pemrograman@telkom.net  Tue Nov  6 15:55:21 2001
From: pemrograman@telkom.net (Adinda Praditya)
Date: Tue, 6 Nov 2001 22:55:21 +0700
Subject: [Tutor] really stange behaviour
Message-ID: <000001c16711$3a7c3c90$0101a8c0@baitullah>

This is a multi-part message in MIME format.

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

Take a look at this:
=3D=3D=3D
>>> import os
>>> user =3D os.getenv('USER')
>>> print user
dida
>>> group =3D os.system('set -- `groups $USER`; echo $3')
staff
>>> print group
0
=3D=3D=3D

How did this happened? The reason i create this is for managing users. I =
run python in my environment. How can i take the (os.system...) value?


------=_NextPart_000_002A_01C16716.1CC1F820
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#ffffff>
<DIV>
<DIV><FONT size=3D2>Take a look at this:<BR>=3D=3D=3D<BR>&gt;&gt;&gt; =
import=20
os<BR>&gt;&gt;&gt; user =3D os.getenv('USER')<BR>&gt;&gt;&gt; print=20
user<BR>dida<BR>&gt;&gt;&gt; group =3D os.system('set -- `groups $USER`; =
echo=20
$3')<BR>staff<BR>&gt;&gt;&gt; print group<BR>0<BR>=3D=3D=3D</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT size=3D2>How did this happened? The reason i create this is =
for=20
managing users. I run python in my environment. How can i take the=20
(os.system...) value?<BR></FONT></DIV></DIV></BODY></HTML>

------=_NextPart_000_002A_01C16716.1CC1F820--



From boud@valdyas.org  Mon Nov  5 22:35:55 2001
From: boud@valdyas.org (Boudewijn Rempt)
Date: Mon, 5 Nov 2001 23:35:55 +0100 (CET)
Subject: [Tutor] [Q] how to use more than one source file.
In-Reply-To: <00f801c16640$67153df0$95757e82@visit2>
Message-ID: <Pine.LNX.4.33.0111052334060.5535-100000@calcifer.valdyas.org>

On Mon, 5 Nov 2001, Young-Jin Lee wrote:

> Hi, all.
> I have a question on how to use more than one file creating a Python application.
> Most example code uses only one file, but it is not realistic. I want to separate codes into multiple files and use them.
> For instance, suppose that I created a main python module in the mainApp.py and I created a separate mainFrame.py which will be called from mainApp.py. In this situation, how can I run the whole application package? Once I checked everything works as I expected, how can I created one executable file out of these two files?
> Thanks in advance.
>

If you really want to package it all up as one file, you should
investigate Gordon McMillan's installer -

   http://www.mcmillan-inc.com/standalones.html

Be sure to read the rest of what he writes about the topic of packaging
and distributing too!

Boudewijn Rempt  | http://www.valdyas.org



From gherron@islandtraining.com  Mon Nov  5 22:52:46 2001
From: gherron@islandtraining.com (Gary Herron)
Date: Mon, 5 Nov 2001 14:52:46 -0800
Subject: [Tutor] Re: [wxPython] really stange behaviour
In-Reply-To: <000001c16711$3a7c3c90$0101a8c0@baitullah>
References: <000001c16711$3a7c3c90$0101a8c0@baitullah>
Message-ID: <200111052253.fA5MrWn21005@smtp004pub.verizon.net>

os.system just returns an exit code (or 0 on windows platforms).  If
you want your program to read the output produced by a command try
os.popen (or popen2 or popen3 or popen4 -- RTFM).

f = os.popen('...command string ..., 'r')
result = f.read()

The output of your small example is, perhaps, confusing.  The user
name is printed by the python print statement, but the group name
'staff' is not printed by python.  Here's what happened.  The executed
echo command sends its output to the controlling terminal (that's why
you see the word 'staff'), but it does not communicate back to python
through the os.system call.  The return value of the os.system call
(evidently zero) is assigned to the group variable but is not
printed. (The assignment statement in python never prints to the
screen.)  Finally your print statement show the value of the group
variable to be zero.


On Tuesday 06 November 2001 07:55 am, Adinda Praditya wrote:
> Take a look at this:
> ===
>
> >>> import os
> >>> user = os.getenv('USER')
> >>> print user
>
> dida
>
> >>> group = os.system('set -- `groups $USER`; echo $3')
>
> staff
>
> >>> print group
>
> 0
> ===
>
> How did this happened? The reason i create this is for managing users. I
> run python in my environment. How can i take the (os.system...) value?


From python.tutor@atrixnet.com  Tue Nov  6 08:25:41 2001
From: python.tutor@atrixnet.com (Tommy Butler)
Date: Tue, 6 Nov 2001 00:25:41 -0800
Subject: [Tutor] New Python scoping
In-Reply-To: <E160n7O-000228-00@mail.python.org>
Message-ID: <MABBJNNKNGCCADBAELCHAEEADAAA.python.tutor@atrixnet.com>

   From: alan.gauld@bt.com
   To: python.tutor@atrixnet.com, tutor@python.org
   Subject: RE: [Tutor] New Python scoping
   Date: Mon, 5 Nov 2001 11:03:42 -0000

   >>Can someone explain Python scoping rules in general
   >>for me, taking into account these new changes?

   >I'll leave that to somebody else :-)

Any takers?

    Tommy Butler
    Internet Strategies, Inc.   Everything is Possible

      web     http://www.istrat.com
      email   mailto:tommy@istrat.com
      tel     214=B7393=B71000  ext 207
      fax     800=B7307=B78105

    2200 North Lamar, Suite 307      Dallas, TX  75202




From david.jay.jackson@wcox.com  Tue Nov  6 15:51:23 2001
From: david.jay.jackson@wcox.com (Jackson)
Date: Tue,  6 Nov 2001 08:51:23 -0700
Subject: [Tutor] Contrib: Shelve/DB example
Message-ID: <200111060851.AA269943054@wcox.com>

------------------------------------------------------------------------
This mail message contains standard MIME attachments.  If you see this
note, your e-mail program does not support MIME.  You may need a MIME-
compliant mail reader to read any non-text attachments in this message.
------------------------------------------------------------------------

--==IMail_v5.0==
Content-Type: text/plain; charset=us-ascii

I'm passing along these script which demo basic data storage and retrievial using the shelve module. Hopefully it'll short'en some new users learning curve :)

A Big thanks to the "tutor" and "python-help" folks who help shorten my learning curve.

David Jackson   







--==IMail_v5.0==
Content-Type: text/plain; name="shelve.howto"
Content-Transfer-Encoding: binary

#!/usrlocal/bin/python
import time,string,shelve,os
###########################################################
# David Jackson, 11/06/2001
# Creates datebase to track server outages
# Python script demostrating use of shelve 
# and multi-line raw_input()
# See rca_report.py: for demo of basic report creation
###########################################################
# define multi line input, contributed by Kalle
def get_input(prompt):
    lines = []
    while 1:
        s = raw_input(prompt)
        if s == ".":
            break
        lines.append(s)
    return "\n".join(lines)
####################################################

indx = time.strftime("%Y%j%H%m%S",time.localtime())
server = raw_input("Enter server: ")
date_opened = raw_input("Start date: ")
date_closed = raw_input("Date closed: ")
vendor = raw_input("Vender name: ")
vendor_ticket = raw_input("Vendor ticket: ")
print "-------------------------------------------"
print "Event and Resolution allow mult-line input"
print "Enter \".\" on blank line to exit field"
print "-------------------------------------------"
event = get_input("Describe event: ")
resolution = get_input("Describe resolution: ")
#
rca=shelve.open("rca.db)
os.chmod("rca.db",0666)
rca[server +":"+ indx]=[server,date_opened, date_closed,vendor,vendor_ticket,event,resolution]
rca.close()
rca=shelve.open("rca.db")
print rca.keys()




#!/usr/bin/python
import time,string,shelve
###############################################################
# David Jackson, 2001/11/06
# Uses datebase created by rca_event.py to create quick report
# after prompting for server name.
###############################################################
box = raw_input("Enter server name: ")
def getmatches(pattern, thedict):
	keys = [i for i in thedict.keys() if i.find(pattern)>=0]
	for k in keys:
			print  "Server: ",
			print  '%s' %(thedict[k][0])
			print "Date(opened/closed): ",
			print  '%s' %(thedict[k][1]),
			print  '%s' %(thedict[k][2])
			print "\nEvent:" 
			print  '%s' %(thedict[k][5])
			print "\nResolution:"
			print  "%s" %(thedict[k][6])
db = shelve.open("rca.db")
getmatches(box,db)





--==IMail_v5.0==--


From alan.gauld@bt.com  Tue Nov  6 18:07:24 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 6 Nov 2001 18:07:24 -0000
Subject: [Tutor] [Q] how to use more than one source file.
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C083@mbtlipnt02.btlabs.bt.co.uk>

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


I have a question on how to use more than one file creating a Python
application. 

Read up on modules in the python tutorial
(or indeed in my online tutorial in the section 
on modules and the case study)
 
Also look at the example source that ships 
with python, most of them use modules.

Most example code uses only one file, but it is not realistic. I want to
separate codes into multiple files and use them. 

Python excells at this, its the normal mode of 
operation when you move beyond beginners scripts.
 
>  For instance, suppose that I created a main python module in the  
>  mainApp.py and I created a separate mainFrame.py which will be  
>  called from mainApp.py. In this situation, how can I run the whole  
>  application package?  
 
Assuming mainApp.py contains an import statement 
for mainFrame.py and accesses the functions/classes
via mainFrame.XXXX() syntax then just run mainApp.py
 
eg:
 
### myMod.py ###############
def myFunc(i):
   print i
### end of file myMod.py ###
 
### MainApp.py #############
import myMod
 
def run():
  for n in [1,2,3]:
   myMod.myFunc(n)
 
if __name__ == "__main__": 
   run()
### end of file MainApp.py ###
 
Now run the app from the OS command/shell prompt:
 
C:\>python MainApp.py
 
or double click on MainApp.py in explorer
(assuming Windows)
 
>  Once I checked everything works as I expected, how can I created  
>  one executable file out of these two files? 
 
First, why do you need to? There are few cases where this is really needed.
It's often easier just to package up a full python install with your files.
(or 
only the compiled pyc files for the modules if you prefer) Once your users 
have Python installed once you just need tonship .py or .pyc files to them 
which is much lighter weight. After all that's what Microsoft have done 
with VB apps for years!
 
If you really need to produce a single file distro then py2exe or 
Gordon McMillan's installer (from Activestate site I think?) can 
do the deed.
 
Alan g.
http://www.freenetpages.co.uk/hp/alan.gauld/
<http://www.freenetpages.co.uk/hp/alan.gauld/> 
 

------_=_NextPart_001_01C166ED.E2E40080
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>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
  <DIV><FONT face=Arial>
  <DIV><FONT size=2><FONT face=Arial>I have a question on how to use more than 
  one file creating a Python application.<FONT color=#0000ff 
  face="Courier New"><SPAN 
  class=550545417-06112001>&nbsp;</SPAN></FONT></FONT></FONT></DIV></DIV></BLOCKQUOTE>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001>Read up on modules in the python 
tutorial</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001>(or indeed in my online tutorial in the section 
</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001>on modules and the case 
study)</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001>Also look at the example source that ships 
</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001>with python, </SPAN></FONT></FONT></FONT><FONT 
size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001>most of them use 
modules.</SPAN></FONT></FONT></FONT></DIV>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px; PADDING-LEFT: 5px">
  <DIV><FONT size=2><FONT face=Arial>Most example code uses only one file, but 
  it is not realistic. I want to separate codes into multiple files and use 
  them.<FONT color=#0000ff face="Courier New"><SPAN 
  class=550545417-06112001>&nbsp;</SPAN></FONT></FONT></FONT></DIV></BLOCKQUOTE>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001>Python excells at this, its the normal mode of 
</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001>operation when you move beyond beginners 
scripts.</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001>&nbsp;</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN class=550545417-06112001><FONT 
color=#0000ff face="Courier New">&gt; &nbsp;</FONT></SPAN>For instance, suppose 
that I created a main python module in the&nbsp;<SPAN 
class=550545417-06112001><FONT color=#0000ff 
face="Courier New">&nbsp;</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN class=550545417-06112001><FONT 
color=#0000ff face="Courier New">&gt; </FONT>&nbsp;</SPAN>mainApp.py and I 
created a separate mainFrame.py which will be&nbsp;<SPAN 
class=550545417-06112001><FONT color=#0000ff 
face="Courier New">&nbsp;</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN class=550545417-06112001><FONT 
color=#0000ff face="Courier New">&gt; </FONT>&nbsp;</SPAN>called from 
mainApp.py. In this situation, how can I run the whole&nbsp;<SPAN 
class=550545417-06112001><FONT color=#0000ff 
face="Courier New">&nbsp;</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN class=550545417-06112001><FONT 
color=#0000ff face="Courier New">&gt; </FONT>&nbsp;</SPAN>application 
package?&nbsp;<SPAN class=550545417-06112001><FONT color=#0000ff 
face="Courier New">&nbsp;</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN 
class=550545417-06112001></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>Assuming mainApp.py contains an import statement 
</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>for mainFrame.py and accesses the 
functions/classes</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>via mainFrame.XXXX() syntax then just run 
mainApp.py</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>eg:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>### myMod.py ###############</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>def myFunc(i):</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>&nbsp;&nbsp; print i</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>### end of file myMod.py ###</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>### MainApp.py #############</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>import myMod</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>def run():</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>&nbsp; for&nbsp;n in [1,2,3]:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>&nbsp;&nbsp;  myMod.myFunc(n)</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>if __name__ == "__main__": </SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>&nbsp;&nbsp; run()</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>### end of file MainApp.py 
###</SPAN></FONT></DIV></SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>Now run the app from the OS command/shell 
prompt:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>C:\&gt;python MainApp.py</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>or double click on MainApp.py in 
explorer</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>(assuming Windows)</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN class=550545417-06112001>&gt; 
&nbsp;</SPAN>Once I checked everything works as I expected, how can I 
created&nbsp;<SPAN class=550545417-06112001><FONT color=#0000ff 
face="Courier New">&nbsp;</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN class=550545417-06112001><FONT 
color=#0000ff face="Courier New">&gt; </FONT>&nbsp;</SPAN>one executable file 
out of these two files?</FONT><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001>&nbsp;</SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001><FONT color=#000000 face=Arial>First, why do you need 
to? There are few cases where this is really 
needed.</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001><FONT color=#000000 face=Arial>It's often easier just 
to package up a full python install with your files. (or 
</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001><FONT color=#000000 face=Arial>only the compiled pyc 
files for the modules if you prefer)</FONT>&nbsp;<FONT color=#000000 
face=Arial>Once your users </FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001><FONT color=#000000 face=Arial>have Python installed 
once you just need tonship .py or .pyc files to them 
</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001><FONT color=#000000 face=Arial>which is much lighter 
weight. After all that's what Microsoft have done 
</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001><FONT color=#000000 face=Arial>with VB apps for 
years!</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=550545417-06112001></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><SPAN class=550545417-06112001>If you really need to produce a 
single file distro then py2exe or </SPAN></FONT></DIV>
<DIV><FONT size=2><SPAN class=550545417-06112001>Gordon McMillan's installer 
(from Activestate site I think?) can </SPAN></FONT></DIV>
<DIV><FONT size=2><SPAN class=550545417-06112001>do the 
deed.</SPAN></FONT></DIV>
<DIV><FONT size=2><SPAN class=550545417-06112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001>Alan g.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001><A 
href="http://www.freenetpages.co.uk/hp/alan.gauld/">http://www.freenetpages.co.uk/hp/alan.gauld/</A></SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=550545417-06112001></SPAN></FONT>&nbsp;</DIV></FONT></BODY></HTML>

------_=_NextPart_001_01C166ED.E2E40080--


From dsh8290@rit.edu  Tue Nov  6 21:37:15 2001
From: dsh8290@rit.edu (dman)
Date: Tue, 6 Nov 2001 16:37:15 -0500
Subject: [Tutor] New Python scoping
In-Reply-To: <MABBJNNKNGCCADBAELCHAEEADAAA.python.tutor@atrixnet.com>; from python.tutor@atrixnet.com on Tue, Nov 06, 2001 at 12:25:41AM -0800
References: <E160n7O-000228-00@mail.python.org> <MABBJNNKNGCCADBAELCHAEEADAAA.python.tutor@atrixnet.com>
Message-ID: <20011106163715.A17479@harmony.cs.rit.edu>

On Tue, Nov 06, 2001 at 12:25:41AM -0800, Tommy Butler wrote:
| 
|    From: alan.gauld@bt.com
|    To: python.tutor@atrixnet.com, tutor@python.org
|    Subject: RE: [Tutor] New Python scoping
|    Date: Mon, 5 Nov 2001 11:03:42 -0000
| 
|    >>Can someone explain Python scoping rules in general
|    >>for me, taking into account these new changes?
| 
|    >I'll leave that to somebody else :-)
| 
| Any takers?

If you are using version 2.1, put the line

    from __future__ import nested_scopes

as the first non-blank, non-comment, and non-docstring line in the
file.

If you are using 2.2 or newer, this is not needed (you have no choice
but to use nested scopes).

Then to test it out use the following code


a = 1
def f() :
    a = 2
    def g()
        print a
    g()
f()


If the language has statically nested scopes, then you will get '2'
printed out.  If you remove the "future statement" (as that line above
is called) from the file you will get "1" printed out.


Have you programmed in C, C++ or Java at all?  If so, then Python's
scoping is the same except that you can define a function inside
another, and instances of inner classes don't automagically have
unqualified access to outer-class members (a java hack to work around
the lack of references to functions).

HTH,
-D



From dyoo@hkn.eecs.berkeley.edu  Tue Nov  6 23:06:55 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 6 Nov 2001 15:06:55 -0800 (PST)
Subject: [Tutor] New Python scoping
In-Reply-To: <20011106163715.A17479@harmony.cs.rit.edu>
Message-ID: <Pine.LNX.4.21.0111061422390.18712-100000@hkn.eecs.berkeley.edu>

On Tue, 6 Nov 2001, dman wrote:

> Have you programmed in C, C++ or Java at all?  If so, then Python's
> scoping is the same except that you can define a function inside
> another, and instances of inner classes don't automagically have
> unqualified access to outer-class members (a java hack to work around
> the lack of references to functions).

The scoping rules probably wouldn't make too much sense if we try
explaining it in C or C++ terms, since both languages don't allow
functions to be nested... Hmmm...

Let's look at a concrete example that uses Python's revised scoping rules,
and it might make things clearer.  Below is something called the pocket()
function --- it's totally useless, but sorta fun to play with.

[Note: for people who played around with the Lists and Lists interactive
fiction game at:

    http://www.wurb.com/if/game/128

the snipped below is a translation of the solution to the last puzzle, so
please skip this message if you don't want to see spoilers.  Also, this is
something of a brain twister anyway, so if it looks weird, that's because
it IS.  *grin*]

### Spoiler space ahead ###







Here goes!  As a warning, this function will look very silly, but please
be patient; we'll play around with it and see what it actually does in a
moment:

###
from __future__ import nested_scopes         ## Necessary in Python 2.1

def makePocket(n):
    """A function that creates a "pocket" function that holds some 'n'
       within it."""
    def pocket_function(*x):
        """Given no arguments, returns the contents of the pocket.
        Given a single argument, creates a new pocket with that argument
        as the new contents."""
        if len(x) == 0:
            return n
        return makePocket(x[0])
    return pocket_function
###

This "pocket" allows us to hold a single thing in a function, like this:

###
>>> mypocket = makePocket("rocket")
>>> mypocket()
'rocket'
###

It's a rocket in a pocket.  *grin* This pocket function is sorta neat
because we can put new things in the pocket:

###
>>> mypocket = mypocket("escaflowne")
>>> mypocket()
'escaflowne'
###

So this "pocket" is a function that, when we call it, returns the very
last thing that we put in it.  When we call the "pocket" with a new thing,
it gives us a new pocket.



How in the world does this thing work?  We can take a look at the function
definition again:

###
def makePocket(n):
    def pocket_function(*x):
        if len(x) == 0:
            return n
        return makePocket(x[0])
    return pocket_function
###

makePocket() is a function that knows how to make new pockets().  When we
make a new pocket, we need to build a pocket_function that knows how to
return the thing that the pocket contain, and that's what the the inner
definition does.  Once makePocket() has built a pocket_function(), it
gives that back to the user to fiddle with.


All of the scoping stuff has to do with pocket_function() --- how does
pocket_function() know what 'n' is?  In the old Python scoping rules, it
couldn't!  The only places ("scopes") where functions could look for
variables were:

    1.  Local --- within our own function
    2.  Module --- within our own module
    3.  Builtin --- within the built-in namespace


If we take a close look at the pocket_function():

###
    def pocket_function(*x):
        if len(x) == 0:
            return n
        return makePocket(x[0])
###

we can imagine what older versions of Python thought when it saw the
variable 'n'.  "Is 'n' something we defined in pocket_function?  No.  Is
it something that was defined at the module level, like a global variable?  
Nope.  How about in the builtin level?  No.  Aaaah, I don't know what n
is!"

###
## In Python 1.52:
>>> pocket = makePocket("rocket")
>>> pocket()
Traceback (innermost last):
  File "<stdin>", line 1, in ?
  File "<stdin>", line 4, in pocket_function
NameError: n
###



What makes Python's modified scoping rules neat is that it doesn't
restrict the looking up of variables to just three places --- instead,
scopes can be "nested", or built on top of each other.  In the new
"nested" scoping rules, the pocket_function() in:

###
def makePocket(n):
    def pocket_function(*x):
        if len(x) == 0:
            return n
        return makePocket(x[0])
    return pocket_function
###

has more flexibility when it looks up variables.  First, pocket_function()  
can look things up in it's own, "local" scope.  Next, it can go one level
outside to the scope of the makePocket() function, and so it can find out
what 'n' is.

Please feel free to ask questions about this; it's a very strange thing to
see if you're coming from a strict C/C++ background, so don't worry if it
looks weird.



From pythonpython@hotmail.com  Wed Nov  7 01:42:11 2001
From: pythonpython@hotmail.com (HY)
Date: Wed, 7 Nov 2001 10:42:11 +0900
Subject: [Tutor] How to use variables in regular expressions?
References: <4BB02C541824D311921600902765DB7B44583B@LTISERVER> <20010905202641.D18539@harmony.cs.rit.edu>
Message-ID: <OE54MWbR2fuoU3WwcVD0001d507@hotmail.com>

Could you please give me some ideas regarding how to use variables in
regular expressions?

For example,
>>> x="abc"
>>> re.search(x+"def","abcdefg")
<SRE_Match object at 00F54960>

Above works, but beblow does not work:

>>> x="(a)[b]c"
>>> re.search(x+"def","(a)[b]cdefg")


I understand that ( ) [ ] are special symbols used by Python,
but is there a good way to solve this problem?


Many thanks...

Hy


From kimtitu@yahoo.com  Wed Nov  7 01:40:53 2001
From: kimtitu@yahoo.com (Titu Kim)
Date: Tue, 6 Nov 2001 17:40:53 -0800 (PST)
Subject: [Tutor] Daylight saving time issue
Message-ID: <20011107014053.1065.qmail@web14707.mail.yahoo.com>

Hi,
   I am trying to determine a given date is in dst or
not. For instance, if i have month(mm), day(dd),
year(yyyy) information plus the beginning (00:00:01)
or ending (23:59:59) of this day, i would like to
determine the given date/time is in daylight saving
time. To make the situation complecated, i also have
to consider the day when day light saving time occurs,
which is in Oct and April each year. Any suggestion is
very appreciated.

Thank you very much.

Regards,

Kim Titu 

__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com


From smoynes@nexus.carleton.ca  Wed Nov  7 01:50:37 2001
From: smoynes@nexus.carleton.ca (Scott Moynes)
Date: Tue, 6 Nov 2001 20:50:37 -0500
Subject: [Tutor] How to use variables in regular expressions?
In-Reply-To: <OE54MWbR2fuoU3WwcVD0001d507@hotmail.com>
References: <4BB02C541824D311921600902765DB7B44583B@LTISERVER> <20010905202641.D18539@harmony.cs.rit.edu> <OE54MWbR2fuoU3WwcVD0001d507@hotmail.com>
Message-ID: <20011106205037.A781@marilyn>

--SLDf9lqlvOQaIe6s
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

* HY (pythonpython@hotmail.com) wrote:
> I understand that ( ) [ ] are special symbols used by Python,
> but is there a good way to solve this problem?

I think it has more to do with the fact that they are special regexp
symbols, but fortunately there is a good (and simple) way to solve
this problem.

re.escape(string) "Returns string with all non-alphanumerics
backslashed; this is useful if you want to match an arbitrary literal
string that may have regular expression metacharacters in it."

So, your code would become:=20

>>> x=3D"(a)[b]c"
>>> re.search( re.escape(x)+"def", "(a)[b]cdefg")
<SRE_Match object at 0x8059810>

hth

scott
--
Copyleft (c) 2001, Scott Moynes
--SLDf9lqlvOQaIe6s
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAjvok20ACgkQiPjBXy2RebBipQCfRafwU09wh112WY4mwz52mYvS
bBoAn0dtW6Hs6EqDYkd4uc4xaTO051Jg
=N3KN
-----END PGP SIGNATURE-----

--SLDf9lqlvOQaIe6s--


From shalehperry@home.com  Wed Nov  7 02:51:58 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Tue, 06 Nov 2001 18:51:58 -0800 (PST)
Subject: [Tutor] Daylight saving time issue
In-Reply-To: <20011107014053.1065.qmail@web14707.mail.yahoo.com>
Message-ID: <XFMail.20011106185158.shalehperry@home.com>

On 07-Nov-2001 Titu Kim wrote:
> Hi,
>    I am trying to determine a given date is in dst or
> not. For instance, if i have month(mm), day(dd),
> year(yyyy) information plus the beginning (00:00:01)
> or ending (23:59:59) of this day, i would like to
> determine the given date/time is in daylight saving
> time. To make the situation complecated, i also have
> to consider the day when day light saving time occurs,
> which is in Oct and April each year. Any suggestion is
> very appreciated.
> 

I typed "when is daylight savings time" into google and found this:

http://webexhibits.org/daylightsaving/

Daylight Saving Time begins for most of the United
States at 2 a.m. on the first Sunday of April.
Time reverts to standard time at 2 a.m. on the last
Sunday of October. In the European Union, it
starts at 1 am the last Sunday in March, and ends
the last Sunday in October.
Daylight Saving Time, for the U.S. and its
territories, is NOT observed in Hawaii, American
Samoa, Guam, Puerto Rico, the Virgin Islands, the
Eastern Time Zone portion of the State of Indiana,
and the state of Arizona (not the Navajo Indian
Reservation, which does observe). Navajo Nation
participates in the Daylight Saving Time policy,
due to its large size and location in three states.



From dsh8290@rit.edu  Wed Nov  7 04:21:44 2001
From: dsh8290@rit.edu (dman)
Date: Tue, 6 Nov 2001 23:21:44 -0500
Subject: [Tutor] Daylight saving time issue
In-Reply-To: <20011107014053.1065.qmail@web14707.mail.yahoo.com>; from kimtitu@yahoo.com on Tue, Nov 06, 2001 at 05:40:53PM -0800
References: <20011107014053.1065.qmail@web14707.mail.yahoo.com>
Message-ID: <20011106232144.A20170@harmony.cs.rit.edu>

On Tue, Nov 06, 2001 at 05:40:53PM -0800, Titu Kim wrote:
| Hi,
|    I am trying to determine a given date is in dst or
| not. For instance, if i have month(mm), day(dd),
| year(yyyy) information plus the beginning (00:00:01)
| or ending (23:59:59) of this day, i would like to
| determine the given date/time is in daylight saving
| time. To make the situation complecated, i also have
| to consider the day when day light saving time occurs,
| which is in Oct and April each year. Any suggestion is
| very appreciated.

Create some date objects.

dst_start = day of year dst starts
dst_end = day of year dst ends

if dst_start < myday < dst_end :
    print "is DST"
else :
    print "not DST"


The real trick now is to define the date objects and have the
comparison ignore the year.  I know java has a Calendar class, but at the very
least a tuple might work.  

Let's see :

$ python
Python 1.5.2 (#0, Oct 20 2001, 16:30:45)  [GCC 2.95.4 20011006 (Debian prerelease)] on linux2
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> dst_end = (9 , 14)
>>> dst_start = (3 , 14)
>>> dst_start < dst_end
1
>>> today = (10 , 3)
>>> print dst_start < today < dst_end
0
>>>

(I made the months 0..11)
Honestly, though I don't know the dates for DST but this should give
an idea as to how to approach it.  If DST is during the winter, then
you would certainly want a function to tell you if the date is DST :

def is_dst( date ) :
    return date < dst_start or date > dst_end 


HTH,
-D



From kimtitu@yahoo.com  Wed Nov  7 05:56:26 2001
From: kimtitu@yahoo.com (Titu Kim)
Date: Tue, 6 Nov 2001 21:56:26 -0800 (PST)
Subject: [Tutor] Daylight saving time issue
In-Reply-To: <20011106232144.A20170@harmony.cs.rit.edu>
Message-ID: <20011107055626.35046.qmail@web14707.mail.yahoo.com>

You have a good point. But the start date and end date
of dst for every year is different,  how can this
problem be taken care of. Thanks.

--- dman <dsh8290@rit.edu> wrote:
> On Tue, Nov 06, 2001 at 05:40:53PM -0800, Titu Kim
> wrote:
> | Hi,
> |    I am trying to determine a given date is in dst
> or
> | not. For instance, if i have month(mm), day(dd),
> | year(yyyy) information plus the beginning
> (00:00:01)
> | or ending (23:59:59) of this day, i would like to
> | determine the given date/time is in daylight
> saving
> | time. To make the situation complecated, i also
> have
> | to consider the day when day light saving time
> occurs,
> | which is in Oct and April each year. Any
> suggestion is
> | very appreciated.
> 
> Create some date objects.
> 
> dst_start = day of year dst starts
> dst_end = day of year dst ends
> 
> if dst_start < myday < dst_end :
>     print "is DST"
> else :
>     print "not DST"
> 
> 
> The real trick now is to define the date objects and
> have the
> comparison ignore the year.  I know java has a
> Calendar class, but at the very
> least a tuple might work.  
> 
> Let's see :
> 
> $ python
> Python 1.5.2 (#0, Oct 20 2001, 16:30:45)  [GCC
> 2.95.4 20011006 (Debian prerelease)] on linux2
> Copyright 1991-1995 Stichting Mathematisch Centrum,
> Amsterdam
> >>> dst_end = (9 , 14)
> >>> dst_start = (3 , 14)
> >>> dst_start < dst_end
> 1
> >>> today = (10 , 3)
> >>> print dst_start < today < dst_end
> 0
> >>>
> 
> (I made the months 0..11)
> Honestly, though I don't know the dates for DST but
> this should give
> an idea as to how to approach it.  If DST is during
> the winter, then
> you would certainly want a function to tell you if
> the date is DST :
> 
> def is_dst( date ) :
>     return date < dst_start or date > dst_end 
> 
> 
> HTH,
> -D
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com


From ed@iterunet.com  Wed Nov  7 08:55:53 2001
From: ed@iterunet.com (Edy Lie)
Date: Wed, 7 Nov 2001 16:55:53 +0800
Subject: [Tutor] Hi I need advice
Message-ID: <LHEEKPJKJNOJPGDPPECAGEMMCHAA.ed@iterunet.com>

Hi everyone.

   I need some help/advice over the following code. My 1st attempt using
class.

#!/usr/local/bin/python
import sys

class DataBase:
   def __init__(self, Plan, Domain, Email, Name):
      self.UserPlan = Plan
      self.UserDomain = Domain
      self.UserEmail = Email
      self.UserName = Name

print '1. Adding New User'
print '2. Search New User'
print '3. View All User'
print '4. Exit'
choice = input("Please choose an option: ")

if choice == 1:
    print 'Adding New User\n'
    add = DataBase(' ', ' ', ' ', ' ')
    add.UserPlan = raw_input("Plan: ")
    add.UserDomain = raw_input("Domain: ")
    add.UserEmail = raw_input("Email: ")
    add.UserName = raw_input("Name: ")
    print "Domain %s has registered" % add.UserDomain
    save = raw_input("Do you wanna save? Press Y or N\nChoice: ")
    if save == "Y":
       print "Record Saved\n"
       f=open('record', 'w')
       f.write("Plan: %s\nDomain: %s\nEmail: %s\nName: %s\n-----\n" %
(add.UserPlan,add.UserDomain
,add.UserEmail,add.UserName))
    elif save == "N":
       print "No Data Saved\n"
    else:
       print "Wrong input ... Bye Bye\n"
       sys.exit()

elif choice == 2:
    print 'Search New User\n'


elif choice == 3:
    print 'View All User\n'

elif choice == 4:
    print 'Exit program ...'
    sys.exit()

else:
    print 'Wrong input'
    sys.exit()

My question is why do i can't to use add = DataBase() ?

Thanks

Edy Lie.



From dpetrac@yahoo.com  Wed Nov  7 11:56:29 2001
From: dpetrac@yahoo.com (Danijel Petrac)
Date: Wed, 7 Nov 2001 12:56:29 +0100
Subject: [Tutor] Re: Welcome to the "Tutor" mailing list (Digest mode)
References: <E161QqH-0004yl-00@mail.python.org>
Message-ID: <004001c16783$3f8063c0$a800000a@activmedia.hr>

Ok.
----- Original Message ----- 
From: <tutor-request@python.org>
To: <dpetrac@yahoo.com>
Sent: Wednesday, November 07, 2001 12:26 PM
Subject: Welcome to the "Tutor" mailing list (Digest mode)


> Welcome to the Tutor@python.org mailing list! This list is for folks
> who want to ask (and/or answer) questions from folks who wish to learn
> how to program with Python.  Feel free to ask even the most basic of
> questions -- that's what the list is for!
> 
> To post to this list, send your email to:
> 
>   tutor@python.org
> 
> General information about the mailing list is at:
> 
>   http://mail.python.org/mailman/listinfo/tutor
> 
> If you ever want to unsubscribe or change your options (eg, switch to
> or from digest mode, change your password, etc.), visit your
> subscription page at:
> 
>   http://mail.python.org/mailman/options/tutor/dpetrac%40yahoo.com
> 
> You can also make such adjustments via email by sending a message to:
> 
>   Tutor-request@python.org
> 
> with the word `help' in the subject or body (don't include the
> quotes), and you will get back a message with instructions.
> 
> You must know your password to change your options (including changing
> the password, itself) or to unsubscribe.  It is:
> 
>   bebachpython
> 
> If you forget your password, don't worry, you will receive a monthly
> reminder telling you what all your python.org mailing list passwords
> are, and how to unsubscribe or change your options.  There is also a
> button on your options page that will email your current password to
> you.
> 
> You may also have your password mailed to you automatically off of the
> Web page noted above.


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



From alan.gauld@bt.com  Wed Nov  7 11:52:13 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 7 Nov 2001 11:52:13 -0000
Subject: [Tutor] Daylight saving time issue
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C084@mbtlipnt02.btlabs.bt.co.uk>

>    I am trying to determine a given date is in dst or
> not. 

This is incredibly difficult to do correctly.
I once had a summer graduate student spend 3 months 
writing up a paper on use of local time in a 
globally distributed system - and he wasn't able 
to complete it in the 3 months!

Consider a few of the more obvious and trivial 
examples of the kind of problems you meet:

> to consider the day when day light saving time occurs,
> which is in Oct and April each year. 

That depends entirely on the locality.
On a skiing trip to Andorra (a small principality 
between France and Spain) a few years ago the snow 
was melting too fast so the government held a 
special session and switched to DST a week early 
to try to preserve the snow... 
This was done by the simple expedient of announcing 
it on the "national" news and putting posters up 
in each town square.

In the UK the changeover occurs in March and October
In the US it happens on the last weekend of the 
respective month, in the UK it happens on the 4th 
weekend. These are normally the same but not always! 
(Actually it may be the other way around, I can't 
remember... but it did cause us problems when 
the PC BIOS(US made) tries to change and NT and 
Unix(using Locale settings) didn't!)

Also some places don't have DST at all. Other do but 
it's by more than 1 hour. (A few places its only 30 
minutes!)

When you start to account for the 37 or so different 
timezones around the world too local time is a nightmare!

Alan G.


From arcege@speakeasy.net  Wed Nov  7 13:08:02 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Wed, 7 Nov 2001 08:08:02 -0500
Subject: [Tutor] Daylight saving time issue
In-Reply-To: <20011107055626.35046.qmail@web14707.mail.yahoo.com>; from kimtitu@yahoo.com on Tue, Nov 06, 2001 at 09:56:26PM -0800
References: <20011106232144.A20170@harmony.cs.rit.edu> <20011107055626.35046.qmail@web14707.mail.yahoo.com>
Message-ID: <20011107080802.E1017@speakeasy.net>

On Tue, Nov 06, 2001 at 09:56:26PM -0800, Titu Kim wrote:
> You have a good point. But the start date and end date
> of dst for every year is different,  how can this
> problem be taken care of. Thanks.

You can know if it IS daylight savings time by looking at the date tuples
returned in the time module.

The last value in the tuple is the DST value (just as with C's struct
time structure).  If it is true, the time is in daylight savings time,
and if false, it is not.  This value can be calculated automatically by
the time module.  If the value is -1, then time.mktime() will guess.

You may also want to look at the mxDateTime package, tho I don't know
how well maintained it is.  I can probably handle it more completely
than the time module.

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From toodles@yifan.net  Wed Nov  7 14:30:09 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Wed, 7 Nov 2001 22:30:09 +0800
Subject: [Tutor] Hi I need advice
References: <LHEEKPJKJNOJPGDPPECAGEMMCHAA.ed@iterunet.com>
Message-ID: <000701c16798$b59511e0$0300a8c0@sun>

Hi Edy

> My question is why do i can't to use add = DataBase() ?

You can't as you have your code at the moment, but it is possible to get
around that. I'll get to that in a moment.

> class DataBase:
>    def __init__(self, Plan, Domain, Email, Name):

Because you've specified that the class be instantiated with 4 arguments,
these 4 arguments *must* be passed. That is why DataBase('','','','') works
and not DataBase().
To get around this you can specify default values for the arguments:

class DataBase:
    def __init__(self,Plan='',Domain='',Email='',Name=''):

nb. these values can be whatever you like.

test:
>>> class DataBase:
 def __init__(self,Plan='',Domain='',Email='',Name=''):
  self.Plan=Plan
  self.Domain=Domain
  self.Email=Email
  self.Name=Name

>>> add=DataBase()
>>> add.Plan
''

HTH,
Andrew Wilkins

> Hi everyone.
>
>    I need some help/advice over the following code. My 1st attempt using
> class.
>
> #!/usr/local/bin/python
> import sys
>

>       self.UserPlan = Plan
>       self.UserDomain = Domain
>       self.UserEmail = Email
>       self.UserName = Name
>
> print '1. Adding New User'
> print '2. Search New User'
> print '3. View All User'
> print '4. Exit'
> choice = input("Please choose an option: ")
>
> if choice == 1:
>     print 'Adding New User\n'
>     add = DataBase(' ', ' ', ' ', ' ')
>     add.UserPlan = raw_input("Plan: ")
>     add.UserDomain = raw_input("Domain: ")
>     add.UserEmail = raw_input("Email: ")
>     add.UserName = raw_input("Name: ")
>     print "Domain %s has registered" % add.UserDomain
>     save = raw_input("Do you wanna save? Press Y or N\nChoice: ")
>     if save == "Y":
>        print "Record Saved\n"
>        f=open('record', 'w')
>        f.write("Plan: %s\nDomain: %s\nEmail: %s\nName: %s\n-----\n" %
> (add.UserPlan,add.UserDomain
> ,add.UserEmail,add.UserName))
>     elif save == "N":
>        print "No Data Saved\n"
>     else:
>        print "Wrong input ... Bye Bye\n"
>        sys.exit()
>
> elif choice == 2:
>     print 'Search New User\n'
>
>
> elif choice == 3:
>     print 'View All User\n'
>
> elif choice == 4:
>     print 'Exit program ...'
>     sys.exit()
>
> else:
>     print 'Wrong input'
>     sys.exit()
>

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



From jaapspies@home.nl  Wed Nov  7 15:57:40 2001
From: jaapspies@home.nl (Jaap Spies)
Date: Wed, 07 Nov 2001 15:57:40 +0000
Subject: [Tutor] Daylight saving time issue
References: <6DFE6DA7C6EDD311AC17080009FE8930636492@PDC_EXCHANGE>
Message-ID: <3BE959F4.4020205@home.nl>


Titu Kim [SMTP:kimtitu@yahoo.com] wrote:



>>
>>Hi,
>>   I am trying to determine a given date is in dst or
>>not. For instance, if i have month(mm), day(dd),
>>year(yyyy) information plus the beginning (00:00:01)
>>or ending (23:59:59) of this day, i would like to
>>determine the given date/time is in daylight saving
>>time. To make the situation complecated, i also have
>>to consider the day when day light saving time occurs,
>>which is in Oct and April each year. Any suggestion is
>>very appreciated.
>>
>>Thank you very much.
>>
>>Regards,
>>
>>Kim Titu 
>>

In general your problem is very complex as Alan Gauld
pointed out. However when you are in the USA (not in Verginia!)
or in Europe, things are more easy. You need Universal Time (UT), the 
standard offset of the time zone you are in and a set of formulae
to calculate the Julian Day Number of the date in question, etc.

Astronomy to the rescue: Jean Meeus: Astronomical Algoritms, second 
edition, 1998, Willmann-Bell Inc.

I'm in the proces of providing astrometric software for the Python
community (shameless self promoting :-)):

	http://pynovas.sourceforge.net/

on that page you find a link to:

	http://astrolabe.sourceforge.net/

You should check out astrolabe/lib/python/astrolabe/calendar.py

the function is is_dst(jd) (for USA style of DST)

Good luck!

Jaap Spies



From jeff@ccvcorp.com  Wed Nov  7 17:20:58 2001
From: jeff@ccvcorp.com (Jeff Shannon)
Date: Wed, 07 Nov 2001 09:20:58 -0800
Subject: [Tutor] Re: Tutor digest, Vol 1 #1183 - 8 msgs
References: <E161KEw-0003uR-00@mail.python.org>
Message-ID: <3BE96D7A.779CBFAF@ccvcorp.com>

> Message: 5
> Date: Tue, 6 Nov 2001 17:40:53 -0800 (PST)
> From: Titu Kim <kimtitu@yahoo.com>
> To: tutor@python.org
> Subject: [Tutor] Daylight saving time issue
>
> Hi,
>    I am trying to determine a given date is in dst or
> not. For instance, if i have month(mm), day(dd),
> year(yyyy) information plus the beginning (00:00:01)
> or ending (23:59:59) of this day, i would like to
> determine the given date/time is in daylight saving
> time. To make the situation complecated, i also have
> to consider the day when day light saving time occurs,
> which is in Oct and April each year. Any suggestion is
> very appreciated.
>
> Thank you very much.

Read the docs for the time module.  If your date is  in a seconds-since-epoch format, you can use localtime() to return a
tuple, the last value of which is a flag indicating DST  (1) or regular time (0).  If your date is in month-day-year, then
check into strptime() to convert it to seconds-since-epoch, but beware that the standard time.strptime() is only available
on Unix.  There *are* more portable replacements available, though--check Parnassus or Google.  (Unfortunately I don't
remember specifically where to find this.)

Also, as someone else suggested, check into mxDateTime.  I haven't looked at it myself, but I wouldn't be surprised if it
will handle all your date-conversion and analysis needs.  :)

Jeff Shannon
Technician/Programmer
Credit International




From jeff@ccvcorp.com  Wed Nov  7 17:57:26 2001
From: jeff@ccvcorp.com (Jeff Shannon)
Date: Wed, 07 Nov 2001 09:57:26 -0800
Subject: [Tutor] Hi I need advice
References: <E161W4d-00055g-00@mail.python.org>
Message-ID: <3BE97606.CFF04F79@ccvcorp.com>

> From: "Edy Lie" <ed@iterunet.com>:
>
> Hi everyone.
>
>    I need some help/advice over the following code. My 1st attempt using
> class.

Well, someone else has already shown you the joy of default values.  However, a
bit more extensive advice...  You've got a good start, but you could use your
class much more effectively.  For one thing, when you're creating a new DataBase
instance, you can pass it data that you've already collected.  This is generally
considered cleaner than creating the instance and then stuffing data into it.
But the big advantage to having a class, is that you can add methods to it that
manipulate its data.  Since the method is *part* of the class, it already knows
how it should be used, and then the rest of your code doesn't have to care.  So,
for instance, your code for writing a DataBase() record to a file, should be
part of the DataBase class.  Try the following:

class DataBase:
    def __init__(self, plan='', domain='', email='', name=''):
        self.UserPlan = plan
        self.UserDomain = domain
        self.UserEmail = email
        self.UserName = name
    def save(self, filename='record.txt'):
        # Note that we've got a default filename, so unless
        # you specify otherwise, all records will go in this file.
        f = open(filename,'a')
        # Also note that I'm appending to the end of the file,
        # instead of replacing the file as you did originally.
        f.write("Plan: %s\nDomain: %s\nEmail: %s\nName: %s\n-----\n" %
                             (add.UserPlan, add.UserDomain,
                              add.UserEmail, add.UserName))
        f.close()   # It's a good idea to close files when you're done with them

Now, in your menu code, you can do this:

if choice == 1:
    print 'Adding New User\n'
    myplan = raw_input("Plan? ")
    mydomain = raw_input("Domain? ")
    myemail = raw_input("Email address? ")
    myname = raw_input("Name? ")
    add = DataBase(myplan, mydomain, myemail, myname)
    save = raw_input("Do you want to save?  (y/n):  ")
    save = save.lower()  # We don't care if it's caps or not
    if save == "y":
        add.save()
        print "Record saved.\n"
    elif save == "n":
        print "No data saved.\n"
    else:
        print "Wrong data--exiting.\n"
        raise SystemExit
        # Raising the SystemExit exception is almost the same as
        # calling sys.exit(), but doesn't require importing sys,
        # and leaves the option of catching the exception.

See how the DataBase object takes care of saving itself?  The whole point of
classes, is that they know how to handle all their own stuff.  Ideally, anything
that is normally done *to* the object, should be moved to become *part* of the
object.  So, we could also add a method to DataBase that will get input and fill
out its own data.  We could also add another method that would read in the file
that we've just written out, and initialize itself from that.  And so on, and so
on.  You could also create a Menu class, say, that has a dictionary of options,
and functions to call if that option is selected, to make *that* part of your
program a little cleaner.  The possibilities are endless.    :)

Hope that this gives you something to think about, and good luck!

Jeff Shannon
Technician/Programmer
Credit International




From panis@pacbell.net  Wed Nov  7 18:22:34 2001
From: panis@pacbell.net (John McChesney-Young)
Date: Wed, 07 Nov 2001 10:22:34 -0800
Subject: [Tutor] Simple Question About MacPython Interpreter
Message-ID: <l03130302b80f1fcfc238@[192.168.0.4]>

The welcome message for this list includes the statement:

>Feel free to ask even the most basic of
>questions -- that's what the list is for!

I'm going to take the list up on this offer with a humbling question;
humbling to me, that is.

I have a copy of Ivan Van Laningham's _Teach Yourself Python in 24 Hours_,
and after successfully navigating hour one, I discouragingly ran aground
partway into hour two. This will clearly show how much of a beginner I am.

I downloaded MacPython and was able to type commands into the interpreter
and have it "print" "Hello, World!" and do some basic arithmetic. However,
when I came to the section "Hello, Python!" on page 25 I came to a
stumbling block.

I followed the instructions as carefully as I could: I opened BBEdit Lite
(text editor), typed in the code specified:

print "Hello, World!"
print "Goodbye, World!"

saved the file with the name helloworld.py, double-clicked on the
interpreter to get a box of the sort I thought I needed, typed after the
prompt:

python helloworld.py

and got this error message:

>>> python helloworld.py
  File "<stdin>", line 1
    python helloworld.py
                     ^
SyntaxError: invalid syntax

Hmmm. Not good. I tried various fixes. First I wrote another file of code
in SimpleText on the off-chance that BBEdit was too rich for the
interpreter's taste. That didn't work either. I tried moving the
interpreter and the file into the same (new) folder. That didn't work. I
tried moving the files to the desktop, the hard drive, and the Python
folder in which the interpreter had been living (and to which I'd returned
it), and none of these helped.

Searching around on the Web I found a page which suggested dragging and
dropping. I tried dragging and dropping the icon for the code file onto the
menu strip icon for the interpreter. No dice.

Finally I stumbled on something that did work: I quit the interpreter and
dragged the file with the code in it onto the interpreter's icon. The
interpreter started up and ran, with a "<<terminated>>" title to the
window. I even experimented with a new file:

print 5**4

and as I had hoped would happen, it showed a window with:

625

(also with a <<terminated>> title to the window.)

Although this was gratifying, I still don't know why I can't type the
appropriate command into the box I get when I run the interpreter program
and have it do what it's supposed to. I expect that it's something
forehead-smackingly stupid that I'm either doing or not doing. Might
someone be so kind as to explain it to a Mac person whose "programming"
skills are limited to basic HTML?

Thank you very much!

John

*******
John McChesney-Young  ** panis@pacbell.net **  Berkeley, California, USA




From johnp@reportlab.com  Wed Nov  7 20:54:09 2001
From: johnp@reportlab.com (John Precedo)
Date: Wed, 7 Nov 2001 20:54:09 -0000
Subject: [Tutor] Simple Question About MacPython Interpreter
In-Reply-To: <l03130302b80f1fcfc238@[192.168.0.4]>
Message-ID: <GBEDIFFLINCAGNCJCLIFMEANCKAA.johnp@reportlab.com>

> I have a copy of Ivan Van Laningham's _Teach Yourself Python in 24
Hours_...
> I followed the instructions as carefully as I could: I opened BBEdit Lite
> (text editor), typed in the code specified:
>
> print "Hello, World!"
> print "Goodbye, World!"
>
> saved the file with the name helloworld.py, double-clicked on the
> interpreter to get a box of the sort I thought I needed, typed after the
> prompt:
>
> python helloworld.py
>
> and got this error message:
>
> >>> python helloworld.py
>   File "<stdin>", line 1
>     python helloworld.py
>                      ^
> SyntaxError: invalid syntax

What's happened here is that you are _in_ the python interpreter. So, only
valid Python code is allowed here. That's why 'print "hello world"' works,
and 'python helloworld.py' doesn't. You could type 'import helloworld',
which would load and run helloworld.py, but that not what it's usually used
for. I'm sure you'll come onto the import statement later in your studies
:o)

If you're reading a book, chances are that it's aimed at people using Python
on a PC. In the Windows world, you can open a 'DOS box' which allows you a
command line interface to the operating system. (Unix people have something
similar). The Mac doesn't have anything like this - at least not as part of
the operating system (unless you are using MacOS X, which is a different
story). But up to MacOs 9.x, it's all point and click.

So, when a non-Mac person types 'python myfile.py' into an MS-DOS box, it
tells the operating system to start python and then use that to run the
program called 'myfile.py'. On a Mac, you drag the icon for the file onto
the icon for the Python interpreter. It's just a different way of doing
things.

>Might
> someone be so kind as to explain it to a Mac person whose "programming"
> skills are limited to basic HTML?

If you're a mac person, you might want to sign up for the Mac Python mailing
list:
have a look at http://www.python.org/sigs/pythonmac-sig/ for details.

> Thank you very much!

Hope this has helped.

Regards,
John

PS This has all been from memory - my iMac is at an AASP being fixed :o(
--
John Precedo  (johnp@reportlab.com)    Developer
Reportlab Europe Ltd  (http://www.reportlab.com)



From glingl@aon.at  Wed Nov  7 22:29:26 2001
From: glingl@aon.at (Gregor Lingl)
Date: Wed, 7 Nov 2001 23:29:26 +0100
Subject: [Tutor] Pmw = ok; blt = -&)))#1&%!!
References: <E161W4d-00055g-00@mail.python.org> <3BE97606.CFF04F79@ccvcorp.com>
Message-ID: <000e01c167db$a8a81110$1664a8c0@mega>

Dear Pythonistas!

After having installed successfully Python - MageWidgets and
after having run partially successfully the  All.py - demo
I ran into a problem when trying to install blt - which is
necessary to execute some of the option sin All.py ( and which
I'm rather interested to use):

I'm running Python 2.1 in the ActiveState-flavour (including Tcl/Tkinter)
under WindowsNT 4.0

I downloaded blt2_4u-for-8_3.exe

and then tinkered around a lot of time without success,

The installer ran "successfully", but I seem not to know where to
install the things correctly (Perhaps the installer doesn't know that
I want to know them with Python´).

It installs 3 subdirectories:
    bin
    include
    lib
but not in the correct place.
It doesn't seem to modify then registry (hopefully).

So All.py complains still with:
"I'm sorry, but btl has not been installed" ... or similar

My dir-structure is:

C:\Python21\
      DLLs
      Doc
      Lib
      libs
      Pmw
      pygame
      tcl\
           tcl8.3
           tk8.3

( and more ...)


Could anybody help with hints
   - if I downloaded the correct file
   - what to enter when asked for the install-dir
   - how to get it to run

(Dirty question, I assume)

Thanks in advance
Gregor Lingl





From ed@iterunet.com  Thu Nov  8 02:23:04 2001
From: ed@iterunet.com (Edy Lie)
Date: Thu, 8 Nov 2001 10:23:04 +0800
Subject: [Tutor] Thanks
Message-ID: <LHEEKPJKJNOJPGDPPECACENOCHAA.ed@iterunet.com>

Hellow

   Thanks for the helps! I was wondering anyone use vi or vim to code in
python. It would cool if
there is a .vimrc which could do automatic indentation.

Regards,
Edy Lie



From ak@silmarill.org  Thu Nov  8 02:33:37 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Wed, 07 Nov 2001 21:33:37 -0500
Subject: [Tutor] Thanks
In-Reply-To: <LHEEKPJKJNOJPGDPPECACENOCHAA.ed@iterunet.com>
References: <LHEEKPJKJNOJPGDPPECACENOCHAA.ed@iterunet.com>
Message-ID: <20011107213337.A7419@sill.silmarill.org>

On Thu, Nov 08, 2001 at 10:23:04AM +0800, Edy Lie wrote:
> Hellow
> 
>    Thanks for the helps! I was wondering anyone use vi or vim to code in
> python. It would cool if
> there is a .vimrc which could do automatic indentation.
> 
> Regards,
> Edy Lie

I use these settings:

autocmd BufNewFile,BufRead *.py set tabstop=4 textwidth=79 expandtab
autoindent smartindent softtabstop=4 
cinw=try,if,def,except,for,while,else,elif,class,finally

(all on one line)

The only problem is that it idents after one-line definitions, like this:

if something: do_something()
<autoindent>

but that doesn't happen too often.

> 
> 
> _______________________________________________
> 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 pythonpython@hotmail.com  Thu Nov  8 04:04:34 2001
From: pythonpython@hotmail.com (HY)
Date: Thu, 8 Nov 2001 13:04:34 +0900
Subject: [Tutor] Is there a way to run Perl function in a Python program?
Message-ID: <OE129aQRppL0IHzvZf200011993@hotmail.com>

Could you please tell me//
Is there a way to run Perl function in a Python program?
Where can I get some info on this?

Thanks a million..

:)

Hy


From ed@iterunet.com  Thu Nov  8 05:35:29 2001
From: ed@iterunet.com (Edy Lie)
Date: Thu, 8 Nov 2001 13:35:29 +0800
Subject: [Tutor] Search function
Message-ID: <LHEEKPJKJNOJPGDPPECAGEOBCHAA.ed@iterunet.com>

Hi

   Is there any sample code on doing search function in python ? Scenario is
user asked to input a string and it will search thru a file and print out
the details.

Regards,
Edy Lie



From ak@silmarill.org  Thu Nov  8 05:46:38 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Thu, 08 Nov 2001 00:46:38 -0500
Subject: [Tutor] Search function
In-Reply-To: <LHEEKPJKJNOJPGDPPECAGEOBCHAA.ed@iterunet.com>
References: <LHEEKPJKJNOJPGDPPECAGEOBCHAA.ed@iterunet.com>
Message-ID: <20011108004638.A8391@sill.silmarill.org>

On Thu, Nov 08, 2001 at 01:35:29PM +0800, Edy Lie wrote:
> Hi
> 
>    Is there any sample code on doing search function in python ? Scenario is
> user asked to input a string and it will search thru a file and print out
> the details.
> 
> Regards,
> Edy Lie

Look at string.find() function.

> 
> 
> _______________________________________________
> 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 virketis@fas.harvard.edu  Thu Nov  8 05:51:38 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Thu, 08 Nov 2001 00:51:38 -0500
Subject: [Tutor] Search function
In-Reply-To: <LHEEKPJKJNOJPGDPPECAGEOBCHAA.ed@iterunet.com>
Message-ID: <200111080551.fA85p0A32196@smtp3.fas.harvard.edu>

Hi Edy,

>   Is there any sample code on doing search function in python ? Scenario is
>user asked to input a string and it will search thru a file and print out
>the details.

Here is a link (http://www.courses.fas.harvard.edu/~qr20/lectures/Mar9/) to
a class, which I took last year and which I will CA next semmester. It is
an introduction to programming, taught in Python. The notes and code
implement a few simple searches. Note that the functions assume a list of
list of the form [[name1, phone1], [name2, phone2], ...]. However, they are
easy to modify so that they accept any old list, and the string module has
great functions to put a text file into list form. This should be
straightforward to adapt. 

Cheers, 

Pijus
------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis



From toodles@yifan.net  Thu Nov  8 07:50:47 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Thu, 8 Nov 2001 15:50:47 +0800
Subject: [Tutor] Is there a way to run Perl function in a Python program?
References: <OE129aQRppL0IHzvZf200011993@hotmail.com>
Message-ID: <002301c1682a$15338e60$0300a8c0@sun>

Hi Hy,

I just searched +"perl interpreter" +"written in python" in google, and
found something:
http://conferences.oreillynet.com/cs/os2001/view/e_sess/1437
It talks about a module called "pyperl". I have never used the module, so I
hope it works well enough to do what you want... That link just has a bit of
introductory info (its information for an old conference). So you will have
to do some more hunting to actually download the module...

" 'pyperl' is an extension module that bridges the gap between Perl and
Python. It allows Python code to invoke Perl code and operate directly on
Perl data and permits Perl code to do the same to Python code and data. "

HTH,
Andrew Wilkins

----- Original Message -----
From: "HY" <pythonpython@hotmail.com>
To: <Tutor@python.org>
Sent: Thursday, November 08, 2001 12:04 PM
Subject: [Tutor] Is there a way to run Perl function in a Python program?


> Could you please tell me//
> Is there a way to run Perl function in a Python program?
> Where can I get some info on this?
>
> Thanks a million..
>
> :)
>
> Hy
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From johnp@reportlab.com  Thu Nov  8 10:49:17 2001
From: johnp@reportlab.com (John Precedo)
Date: Thu, 8 Nov 2001 10:49:17 -0000
Subject: [Tutor] Thanks
In-Reply-To: <LHEEKPJKJNOJPGDPPECACENOCHAA.ed@iterunet.com>
Message-ID: <GBEDIFFLINCAGNCJCLIFIEBCCKAA.johnp@reportlab.com>

Edy Lie asked:
> I was wondering anyone use vi or vim to code in
> python. It would cool if
> there is a .vimrc which could do automatic indentation.

If you are on a PC, you can use gvim.

According to one of the guys in my office (who is a big fan), it does syntax
colorizing and all kinds of cool stuff. You can even use Python as the macro
language (extension language?) for it. And I _think_ it does indentation as
well.

According to the 'Vi Lovers Home Page'
(http://www.thomer.com/thomer/vi/vi.html), the current version is
gvim60.zip, and available from ftp://ftp.vim.org/pub/vim/pc/gvim60.zip.

Hope this helps,
John

PS This is hearsay - I use Pythonwin for coding in myself.
--
John Precedo  (johnp@reportlab.com)    Developer
Reportlab Europe Ltd  (http://www.reportlab.com)



From babu@mail.premiertechnologygroup.com  Thu Nov  8 11:51:41 2001
From: babu@mail.premiertechnologygroup.com (babu)
Date: Thu, 8 Nov 2001 17:21:41 +0530
Subject: [Tutor] Help Pls
Message-ID: <001101c1684b$bf901010$1900a8c0@ptgdomain.com>

I need a help from you. Currently i am working with Pyhon and done some
windows programming using Tk. How can i write a program to interact with IIS
using Python.
(i.e) Creating ASP pages using Python Script.

I seached lot of site, but all will give in Unix Platform. So Please some
related links about web programming in Python

Thanking You




From toodles@yifan.net  Thu Nov  8 12:07:48 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Thu, 8 Nov 2001 20:07:48 +0800
Subject: [Tutor] Help Pls
References: <001101c1684b$bf901010$1900a8c0@ptgdomain.com>
Message-ID: <001801c1684d$fcc53e40$0300a8c0@sun>

Hi

I've never tried this, but I believe this to be relevant:
http://www.4guysfromrolla.com/webtech/082201-1.shtml
Maybe I'm wrong though. It'll only take a few minutes to find out :)
(BTW all I did was search 'ASP Python' on google...)

HTH,
Andrew

----- Original Message -----
From: "babu" <babu@mail.premiertechnologygroup.com>
To: <tutor@python.org>
Sent: Thursday, November 08, 2001 7:51 PM
Subject: [Tutor] Help Pls


> I need a help from you. Currently i am working with Pyhon and done some
> windows programming using Tk. How can i write a program to interact with
IIS
> using Python.
> (i.e) Creating ASP pages using Python Script.
>
> I seached lot of site, but all will give in Unix Platform. So Please some
> related links about web programming in Python
>
> Thanking You
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From alan.gauld@bt.com  Thu Nov  8 15:05:53 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 8 Nov 2001 15:05:53 -0000
Subject: [Tutor] Help Pls
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C096@mbtlipnt02.btlabs.bt.co.uk>

> (i.e) Creating ASP pages using Python Script.

You can use the winall library from Mark Hammond.
This conains a script that you run which registers Python as
an Active Scripting language under Windows Script Host.
What that means is you can then write ASP pages in Python 
just by doing:

<script language="python"> etc

Of course you need to do that on your Web server!

There is also PSP which is similar in concept to ASP but 
uses Python exclusively.

Finally there are various other Web style things you can do 
on IIS including Windows CGI.

Mark Hammonds Win32 Python book from O'Reilly explains the ASP stuff in more
eetail with a 

> 
> I seached lot of site, but all will give in Unix Platform. So 
> Please some
> related links about web programming in Python
> 
> Thanking You
> 
> 
> 
> 


From kimtitu@yahoo.com  Thu Nov  8 17:00:04 2001
From: kimtitu@yahoo.com (Titu Kim)
Date: Thu, 8 Nov 2001 09:00:04 -0800 (PST)
Subject: [Tutor] Re: Tutor digest, Vol 1 #1183 - 8 msgs
In-Reply-To: <3BE96D7A.779CBFAF@ccvcorp.com>
Message-ID: <20011108170004.48821.qmail@web14708.mail.yahoo.com>

--- Jeff Shannon <jeff@ccvcorp.com> wrote:
> > Message: 5
> > Date: Tue, 6 Nov 2001 17:40:53 -0800 (PST)
> > From: Titu Kim <kimtitu@yahoo.com>
> > To: tutor@python.org
> > Subject: [Tutor] Daylight saving time issue
> >
> > Hi,
> >    I am trying to determine a given date is in dst
> or
> > not. For instance, if i have month(mm), day(dd),
> > year(yyyy) information plus the beginning
> (00:00:01)
> > or ending (23:59:59) of this day, i would like to
> > determine the given date/time is in daylight
> saving
> > time. To make the situation complecated, i also
> have
> > to consider the day when day light saving time
> occurs,
> > which is in Oct and April each year. Any
> suggestion is
> > very appreciated.
> >
> > Thank you very much.
> 
> Read the docs for the time module.  If your date is 
> in a seconds-since-epoch format, you can use
> localtime() to return a
> tuple, the last value of which is a flag indicating
> DST  (1) or regular time (0).  If your date is in
> month-day-year, then
> check into strptime() to convert it to
> seconds-since-epoch, but beware that the standard
> time.strptime() is only available
> on Unix.  There *are* more portable replacements
> available, though--check Parnassus or Google. 
> (Unfortunately I don't
> remember specifically where to find this.)
> 
> Also, as someone else suggested, check into
> mxDateTime.  I haven't looked at it myself, but I
> wouldn't be surprised if it
> will handle all your date-conversion and analysis
> needs.  :)
> 
> Jeff Shannon
> Technician/Programmer
> Credit International
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

I check time module many times but i still cannot
figure out a satisfactory solution.
You suggest localtime() method to determine if the
machine is running at dst. This works
if i want to know the dst mode for now. What if i want
to determine the 2001-10-15 00:00:01 is in
dst or not programmatically? Can i find out how many
seconds evolve since epoch on this date? Then,
i want to know how many seconds evolve since epoch on
2001-11-1 00:00:01 (both in PST, EST, CST,..).
The difference between these two dates is + and - one
hour or (3600 sec). I have not figured out how to make
the decision to add or minus 3600 seconds on a given
date/time.
    If i can programmatically determine the first
Sunday 2 am in April and the last Sunday 2am in Oct
in any year, then i can compare the input date by back
track or forward track the input date
to check if it is within dst range. This is analysis
wise and i am still try to figure how to
do it programmatically. If timezones kick in, the
problem is more complex. This is my thought.

Regards,

Kim Titu

__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com


From dsh8290@rit.edu  Thu Nov  8 18:27:41 2001
From: dsh8290@rit.edu (dman)
Date: Thu, 8 Nov 2001 13:27:41 -0500
Subject: [Tutor] Thanks
In-Reply-To: <GBEDIFFLINCAGNCJCLIFIEBCCKAA.johnp@reportlab.com>; from johnp@reportlab.com on Thu, Nov 08, 2001 at 10:49:17AM +0000
References: <LHEEKPJKJNOJPGDPPECACENOCHAA.ed@iterunet.com> <GBEDIFFLINCAGNCJCLIFIEBCCKAA.johnp@reportlab.com>
Message-ID: <20011108132739.A27237@harmony.cs.rit.edu>

On Thu, Nov 08, 2001 at 10:49:17AM +0000, John Precedo wrote:
| Edy Lie asked:
| > I was wondering anyone use vi or vim to code in
| > python. It would cool if
| > there is a .vimrc which could do automatic indentation.
| 
| If you are on a PC, you can use gvim.
| 
| According to one of the guys in my office (who is a big fan), it does syntax
| colorizing and all kinds of cool stuff. You can even use Python as the macro
| language (extension language?) for it. And I _think_ it does indentation as
| well.

Yes, it does all of this.  I use (g)vim exclusively for all coding
(python and otherwise).  Version 6 is out now and has a lot of neat
new features including filetype plugins.  A piece of my vimrc looks
like :

" enable the new filetype plugins and the indent plugins
filetype on
filetype plugin on
filetype indent on

" this takes effect when the syntax file is loaded
let python_highlight_all = 1

augroup Python
    au!
    au BufNewFile *.py 0read ~/util/templates/Python.py

    " see also :help smartindent , cinwords
    au FileType python set autoindent smartindent sts=4 sw=4 tw=80 fo=croq

    " turn off the C preprocessor indenting
    " (allow comments in Python to be indented properly)
    au FileType python inoremap # X^H#

    au FileType python set foldenable foldmethod=indent
augroup END


Vim has lots of awesome features that make coding really pleasant.  If
you want more details on them (or even my entire .vimrc) just ask.

-D



From pobrien@orbtech.com  Thu Nov  8 19:18:45 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Thu, 8 Nov 2001 13:18:45 -0600
Subject: [Tutor] Thanks
In-Reply-To: <20011108132739.A27237@harmony.cs.rit.edu>
Message-ID: <NBBBIOJPGKJEKIECEMCBOEALLBAA.pobrien@orbtech.com>

I just download vim 6.0 and am determined to use it. (Giving up on Emacs -
my brain appears to be the wrong shape.) I'd love to have a good .vimrc file
to start with. That default python color scheme is too much - gives me a
headache. <grin> Thanks.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
dman
Sent: Thursday, November 08, 2001 12:28 PM
To: tutor@python.org
Subject: Re: [Tutor] Thanks

On Thu, Nov 08, 2001 at 10:49:17AM +0000, John Precedo wrote:
| Edy Lie asked:
| > I was wondering anyone use vi or vim to code in
| > python. It would cool if
| > there is a .vimrc which could do automatic indentation.
|
| If you are on a PC, you can use gvim.
|
| According to one of the guys in my office (who is a big fan), it does
syntax
| colorizing and all kinds of cool stuff. You can even use Python as the
macro
| language (extension language?) for it. And I _think_ it does indentation
as
| well.

Yes, it does all of this.  I use (g)vim exclusively for all coding
(python and otherwise).  Version 6 is out now and has a lot of neat
new features including filetype plugins.  A piece of my vimrc looks
like :

" enable the new filetype plugins and the indent plugins
filetype on
filetype plugin on
filetype indent on

" this takes effect when the syntax file is loaded
let python_highlight_all = 1

augroup Python
    au!
    au BufNewFile *.py 0read ~/util/templates/Python.py

    " see also :help smartindent , cinwords
    au FileType python set autoindent smartindent sts=4 sw=4 tw=80 fo=croq

    " turn off the C preprocessor indenting
    " (allow comments in Python to be indented properly)
    au FileType python inoremap # X^H#

    au FileType python set foldenable foldmethod=indent
augroup END


Vim has lots of awesome features that make coding really pleasant.  If
you want more details on them (or even my entire .vimrc) just ask.

-D


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



From kent@springfed.com  Fri Nov  9 19:48:42 2001
From: kent@springfed.com (Kent Tenney)
Date: Fri, 9 Nov 2001 13:48:42 -0600
Subject: [Tutor] Thanks
In-Reply-To: <GBEDIFFLINCAGNCJCLIFIEBCCKAA.johnp@reportlab.com>; from johnp@reportlab.com on Thu, Nov 08, 2001 at 10:49:17AM +0000
References: <LHEEKPJKJNOJPGDPPECACENOCHAA.ed@iterunet.com> <GBEDIFFLINCAGNCJCLIFIEBCCKAA.johnp@reportlab.com> <20011108132739.A27237@harmony.cs.rit.edu>
Message-ID: <200111081959.NAA13668@svc.millstream.net>

I would like an example .vimrc belonging to a Python programmer

BTW, where is the download?

Thanks,
Kent
-- Kent Tenney, kent@springfed.com on 11/09/2001


On Thu, 8 Nov 2001 13:27:41 -0500, dman wrote:
On Thu, Nov 08, 2001 at 10:49:17AM +0000, John Precedo wrote:
| Edy Lie asked:
| > I was wondering anyone use vi or vim to code in
| > python. It would cool if
| > there is a .vimrc which could do automatic indentation.
|
| If you are on a PC, you can use gvim.
|
| According to one of the guys in my office (who is a big fan),=
 it 
does syntax
| colorizing and all kinds of cool stuff. You can even use Python=
 as 
the macro
| language (extension language?) for it. And I _think_ it does 
indentation as
| well.

Yes, it does all of this.  I use (g)vim exclusively for all=
 coding
(python and otherwise).  Version 6 is out now and has a lot of=
 neat
new features including filetype plugins.  A piece of my vimrc=
 looks
like :

" enable the new filetype plugins and the indent plugins
filetype on
filetype plugin on
filetype indent on

" this takes effect when the syntax file is loaded
let python_highlight_all =3D 1

augroup Python
  au!
  au BufNewFile *.py 0read ~/util/templates/Python.py

  " see also :help smartindent , cinwords
  au FileType python set autoindent smartindent sts=3D4 sw=3D4 tw=3D80=
 
fo=3Dcroq

  " turn off the C preprocessor indenting
  " (allow comments in Python to be indented properly)
  au FileType python inoremap # X^H#

  au FileType python set foldenable foldmethod=3Dindent
augroup END


Vim has lots of awesome features that make coding really=
 pleasant. 
 If
you want more details on them (or even my entire .vimrc) just=
 ask.

-D


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





From virketis@fas.harvard.edu  Thu Nov  8 20:16:44 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Thu, 08 Nov 2001 15:16:44 -0500
Subject: [Tutor] remarkable features of Python
Message-ID: <200111082016.fA8KG3H06545@smtp2.fas.harvard.edu>

Hi all, 

Today Slashdot posted a long and interesting interview
(http://slashdot.org/article.pl?sid=01/11/03/1726251&mode=nested) with Kent
M. Pitman, expert on Lisp/Scheme. One of the questions compared Lisp to
Python (pretty favourably, in fact :)): "Some of the Lisp-ish features in
Python that spring right to mind are functions as objects, closures,
garbage collection, and dynamic-yet-strong typing." Can someone who has a
deeper understanding of Python briefly explain how it implements these
things (give a little example?) for those of us, who have not taken a lot
of hard-core CS.

Thanks!

Pijus

------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis



From dyoo@hkn.eecs.berkeley.edu  Thu Nov  8 20:26:53 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 8 Nov 2001 12:26:53 -0800 (PST)
Subject: [Tutor] Is there a way to run Perl function in a Python program?
In-Reply-To: <002301c1682a$15338e60$0300a8c0@sun>
Message-ID: <Pine.LNX.4.21.0111081223360.10140-100000@hkn.eecs.berkeley.edu>

On Thu, 8 Nov 2001, Andrew Wilkins wrote:

> Hi Hy,
> 
> I just searched +"perl interpreter" +"written in python" in google, and
> found something:
> http://conferences.oreillynet.com/cs/os2001/view/e_sess/1437
> It talks about a module called "pyperl". I have never used the module, so I
> hope it works well enough to do what you want... That link just has a bit of
> introductory info (its information for an old conference). So you will have
> to do some more hunting to actually download the module...
> 
> " 'pyperl' is an extension module that bridges the gap between Perl and
> Python. It allows Python code to invoke Perl code and operate directly on
> Perl data and permits Perl code to do the same to Python code and data. "


Here you go:

    http://downloads.activestate.com/Zope-Perl/



From aschmidt@nv.cc.va.us  Thu Nov  8 23:04:57 2001
From: aschmidt@nv.cc.va.us (Schmidt, Allen J.)
Date: Thu, 8 Nov 2001 18:04:57 -0500
Subject: [Tutor] How long can a line be for readline() or readlines()  ??
Message-ID: <5CDFEBB60E7FD311B9E30000F6D6090608CB8DE8@novamail2.nv.cc.va.us>

Is there a limit to the length of an individual line when using readlines()
or readline() ?

I get errors when a line exceeds 2048 characters.

Thanks

Allen


From ak@silmarill.org  Thu Nov  8 23:41:00 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Thu, 08 Nov 2001 18:41:00 -0500
Subject: [Tutor] How long can a line be for readline() or readlines()  ??
In-Reply-To: <5CDFEBB60E7FD311B9E30000F6D6090608CB8DE8@novamail2.nv.cc.va.us>
References: <5CDFEBB60E7FD311B9E30000F6D6090608CB8DE8@novamail2.nv.cc.va.us>
Message-ID: <20011108184100.A13707@sill.silmarill.org>

On Thu, Nov 08, 2001 at 06:04:57PM -0500, Schmidt, Allen J. wrote:
> Is there a limit to the length of an individual line when using readlines()
> or readline() ?
> 
> I get errors when a line exceeds 2048 characters.

Hm, I just tried it, I don't get any errors. I tried a line of 3000
characters:

...
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n'
>>> len(a)
3001

I used readline() to read it in, with Python 2.1.1.

> 
> Thanks
> 
> Allen
> 
> _______________________________________________
> 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 dyoo@hkn.eecs.berkeley.edu  Fri Nov  9 01:51:50 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 8 Nov 2001 17:51:50 -0800 (PST)
Subject: [Tutor] How long can a line be for readline() or readlines()
 ??
In-Reply-To: <5CDFEBB60E7FD311B9E30000F6D6090608CB8DE8@novamail2.nv.cc.va.us>
Message-ID: <Pine.LNX.4.21.0111081712130.18198-100000@hkn.eecs.berkeley.edu>

On Thu, 8 Nov 2001, Schmidt, Allen J. wrote:

> Is there a limit to the length of an individual line when using
> readlines() or readline() ?
> 
> I get errors when a line exceeds 2048 characters.

Hmm!  There should be no hard limit to how long a line should be!  That's
one of the reasons why Python is good for text manipulation: it can handle
these files without any handholding from us.

Can you show us the error message, as well as a sample file that triggers
the error?  Thanks!



From dsh8290@rit.edu  Fri Nov  9 01:56:20 2001
From: dsh8290@rit.edu (dman)
Date: Thu, 8 Nov 2001 20:56:20 -0500
Subject: [Tutor] remarkable features of Python
In-Reply-To: <200111082016.fA8KG3H06545@smtp2.fas.harvard.edu>; from virketis@fas.harvard.edu on Thu, Nov 08, 2001 at 03:16:44PM -0500
References: <200111082016.fA8KG3H06545@smtp2.fas.harvard.edu>
Message-ID: <20011108205620.A29633@harmony.cs.rit.edu>

On Thu, Nov 08, 2001 at 03:16:44PM -0500, Pijus Virketis wrote:
| Hi all, 
| 
| Today Slashdot posted a long and interesting interview
| (http://slashdot.org/article.pl?sid=01/11/03/1726251&mode=nested) with Kent
| M. Pitman, expert on Lisp/Scheme. One of the questions compared Lisp to
| Python (pretty favourably, in fact :)): "Some of the Lisp-ish features in
| Python that spring right to mind are functions as objects, closures,
| garbage collection, and dynamic-yet-strong typing." Can someone who has a
| deeper understanding of Python briefly explain how it implements these
| things (give a little example?) for those of us, who have not taken a lot
| of hard-core CS.


Functions (and classes and modules) are objects.  They behave the same
as any other python object.

# here is a function being defined
def foo() : pass

print foo
a = foo
print a
print a is foo
print a == foo

def demo( obj ) :
    print obj
    print obj is a
    print obj is foo

demo( foo )
demo( a )


These statements attempt to show that the function object can be
bound to another name (assignment), passed as an argument to another
function, and compared with other objects.  In C/C++ a function is
basically a chunk of memory that contains executable code that can be
jumped too.  They allow taking the address of that memory and passing
it around as a pointer, but it is not as simple as in python.  Java
doesn't allow directly referencing a method (kinda, through reflection
but it is ugly), but instead has the inner-class hack to work around
it.



Garbage collection :

Have you ever used C or C++?  In C and C++ you (the programmer) needs
to explicitly request memory from the system in order to use it.  When
you are done you need to give it back to the system so that someone
else can use it.  (malloc/free and new/delete respectively)  If you
don't you have what is called a "memory leak".  Python (and Lisp and
Java) do this memory allocating and freeing for you.  When you create
an object you allocate memory.  When you no longer refer to it, the
system realizes it and returns the memory to the system.


Dynamic-yet-Strong typing :

You don't declare the type of a python object.  In Java you would
write, ex,

class Foo
{
    public int a_func( String s , float f )
    {
        int result = 0 ;
        System.out.println( s ) ;
        return result ;
    }
}


Notice how I needed to specify the type (int) returned by the method,
the arguments (String, float) taken by the method and the local
variable (int).  In python that would be written as

class Foo :
    def a_func( s , f ) :
        result = 0
        print s
        return result

There are no static (written by you, read by the compiler) type
declarations.

Now suppose I try to do something that would not be type-safe :

obj = "abcd" # a string, obviously
print obj.readline() # maybe want it to be a file

In python this fails because the string object has no readline()
method.  In Java this would be a compile-time error due to the static
typing.  In C/C++ you would have to "cast" (fake conversion) the
object first, but when it ran it would do really weird things and
hopefully crash.  C/C++ are not typesafe because they let you do
operations on objects that are not valid.

Perl and Sh also have dynamic typing but their typing is weak.  In
python, try this :

print "123" + 4
print 4 + "123"

Try it in perl

print "123" + 4 ;
print 4 + "123" ;
print "123" . 4 ;
print 4 . "123" ;

In python you will get a TypeError -- adding strings and numbers
doesn't make sense.  In perl, the interpreter magically converts
between the number and the string and gives you either the
concatenation ("1234") or the sum (127).  I don't remember which is
does, but I think it is related to the exact "addition" operator used.



I don't know too much about closures, other than they are the state of
a function at a given time.  Having closures allows concurrent things
like coroutines.  (See, for example, Stackless Python)


HTH,
-D



From james_fjm@yahoo.com  Fri Nov  9 02:36:45 2001
From: james_fjm@yahoo.com (=?iso-8859-1?q?James=20Foo?=)
Date: Fri, 9 Nov 2001 02:36:45 +0000 (GMT)
Subject: [Tutor] How to find out what procedures/functions are imported?
Message-ID: <20011109023645.60235.qmail@web9601.mail.yahoo.com>

--0-1658653723-1005273405=:59599
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit


Hi there,

I am hoping to know how do we find out what procedures/functions that we have imported in a session.

Thanks.

James


Have a heart for them, visit http://www.geocities.com/james_fjm/charity.htm


---------------------------------
Do You Yahoo!?
Get personalised at My Yahoo!.
--0-1658653723-1005273405=:59599
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

<P>Hi there,</P>
<P>I am hoping to know how do we find out what procedures/functions that we have imported in a session.</P>
<P>Thanks.</P>
<P>James</P><BR><BR>Have a heart for them, visit http://www.geocities.com/james_fjm/charity.htm<p><br><hr size=1><b>Do You Yahoo!?</b><br>
Get personalised at <a
href="http://uk.rd.yahoo.com/mail_uk/my?http://uk.my.yahoo.com" target="_blank">My Yahoo!</a>.
--0-1658653723-1005273405=:59599--


From dsh8290@rit.edu  Fri Nov  9 02:49:05 2001
From: dsh8290@rit.edu (dman)
Date: Thu, 8 Nov 2001 21:49:05 -0500
Subject: [Tutor] How to find out what procedures/functions are imported?
In-Reply-To: <20011109023645.60235.qmail@web9601.mail.yahoo.com>; from james_fjm@yahoo.com on Fri, Nov 09, 2001 at 02:36:45AM +0000
References: <20011109023645.60235.qmail@web9601.mail.yahoo.com>
Message-ID: <20011108214905.A29810@harmony.cs.rit.edu>

On Fri, Nov 09, 2001 at 02:36:45AM +0000, James Foo wrote:
| 
| Hi there,
| 
| I am hoping to know how do we find out what procedures/functions that we have imported in a session.

print dir()

-D



From dyoo@hkn.eecs.berkeley.edu  Fri Nov  9 07:34:23 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 8 Nov 2001 23:34:23 -0800 (PST)
Subject: [Tutor] remarkable features of Python  [types and a language
 comparison]
In-Reply-To: <20011108205620.A29633@harmony.cs.rit.edu>
Message-ID: <Pine.LNX.4.21.0111082235130.25511-100000@hkn.eecs.berkeley.edu>

> Perl and Sh also have dynamic typing but their typing is weak.  In
> python, try this :
> 
> print "123" + 4
> print 4 + "123"
> 
> Try it in perl
> 
> print "123" + 4 ;
> print 4 + "123" ;
> print "123" . 4 ;
> print 4 . "123" ;



[Note: this is something of a Perl language post --- please avert your
eyes if you're sensitive to this.  *grin*]


Perl's design deliberately blends strings and numbers into a concept known
as a "scalar".  Because of this blending, the language does end up having
a lot of operators.

For example, in Perl, '.' is the "concatenation" operator used to join two
strings together, and 'x' is the "multiplication" operator used to
multiply a string against a number.  As one would expect from this design,
Perl also has a set of separate comparision operators: 'lt', 'gt', and
'eq', specifically for strings.



Python, on the other hand, pushes more information on the "type" of a
value --- it figures out what we mean by "type" of the arguments.  For
example, here are three uses of the concept of "multiplication" on
different types of things:

###
## Python ##
>>> "3" * 3
'333'
>>> 3 * 3
9
>>> (3,) * 3
(3, 3, 3)
###

Python has fewer operators, but does place more emphasis on knowing about
the idea of a values's "type".  This "type" idea is something that
beginning Python programmers sometimes get stuck on, so it too has a
tradeoff.


I'm trying to figure out a way of sounding impartial about all of this,
but I must admit I'm very very biased.  *grin* I like Python's approach
better because Python's design "feels" more uniform: taking a "slice" of a
list and taking a "slice" of a string look the same in Python:

###
## Python ##
shopping_list = ['toothpaste', 'deodorant', 'mouthwash']
print shopping_list[1:]
name = 'hal'
print name[1:]
###


but "slicing" involves different operations in Perl:

###
## Perl ##
my @shopping_list = ('toothpaste', 'deodorant', 'mouthwash');
print @shopping_list[1..$#shopping_list]), "\n";
my $name = "hal";
print substr($name, 1), "\n";
###


(Note: the Perl code is not quite equivalent to the Python version, since
Perl does not define how to print arrays.  Using something like:

    print '(', join(', ', @shopping_list[1..$#shopping_list]), ')\n';

would make the outputs match more closely, but would really obscure
similarities between the code.)



Hope this helps!



From perumal@mail.premiertechnologygroup.com  Fri Nov  9 09:15:30 2001
From: perumal@mail.premiertechnologygroup.com (AlaguShenbagaPerumal)
Date: Fri, 9 Nov 2001 14:45:30 +0530
Subject: [Tutor] database connectivity from python scripting ???
Message-ID: <000a01c168ff$17d10cd0$1e00a8c0@ptgdomain.com>

This is a multi-part message in MIME format.

------=_NextPart_000_0007_01C1692D.2D98FBD0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

hi,
   i don't know how to connect python scripting written inside ASP for =
IIS webserver to database and retrieve data from the database. i tried =
for "odbc" module but it gives error.  please help me with some sample =
codes.
   what are the modules, we can use for  scripting in python.

regards.
bas

------=_NextPart_000_0007_01C1692D.2D98FBD0
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#ffffff>
<DIV><FONT face=3DCourier size=3D2>hi,</FONT></DIV>
<DIV><FONT face=3DCourier size=3D2>&nbsp;&nbsp; i don't know how to =
connect python=20
scripting written inside ASP for IIS webserver to database and retrieve =
data=20
from the database. i tried for "odbc" module but it gives error.&nbsp; =
please=20
help me with some sample codes.</FONT></DIV>
<DIV><FONT face=3DCourier size=3D2>&nbsp;&nbsp; what are the modules, we =
can use=20
for&nbsp; scripting in python.</FONT></DIV>
<DIV><FONT face=3DCourier size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DCourier size=3D2>regards.</FONT></DIV>
<DIV><FONT face=3DCourier size=3D2>bas</FONT></DIV></BODY></HTML>

------=_NextPart_000_0007_01C1692D.2D98FBD0--



From aschmidt@nv.cc.va.us  Fri Nov  9 16:09:59 2001
From: aschmidt@nv.cc.va.us (Schmidt, Allen J.)
Date: Fri, 9 Nov 2001 11:09:59 -0500
Subject: [Tutor] How long can a line be for readline() or readlines()
 ?? ((LONG)) file, example and console
Message-ID: <5CDFEBB60E7FD311B9E30000F6D6090608CB8DED@novamail2.nv.cc.va.us>

importClassifieds.py

------
import MySQLdb
import string
import re
import time
import fileinput
import os

def doit(dir,ext1,ext2):
   """Rename files in "dir" with extension "ext1" to extension "ext2"."""

   print "Directory",dir
   print "Ext1", ext1
   print "Ext2", ext2
   files = os.listdir(dir)
   files.sort()

   for file in files:
      root,ext = os.path.splitext(file)

      if ext == ext1:
         oldfile = os.path.join(dir,file)
         newfile = os.path.join(dir,root+ext2)
         print "Renaming %s to %s"%(oldfile,newfile)
   
         if os.path.exists(os.path.join(dir,newfile)):
            print "*** Unable to rename %s to %s (already
exists"%(oldfile,newfile)
         else:
            try:
               os.rename(oldfile,newfile)
               print "Rename worked for file: ",newfile
            except:
               print "*** Unable to rename %s"%oldfile

def main():
   """ main """
   print "starting...."
   curtime=time.localtime(time.time())
   fmt='%Y%m%d_%H:%M'
   ourtimestamp=time.strftime(fmt,curtime)
   starttime=time.strftime(fmt,curtime)
   
   replaceApos=re.compile('\'', re.IGNORECASE|re.DOTALL)
   replaceComma=re.compile(',', re.IGNORECASE|re.DOTALL)
   replacePeriod=re.compile('\.', re.IGNORECASE|re.DOTALL)
   
   files = os.listdir("F:\\classifieds\\current\\")
   
   dbc = MySQLdb.connect(host="127.0.0.1", db="Classifieds")  # here's where
we hook up to the database and get a cursor
   crsr = dbc.cursor() 
   for file in files:
     if file[-3:]=='txt':
       filein = open("F:\\classifieds\\current\\"+file,"r")
       dash = file.index('-')
       dot = file.index('.')
       date = file[:dash]
       day = file[dash+1:dot]
       print "Processing: ",file
       for linein in filein.readlines():
         lineout = replaceApos.sub('\'\'', linein)
         lineout=string.split(lineout,'|')
         sql="insert into current (adnum, logo, rundate, runday, status,
adtext, category) values
('"+lineout[1]+"','"+lineout[2]+"','"+date+"','"+day+"','ENABLED','"+lineout
[3]+"','"+lineout[4]+"')"
         crsr.execute(sql)
       filein.close()
   doit('F:\\classifieds\\current\\','.txt','.ARCHIVE')
     

if __name__ == "__main__":
    main()

-----------------------
END of importClassifieds.py

START of one line of the file
------------------------

|00822chp||<A
HREF="http://www.harvestadsdepot.com/fredricksbrg/outgoing/00822chp.gif">Cli
ck here to see the display ad!</A><BR>SPOTSYLVANIA COUNTY<BR><BR>Find a
Great Job Close to Home<BR><BR>WHERE SERVICE, INTEGRITY & PRIDE ARE
VALUED<BR><BR>COUNTY OF SPOTSYLVANIA * VIRGINIA<BR><BR>PATIOR UT
POTIAR<BR><BR>Spotsylvania has become one of the fastest growing communities
in Virginia and is continually seeking highly motivated, self-starting
applicants. Persons seeking employment opportunities, position details,
qualifications and/or special requirements may access Job Information (24
hours, 7 days a week) by dialing 540/582-7192, Press #2. Selections may be
made from one of three menus: #1: Job Information Line; #2: Request a Job
Application; #3: Human Resources Staff Assistance. You may also obtain the
same information along with a County application by visiting our website: <A
HREF="http://www.spotsylvania.va.us/gov/hr/jobs.htm">www.spotsylvania.va.us/
gov/hr/jobs.htm</A><BR><BR>Parks & Recreation:<BR><BR>Facility Attendant
(Part Time)...$7.00/hr.--$9.33/hr.--December 1, 2001<BR><BR>Senior/Teen
Center Attendant (Part Time)...$7.65/hr.--$11.48/hr.--November 16,
2001<BR><BR>General Services:<BR><BR>Solid Waste Equip. Op./Refuse Truck
Driver (Part Time)...$11.42/hr.--$14.28/hr.--November 9, 2001<BR><BR>Solid
Waste Equip. Op. Composting (Full Time)...$11.42/hr.--$14.28/hr.--November
9, 2001<BR><BR>Maintenance Worker/Custodial (Part
Time)...$8.78/hr.--$11.19/hr.--November 16, 2001<BR><BR>Maintenance
Technician (Full Time)...$10.88/hr.--$13.61/hr.--November 9,
2001<BR><BR>Clerk Typist (Part Time)...$8.53/hr.--$10.66/hr.--November 16,
2001<BR><BR>Utilities:<BR><BR>Utility Field Crew Worker/Op. (Full
Time)...$11.08/hr.--$13.85/hr.--November 16, 2001<BR><BR>Human
Resources:<BR><BR>Secretary (Part Time)...$9.87/hr.--$10.29/hr.--November
16, 2001<BR><BR>Benefits for full-time positions include fully paid health
insurance, paid retirement, including LEOS (Law Enforcement and Firefighter
uniformed personnel), 12 1/2 paid holidays, accrual of annual and sick
leave, and a variety of voluntary retirement and disability programs.
Regular part-time positions are eligible to receive prorated annual and sick
leave benefits.<BR><BR>A County application is required for each advertised
position.<BR><BR>For personal assistance, please contact 540/582-7018, ext.
674<BR><BR>Monday--Friday, 8:00 a.m.--4:30 p.m. * TTP
540/582-7178<BR><BR>Minorities are encouraged to
apply.<BR><BR>E.O.E/ADA<BR><BR><A
HREF="http://www.harvestadsdepot.com/fredricksbrg/outgoing/00822chp.gif">Cli
ck here to see the display ad!</A>|051|RM|
--------------
End of line of file

Start of console messages...
----------------

starting....
Processing:  20011101-HAR.txt
Traceback (most recent call last):
  File "importClassifieds.py", line 68, in ?
    main()
  File "importClassifieds.py", line 61, in main
    sql="insert into current (adnum, logo, rundate, runday, status, adtext,
category) values
('"+lineout[1]+"','"+lineout[2]+"','"+date+"','"+day+"','ENABLED','"+lineout
[3]+"','"+lineout[4]+"')"
IndexError: list index out of range

---------------
End of console messages



Does this help??? It's obvious I am a PyNewbian...I borrowed some of the
code I found on the web (probably someone from this list) and some from
examples I already had from DB methods that work.

Thanks 

Allen

-----Original Message-----
From: Danny Yoo [mailto:dyoo@hkn.eecs.berkeley.edu]
Sent: Thursday, November 08, 2001 8:52 PM
To: Schmidt, Allen J.
Cc: tutor@python.org
Subject: Re: [Tutor] How long can a line be for readline() or
readlines() ??


On Thu, 8 Nov 2001, Schmidt, Allen J. wrote:

> Is there a limit to the length of an individual line when using
> readlines() or readline() ?
> 
> I get errors when a line exceeds 2048 characters.

Hmm!  There should be no hard limit to how long a line should be!  That's
one of the reasons why Python is good for text manipulation: it can handle
these files without any handholding from us.

Can you show us the error message, as well as a sample file that triggers
the error?  Thanks!


From lkvam@venix.com  Fri Nov  9 16:56:32 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Fri, 09 Nov 2001 11:56:32 -0500
Subject: [Tutor] How long can a line be for readline() or readlines() 	 ?? ((LONG)) file, example and console
References: <5CDFEBB60E7FD311B9E30000F6D6090608CB8DED@novamail2.nv.cc.va.us>
Message-ID: <3BEC0AC0.9080201@venix.com>

THIS is your problem area:

  lineout=string.split(lineout,'|')
          sql="insert into current (adnum, logo, rundate, runday, status,
adtext, category) values
('"+lineout[1]+"','"+lineout[2]+"','"+date+"','"+day+"','ENABLED','"+lineout
[3]+"','"+lineout[4]+"')"

lineout becomes a list of lines that is made up of those pieces between 
the |s of the orinal lineout.  The sql statement requires that the 
lineout list contain at least 5 lines.  Thus there needs to be at least 
4 |s in the original lineout.


Schmidt, Allen J. wrote:

> importClassifieds.py
> 
> ------
> import MySQLdb
> import string
> import re
> import time
> import fileinput
> import os
> 
> def doit(dir,ext1,ext2):
>    """Rename files in "dir" with extension "ext1" to extension "ext2"."""
> 
>    print "Directory",dir
>    print "Ext1", ext1
>    print "Ext2", ext2
>    files = os.listdir(dir)
>    files.sort()
> 
>    for file in files:
>       root,ext = os.path.splitext(file)
> 
>       if ext == ext1:
>          oldfile = os.path.join(dir,file)
>          newfile = os.path.join(dir,root+ext2)
>          print "Renaming %s to %s"%(oldfile,newfile)
>    
>          if os.path.exists(os.path.join(dir,newfile)):
>             print "*** Unable to rename %s to %s (already
> exists"%(oldfile,newfile)
>          else:
>             try:
>                os.rename(oldfile,newfile)
>                print "Rename worked for file: ",newfile
>             except:
>                print "*** Unable to rename %s"%oldfile
> 
> def main():
>    """ main """
>    print "starting...."
>    curtime=time.localtime(time.time())
>    fmt='%Y%m%d_%H:%M'
>    ourtimestamp=time.strftime(fmt,curtime)
>    starttime=time.strftime(fmt,curtime)
>    
>    replaceApos=re.compile('\'', re.IGNORECASE|re.DOTALL)
>    replaceComma=re.compile(',', re.IGNORECASE|re.DOTALL)
>    replacePeriod=re.compile('\.', re.IGNORECASE|re.DOTALL)
>    
>    files = os.listdir("F:\\classifieds\\current\\")
>    
>    dbc = MySQLdb.connect(host="127.0.0.1", db="Classifieds")  # here's where
> we hook up to the database and get a cursor
>    crsr = dbc.cursor() 
>    for file in files:
>      if file[-3:]=='txt':
>        filein = open("F:\\classifieds\\current\\"+file,"r")
>        dash = file.index('-')
>        dot = file.index('.')
>        date = file[:dash]
>        day = file[dash+1:dot]
>        print "Processing: ",file
>        for linein in filein.readlines():
>          lineout = replaceApos.sub('\'\'', linein)
>          lineout=string.split(lineout,'|')
>          sql="insert into current (adnum, logo, rundate, runday, status,
> adtext, category) values
> ('"+lineout[1]+"','"+lineout[2]+"','"+date+"','"+day+"','ENABLED','"+lineout
> [3]+"','"+lineout[4]+"')"
>          crsr.execute(sql)
>        filein.close()
>    doit('F:\\classifieds\\current\\','.txt','.ARCHIVE')
>      
> 
> if __name__ == "__main__":
>     main()
> 
> -----------------------
> END of importClassifieds.py
> 
> START of one line of the file
> ------------------------
> 
> |00822chp||<A
> HREF="http://www.harvestadsdepot.com/fredricksbrg/outgoing/00822chp.gif">Cli
> ck here to see the display ad!</A><BR>SPOTSYLVANIA COUNTY<BR><BR>Find a
> Great Job Close to Home<BR><BR>WHERE SERVICE, INTEGRITY & PRIDE ARE
> VALUED<BR><BR>COUNTY OF SPOTSYLVANIA * VIRGINIA<BR><BR>PATIOR UT
> POTIAR<BR><BR>Spotsylvania has become one of the fastest growing communities
> in Virginia and is continually seeking highly motivated, self-starting
> applicants. Persons seeking employment opportunities, position details,
> qualifications and/or special requirements may access Job Information (24
> hours, 7 days a week) by dialing 540/582-7192, Press #2. Selections may be
> made from one of three menus: #1: Job Information Line; #2: Request a Job
> Application; #3: Human Resources Staff Assistance. You may also obtain the
> same information along with a County application by visiting our website: <A
> HREF="http://www.spotsylvania.va.us/gov/hr/jobs.htm">www.spotsylvania.va.us/
> gov/hr/jobs.htm</A><BR><BR>Parks & Recreation:<BR><BR>Facility Attendant
> (Part Time)...$7.00/hr.--$9.33/hr.--December 1, 2001<BR><BR>Senior/Teen
> Center Attendant (Part Time)...$7.65/hr.--$11.48/hr.--November 16,
> 2001<BR><BR>General Services:<BR><BR>Solid Waste Equip. Op./Refuse Truck
> Driver (Part Time)...$11.42/hr.--$14.28/hr.--November 9, 2001<BR><BR>Solid
> Waste Equip. Op. Composting (Full Time)...$11.42/hr.--$14.28/hr.--November
> 9, 2001<BR><BR>Maintenance Worker/Custodial (Part
> Time)...$8.78/hr.--$11.19/hr.--November 16, 2001<BR><BR>Maintenance
> Technician (Full Time)...$10.88/hr.--$13.61/hr.--November 9,
> 2001<BR><BR>Clerk Typist (Part Time)...$8.53/hr.--$10.66/hr.--November 16,
> 2001<BR><BR>Utilities:<BR><BR>Utility Field Crew Worker/Op. (Full
> Time)...$11.08/hr.--$13.85/hr.--November 16, 2001<BR><BR>Human
> Resources:<BR><BR>Secretary (Part Time)...$9.87/hr.--$10.29/hr.--November
> 16, 2001<BR><BR>Benefits for full-time positions include fully paid health
> insurance, paid retirement, including LEOS (Law Enforcement and Firefighter
> uniformed personnel), 12 1/2 paid holidays, accrual of annual and sick
> leave, and a variety of voluntary retirement and disability programs.
> Regular part-time positions are eligible to receive prorated annual and sick
> leave benefits.<BR><BR>A County application is required for each advertised
> position.<BR><BR>For personal assistance, please contact 540/582-7018, ext.
> 674<BR><BR>Monday--Friday, 8:00 a.m.--4:30 p.m. * TTP
> 540/582-7178<BR><BR>Minorities are encouraged to
> apply.<BR><BR>E.O.E/ADA<BR><BR><A
> HREF="http://www.harvestadsdepot.com/fredricksbrg/outgoing/00822chp.gif">Cli
> ck here to see the display ad!</A>|051|RM|
> --------------
> End of line of file
> 
> Start of console messages...
> ----------------
> 
> starting....
> Processing:  20011101-HAR.txt
> Traceback (most recent call last):
>   File "importClassifieds.py", line 68, in ?
>     main()
>   File "importClassifieds.py", line 61, in main
>     sql="insert into current (adnum, logo, rundate, runday, status, adtext,
> category) values
> ('"+lineout[1]+"','"+lineout[2]+"','"+date+"','"+day+"','ENABLED','"+lineout
> [3]+"','"+lineout[4]+"')"
> IndexError: list index out of range
> 
> ---------------
> End of console messages
> 
> 
> 
> Does this help??? It's obvious I am a PyNewbian...I borrowed some of the
> code I found on the web (probably someone from this list) and some from
> examples I already had from DB methods that work.
> 
> Thanks 
> 
> Allen
> 
> -----Original Message-----
> From: Danny Yoo [mailto:dyoo@hkn.eecs.berkeley.edu]
> Sent: Thursday, November 08, 2001 8:52 PM
> To: Schmidt, Allen J.
> Cc: tutor@python.org
> Subject: Re: [Tutor] How long can a line be for readline() or
> readlines() ??
> 
> 
> On Thu, 8 Nov 2001, Schmidt, Allen J. wrote:
> 
> 
>>Is there a limit to the length of an individual line when using
>>readlines() or readline() ?
>>
>>I get errors when a line exceeds 2048 characters.
>>
> 
> Hmm!  There should be no hard limit to how long a line should be!  That's
> one of the reasons why Python is good for text manipulation: it can handle
> these files without any handholding from us.
> 
> Can you show us the error message, as well as a sample file that triggers
> the error?  Thanks!
> 
> _______________________________________________
> 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 aschmidt@nv.cc.va.us  Fri Nov  9 17:28:42 2001
From: aschmidt@nv.cc.va.us (Schmidt, Allen J.)
Date: Fri, 9 Nov 2001 12:28:42 -0500
Subject: [Tutor] How long can a line be for readline() or readlines()
 ?? ((LONG)) file, example and console
Message-ID: <5CDFEBB60E7FD311B9E30000F6D6090608CB8DEF@novamail2.nv.cc.va.us>

Each line has actually 6 pipes:
|adnum|logo|adtext|catnum|RM|

The RM on the end is a holdover from when the text was processed a different
way.

Lines under 2k go in without a hitch. The line I sent is one over the 2k
limit.

-----Original Message-----
From: Lloyd Kvam [mailto:lkvam@venix.com]

THIS is your problem area:

  lineout=string.split(lineout,'|')
          sql="insert into current (adnum, logo, rundate, runday, status,
adtext, category) values
('"+lineout[1]+"','"+lineout[2]+"','"+date+"','"+day+"','ENABLED','"+lineout
[3]+"','"+lineout[4]+"')"

lineout becomes a list of lines that is made up of those pieces between 
the |s of the orinal lineout.  The sql statement requires that the 
lineout list contain at least 5 lines.  Thus there needs to be at least 
4 |s in the original lineout.



From ed@iterunet.com  Fri Nov  9 17:33:18 2001
From: ed@iterunet.com (Edy Lie)
Date: Sat, 10 Nov 2001 01:33:18 +0800
Subject: [Tutor] A quick question
Message-ID: <001501c16944$b9035320$0300a8c0@vodka>

This is a multi-part message in MIME format.

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

Hi everyone

   I was thinking to change the following codes to python but aint sure =
how should i approach it.

Btw these are the codes

  open (SEARCH, "$file") or die switch();
   while ($line =3D <SEARCH>) {
      if ($line =3D~ /$domain/i) {
         print "Found ... \n\n";
         for ($x=3D0; $x<5; $x++){
            $line =3D <SEARCH>;
            print $line;
            }
        }
}


I have declared the=20

def search(self, filename=3D'record.txt'):
        f =3D open(filename,'r')
        f.readlines()
        f.close()

and my search part is like=20

print 'Searching New User\n'
   UserInput =3D raw_input("Search for text: ")
   SearchInput =3D string.split(UserInput) #create a list of tokens by =
spliting the search-string at each space (" ")
   ReString =3D string.join(SearchInput, "\n+")
   add =3D DataBase()


Thanks :)
Regards,
Edy Lie

------=_NextPart_000_0010_01C16987.ACB09680
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.4807.2300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi everyone</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;&nbsp; I was thinking to change =
the following=20
codes to python but aint sure how should i approach it.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Btw these are the codes</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp; open (SEARCH, "$file") or die=20
switch();<BR>&nbsp;&nbsp; while ($line =3D &lt;SEARCH&gt;)=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($line =3D~ /$domain/i)=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print "Found ...=20
\n\n";<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for ($x=3D0; =
$x&lt;5;=20
$x++){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;=20
$line =3D=20
&lt;SEARCH&gt;;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;=20
print=20
$line;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;=20
}</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>}</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have declared the </FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>def search(self,=20
filename=3D'record.txt'):<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
f =3D=20
open(filename,'r')<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
f.readlines()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
f.close()<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2>and my search part is like =
</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>print 'Searching New =
User\n'<BR>&nbsp;&nbsp;=20
UserInput =3D raw_input("Search for text: ")<BR>&nbsp;&nbsp; SearchInput =
=3D=20
string.split(UserInput) #create a list of tokens by spliting the =
search-string=20
at each space (" ")<BR>&nbsp;&nbsp; ReString =3D =
string.join(SearchInput,=20
"\n+")<BR>&nbsp;&nbsp; add =3D DataBase()<BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks :)</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Regards,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Edy Lie</DIV></FONT></BODY></HTML>

------=_NextPart_000_0010_01C16987.ACB09680--



From newsletters@the-financial-news.org  Fri Nov  9 17:26:58 2001
From: newsletters@the-financial-news.org (The Financial News)
Date: Fri, 9 Nov 2001 18:26:58 +0100
Subject: [Tutor] Production Mini-plants in mobile containers
Message-ID: <MDAEMON-F200111091830.AA300949md50007712940@wtnserver>

This is a multi-part message in MIME format

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


The Financial News, November 2001

Production Mini-plants in mobile containers

=22...Science Network will supply to countries and developing regions the technology and the necessary support for the production in series of Mini-plants in mobile=20containers (40-foot). The Mini-plant system is designed in such a way that all the production machinery is fixed on the platform of the container, with all wiring,=20piping, and installation parts; that is to say, they are fully equipped... and the mini-plant is ready for production.=22

More than 700 portable production systems: Bakeries, Steel Nails, Welding Electrodes, Tire Retreading, Reinforcement Bar Bending for Construction Framework,=20Sheeting for Roofing, Ceilings and Fa=E7ades, Plated Drums, Aluminum Buckets, Injected Polypropylene Housewares, Pressed Melamine Items (Glasses, Cups,=20Plates, Mugs, etc.), Mufflers, Construction Electrically Welded Mesh, Plastic Bags and Packaging, Mobile units of medical assistance, Sanitary Material,=20Hypodermic Syringes, Hemostatic Clamps, etc.=20
For more information: <A HREF=3D=22mailto:reports=40the-financial-news.org=22>Mini-plants in mobile containers</A>

By Steven P. Leibacher, The Financial News, Editor

-------------------------------------------------------------------------
If you received this in error or would like to be removed from our list, please return us indicating: remove or un-subscribe in 'subject' field, Thanks. <A=20HREF=3D=22mailto:newsletters=40the-financial-news.org=22> Editor</A>
=A9 2001 The Financial News. All rights reserved.


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

<HTML>
<HEAD>
<meta http-equiv=3D=22content-type=22 content=3D=22text/html;CHARSET=3Diso8859-1=22>
</HEAD>
<BODY BGCOLOR=3D=22=23FFFFFF=22>
<FONT SIZE=3D2><FONT FACE=3D=22Arial=22><FONT SIZE=3D2><FONT COLOR=3D=22=23000000=22><BR>
<FONT SIZE=3D2><FONT FACE=3D=22Arial=22><FONT SIZE=3D2><FONT COLOR=3D=22=23000000=22><B>The Financial News, November 2001</B><FONT SIZE=3D2><FONT FACE=3D=22Arial=22><FONT SIZE=3D2><BR>
<BR>
<FONT SIZE=3D2><FONT FACE=3D=22Arial=22><FONT SIZE=3D2><B>Production Mini-plants in mobile containers</B><FONT SIZE=3D2><FONT FACE=3D=22Arial=22><FONT SIZE=3D2><BR>
<BR>
=22...Science Network will supply to countries and developing regions the technology and the necessary support for the production in series of Mini-plants in mobile containers (40-foot). The Mini-plant system is designed in such a way that all the production machinery is fixed on the platform of the container, with all wiring, piping, and installation parts; that is to say, they are fully equipped... and the mini-plant is ready for production.=22<BR>
<BR>
More than 700 portable production systems: Bakeries, Steel Nails, Welding Electrodes, Tire Retreading, Reinforcement Bar Bending for Construction Framework, Sheeting for Roofing, Ceilings and Fa&ccedil;ades, Plated Drums, Aluminum Buckets, Injected Polypropylene Housewares, Pressed Melamine Items (Glasses, Cups, Plates, Mugs, etc.), Mufflers, Construction Electrically Welded Mesh, Plastic Bags and Packaging, Mobile units of medical assistance, Sanitary Material, Hypodermic Syringes, Hemostatic Clamps, etc. <BR>
<BR>
For more information: <a href=3D=22mailto:reports=40the-financial-news.org=22>Mini-plants in mobile containers</a><BR>
<BR>
By Steven P. Leibacher, The Financial News, Editor<BR>
<BR>
-------------------------------------------------------------------------<BR>
If you received this in error or would like to be removed from our list, please return us indicating: remove or un-subscribe in 'subject' field, Thanks. <a href=3D=22mailto:newsletters=40the-financial-news.org=22> Editor</a><BR>
&copy; 2001 The Financial News. All rights reserved.<BR>
<FONT SIZE=3D2><FONT FACE=3D=22Arial=22><FONT SIZE=3D2><FONT COLOR=3D=22=23000000=22><BR>
<FONT SIZE=3D2><FONT FACE=3D=22Arial=22><FONT SIZE=3D2><FONT COLOR=3D=22=23000000=22><BR>
</FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT></FONT>
</BODY>
</HTML>

--=_NextPart_2rfkindysadvnqw3nerasdf--



From lkvam@venix.com  Fri Nov  9 18:33:01 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Fri, 09 Nov 2001 13:33:01 -0500
Subject: [Tutor] How long can a line be for readline() or readlines() 	  ?? ((LONG)) file, example and console
References: <5CDFEBB60E7FD311B9E30000F6D6090608CB8DEF@novamail2.nv.cc.va.us>
Message-ID: <3BEC215D.4020204@venix.com>

How do you know that line is the culprit?  I can't run your script 
directly, but I suspect that there is an extra (empty??) line in the 
file that is breaking it.

The long line works in my extract of your script!

Schmidt, Allen J. wrote:

> Each line has actually 6 pipes:
> |adnum|logo|adtext|catnum|RM|
> 
> The RM on the end is a holdover from when the text was processed a different
> way.
> 
> Lines under 2k go in without a hitch. The line I sent is one over the 2k
> limit.
> 
> -----Original Message-----
> From: Lloyd Kvam [mailto:lkvam@venix.com]
> 
> THIS is your problem area:
> 
>   lineout=string.split(lineout,'|')
>           sql="insert into current (adnum, logo, rundate, runday, status,
> adtext, category) values
> ('"+lineout[1]+"','"+lineout[2]+"','"+date+"','"+day+"','ENABLED','"+lineout
> [3]+"','"+lineout[4]+"')"
> 
> lineout becomes a list of lines that is made up of those pieces between 
> the |s of the orinal lineout.  The sql statement requires that the 
> lineout list contain at least 5 lines.  Thus there needs to be at least 
> 4 |s in the original lineout.
> 
> 


-- 
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  Fri Nov  9 19:09:59 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 9 Nov 2001 11:09:59 -0800 (PST)
Subject: [Tutor] A quick question
In-Reply-To: <001501c16944$b9035320$0300a8c0@vodka>
Message-ID: <Pine.LNX.4.21.0111091054320.4933-100000@hkn.eecs.berkeley.edu>

On Sat, 10 Nov 2001, Edy Lie wrote:

>    I was thinking to change the following codes to python but aint
> sure how should i approach it.

Hi Edy!  Sure; let's take a look.



>   open (SEARCH, "$file") or die switch();
>   while ($line = <SEARCH>) {
>   ...
> }

This while loop in Perl can be written in Python like this:

###
for line in f.readlines():
    ....
###

This is not exactly equivalent though, since this translation tries to
suck the whole file at once.  This might be a good thing if the file is
small, but if the file is fairly large, you'll probably want to eat it a
line at a time.


In that case, we can rewrite it like this:

###
while 1:
    line = f.readline()
    if not line: break
    ...
###

which means "do this loop until we can't read any more lines from our file
f."  It's actually a little closer to what the Perl code does because it
only reads a line at a time.  Also, it looks like you might need to use
this version of the code because of the stuff done later in the code.



>       if ($line =~ /$domain/i) {
>       ...

I'm guessing that '$domain' is some sort of variable that contains your
search string.  You can use Python's regular expression module to do the
same thing:

###
if re.search(domain, line, re.IGNORECASE):
    ...
###


Python has a lot of good documentation on regular expressions online: you
can find out more about the 're' module here:

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



You might also find the 'string' module really useful as well if you do a
lot of string manipulations:

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

Personally, I use string.strip() a lot ---- it's similar to Perl's chomp()
function.


Hope this helps!



From dsh8290@rit.edu  Fri Nov  9 19:16:16 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 9 Nov 2001 14:16:16 -0500
Subject: [Tutor] A quick question
In-Reply-To: <Pine.LNX.4.21.0111091054320.4933-100000@hkn.eecs.berkeley.edu>; from dyoo@hkn.eecs.berkeley.edu on Fri, Nov 09, 2001 at 11:09:59AM -0800
References: <001501c16944$b9035320$0300a8c0@vodka> <Pine.LNX.4.21.0111091054320.4933-100000@hkn.eecs.berkeley.edu>
Message-ID: <20011109141616.A1397@harmony.cs.rit.edu>

On Fri, Nov 09, 2001 at 11:09:59AM -0800, Danny Yoo wrote:
| On Sat, 10 Nov 2001, Edy Lie wrote:
| 
| >    I was thinking to change the following codes to python but aint
| > sure how should i approach it.
| 
| Hi Edy!  Sure; let's take a look.
| 
| >   open (SEARCH, "$file") or die switch();
| >   while ($line = <SEARCH>) {
| >   ...
| > }
| 
| This while loop in Perl can be written in Python like this:
| 
| ###
| for line in f.readlines():
|     ....
| ###
| 
| This is not exactly equivalent though, since this translation tries to
| suck the whole file at once.  This might be a good thing if the file is
| small, but if the file is fairly large, you'll probably want to eat it a
| line at a time.
| 
| 
| In that case, we can rewrite it like this:
| 
| ###
| while 1:
|     line = f.readline()
|     if not line: break
|     ...
| ###

If you have python 2.0 or newer, I prefer

for line in f.xreadlines() :
    ...

to lazily iterate over all the lines in a file.

-D



From karthikg@aztec.soft.net  Sat Nov 10 12:19:53 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Sat, 10 Nov 2001 17:49:53 +0530
Subject: [Tutor] Simple Thread Program not working (Newbie: Python)
Message-ID: <NEBBJNMDEKBIBCMCNMBDGEIMCIAA.karthikg@aztec.soft.net>

hello all,

Am not sure why am getting the errors at the specified place ( I have pasted
the error on those lines)
Can someone help.
---------------

import threading, time

class Test:
    def __init__(self):
        self.data = "start"
    def change(self,data):
        self.data = data
    def __str__(self):
        return self.data
    def __repr__(self):
        return self.data

class ChangeThread(threading.Thread):
    def __init_(self,val,a):
        self.ref = a
        threading.Thread.__init__(None,self)
    def run(self):
        count = 1
        while 1:
            self.ref.change(s,count) # AttributeError: ChangeThread instance
has no attribute 'ref'
            count+=1
            time.sleep(1)

class WatchThread(threading.Thread):
    def __init_(self,val,a):
        self.ref = a
        threading.Thread.__init__(None,self)
    def run(self):
        while 1:
            print 'changed data : ' + self.ref.data   # AttributeError:
#ChangeThread instance has no attribute 'ref'
            time.sleep(3)


def execute():
    print 'Start execute'
    t = Test()
    t1 = WatchThread(None,t)
    t2 = WatchThread(None,t)
    t3 = WatchThread(None,t)
    t1.start()
    t2.start()
    t3.start()
    time.sleep(2)

    t4 = ChangeThread(None,t)
    t4.start()

if __name__ == '__main__':
    execute()



This is the trace:

Start execute
Exception in thread Thread-1:
Traceback (most recent call last):
  File "d:\python21\lib\threading.py", line 378, in __bootstrap
    self.run()
  File "thread1.py", line 30, in run
    print 'changed data : ' + self.ref.data
AttributeError: WatchThread instance has no attribute 'ref'

Exception in thread Thread-2:
Traceback (most recent call last):
  File "d:\python21\lib\threading.py", line 378, in __bootstrap
    self.run()
  File "thread1.py", line 30, in run
    print 'changed data : ' + self.ref.data
AttributeError: WatchThread instance has no attribute 'ref'

Exception in thread Thread-3:
Traceback (most recent call last):
  File "d:\python21\lib\threading.py", line 378, in __bootstrap
    self.run()
  File "thread1.py", line 30, in run
    print 'changed data : ' + self.ref.data
AttributeError: WatchThread instance has no attribute 'ref'

Exception in thread Thread-4:
Traceback (most recent call last):
  File "d:\python21\lib\threading.py", line 378, in __bootstrap
    self.run()
  File "thread1.py", line 20, in run
    self.ref.change(s,count)
AttributeError: ChangeThread instance has no attribute 'ref'



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



From karthikg@aztec.soft.net  Sat Nov 10 12:51:20 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Sat, 10 Nov 2001 18:21:20 +0530
Subject: [Tutor] RE: Simple Thread Program not working (Newbie: Python)
In-Reply-To: <NEBBJNMDEKBIBCMCNMBDGEIMCIAA.karthikg@aztec.soft.net>
Message-ID: <NEBBJNMDEKBIBCMCNMBDCEIOCIAA.karthikg@aztec.soft.net>

sorry got the bug. My __init__() declaration was the problem!


-----Original Message-----
From: karthik Guru [mailto:karthikg@aztec.soft.net]
Sent: Saturday, November 10, 2001 5:50 PM
To: tutor@python.org
Subject: Simple Thread Program not working (Newbie: Python)
Importance: High



hello all,

Am not sure why am getting the errors at the specified place ( I have pasted
the error on those lines)
Can someone help.
---------------

import threading, time

class Test:
    def __init__(self):
        self.data = "start"
    def change(self,data):
        self.data = data
    def __str__(self):
        return self.data
    def __repr__(self):
        return self.data

class ChangeThread(threading.Thread):
    def __init_(self,val,a):
        self.ref = a
        threading.Thread.__init__(None,self)
    def run(self):
        count = 1
        while 1:
            self.ref.change(s,count) # AttributeError: ChangeThread instance
has no attribute 'ref'
            count+=1
            time.sleep(1)

class WatchThread(threading.Thread):
    def __init_(self,val,a):
        self.ref = a
        threading.Thread.__init__(None,self)
    def run(self):
        while 1:
            print 'changed data : ' + self.ref.data   # AttributeError:
#ChangeThread instance has no attribute 'ref'
            time.sleep(3)


def execute():
    print 'Start execute'
    t = Test()
    t1 = WatchThread(None,t)
    t2 = WatchThread(None,t)
    t3 = WatchThread(None,t)
    t1.start()
    t2.start()
    t3.start()
    time.sleep(2)

    t4 = ChangeThread(None,t)
    t4.start()

if __name__ == '__main__':
    execute()



This is the trace:

Start execute
Exception in thread Thread-1:
Traceback (most recent call last):
  File "d:\python21\lib\threading.py", line 378, in __bootstrap
    self.run()
  File "thread1.py", line 30, in run
    print 'changed data : ' + self.ref.data
AttributeError: WatchThread instance has no attribute 'ref'

Exception in thread Thread-2:
Traceback (most recent call last):
  File "d:\python21\lib\threading.py", line 378, in __bootstrap
    self.run()
  File "thread1.py", line 30, in run
    print 'changed data : ' + self.ref.data
AttributeError: WatchThread instance has no attribute 'ref'

Exception in thread Thread-3:
Traceback (most recent call last):
  File "d:\python21\lib\threading.py", line 378, in __bootstrap
    self.run()
  File "thread1.py", line 30, in run
    print 'changed data : ' + self.ref.data
AttributeError: WatchThread instance has no attribute 'ref'

Exception in thread Thread-4:
Traceback (most recent call last):
  File "d:\python21\lib\threading.py", line 378, in __bootstrap
    self.run()
  File "thread1.py", line 20, in run
    self.ref.change(s,count)
AttributeError: ChangeThread instance has no attribute 'ref'



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



From karthikg@aztec.soft.net  Sat Nov 10 14:49:01 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Sat, 10 Nov 2001 20:19:01 +0530
Subject: [Tutor] __getattr__ and __setattr__ ???
Message-ID: <NEBBJNMDEKBIBCMCNMBDGEJACIAA.karthikg@aztec.soft.net>

hi all,

class test:
    def __init__(self):
            self.name="employee"
    def __getattr__(self,name):
            print 'get attr called ' + str(name)
    def __setattr__(self,name,value):
            print 'set attr called ' + str(name) + " " + str(value)

if __name__ == '__main__':
    t = test()
    print t.name
    t.name = "manager"


This is the code i have.
My understanding was that __getattr__() or __setattr__() w'd'nt be called
when
the main executes as it can find the attribute in the local namespace.

BUT it does call the 2 methods.

This means i can trap the events when someone is "reading" or "modifying" my
instance attributes?
Somewhat similar to the way "properties" work in C#??

please clear my confusion.

regards
karthik.





From pobrien@orbtech.com  Sat Nov 10 14:59:58 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Sat, 10 Nov 2001 08:59:58 -0600
Subject: [Tutor] __getattr__ and __setattr__ ???
In-Reply-To: <NEBBJNMDEKBIBCMCNMBDGEJACIAA.karthikg@aztec.soft.net>
Message-ID: <NBBBIOJPGKJEKIECEMCBAEEILBAA.pobrien@orbtech.com>

Yes and no. __setattr__ will always be called, __getattr__ is only called
when the attribute cannot be found in the objects local dictionary, which is
t.__dict__ in this case. In your example, the __getattr__ *is* getting
called because it also gets called from *within* the __init__. Since your
__setattr__ doesn't actually set the value of the attribute in the local
dictionary (self.__dict__[name] = value) it doesn't exist. So then print
t.name can't find it in the local objects dictionary and the __getattr__
gets invoked. Normally this wouldn't happen. Of course, you can play lots of
tricks like this if you *do* want __getattr__ to *always* get invoked. But
that is a bit advanced and I won't go into that here. Also, Python 2.2 has
some new mechanisms that make all of this even easier and more doable on a
finer level of granularity.

Here is a shell session to show you a bit of what is happening:

Welcome To PyCrust 0.7 - 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
>>> class test:
...     def __init__(self):
...             self.name="employee"
...     def __getattr__(self,name):
...             print 'get attr called ' + str(name)
...     def __setattr__(self,name,value):
...             print 'set attr called ' + str(name) + " " + str(value)
...
>>> t = test()
set attr called name employee
>>> t.name
get attr called name
>>> dir(t)
get attr called __members__
get attr called __methods__
[]
>>> t.__dict__
{}
>>>

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
karthik Guru
Sent: Saturday, November 10, 2001 8:49 AM
To: tutor@python.org
Subject: [Tutor] __getattr__ and __setattr__ ???
Importance: High


hi all,

class test:
    def __init__(self):
            self.name="employee"
    def __getattr__(self,name):
            print 'get attr called ' + str(name)
    def __setattr__(self,name,value):
            print 'set attr called ' + str(name) + " " + str(value)

if __name__ == '__main__':
    t = test()
    print t.name
    t.name = "manager"


This is the code i have.
My understanding was that __getattr__() or __setattr__() w'd'nt be called
when
the main executes as it can find the attribute in the local namespace.

BUT it does call the 2 methods.

This means i can trap the events when someone is "reading" or "modifying" my
instance attributes?
Somewhat similar to the way "properties" work in C#??

please clear my confusion.

regards
karthik.




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



From pobrien@orbtech.com  Sat Nov 10 15:18:56 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Sat, 10 Nov 2001 09:18:56 -0600
Subject: [Tutor] __getattr__ and __setattr__ ???
In-Reply-To: <NBBBIOJPGKJEKIECEMCBAEEILBAA.pobrien@orbtech.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBCEEJLBAA.pobrien@orbtech.com>

Some days I really need an editor. <wink>

What I meant to say was that __setattr__ gets called from within the
__init__, in this case.

In a nutshell:

1. If you have a __getattr__ it gets invoked when the attribute cannot be
found in the instance's local dictionary (or class hierarchy).

2. If you have a __setattr__, it always gets invoked.

3. These rules apply even to code within the class definition, so you must
be aware of when you need to bypass these methods by manipulating the
object's local dictionary directly (self.__dict__[somekey] = somevalue, for
example).

I hope that helps.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Patrick K. O'Brien
Sent: Saturday, November 10, 2001 9:00 AM
To: karthik Guru; tutor@python.org
Subject: RE: [Tutor] __getattr__ and __setattr__ ???

Yes and no. __setattr__ will always be called, __getattr__ is only called
when the attribute cannot be found in the objects local dictionary, which is
t.__dict__ in this case. In your example, the __getattr__ *is* getting
called because it also gets called from *within* the __init__. Since your
__setattr__ doesn't actually set the value of the attribute in the local
dictionary (self.__dict__[name] = value) it doesn't exist. So then print
t.name can't find it in the local objects dictionary and the __getattr__
gets invoked. Normally this wouldn't happen. Of course, you can play lots of
tricks like this if you *do* want __getattr__ to *always* get invoked. But
that is a bit advanced and I won't go into that here. Also, Python 2.2 has
some new mechanisms that make all of this even easier and more doable on a
finer level of granularity.

Here is a shell session to show you a bit of what is happening:

Welcome To PyCrust 0.7 - 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
>>> class test:
...     def __init__(self):
...             self.name="employee"
...     def __getattr__(self,name):
...             print 'get attr called ' + str(name)
...     def __setattr__(self,name,value):
...             print 'set attr called ' + str(name) + " " + str(value)
...
>>> t = test()
set attr called name employee
>>> t.name
get attr called name
>>> dir(t)
get attr called __members__
get attr called __methods__
[]
>>> t.__dict__
{}
>>>

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
karthik Guru
Sent: Saturday, November 10, 2001 8:49 AM
To: tutor@python.org
Subject: [Tutor] __getattr__ and __setattr__ ???
Importance: High


hi all,

class test:
    def __init__(self):
            self.name="employee"
    def __getattr__(self,name):
            print 'get attr called ' + str(name)
    def __setattr__(self,name,value):
            print 'set attr called ' + str(name) + " " + str(value)

if __name__ == '__main__':
    t = test()
    print t.name
    t.name = "manager"


This is the code i have.
My understanding was that __getattr__() or __setattr__() w'd'nt be called
when
the main executes as it can find the attribute in the local namespace.

BUT it does call the 2 methods.

This means i can trap the events when someone is "reading" or "modifying" my
instance attributes?
Somewhat similar to the way "properties" work in C#??

please clear my confusion.

regards
karthik.




_______________________________________________
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 discuss@sendme.cz  Sat Nov 10 19:32:27 2001
From: discuss@sendme.cz (A)
Date: Sat, 10 Nov 2001 20:32:27 +0100
Subject: [Tutor] The Best solution?
Message-ID: <3BED8EDB.24818.1F8E1C@localhost>

Hello,
I need from my program send an email and I would like to send it in 
a different thread or process.
Can you please give me an example how I can start a new thread 
or process Under Win32 systems?

 Is it better to  use a new thread  or a new process?
Thank you for help.
Ladislav


From printers@sendme.cz  Sat Nov 10 19:32:27 2001
From: printers@sendme.cz (A)
Date: Sat, 10 Nov 2001 20:32:27 +0100
Subject: [Tutor] The Best solution?
Message-ID: <3BED8EDB.16670.1F8E02@localhost>

Hello,
I need from my program send an email and I would like to send it in 
a different thread or process.
Can you please give me an example how I can start a new thread 
or process Under Win32 systems?

 Is it better to  use a new thread  or a new process?
Thank you for help.
Ladislav


From heynow@cmsystems.org  Sat Nov 10 19:40:38 2001
From: heynow@cmsystems.org (Ken Mead)
Date: Sat, 10 Nov 2001 14:40:38 -0500
Subject: [Tutor] Python2 getting backspace key to work
Message-ID: <000d01c16a1f$9315bb90$ec58e540@mine>

Hi list,

I'm running debian, I have both python1.5 and now python2 on my machine,
when using v.1.5* my backspace and arrow keys work to edit a line of code.

However, when I use python2 when I hit backspace or arrow keys I get escape
characters like ^B and so on.

Why is this happening? How can I fix it? Normally I'd query Google for this
problem but it seems to be down, for me, anyway!

Thanks for any explanation or fix,

CM




From dsh8290@rit.edu  Sat Nov 10 22:49:35 2001
From: dsh8290@rit.edu (dman)
Date: Sat, 10 Nov 2001 17:49:35 -0500
Subject: [Tutor] Python2 getting backspace key to work
In-Reply-To: <000d01c16a1f$9315bb90$ec58e540@mine>; from heynow@cmsystems.org on Sat, Nov 10, 2001 at 02:40:38PM -0500
References: <000d01c16a1f$9315bb90$ec58e540@mine>
Message-ID: <20011110174935.A13997@harmony.cs.rit.edu>

On Sat, Nov 10, 2001 at 02:40:38PM -0500, Ken Mead wrote:
| Hi list,
| 
| I'm running debian, I have both python1.5 and now python2 on my machine,
| when using v.1.5* my backspace and arrow keys work to edit a line of code.

GNU readline is nice!

| However, when I use python2 when I hit backspace or arrow keys I get escape
| characters like ^B and so on.

The 'python2-base' package doesn't link against
GNU readline because of those icky license issues.  It is obsolete now
because 2.1 is out without the license problems, and Policy has
finally been made.

python2.1 is in sid now, and I recommend installing it.  It has none
of the license issues so it is linked against GNU readline.  The down
side is that not all of the libraries are converted to use python2.1
and conform to the new Policy, but they will be there soon.  In the
meantime use 1.5 if you need the extensions (ie pygtk) and use 2.1 if
you don't.

HTH,
-D



From heynow@cmsystems.org  Sun Nov 11 02:20:49 2001
From: heynow@cmsystems.org (Ken Mead)
Date: Sat, 10 Nov 2001 21:20:49 -0500
Subject: [Tutor] Python2 getting backspace key to work
References: <000d01c16a1f$9315bb90$ec58e540@mine> <20011110174935.A13997@harmony.cs.rit.edu>
Message-ID: <001a01c16a57$7ae101f0$5f5ae540@mine>

Thanks, dman for the heads up. I guess I'll wait for the new packages to go
into testing.

Cheers,
CM
----- Original Message -----
From: "dman" <dsh8290@rit.edu>
To: <tutor@python.org>
Sent: Saturday, November 10, 2001 5:49 PM
Subject: Re: [Tutor] Python2 getting backspace key to work


> On Sat, Nov 10, 2001 at 02:40:38PM -0500, Ken Mead wrote:
> | Hi list,
> |
> | I'm running debian, I have both python1.5 and now python2 on my machine,
> | when using v.1.5* my backspace and arrow keys work to edit a line of
code.
>
> GNU readline is nice!
>
> | However, when I use python2 when I hit backspace or arrow keys I get
escape
> | characters like ^B and so on.
>
> The 'python2-base' package doesn't link against
> GNU readline because of those icky license issues.  It is obsolete now
> because 2.1 is out without the license problems, and Policy has
> finally been made.
>
> python2.1 is in sid now, and I recommend installing it.  It has none
> of the license issues so it is linked against GNU readline.  The down
> side is that not all of the libraries are converted to use python2.1
> and conform to the new Policy, but they will be there soon.  In the
> meantime use 1.5 if you need the extensions (ie pygtk) and use 2.1 if
> you don't.
>
> HTH,
> -D
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>





From in657@mail.com  Sun Nov 11 02:00:32 2001
From: in657@mail.com (infoMARKET)
Date: Sun, 11 Nov 2001 05:00:32 +0300
Subject: [Tutor] =?windows-1251?Q?=C2=E0=F8=E8_=ED=EE=E2=FB=E5_=EA=EB=E8=E5=ED=F2=FB_!?=
Message-ID: <115432001110112032157@mail.com>

Çäðàâñòâóéòå!

 ýòîì ïèñüìå:
- áàçû äàííûõ ïðåäïðèÿòèé äëÿ êîíòàêòîâ ïî ýëåêòðîííîé ïî÷òå (ï.1);
- ïðîãðàììà äëÿ àâòîìàòè÷åñêîé ðàññûëêè ýëåêòðîííîé ïî÷òû (ï.2);
- áàçû äàííûõ êðóïíåéøèõ ïðåäïðèÿòèé Ìîñêâû, Ðîññèè, ÑÍÃ (ï.3);
- áàçû äàííûõ ðåãèîíàëüíûõ ïðîìûøëåííûõ ïðåäïðèÿòèé (âñå ðåãèîíû Ðîññèè è
ÑÍÃ) (ï.4);
- îòðàñëåâûå áàçû äàííûõ ïðåäïðèÿòèé Ìîñêâû (ï.5);
- âàøà êîðïîðàòèâíàÿ ýëåêòðîííàÿ ïî÷òà (ï.6).


1.
Êîãäà íåîáõîäèìî áûñòðî è ñ ìèíèìàëüíûìè çàòðàòàìè ñîîáùèòü îïðåäåëåííîé
öåëåâîé ãðóïïå ïðåäïðèÿòèé êàêóþ-ëèáî èíôîðìàöèþ, íåò íè÷åãî ëó÷øå, ÷åì
ñäåëàòü ýòî ïî ýëåêòðîííîé ïî÷òå. Íàøè áàçû äàííûõ äëÿ êîíòàêòîâ ïî
ýëåêòðîííîé ïî÷òå ïðåäíàçíà÷åíû ñïåöèàëüíî äëÿ ýòèõ öåëåé. Ïîêóïàÿ èõ, âû
ïðèîáðåòàåòå ìîùíåéøèé ìàðêåòèíãîâûé ìåõàíèçì, ïîçâîëÿþùèé ìîìåíòàëüíî è ñ
ìèíèìàëüíûìè çàòðàòàìè ïðèâëåêàòü íîâûõ è íîâûõ êëèåíòîâ.

Ìíîãèå îòðèöàòåëüíî îòíîñÿòñÿ ê ìàññîâûì ýëåêòðîííûì ðàññûëêàì, ïå÷àëüíî
èçâåñòíûì êàê spam. Îäíàêî ñ÷èòàåì, íåò íè÷åãî ïëîõîãî â òîì ÷òî ôèðìà,
âûáðàâ èç áàçû îãðàíè÷åííûé êðóã ïðåäïðèÿòèé ëèøü îïðåäåëåííîãî ðîäà
äåÿòåëüíîñòè, ðàññûëàåò ïî íèì ñîîòâåòñòâóþùåå ïðåäëîæåíèå íåáîëüøîãî
îáúåìà, êîòîðîå äåéñòâèòåëüíî ìîæåò èõ çàèíòåðåñîâàòü. Òàêèå ðàññûëêè ìîæíî
èñïîëüçîâàòü íå òîëüêî äëÿ ðåêëàìíûõ öåëåé. Íàïðèìåð, âàì íóæíî óçíàòü
ñòîèìîñòü îïðåäåëåííîãî òîâàðà, ïðîèçâîäèìîãî èëè ïðîäàâàåìîãî îïðåäåëåííîé
ãðóïïîé îðãàíèçàöèé. Îáçâîíèòü 500, à òî è 1000 ôèðì - çàíÿòèå, òðåáóþùåå
ìíîãî âðåìåíè è çíà÷èòåëüíûõ ñðåäñòâ. À åñëè ñäåëàòü ðàññûëêó ñ
ñîîòâåòñòâóþùèì çàïðîñîì ïî äàííîé ãðóïïå îðãàíèçàöèé, ìîæíî ìãíîâåííî
ïîëó÷èòü ïîëíóþ èíôîðìàöèþ ïî èíòåðåñóþùåìó âîïðîñó.

Ïðåäëàãàåì âàì äâà êîìïëåêòà äëÿ êîíòàêòîâ ïî ýëåêòðîííîé ïî÷òå:

Êîìïëåêò "Îðãàíèçàöèè Ìîñêâû" - 38000 ïðåäïðèÿòèé (âñå ñ ýëåêòðîííûìè
àäðåñàìè);
Êîìïëåêò "Îðãàíèçàöèè ÑÍÃ" - 26000 ïðåäïðèÿòèé (âñå ñ ýëåêòðîííûìè
àäðåñàìè).

Êàæäûé êîìïëåêò âêëþ÷àåò â ñåáÿ:
- ñîîòâåòñòâóþùóþ áàçó äàííûõ äëÿ êîíòàêòîâ ïî ýëåêòðîííîé ïî÷òå;
- ïðîãðàììó GroupMail äëÿ àâòîìàòè÷åñêîé ðàññûëêè ýëåêòðîííîé ïî÷òû.

Áàçà äàííûõ "38000 îðãàíèçàöèé Ìîñêâû". Êðîìå ýëåêòðîííîãî àäðåñà (e-mail
èìååòñÿ ó êàæäîé îðãàíèçàöèè) ïî êàæäîé êîìïàíèè ïðåäñòàâëåíû:
- íàçâàíèå,
- ðîä äåÿòåëüíîñòè,
- òåëåôîíû,
- ôàêñ,
- ïî÷òîâûé àäðåñ,
- àäðåñ ñàéòà.
Áàçà îôîðìëåíà â âèäå ñòàíäàðòíîé òàáëèöû Excel, ÷òî ïîçâîëÿåò ðàáîòàòü ñ
íåþ ïîëüçîâàòåëþ ñ ëþáûì óðîâíåì çíàíèÿ êîìïüþòåðà, è äàåò âîçìîæíîñòü
ñîðòèðîâêè ñòðîê ïî ëþáîìó èç ïàðàìåòðîâ, íàïðèìåð, ïî ðîäó äåÿòåëüíîñòè. Â
áàçó âîøëè âñå êîìïàíèè, êîòîðûå ñàìè ïóáëèêóþò ñâîé e-mail â ðàçëè÷íûõ
áèçíåñ-ñïðàâî÷íèêàõ ïî Ìîñêâå. Âîçâðàòîâ ñ íåñóùåñòâóþùèõ àäðåñîâ ïðè
ðàññûëêàõ: 15%. Îáíîâëåíèå áàçû ïðîèñõîäèò êàæäûé êâàðòàë. Áàçà ñ
ïðîãðàììîé ïðåäîñòàâëÿåòñÿ íà êîìïàêò-äèñêå (â ò.÷. ïî ïî÷òå) èëè
âûñûëàåòñÿ ýëåêòðîííîé ïî÷òîé.
ÑÒÎÈÌÎÑÒÜ äàííîé áàçû â êîìïëåêòå ñ ïðîãðàììîé GroupMail (ñì. íèæå) $300.
Ñòîèìîñòü îáíîâëåíèÿ $60. Ôîðìà îïëàòû ëþáàÿ. Çàêàçû è âîïðîñû íàïðàâëÿéòå
íà àäðåñ InfoMarket@global-mail.ru.

Áàçà äàííûõ "26000 ïðåäïðèÿòèé ÑÍÃ". Êðîìå ýëåêòðîííîãî àäðåñà (e-mail
èìååòñÿ ó êàæäîé îðãàíèçàöèè) ïî êàæäîé êîìïàíèè ïðåäñòàâëåíû:
- íàçâàíèå,
- ôîðìà ñîáñòâåííîñòè,
- òåëåôîíû,
- ôàêñ,
- ïî÷òîâûé àäðåñ,
- àäðåñ ñàéòà,
- Ô.È.Î. è äîëæíîñòü ðóêîâîäèòåëÿ (!),
- ÷èñëåííîñòü øòàòà,
- ñïèñîê ïðîèçâîäèìûõ òîâàðîâ è óñëóã.
Áàçà îôîðìëåíà â âèäå ñòàíäàðòíîé òàáëèöû Excel, ÷òî ïîçâîëÿåò ðàáîòàòü ñ
íåþ ïîëüçîâàòåëþ ñ ëþáûì óðîâíåì çíàíèÿ êîìïüþòåðà. Âîçâðàòîâ ñ
íåñóùåñòâóþùèõ àäðåñîâ ïðè ðàññûëêàõ: 20%. Îáíîâëåíèå áàçû ïðîèñõîäèò
êàæäûé êâàðòàë. Áàçà ñ ïðîãðàììîé ïðåäîñòàâëÿåòñÿ íà êîìïàêò-äèñêå (â ò.÷.
ïî ïî÷òå) èëè âûñûëàåòñÿ ýëåêòðîííîé ïî÷òîé.
ÑÒÎÈÌÎÑÒÜ äàííîé áàçû â êîìïëåêòå ñ ïðîãðàììîé GroupMail (ñì. íèæå) $200.
Ñòîèìîñòü îáíîâëåíèÿ $40. Ôîðìà îïëàòû ëþáàÿ. Çàêàçû è âîïðîñû íàïðàâëÿéòå
íà àäðåñ InfoMarket@global-mail.ru.

Âíèìàíèå! Ïðè îäíîâðåìåííîì ïðèîáðåòåíèè îáåèõ áàç äàííûõ ïðåäîñòàâëÿåòñÿ
ñêèäêà: $100!


2.
Ïðîãðàììà "GroupMail" ïðåäíàçíà÷åíà äëÿ îñóùåñòâëåíèÿ ýëåêòðîííûõ ðàññûëîê.
Âî âðåìÿ ðàññûëêè "Group Mail" ãåíåðèðóåò è îòñûëàåò ïèñüìà äëÿ êàæäîãî
ïîëó÷àòåëÿ â îòäåëüíîñòè. Ïðè ýòîì â òåêñòàõ (êàê â òåìå, òàê è â òåëå
ïèñüìà) ìîæåò èñïîëüçîâàòüñÿ ïîäñòàíîâêà èíôîðìàöèè èç ðàçëè÷íûõ ÿ÷ååê
áàçû, ñîîòâåòñòâóþùèõ êîíêðåòíîìó àäðåñó. Ýòî ïîçâîëÿåò îáðàùàòüñÿ ê
êàæäîìó ïîëó÷àòåëþ ïî èìåíè â ðàññûëêàõ ïî áàçàì âàøèõ êëèåíòîâ èëè
ïàðòíåðîâ, à òàêæå ëþáûì äðóãèì îáðàçîì ïåðñîíèôèöèðîâàòü âàøè ðàññûëêè.
"GroupMail" èìååò øèðîêèå âîçìîæíîñòè ïî âåäåíèþ áàç äàííûõ. Âû ìîæåòå
èìïîðòèðîâàòü â ïðîãðàììó ñâîè áàçû. Èõ ìîæåò áûòü íåîãðàíè÷åííîå
êîëè÷åñòâî. Áàçû ìîæíî ñîçäàâàòü, äîïîëíÿòü, ðåäàêòèðîâàòü. Ïèñüìà â
ðàññûëêàõ ìîãóò ñîñòàâëÿòüñÿ êàê â ôîðìàòå txt, òàê è html. Ðåàëèçîâàíà
âîçìîæíîñòü ïðèêðåïëåíèÿ ôàéëîâ ëþáîãî ôîðìàòà. GroupMail ðàáîòàåò áåç
ó÷àñòèÿ êàêîé-ëèáî äðóãîé ïî÷òîâîé ïðîãðàììû. Ïðîãðàììà "GroupMail"
áåñïëàòíî ïðèëàãàåòñÿ ê êàæäîé èç âûøåîïèñàííûõ (ï.1) áàç äàííûõ. Íî åå
ìîæíî ïðèîáðåñòè è îòäåëüíî äëÿ ðàññûëêè ïî ñâîèì áàçàì.  ýòîì ñëó÷àå
ñòîèìîñòü åå ïðåäîñòàâëåíèÿ $25. Ôîðìà îïëàòû ëþáàÿ. Ïðîãðàììà
ïðåäîñòàâëÿåòñÿ íà êîìïàêò-äèñêå (â ò.÷. ïî ïî÷òå) èëè âûñûëàåòñÿ
ýëåêòðîííîé ïî÷òîé. Çàêàçû è âîïðîñû íàïðàâëÿéòå íà àäðåñ
InfoMarket@global-mail.ru.

Âûïîëíÿåì ýëåêòðîííûå ðàññûëêè ïî Âàøåìó çàêàçó. Çàêàçû è âîïðîñû
íàïðàâëÿéòå íà àäðåñ InfoMarket@global-mail.ru.


3.
Èìåþòñÿ â ïðîäàæå áàçû äàííûõ ÊÐÓÏÍÅÉØÈÕ ÏÐÅÄÏÐÈßÒÈÉ:
"Ïðåäïðèÿòèÿ Ìîñêâû/Ðîññèè/ÑÍà ñ ÷èñëåííîñòüþ øòàòà áîëåå 50/500/1000
÷åëîâåê". Ñòîèìîñòè ýòèõ áàç äàííûõ îò $15 äî $300. Ôîðìà îïëàòû ëþáàÿ.
Áàçû ïðåäîñòàâëÿåòñÿ íà êîìïàêò äèñêå (â ò.÷. ïî ïî÷òå) èëè âûñûëàåòñÿ
ýëåêòðîííîé ïî÷òîé. Çàêàçû è âîïðîñû íàïðàâëÿéòå íà àäðåñ
InfoMarket@global-mail.ru.


4.
Áàçû äàííûõ ðåãèîíàëüíûõ ïðîìûøëåííûõ ïðåäïðèÿòèé (âñå ðåãèîíû Ðîññèè è
ÑÍÃ). Âîïðîñû: InfoMarket@global-mail.ru.


5. Èìåþòñÿ â ïðîäàæå ñëåäóþùèå îòðàñëåâûå áàçû äàííûõ ïðåäïðèÿòèé Ìîñêâû:
- Ïðåäñòàâèòåëüñòâà çàðóáåæíûõ êîìïàíèé, ïîñîëüñòâà; 
- Ôèíàíñîâûå îðãàíèçàöèè; 
- Íåäâèæèìîñòü è ñòðîèòåëüñòâî; 
- Ìåáåëü è äåðåâîîáðàáîòêà; 
- Âíåøíîñòü, êðàñîòà, îòäûõ; 
- Ïðîäóêòû ïèòàíèÿ; 
- Îäåæäà è îáóâü; 
- Àâòî-ìîòî; 
- Ïðîìûøëåííîñòü; 
- Òóðèçì è îòäûõ; 
- Ìåäèöèíà è Ôàðìàöèÿ; 
- Ðåêëàìà; 
- ÑÌÈ. 
Çàïðîñû íàïðàâëÿéòå íà InfoMarket@global-mail.ru


6.
Âàøà êîðïîðàòèâíàÿ ýëåêòðîííàÿ ïî÷òà.
Ó âàñ åùå íåò ñîáñòâåííîãî âåá-ñàéòà? Åñëè òàê, çíà÷èò, îí âàì ïîêà íå
íóæåí. Ýòî íîðìàëüíî. Íî ïðè ìèíèìàëüíûõ çàòðàòàõ (ìåíüøå $100 â ãîä!) âû
ìîæåòå ñ íàøåé ïîìîùüþ, ïîòðàòèâ âñåãî 5 ìèíóò:
- çàðåãèñòðèðîâàòü äîìåí (àäðåñ âàøåé êîìïàíèè â Èíòåðíåòå). Òîãäà åãî óæå
íå çàéìåò íèêòî äðóãîé è âû â ëþáîé ìîìåíò ñìîæåòå çàïóñòèòü ñàéò ñ  ýòèì
àäðåñîì. Àäðåñ ìîæåò âûãëÿäåòü òàê: www.ÂÀØÀ_ÔÈÐÌÀ.ru. Èëè:
www.ÂÀØÀ_ÔÈÐÌÀ.com;

- ïîëó÷èòü íåîãðàíè÷åííîå (!) êîëè÷åñòâî ýëåêòðîííûõ ÿùèêîâ âèäà
èìÿ@ÂÀØÀ_ÔÈÐÌÀ.ru. Âû ñìîæåòå äàòü ëè÷íûé ýëåêòðîííûé ÿùèê êàæäîìó âàøåìó
ñîòðóäíèêó èëè îòäåëó. È àäðåñà ýòè áóäóò ïðèíàäëåæàòü íå äîìåíó âàøåãî
ïðîâàéäåðà, à âàøåìó ñîáñòâåííîìó äîìåíó. Ýòî ÿâëÿåòñÿ ïðåñòèæíûì è âûäåëèò
âàñ ñðåäè êîíêóðåíòîâ. Ñîçäàíèå î÷åðåäíîãî íîâîãî ýëåêòðîííîãî ÿùèêà áóäåò
äëÿ âàñ ìèíóòíûì äåëîì.

Åñëè ó Âàñ åñòü ôèëèàëû èëè ïîääîò÷åòíûå îòäåëû, è Âàì ïðèõîäèòñÿ ðåãóëÿðíî
ðàññûëàòü ïî íèì öèðêóëÿðíûå ïèñüìà, èíñòðóêöèè, äîêóìåíòàöèþ è ò.ä., òî
òåïåðü Âû ñìîæåòå âûäàòü èì ýëåêòðîííûå àäðåñà è îðãàíèçîâàòü
àâòîìàòè÷åñêóþ ýëåêòðîííóþ ðàññûëêó èíôîðìàöèè, ÷òî íåñîïîñòàâèìî ïî
çàòðàòàì ñ ðàññûëêîé ïî ôàêñó èëè ïî ïî÷òå.

Ïðè ýòîì, åñëè ñàéò ó âàñ êîãäà-íèáóäü ïîÿâèòñÿ, òî âû óæå íå áóäåòå
äîïëà÷âàòü çà åãî ðàçìåùåíèå, à ïðîñòî âûëîæèòå åãî â óæå ïðèíàäëåæàùåå âàì
äèñêîâîå ïðîñòàíñòâî â Èíòåðíåòå. Äî ýòîãî âðåìåíè Âû ìîæåòå ïî àäðåñó
www.ÂÀØÀ_ÔÈÐÌÀ.ru ïîëîæèòü "âèçèòíóþ êàðòî÷êó" âàøåé êîìïàíèè ñ êîíòàêòíûìè
ñâåäåíèÿìè è îïèñàíèåì âàøåé äåÿòåëüíîñòè. Îíà áóäåò äîñòóïíà ïî ýòîìó
àäðåñó èç ëþáîé òî÷êè ìèðà.

Âûøåîïèñàííîå ìîæíî ñäåëàòü ñ íàøåé ïîìîùüþ â ëþáîé ñòðàíå, ëþáîì ãîðîäå è
ïðè ëþáîì ñïîñîáå îïëàòû.

Åñëè æå âû ðåøèëè, ÷òî ñàéò âàì óæå íåîáõîäèì, ñìåëî îáðàùàéòåñü ê íàì.
Èìåÿ áîëüøîé îïûò â ñîçäàíèè âåá-ñàéòîâ, ìû ìîæåì èçãîòîâèòü  âàø
âåá-ðåñóðñ ëþáîãî óðîâíÿ ñëîæíîñòè. Ïî ëþáûì âîïðîñàì ïèøèòå íà
InfoMarket@global-mail.ru.




Êîìïàíèÿ InfoMarket,
E-mail: InfoMarket@global-mail.ru





From dsh8290@rit.edu  Sun Nov 11 02:57:35 2001
From: dsh8290@rit.edu (dman)
Date: Sat, 10 Nov 2001 21:57:35 -0500
Subject: [Tutor] Python2 getting backspace key to work
In-Reply-To: <001a01c16a57$7ae101f0$5f5ae540@mine>; from heynow@cmsystems.org on Sat, Nov 10, 2001 at 09:20:49PM -0500
References: <000d01c16a1f$9315bb90$ec58e540@mine> <20011110174935.A13997@harmony.cs.rit.edu> <001a01c16a57$7ae101f0$5f5ae540@mine>
Message-ID: <20011110215735.A8686@buddy.cs.rit.edu>

On Sat, Nov 10, 2001 at 09:20:49PM -0500, Ken Mead wrote:
| Thanks, dman for the heads up. I guess I'll wait for the new packages to go
| into testing.

If you have testing already, then you can setup apt preferences to
make it easy to get just a single package from unstable.  I've done
this, and installed python 2.1 because I didn't want to wait for it to
get to testing :-).

-D



From K9Trainin1@cs.com  Sun Nov 11 19:52:04 2001
From: K9Trainin1@cs.com (K9Trainin1@cs.com)
Date: Sun, 11 Nov 2001 14:52:04 EST
Subject: [Tutor] I have a legit question
Message-ID: <a6.1c8f4e25.292030e4@cs.com>

--part1_a6.1c8f4e25.292030e4_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

I believe that Leo laporte on TechTV said that Python was the best language 
to learn first.    Is this true?  why?  and how is Python useful? or what do 
you really do with it?  Thank you - Dr. Norman Skiba
p.s. any other useful info would be of great help and counsel to me!

--part1_a6.1c8f4e25.292030e4_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

<HTML><FONT FACE=arial,helvetica><FONT  SIZE=2>I believe that Leo laporte on TechTV said that Python was the best language to learn first. &nbsp;&nbsp;&nbsp;Is this true? &nbsp;why? &nbsp;and how is Python useful? or what do you really do with it? &nbsp;Thank you - Dr. Norman Skiba
<BR>p.s. any other useful info would be of great help and counsel to me!</FONT></HTML>

--part1_a6.1c8f4e25.292030e4_boundary--


From K9Trainin1@cs.com  Sun Nov 11 19:55:00 2001
From: K9Trainin1@cs.com (K9Trainin1@cs.com)
Date: Sun, 11 Nov 2001 14:55:00 EST
Subject: [Tutor] (no subject)
Message-ID: <148.46c3838.29203194@cs.com>

--part1_148.46c3838.29203194_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

p.s    which version is the best ----Python 2.2?  or 2.1 or 2.0 ? or what????

--part1_148.46c3838.29203194_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

<HTML><FONT FACE=arial,helvetica><FONT  SIZE=2>p.s &nbsp;&nbsp;&nbsp;which version is the best ----Python 2.2? &nbsp;or 2.1 or 2.0 ? or what????</FONT></HTML>

--part1_148.46c3838.29203194_boundary--


From ak@silmarill.org  Sun Nov 11 20:05:52 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Sun, 11 Nov 2001 15:05:52 -0500
Subject: [Tutor] I have a legit question
In-Reply-To: <a6.1c8f4e25.292030e4@cs.com>
References: <a6.1c8f4e25.292030e4@cs.com>
Message-ID: <20011111150551.A28135@sill.silmarill.org>

On Sun, Nov 11, 2001 at 02:52:04PM -0500, K9Trainin1@cs.com wrote:
> I believe that Leo laporte on TechTV said that Python was the best language 
> to learn first.    Is this true?  

Yeah.

why?  

Because it was designed as an easy to learn language from start.

and how is Python useful? 

A lot of things.. games, database web sites, business apps, graphics
apps, math, science.. Look at vaults of parnassus listing (linked to
from python.org).

or what do 
> you really do with it?

Pretty much anything you want except for low level OS drivers, extremely
performance-critical stuff like FPS games..

Thank you - Dr. Norman Skiba
> p.s. any other useful info would be of great help and counsel to me!

If you want to learn it, tutorial on python.org is a good start.

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


From ak@silmarill.org  Sun Nov 11 20:07:20 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Sun, 11 Nov 2001 15:07:20 -0500
Subject: [Tutor] (no subject)
In-Reply-To: <148.46c3838.29203194@cs.com>
References: <148.46c3838.29203194@cs.com>
Message-ID: <20011111150720.B28135@sill.silmarill.org>

On Sun, Nov 11, 2001 at 02:55:00PM -0500, K9Trainin1@cs.com wrote:
> p.s    which version is the best ----Python 2.2?  or 2.1 or 2.0 ? or what????

2.2 is the best, but it may be that your isp or web host only has 2.0 or
2.1 or even 1.5 installed on their server. Most people have 2.0 or 2.1
installed, so if you plan to distribute your app this may be a
consideration.

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


From karthikg@aztec.soft.net  Mon Nov 12 05:28:26 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Mon, 12 Nov 2001 10:58:26 +0530
Subject: [Tutor] __getattr__ and __setattr__ ???
In-Reply-To: <NBBBIOJPGKJEKIECEMCBAEEILBAA.pobrien@orbtech.com>
Message-ID: <NEBBJNMDEKBIBCMCNMBDIEKKCIAA.karthikg@aztec.soft.net>

that was more than helpful. Thanks a lot.
looked at some of the recipies in the python cookbook @active state's site.
But am finding some of the things difficult to comprehend as of now! :-(

karthik.



-----Original Message-----
From: Patrick K. O'Brien [mailto:pobrien@orbtech.com]
Sent: Saturday, November 10, 2001 8:30 PM
To: karthik Guru; tutor@python.org
Subject: RE: [Tutor] __getattr__ and __setattr__ ???


Yes and no. __setattr__ will always be called, __getattr__ is only called
when the attribute cannot be found in the objects local dictionary, which is
t.__dict__ in this case. In your example, the __getattr__ *is* getting
called because it also gets called from *within* the __init__. Since your
__setattr__ doesn't actually set the value of the attribute in the local
dictionary (self.__dict__[name] = value) it doesn't exist. So then print
t.name can't find it in the local objects dictionary and the __getattr__
gets invoked. Normally this wouldn't happen. Of course, you can play lots of
tricks like this if you *do* want __getattr__ to *always* get invoked. But
that is a bit advanced and I won't go into that here. Also, Python 2.2 has
some new mechanisms that make all of this even easier and more doable on a
finer level of granularity.

Here is a shell session to show you a bit of what is happening:

Welcome To PyCrust 0.7 - 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
>>> class test:
...     def __init__(self):
...             self.name="employee"
...     def __getattr__(self,name):
...             print 'get attr called ' + str(name)
...     def __setattr__(self,name,value):
...             print 'set attr called ' + str(name) + " " + str(value)
...
>>> t = test()
set attr called name employee
>>> t.name
get attr called name
>>> dir(t)
get attr called __members__
get attr called __methods__
[]
>>> t.__dict__
{}
>>>

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
karthik Guru
Sent: Saturday, November 10, 2001 8:49 AM
To: tutor@python.org
Subject: [Tutor] __getattr__ and __setattr__ ???
Importance: High


hi all,

class test:
    def __init__(self):
            self.name="employee"
    def __getattr__(self,name):
            print 'get attr called ' + str(name)
    def __setattr__(self,name,value):
            print 'set attr called ' + str(name) + " " + str(value)

if __name__ == '__main__':
    t = test()
    print t.name
    t.name = "manager"


This is the code i have.
My understanding was that __getattr__() or __setattr__() w'd'nt be called
when
the main executes as it can find the attribute in the local namespace.

BUT it does call the 2 methods.

This means i can trap the events when someone is "reading" or "modifying" my
instance attributes?
Somewhat similar to the way "properties" work in C#??

please clear my confusion.

regards
karthik.




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



From alan.gauld@bt.com  Mon Nov 12 13:34:17 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 12 Nov 2001 13:34:17 -0000
Subject: [Tutor] How long can a line be for readline() or readlines() ??
 ((LONG)) file, example and console
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0A4@mbtlipnt02.btlabs.bt.co.uk>

> Lines under 2k go in without a hitch. The line I sent is one 
> over the 2k limit.

This is a shot in the dark but....

Are you using the same test data each time? If so is it the 
same line that fails each time? If so what happens if you 
delete that line from the test file?

If that's the only line that fails have you tried printing 
out the split lines?

for L in lineout: print "-------------\n" + L

It just might be that there's something strange happening in 
the substitution or splitting of that particular line?

Just a thought,

Alan g.


From alan.gauld@bt.com  Mon Nov 12 18:44:48 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 12 Nov 2001 18:44:48 -0000
Subject: [Tutor] I have a legit question
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0B1@mbtlipnt02.btlabs.bt.co.uk>

------_=_NextPart_001_01C16BAA.1AF41260
Content-type: text/plain; charset="iso-8859-1"

I believe that Leo laporte on TechTV said that Python was the best language
to learn first.    Is this true?   
 

Python is one of several good beginners languages.
I personally believe its the best currently available 
which is also suitable for real world use once the 
beginners phase is over. Thats why I chose it for 
my "Learn to Program" book.

 why?   
 

For the very basics:
It has simple syntax, an interactive interpreter,
very clear error reporting(compared to other languages!)
its free and has a very good and friendly user community.
 
For the next step:
It supports many different types, with strong but 
dynamic typing, it also supports many programming 
paradigms:  procedural, functional and OO.
 
Finally:
It is powerful, it can do OS stuff as well as GUIs and
even quite intensive math based programming.
 

 and how is Python useful? or what do you really do with it?  

There is a very useful section on the Python web 
site which explains what Python can and can't do.   
Along with comparisons to other languages etc, 
I suggest you take a look.
 
Alan Gauld
http://www.freenetpages.co.uk/hp/alan.gauld/
<http://www.freenetpages.co.uk/hp/alan.gauld/> 
 

------_=_NextPart_001_01C16BAA.1AF41260
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>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; PADDING-LEFT: 5px">
  <DIV><FONT face=arial,helvetica><FONT size=2>I believe that Leo laporte on 
  TechTV said that Python was the best language to learn first. 
  &nbsp;&nbsp;&nbsp;Is this true?&nbsp;&nbsp;<SPAN 
  class=370114118-12112001><FONT color=#0000ff 
  face="Courier New">&nbsp;</FONT></SPAN></FONT></FONT></DIV>
  <DIV><FONT face=arial,helvetica><FONT size=2><SPAN 
  class=370114118-12112001></SPAN></FONT></FONT>&nbsp;</DIV></BLOCKQUOTE>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>Python is one of several good beginners 
languages.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>I personally believe its the best currently available 
</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>which is also suitable for real world use once the 
</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>beginners phase is over. Thats why I chose it for 
</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>my "Learn to Program" book.</SPAN></FONT></DIV>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; PADDING-LEFT: 5px">
  <DIV><FONT face=arial,helvetica><FONT size=2><SPAN 
  class=370114118-12112001>&nbsp;</SPAN>why?&nbsp;&nbsp;<SPAN 
  class=370114118-12112001><FONT color=#0000ff 
  face="Courier New">&nbsp;</FONT></SPAN></FONT></FONT></DIV>
  <DIV><FONT face=arial,helvetica><FONT size=2><SPAN 
  class=370114118-12112001></SPAN></FONT></FONT>&nbsp;</DIV></BLOCKQUOTE>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>For the very basics:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>It has simple syntax, an interactive 
interpreter,</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>very clear error reporting(compared to other 
languages!)</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>its free and has a very good and friendly user 
community.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>For the next step:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>It supports many different types, with strong but 
</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>dynamic typing, it also supports many programming 
</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>paradigms:&nbsp; procedural, functional and 
OO.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001></SPAN></FONT>&nbsp;</DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>Finally:</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>It is powerful, it can do OS stuff as well as GUIs 
and</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001>even quite intensive math based 
programming.</SPAN></FONT></DIV>
<DIV><FONT color=#0000ff face="Courier New" size=2><SPAN 
class=370114118-12112001></SPAN></FONT>&nbsp;</DIV>
<BLOCKQUOTE 
style="BORDER-LEFT: #0000ff 2px solid; MARGIN-LEFT: 5px; PADDING-LEFT: 5px">
  <DIV><FONT size=2><FONT face=arial,helvetica><SPAN 
  class=370114118-12112001>&nbsp;</SPAN>and how is Python useful? or what do you 
  really do with it?&nbsp;<SPAN class=370114118-12112001><FONT color=#0000ff 
  face="Courier New">&nbsp;</FONT></SPAN></FONT></FONT></DIV></BLOCKQUOTE>
<DIV><FONT size=2><FONT face=arial,helvetica><SPAN 
class=370114118-12112001><FONT color=#0000ff face="Courier New">There is a very 
useful section on the Python web </FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=arial,helvetica><SPAN 
class=370114118-12112001><FONT color=#0000ff face="Courier New">site which 
explains what Python can and can't do.</FONT>&nbsp;</SPAN>&nbsp;</FONT><FONT 
color=#0000ff face="Courier New"><SPAN 
class=370114118-12112001>&nbsp;</SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=370114118-12112001>Along with comparisons to other languages etc, 
</SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=370114118-12112001>I suggest you take a look.</SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=370114118-12112001></SPAN></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=2><FONT color=#0000ff face="Courier New"><SPAN 
class=370114118-12112001><FONT color=#000000 face=Arial>Alan 
Gauld</FONT></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN class=370114118-12112001><A 
href="http://www.freenetpages.co.uk/hp/alan.gauld/">http://www.freenetpages.co.uk/hp/alan.gauld/</A></SPAN></FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial><SPAN 
class=370114118-12112001></SPAN></FONT></FONT>&nbsp;</DIV></BODY></HTML>

------_=_NextPart_001_01C16BAA.1AF41260--


From myuen@ucalgary.ca  Mon Nov 12 21:03:52 2001
From: myuen@ucalgary.ca (Mike Yuen)
Date: Mon, 12 Nov 2001 14:03:52 -0700 (MST)
Subject: [Tutor] Difference
Message-ID: <Pine.A41.4.10.10111121400190.13412-100000@acs2.acs.ucalgary.ca>

I'm wondering if there's a simple function that will return the difference
between two lists OR dictionary items.

For example, say i've got the following:
A: [a, b, c, d, e, f, g, h, i]
B: [a, b, d, c, e, g, f, i, h]

I would like to know if there's a comparison function that will tell me
there are 6 differences between lists A,B

Thanks,
M



From ak@silmarill.org  Mon Nov 12 21:23:21 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Mon, 12 Nov 2001 16:23:21 -0500
Subject: [Tutor] Difference
In-Reply-To: <Pine.A41.4.10.10111121400190.13412-100000@acs2.acs.ucalgary.ca>
References: <Pine.A41.4.10.10111121400190.13412-100000@acs2.acs.ucalgary.ca>
Message-ID: <20011112162321.A1334@sill.silmarill.org>

On Mon, Nov 12, 2001 at 02:03:52PM -0700, Mike Yuen wrote:
> I'm wondering if there's a simple function that will return the difference
> between two lists OR dictionary items.
> 
> For example, say i've got the following:
> A: [a, b, c, d, e, f, g, h, i]
> B: [a, b, d, c, e, g, f, i, h]
> 
> I would like to know if there's a comparison function that will tell me
> there are 6 differences between lists A,B
> 
> Thanks,
> M

Well, I don't think there is one but you can write it..

def diff(a, b):
    if type(a) == type({}):
        a = a.keys()
        b = b.keys()
    d = 0
    for i in range(len(a)):
        if a[i] != b[i]:
            d += 1
    print "%d differences between a and b" % d
        
A= "a, b, c, d, e, f, g, h, i".split(',')
B= "a, b, d, c, e, g, f, i, h".split(',')

diff(A, B)

6 differences between a and b

> 
> 
> _______________________________________________
> 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 myuen@ucalgary.ca  Mon Nov 12 21:33:27 2001
From: myuen@ucalgary.ca (Mike Yuen)
Date: Mon, 12 Nov 2001 14:33:27 -0700 (MST)
Subject: [Tutor] Testing for empty line
Message-ID: <Pine.A41.4.10.10111121432530.13416-100000@acs2.acs.ucalgary.ca>

This is a simple question.  How do I test for an empty line when i'm
reading in a file?

Thanks,
M




From paulsid@home.com  Mon Nov 12 22:51:02 2001
From: paulsid@home.com (Paul Sidorsky)
Date: Mon, 12 Nov 2001 15:51:02 -0700
Subject: [Tutor] Difference
References: <Pine.A41.4.10.10111121400190.13412-100000@acs2.acs.ucalgary.ca>
Message-ID: <3BF05256.36969E5A@home.com>

Mike Yuen wrote:

> I'm wondering if there's a simple function that will return the difference
> between two lists OR dictionary items.
> 
> For example, say i've got the following:
> A: [a, b, c, d, e, f, g, h, i]
> B: [a, b, d, c, e, g, f, i, h]
> 
> I would like to know if there's a comparison function that will tell me
> there are 6 differences between lists A,B

Here's a handy list comprehension that will do the job (Python 2.0+) on two
lists A and B:

difflist = [i for i in range(len(A)) if A[i] != B[i]]

In your example this would give:

[2, 3, 5, 6, 7, 8]

The length of the list is the number of differences; the items in it are the
indexes where the differences occur.

Note that this assumes the two lists have the same length.

-- 
======================================================================
Paul Sidorsky                                          Calgary, Canada
paulsid@home.com                      http://members.home.net/paulsid/


From dyoo@hkn.eecs.berkeley.edu  Mon Nov 12 23:00:44 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 12 Nov 2001 15:00:44 -0800 (PST)
Subject: [Tutor] Testing for empty line
In-Reply-To: <Pine.A41.4.10.10111121432530.13416-100000@acs2.acs.ucalgary.ca>
Message-ID: <Pine.LNX.4.21.0111121456200.12487-100000@hkn.eecs.berkeley.edu>

On Mon, 12 Nov 2001, Mike Yuen wrote:

> This is a simple question.  How do I test for an empty line when i'm
> reading in a file?

If you're reading the file, line by line, using readline() or readlines(),
then an "empty" line will only contain the newline character "\n".  You
can take advantage of this by using a comparison against this newline
string:

###
if line == '\n':
    print "This is an empty line."
###


However, be careful about what an "empty" line looks like --- a line
containing spaces wouldn't be considered empty by this comparison, so you
might need to do something more, like strip()ping out whitespace.  Here's
one possible definition that might help:

###
def isEmptyLine(line):
   if string.strip(line) == '':
       return 1
   return 0
###

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



From myuen@ucalgary.ca  Mon Nov 12 23:21:02 2001
From: myuen@ucalgary.ca (Mike Yuen)
Date: Mon, 12 Nov 2001 16:21:02 -0700 (MST)
Subject: [Tutor] Dictionaries
Message-ID: <Pine.A41.4.10.10111121607520.19562-100000@acs2.acs.ucalgary.ca>

I have to use dictionaries for this particular portion.  I've got some
data in the following format:

1
 a b c
 d e f
 g h i

2
 j k l
 m n o
 p q r

And so on.

What I want to do is have 1, 2,... as keys in my dictionary and have each
of the next 3 rows as the data associated with the keys.  The problem i'm
having is that dictionaries are immutable add/delete stuff like lists
meaning I can't get the data to look like:

	{1: a,b,c,d,e,f,g,h,i}

So, if I can combine these 3 rows into 1 row, I can manipulate it easier later.
Any suggestions on how to get around this little dilemma i'm having.


Thanks,
M



From lkvam@venix.com  Tue Nov 13 01:15:14 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Mon, 12 Nov 2001 20:15:14 -0500
Subject: [Tutor] Dictionaries
References: <Pine.A41.4.10.10111121607520.19562-100000@acs2.acs.ucalgary.ca>
Message-ID: <3BF07422.3040801@venix.com>

If I understodd properly, you could replace:
	{1: a,b,c,d,e,f,g,h,i}
with
	{1: [a,b,c,d,e,f,g,h,i]}

The square brackets are used to represnt a list. Parentheses are used to 
denote a tuple.  The parentheses will sometimes be assumed as in your 
case.  a,b,c == (a,b,c).

Lists are mutable, tuples are not mutable.

dict[1][2] = C will replace c with C in your first list.

Mike Yuen wrote:

> I have to use dictionaries for this particular portion.  I've got some
> data in the following format:
> 
> 1
>  a b c
>  d e f
>  g h i
> 
> 2
>  j k l
>  m n o
>  p q r
> 
> And so on.
> 
> What I want to do is have 1, 2,... as keys in my dictionary and have each
> of the next 3 rows as the data associated with the keys.  The problem i'm
> having is that dictionaries are immutable add/delete stuff like lists
> meaning I can't get the data to look like:
> 
> 	{1: a,b,c,d,e,f,g,h,i}
> 
> So, if I can combine these 3 rows into 1 row, I can manipulate it easier later.
> Any suggestions on how to get around this little dilemma i'm having.
> 
> 
> Thanks,
> M
> 
> 
> _______________________________________________
> 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 myuen@ucalgary.ca  Tue Nov 13 01:54:11 2001
From: myuen@ucalgary.ca (Mike Yuen)
Date: Mon, 12 Nov 2001 18:54:11 -0700 (MST)
Subject: [Tutor] Strange problem
Message-ID: <Pine.A41.4.10.10111121849360.19562-100000@acs2.acs.ucalgary.ca>

I'll attach some code to make my question clearer.

RowCol = sys.stdin.readline() # Gets Row / Col
Row = RowCol[0]

counter = 0
for line in sys.stdin.readlines():
        line = string.strip(line)# Have clean line now
        if (counter == 0):
                key = line
                counter = counter + 1
        elif (counter < 4):  ********* PROBLEM HERE! ***********
                data = line
                counter = counter + 1
        else:
                dict[key] = data
                counter = 0

The problem occurs on the line i've indicated above.  If I hardcode it by
putting a 4 it works great and creates the dictionary items I want.
However, when I put Row (which is: Row = RowCol[0]).  The comparison
operation doesn't work properly.

Can someone helpe me out.  I'm pretty stumped as to why.  

* I've put Row and RowCol[0] in place of the 4 above but it still doesn't
work.

Thanks,
M



From lha2@columbia.edu  Tue Nov 13 01:57:21 2001
From: lha2@columbia.edu (Lloyd Hugh Allen)
Date: Mon, 12 Nov 2001 20:57:21 -0500
Subject: [Fwd: Re: [Tutor] Dictionaries]
Message-ID: <3BF07E01.B08B6FD5@mail.verizon.net>

Darn "reply" instead of "reply-to-all"--still not used receiving the
list in not digest-form.

-------- Original Message --------
From: Lloyd Hugh Allen <vze2f978@mail.verizon.net>
Subject: Re: [Tutor] Dictionaries
To: Mike Yuen <myuen@ucalgary.ca>

Have you tried using the data as a tuple? Since tuples are immutable (or
hashable, or something like that), they're allowed to be dictionary
data. Your dictionary in the example below would be

{1: (a,b,c,d,e,f,g,h,i)}

or

{1: ((a,b,c),(d,e,f),(g,h,i))}

or something like that. When you want to play with your data as a list,
send the tuple to list(); when you want to re-store it in the
dictionary, turn it back into a tuple with tuple(). (unless you use the
nested tuple to represent your matrix, in which case you have to be more
creative).

Mike Yuen wrote:
> 
> I have to use dictionaries for this particular portion.  I've got some
> data in the following format:
> 
> 1
>  a b c
>  d e f
>  g h i
> 
> 2
>  j k l
>  m n o
>  p q r
> 
> And so on.
> 
> What I want to do is have 1, 2,... as keys in my dictionary and have each
> of the next 3 rows as the data associated with the keys.  The problem i'm
> having is that dictionaries are immutable add/delete stuff like lists
> meaning I can't get the data to look like:
> 
>         {1: a,b,c,d,e,f,g,h,i}
> 
> So, if I can combine these 3 rows into 1 row, I can manipulate it easier later.
> Any suggestions on how to get around this little dilemma i'm having.
> 
> Thanks,
> M
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


From pobrien@orbtech.com  Tue Nov 13 02:10:40 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Mon, 12 Nov 2001 20:10:40 -0600
Subject: [Fwd: Re: [Tutor] Dictionaries]
In-Reply-To: <3BF07E01.B08B6FD5@mail.verizon.net>
Message-ID: <NBBBIOJPGKJEKIECEMCBMEJALBAA.pobrien@orbtech.com>

Dictionary data can be any type. It is only dictionary keys that must be
immutable/hashable.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Lloyd Hugh Allen
Sent: Monday, November 12, 2001 7:57 PM
To: tutor@python.org
Subject: [Fwd: Re: [Tutor] Dictionaries]

Darn "reply" instead of "reply-to-all"--still not used receiving the
list in not digest-form.

-------- Original Message --------
From: Lloyd Hugh Allen <vze2f978@mail.verizon.net>
Subject: Re: [Tutor] Dictionaries
To: Mike Yuen <myuen@ucalgary.ca>

Have you tried using the data as a tuple? Since tuples are immutable (or
hashable, or something like that), they're allowed to be dictionary
data. Your dictionary in the example below would be



From ak@silmarill.org  Tue Nov 13 02:23:46 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Mon, 12 Nov 2001 21:23:46 -0500
Subject: [Tutor] Strange problem
In-Reply-To: <Pine.A41.4.10.10111121849360.19562-100000@acs2.acs.ucalgary.ca>
References: <Pine.A41.4.10.10111121849360.19562-100000@acs2.acs.ucalgary.ca>
Message-ID: <20011112212346.A2218@sill.silmarill.org>

On Mon, Nov 12, 2001 at 06:54:11PM -0700, Mike Yuen wrote:
> I'll attach some code to make my question clearer.
> 
> RowCol = sys.stdin.readline() # Gets Row / Col
> Row = RowCol[0]
> 
> counter = 0
> for line in sys.stdin.readlines():
>         line = string.strip(line)# Have clean line now
>         if (counter == 0):
>                 key = line
>                 counter = counter + 1
>         elif (counter < 4):  ********* PROBLEM HERE! ***********
>                 data = line
>                 counter = counter + 1
>         else:
>                 dict[key] = data
>                 counter = 0
> 
> The problem occurs on the line i've indicated above.  If I hardcode it by
> putting a 4 it works great and creates the dictionary items I want.
> However, when I put Row (which is: Row = RowCol[0]).  The comparison
> operation doesn't work properly.
> 
> Can someone helpe me out.  I'm pretty stumped as to why.  
> 
> * I've put Row and RowCol[0] in place of the 4 above but it still doesn't
> work.
> 
> Thanks,
> M

Umm.. RowCol[0] is a string, isn't it? You can convert it to an integer
like this:

val = int(RowCol[0]
> 
> 
> _______________________________________________
> 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 lha2@columbia.edu  Tue Nov 13 02:24:50 2001
From: lha2@columbia.edu (Lloyd Hugh Allen)
Date: Mon, 12 Nov 2001 21:24:50 -0500
Subject: [Fwd: Re: [Tutor] Dictionaries]
References: <NBBBIOJPGKJEKIECEMCBMEJALBAA.pobrien@orbtech.com>
Message-ID: <3BF08472.994A1EE1@mail.verizon.net>

Silly me. Glad that I /did/ forward that to the list so that I won't
keep thinking I can't do that (use lists as data).

Thanks.

"Patrick K. O'Brien" wrote:
> 
> Dictionary data can be any type. It is only dictionary keys that must be
> immutable/hashable.
> 
> ---
> Patrick K. O'Brien
> Orbtech
> "I am, therefore I think."
> 
> -----Original Message-----
> From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
> Lloyd Hugh Allen
> Sent: Monday, November 12, 2001 7:57 PM
> To: tutor@python.org
> Subject: [Fwd: Re: [Tutor] Dictionaries]
> 
> Darn "reply" instead of "reply-to-all"--still not used receiving the
> list in not digest-form.
> 
> -------- Original Message --------
> From: Lloyd Hugh Allen <vze2f978@mail.verizon.net>
> Subject: Re: [Tutor] Dictionaries
> To: Mike Yuen <myuen@ucalgary.ca>
> 
> Have you tried using the data as a tuple? Since tuples are immutable (or
> hashable, or something like that), they're allowed to be dictionary
> data. Your dictionary in the example below would be
>


From dyoo@hkn.eecs.berkeley.edu  Tue Nov 13 04:59:16 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 12 Nov 2001 20:59:16 -0800 (PST)
Subject: [Tutor] Dictionaries
In-Reply-To: <Pine.A41.4.10.10111121607520.19562-100000@acs2.acs.ucalgary.ca>
Message-ID: <Pine.LNX.4.21.0111121812460.16494-100000@hkn.eecs.berkeley.edu>

On Mon, 12 Nov 2001, Mike Yuen wrote:

> I have to use dictionaries for this particular portion.  I've got some
> data in the following format:
> 
> 1
>  a b c
>  d e f
>  g h i
> 
> 2
>  j k l
>  m n o
>  p q r
> 
> And so on.
> 
> What I want to do is have 1, 2,... as keys in my dictionary and have each
> of the next 3 rows as the data associated with the keys.  The problem i'm


Hello Mike,

I'm guessing that you'd like something to help parse a bunch of lines
following the format:

###
<Some Key>
    <element> <element> <element>
    <element> <element> <element>
    ...
<empty line>
###


That is, each record is separated by two newlines, and each record has a
fairly consistant format.  If so, then it's not too bad to parse your file
into a dictionary.  Here's some code that sorta does it, in a sloppy
fashion:


###
def parseTextFile(text_of_file):
    """Given a string containing all of the text, returns
    a dictionary that represents the parsing of that file."""
    fragments = string.split(text_of_file, "\n\n")
    dict = {}
    for f in fragments:
        key, value = parseFragment(f)
        dict[key] = value
    return dict


def parseFragment(fragment):
    lines = string.split(fragment, '\n')
    key = string.strip(lines[0])
    value = string.join(lines[1:], ' ')
    return key, value
###




We'd better test this out... *grin*  Let's take a look!

###
>>> sample = """1
... this is a test
... 
... 2
... of the emergency
... broadcast
... 
... 3
... system
... """
>>> parseTextFile(sample)
{'2': 'of the emergency broadcast', '3': 'system ', '1': 'this is a test'}
###


This isn't quite right, since what you're asking sounds more like:

###
    { 2: ['of', 'the', 'emergency', 'broadcast'],
      3: ['system'],
      1: ['this', 'is', 'a', 'test'] }
###

Still, parseTextFile() should help you write the function you're looking
for.


If you have more questions, please feel free to ask them on Tutor.  We'll
be happy to talk more about this.  Hope this helps!



From james_fjm@yahoo.com  Tue Nov 13 06:19:21 2001
From: james_fjm@yahoo.com (=?iso-8859-1?q?James=20Foo?=)
Date: Tue, 13 Nov 2001 06:19:21 +0000 (GMT)
Subject: [Tutor] HTMLgen module download
Message-ID: <20011113061921.69814.qmail@web9603.mail.yahoo.com>

Hi,

Can anyone point to me where to download the HTMLgen
module?

I am running Python 2.1.1 on Linux.

Thanks.

James

=====
Have a heart for them, visit http://www.geocities.com/james_fjm/charity.htm

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


From karthikg@aztec.soft.net  Tue Nov 13 07:38:37 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Tue, 13 Nov 2001 13:08:37 +0530
Subject: [Tutor] HTMLgen module download
In-Reply-To: <20011113061921.69814.qmail@web9603.mail.yahoo.com>
Message-ID: <NEBBJNMDEKBIBCMCNMBDMEMHCIAA.karthikg@aztec.soft.net>

http://starship.python.net/lib.html



-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
James Foo
Sent: Tuesday, November 13, 2001 11:49 AM
To: tutor@python.org
Subject: [Tutor] HTMLgen module download


Hi,

Can anyone point to me where to download the HTMLgen
module?

I am running Python 2.1.1 on Linux.

Thanks.

James

=====
Have a heart for them, visit http://www.geocities.com/james_fjm/charity.htm

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page from News and Sport to Email and
Music Charts
http://uk.my.yahoo.com

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



From aschmidt@nv.cc.va.us  Tue Nov 13 11:57:57 2001
From: aschmidt@nv.cc.va.us (Schmidt, Allen J.)
Date: Tue, 13 Nov 2001 06:57:57 -0500
Subject: [Tutor] How long can a line be for readline() or readlines()
 ??   ((LONG)) file, example and console
Message-ID: <5CDFEBB60E7FD311B9E30000F6D6090608CB8DFD@novamail2.nv.cc.va.us>

I ran my program with the first set up data along with a few other similar
files from different days. It works fine on ALL the files but when it hits
the file with the long line I sent previously, it throughs the error and
does not continue to the file rename but DOES do the import. Almost like it
burps when the line is encountered but continues to the next line and just
continues because the whole line is added to the table.

I ran it again with a new file that had two lines longer than 2048 and it
worked fine. Alan, you may be right and I am looking at that now. Maybe
something in the line itself caused the problem rather than the length. I
will keep checking it.

Thanks to all for helping and responding. 

Allen Schmidt

-----Original Message-----
From: alan.gauld@bt.com [mailto:alan.gauld@bt.com]
Sent: Monday, November 12, 2001 8:34 AM
To: aschmidt@nv.cc.va.us; lkvam@venix.com
Cc: dyoo@hkn.eecs.berkeley.edu; tutor@python.org
Subject: RE: [Tutor] How long can a line be for readline() or
readlines() ?? ((LONG)) file, example and console


> Lines under 2k go in without a hitch. The line I sent is one 
> over the 2k limit.

This is a shot in the dark but....

Are you using the same test data each time? If so is it the 
same line that fails each time? If so what happens if you 
delete that line from the test file?

If that's the only line that fails have you tried printing 
out the split lines?

for L in lineout: print "-------------\n" + L

It just might be that there's something strange happening in 
the substitution or splitting of that particular line?

Just a thought,

Alan g.


From aurumxxl@polbox.com  Tue Nov 13 16:00:30 2001
From: aurumxxl@polbox.com (Irmingard Anna Kotelev)
Date: Tue, 13 Nov 2001 16:00:30
Subject: [Tutor] New York Remembrance
Message-ID: <022ab1203150db1WEB5277@mailto.t-online-com.de>

 Dear friends,

the madness incarnate of  September 11th, 2001 is one which will never 
be
forgotten. How could it be?
This shook the entire world, and my heart was broken along with all of
yours.

I have created a slide show in respectful tribute to all who passed, as
well as the heroics of the people. I know that America...the world... will
not allow this attack to ruffle it's feathers, and I stand and applaude 
for
the strength and resolve of it's people.

God bless America...God bless the world.

Do sign my 'Response to this Tribute' if compelled and please pass this 
on to at least one friend.

http://www.aurumxxl.de/ny/ny.htm

Irmingard Anna Kotelev
Photographer

21th of September 2001










If you have received this email by error, please excuse it, and me for
sending it. Thank you. 


From myuen@ucalgary.ca  Wed Nov 14 00:02:55 2001
From: myuen@ucalgary.ca (Mike Yuen)
Date: Tue, 13 Nov 2001 17:02:55 -0700 (MST)
Subject: [Tutor] Problem with tuple and dictionary
Message-ID: <Pine.A41.4.10.10111131659050.49554-100000@acs2.acs.ucalgary.ca>

I'm writing a larger program and for some reason, I keep getting an error
at the following:

matrix[(curr,last)] = int(diff)

Here's some more code in case the above line isn't the actual problem:
def compare (self, last, dict):
	#
	# Some other irrelevant stuff here
	#

	while (curr < last):
                        dcurr = dict[curr]
                        end = len(dict[last])

                        for index1 in range(end):
                                if dcurr[index1] != dlast[index1]:
                                        diff = diff + 1
                        matrix[(curr,last)] = int(diff) #WhAT's UP HERe?
                        curr = curr + 1 #Get next applicable dict entry
                        diff = 0
                        index1 = 0

Thanks,
M



From urnerk@qwest.net  Wed Nov 14 00:53:51 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Tue, 13 Nov 2001 16:53:51 -0800
Subject: [Tutor] Problem with tuple and dictionary
In-Reply-To: <Pine.A41.4.10.10111131659050.49554-100000@acs2.acs.ucalgar
 y.ca>
Message-ID: <4.2.0.58.20011113164802.00c06d80@pop3.norton.antivirus>

At 05:02 PM 11/13/2001 -0700, Mike Yuen wrote:
>I'm writing a larger program and for some reason,
>I keep getting an error
>at the following:
>
>matrix[(curr,last)] = int(diff)

You should cut and past the error you're getting.

It's OK to use a tuple object as a dictionary key:

   >>> matrix = {}
   >>> t = (1,2)
   >>> matrix[t] = 3
   >>> matrix
   {(1, 2): 3}

I assume you don't mean your matrix to be a 2-dimensional
list, in which case it'd be more like:

   >>> matrix = [[0 for j in range(2)] for i in range(2)]
   >>> matrix
   [[0, 0], [0, 0]]
   >>> matrix[1][1]=3
   >>> matrix[0][1]=2
   >>> matrix
   [[0, 2], [0, 3]]

Kirby



From showell@zipcon.com  Wed Nov 14 01:01:26 2001
From: showell@zipcon.com (Steve Howell)
Date: Tue, 13 Nov 2001 17:01:26 -0800
Subject: [Tutor] Problem with tuple and dictionary
References: <Pine.A41.4.10.10111131659050.49554-100000@acs2.acs.ucalgary.ca>
Message-ID: <3BF1C266.1A25C0F@zipcon.com>

Mike Yuen wrote:
> 
> I'm writing a larger program and for some reason, I keep getting an error
> at the following:
> 
> matrix[(curr,last)] = int(diff)

What's the error?

> 
> Here's some more code in case the above line isn't the actual problem:
> def compare (self, last, dict):
>         #
>         # Some other irrelevant stuff here
>         #
> 
>         while (curr < last):
>                         dcurr = dict[curr]
>                         end = len(dict[last])
> 
>                         for index1 in range(end):
>                                 if dcurr[index1] != dlast[index1]:
>                                         diff = diff + 1
>                         matrix[(curr,last)] = int(diff) #WhAT's UP HERe?
>                         curr = curr + 1 #Get next applicable dict entry
>                         diff = 0
>                         index1 = 0
> 

You probably need to add this line to the method:

global matrix


From dyoo@hkn.eecs.berkeley.edu  Wed Nov 14 01:17:00 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 13 Nov 2001 17:17:00 -0800 (PST)
Subject: [Tutor] Problem with tuple and dictionary
In-Reply-To: <3BF1C266.1A25C0F@zipcon.com>
Message-ID: <Pine.LNX.4.21.0111131716541.1518-100000@hkn.eecs.berkeley.edu>

On Tue, 13 Nov 2001, Steve Howell wrote:

> Mike Yuen wrote:
> > 
> > I'm writing a larger program and for some reason, I keep getting an error
> > at the following:
> > 
> > matrix[(curr,last)] = int(diff)
> 
> What's the error?
> 
> > 
> > Here's some more code in case the above line isn't the actual problem:
> > def compare (self, last, dict):
> >         #
> >         # Some other irrelevant stuff here
> >         #
> > 
> >         while (curr < last):
> >                         dcurr = dict[curr]
> >                         end = len(dict[last])
> > 
> >                         for index1 in range(end):
> >                                 if dcurr[index1] != dlast[index1]:
> >                                         diff = diff + 1
> >                         matrix[(curr,last)] = int(diff) #WhAT's UP HERe?
> >                         curr = curr + 1 #Get next applicable dict entry
> >                         diff = 0
> >                         index1 = 0
> > 
> 
> You probably need to add this line to the method:
> 
> global matrix
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 



From dyoo@hkn.eecs.berkeley.edu  Wed Nov 14 01:30:47 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 13 Nov 2001 17:30:47 -0800 (PST)
Subject: [Tutor] Problem with tuple and dictionary
In-Reply-To: <Pine.LNX.4.21.0111131716541.1518-100000@hkn.eecs.berkeley.edu>
Message-ID: <Pine.LNX.4.21.0111131717260.1518-100000@hkn.eecs.berkeley.edu>

Whoops, sorry, I pressed "send" on accident before even responding to the
question.  Sorry about that!


> I'm writing a larger program and for some reason, I keep getting
> an error at the following:
>
>    matrix[(curr,last)] = int(diff)

> > > What's the error?


If the error really is on this line, there are two things that come to
mind as potential errors:

    1.  Perhaps "matrix" hasn't been set up as a dictionary.  From looking
    at the compare() code, it looks like "matrix" is a global variable, so
    it's very possible that something has mangled "matrix" into something
    that doesn't look like a dictionary anymore.

    2.  Perhaps "diff" doesn't look like an integer.  It isn't too
    surprising that int() breaks on strings that look like words:

    >>> int("nebuchadnezzar")
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    ValueError: invalid literal for int(): nebuchadnezzar


    But what's surprising that trying to int()ify a string like "2.718"
    doesn't work!   At least, not without an intermediate step:

    ###
    >>> int("2.718")
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    ValueError: invalid literal for int(): 2.718
    
    >>> int(float("2.718"))
    2
    ###

However, these are just wild guesses; the bug could be something
completely unexpected.  Error messages are really important because there
are so many things that can go askew in a program...  Send us the error
message too, and once we see it, we'll be better able to focus our
spotlights.

Best of wishes to you.




From myuen@ucalgary.ca  Wed Nov 14 02:02:45 2001
From: myuen@ucalgary.ca (Mike Yuen)
Date: Tue, 13 Nov 2001 19:02:45 -0700 (MST)
Subject: [Tutor] Whitespace
Message-ID: <Pine.A41.4.10.10111131901440.18308-100000@acs2.acs.ucalgary.ca>

I'm not understanding how "whitespace" works for strings. 

I thought we could use it like split, lower, etc.

Can someone provide an example of how this works?

Thank,
M




From shalehperry@home.com  Wed Nov 14 02:12:25 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Tue, 13 Nov 2001 18:12:25 -0800 (PST)
Subject: [Tutor] Whitespace
In-Reply-To: <Pine.A41.4.10.10111131901440.18308-100000@acs2.acs.ucalgary.ca>
Message-ID: <XFMail.20011113181225.shalehperry@home.com>

On 14-Nov-2001 Mike Yuen wrote:
> I'm not understanding how "whitespace" works for strings. 
> 
> I thought we could use it like split, lower, etc.
> 
> Can someone provide an example of how this works?
> 

If you open string.py from your python dist you will see:

whitespace = ' \t\n\r\v\f'

as you can see, it is a string.  Common usage is:

if char in whitespace:
    handle_whitespace(char)

where char is something like 'char = " "' or 'char = "c"'.


From ak@silmarill.org  Wed Nov 14 02:13:20 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Tue, 13 Nov 2001 21:13:20 -0500
Subject: [Tutor] Whitespace
In-Reply-To: <Pine.A41.4.10.10111131901440.18308-100000@acs2.acs.ucalgary.ca>
References: <Pine.A41.4.10.10111131901440.18308-100000@acs2.acs.ucalgary.ca>
Message-ID: <20011113211320.A4677@sill.silmarill.org>

On Tue, Nov 13, 2001 at 07:02:45PM -0700, Mike Yuen wrote:
> I'm not understanding how "whitespace" works for strings. 
> 
> I thought we could use it like split, lower, etc.
> 
> Can someone provide an example of how this works?

Whitespace is blanks, newlines, tabs. You're probably talking about
string.whitespace which is simply a string of all whitespace characters.

>>> string.whitespace
'\t\n\x0b\x0c\r '
>>> print string.whitespace




>>>

You use it like this:

if somechar in string.whitespace:
    print "somechar is whitespace!"

> 
> Thank,
> M
> 
> 
> 
> _______________________________________________
> 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  Wed Nov 14 10:51:27 2001
From: printers@sendme.cz (A)
Date: Wed, 14 Nov 2001 11:51:27 +0100
Subject: [Tutor] Mimetools  and how to use it
Message-ID: <3BF25ABF.27201.B52A60@localhost>

Hi,
>From a web server I receive headers that is an instance of the class 
MIMETOOLS.MESSAGE.
How can decode it to  get something like this

Date: Wed, 14 Nov 2001 10:02:17 GMT
Server: Apache/1.3.6 (Unix) PHP/3.0.14
X-Powered-By: PHP/3.0.14
Set-Cookie: PHPSESSID=000741aaa06ae3645ff0106145f842b5; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0
Pragma: no-cache
Set-Cookie: c_id=bla; path=/
Connection: close
Content-Type: text/html


and how  to extract cookies then?
Any help would be highly appreciated.

Ladislav








From skip@pobox.com (Skip Montanaro)  Wed Nov 14 11:14:30 2001
From: skip@pobox.com (Skip Montanaro) (Skip Montanaro)
Date: Wed, 14 Nov 2001 12:14:30 +0100
Subject: [Tutor] Re: Mimetools  and how to use it
In-Reply-To: <3BF25ABF.27201.B52A60@localhost>
References: <3BF25ABF.27201.B52A60@localhost>
Message-ID: <15346.21014.2141.219451@beluga.mojam.com>

    Ladislav> From a web server I receive headers that is an instance of the
    Ladislav> class MIMETOOLS.MESSAGE.  How can decode it ...

You need to call one of its header retrieval methods (there are several to
choose from).  For more detail, check the mimetools library reference page:

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

and the libref page of rfc822, its base class:

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

    Ladislav> and how to extract cookies then?

Assuming your mimetools.Message instance is referenced by the name "msg",
you'd retrieve the Set-Cookie headers with something like:

    cookies = msg.getallmatchigheaders("Set-Cookie")

Note that you may need to put the actual headers back together.  This method
returns the raw lines, including continuation lines, as separate list
elements. 

-- 
Skip Montanaro (skip@pobox.com)
http://www.mojam.com/
http://www.musi-cal.com/


From cerulean_rodent@yahoo.co.uk  Wed Nov 14 13:23:59 2001
From: cerulean_rodent@yahoo.co.uk (Cerulean Rodent)
Date: Wed, 14 Nov 2001 16:23:59 +0300
Subject: [Tutor] retrieving a variable from a function
Message-ID: <E16401H-00015i-00@ecosse>

Heya, 

Haven't posted in ages - however, today I have yet again been stopped in my tracks by a simple task. 
Suppose I have a script that has several functions; I need to retrieve some data and store it in a 
variable _within_ a function, and later use this data in a different function. So far all I get is a name 
error, since the other function doesn't recognize the bloody variable - there must be a way around it, 
but my brain cells refuse to strike me with a Coder's Satori. Can anybody help?

Cheerio, 

Pope Mickey XXIII, Patron Saint Ov Theriomorphic Memes-----------------------------------------------------
 
 


From scarblac@pino.selwerd.nl  Wed Nov 14 13:34:07 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 14 Nov 2001 14:34:07 +0100
Subject: [Tutor] retrieving a variable from a function
In-Reply-To: <E16401H-00015i-00@ecosse>; from cerulean_rodent@yahoo.co.uk on Wed, Nov 14, 2001 at 04:23:59PM +0300
References: <E16401H-00015i-00@ecosse>
Message-ID: <20011114143407.A25932@pino.selwerd.nl>

On  0, Cerulean Rodent <cerulean_rodent@yahoo.co.uk> wrote:
> Heya, 
> 
> Haven't posted in ages - however, today I have yet again been stopped in my tracks by a simple task. 
> Suppose I have a script that has several functions; I need to retrieve some data and store it in a 
> variable _within_ a function, and later use this data in a different function. So far all I get is a name 
> error, since the other function doesn't recognize the bloody variable - there must be a way around it, 
> but my brain cells refuse to strike me with a Coder's Satori. Can anybody help?

Although there are a few ways to do this, they have in common that they are
usually the wrong way to solve the problem. You don't usually store data
inside a function.

You probably want to return the result and store it, or let the function
store it inside some global or an object, but it would help if you could
explain a bit more about what you're trying to do; if we have more context,
we can explain the pros and cons of different approaches.

-- 
4Remco Gerlich


From K9Trainin1@cs.com  Wed Nov 14 13:54:03 2001
From: K9Trainin1@cs.com (K9Trainin1@cs.com)
Date: Wed, 14 Nov 2001 08:54:03 EST
Subject: [Tutor] (no subject)
Message-ID: <a7.16cb67b6.2923d17b@cs.com>

--part1_a7.16cb67b6.2923d17b_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

I need to know which version of Python to use? and to learn and to get 
without 'the bugs!'   Please --- Thank you - 

--part1_a7.16cb67b6.2923d17b_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

<HTML><FONT FACE=arial,helvetica><FONT  SIZE=2>I need to know which version of Python to use? and to learn and to get without 'the bugs!' &nbsp;&nbsp;Please --- Thank you - </FONT></HTML>

--part1_a7.16cb67b6.2923d17b_boundary--


From lkvam@venix.com  Wed Nov 14 13:55:11 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Wed, 14 Nov 2001 08:55:11 -0500
Subject: [Tutor] retrieving a variable from a function
References: <E16401H-00015i-00@ecosse>
Message-ID: <3BF277BF.2060906@venix.com>

One solution is a global variable:

<python code>
...
special_variable = None	# create the global variable
...
def func1():
	global special_variable
	special_variable = "correct value"
	...

def func2()
	x = special_variable
	...

</python code>

Any function that assigns to a global variable must "declare" that 
variable name as global.

A cute alternative to this is the pocket function that Danny Yoo posted 
recently.  I'll forward that separately.


Cerulean Rodent wrote:

> Heya, 
> 
> Haven't posted in ages - however, today I have yet again been stopped in my tracks by a simple task. 
> Suppose I have a script that has several functions; I need to retrieve some data and store it in a 
> variable _within_ a function, and later use this data in a different function. So far all I get is a name 
> error, since the other function doesn't recognize the bloody variable - there must be a way around it, 
> but my brain cells refuse to strike me with a Coder's Satori. Can anybody help?
> 
> Cheerio, 
> 
> Pope Mickey XXIII, Patron Saint Ov Theriomorphic Memes-----------------------------------------------------
>  
>  
> 
> _______________________________________________
> 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 wilson@visi.com  Wed Nov 14 13:59:24 2001
From: wilson@visi.com (Timothy Wilson)
Date: Wed, 14 Nov 2001 07:59:24 -0600 (CST)
Subject: [Tutor] (no subject)
In-Reply-To: <a7.16cb67b6.2923d17b@cs.com>
Message-ID: <Pine.GSO.4.21.0111140758530.18536-100000@isis.visi.com>

On Wed, 14 Nov 2001 K9Trainin1@cs.com wrote:

> I need to know which version of Python to use? and to learn and to get 
> without 'the bugs!'   Please --- Thank you - 

The latest stable version is 2.1.1. I'd got with that one. Get it at
http://www.python.org/

Have fun!

-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 wilson@visi.com  Wed Nov 14 14:14:40 2001
From: wilson@visi.com (Timothy Wilson)
Date: Wed, 14 Nov 2001 08:14:40 -0600 (CST)
Subject: [Tutor] (no subject)
In-Reply-To: <120.70ddd51.2923d3f6@cs.com>
Message-ID: <Pine.GSO.4.21.0111140812550.18536-100000@isis.visi.com>

On Wed, 14 Nov 2001 K9Trainin1@cs.com wrote:

> In a message dated 11/14/01 7:59:34 AM Central Standard Time, wilson@visi.com 
> writes:
> 
> > The latest stable version is 2.1.1. I'd got with that one. Get it at
> > http://www.python.org/
> 
> when I look at the files there are anywhere from 3-5 or 6 files, a debug zip, 
> and exe and another file extension ---  which onw do i download and which one 
> or ones do I need? and what about the documentation???? too????  thanks 

The version download depends on the platform you're using. The instructions
at http://www.python.org/2.1.1/ give some hints. If you're using Windows,
get the .exe version. It's a self-installer and will include all the
documentation.

-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 alan.gauld@bt.com  Wed Nov 14 17:13:15 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 14 Nov 2001 17:13:15 -0000
Subject: [Tutor] Problem with tuple and dictionary
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0BE@mbtlipnt02.btlabs.bt.co.uk>

> I'm writing a larger program and for some reason, I keep 
> getting an error at the following:
> 
> matrix[(curr,last)] = int(diff)
> 
> Here's some more code in case the above line isn't 
> the actual problem:

We've seen a few of these lately so can I put out a plea
for posers to include the error messages in mails.
They may look cryptic to beginners but python errorv 
traces are actually very very helpful containg, as they 
do, both the actual error report plus the call stack. Usually this is enough
to
obviate the need for debugging.

> def compare (self, last, dict):
> 	#
> 	# Some other irrelevant stuff here
> 	#
> 
> 	while (curr < last):
>                         dcurr = dict[curr]
>                         end = len(dict[last])
> 
>                         for index1 in range(end):
>                                 if dcurr[index1] != dlast[index1]:
>                                         diff = diff + 1
>                         matrix[(curr,last)] = int(diff) 
> #WhAT's UP HERe?
>                         curr = curr + 1 #Get next applicable 
> dict entry
>                         diff = 0
>                         index1 = 0
> 
> Thanks,
> M
> 
> 
> 


From alan.gauld@bt.com  Wed Nov 14 17:19:33 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 14 Nov 2001 17:19:33 -0000
Subject: [Tutor] Whitespace
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0BF@mbtlipnt02.btlabs.bt.co.uk>

> I'm not understanding how "whitespace" works for strings. 

I assume you mean the string.whitespace predefined sequence?
Its used for testing whether something is a whitespace 
charater or not:

while str[i] not in string.whitespace: i += 1

will find the first whitespace char in str.


> I thought we could use it like split, lower, etc.

Nope, its a variable not a function.
Rather like string.numbers, string.punctuation, 
uppercase, lowercase etc.

> Can someone provide an example of how this works?

See above.

Alan G


From lkvam@venix.com  Wed Nov 14 17:48:25 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Wed, 14 Nov 2001 12:48:25 -0500
Subject: [Tutor] Whitespace
References: <Pine.A41.4.10.10111131901440.18308-100000@acs2.acs.ucalgary.ca>
Message-ID: <3BF2AE69.8000403@venix.com>

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65225
ASPN : Python Cookbook : Reversing a String by Words or Characters

This includes examples for splitting strings.  The regular expression 
split at the end may be close to what you actually want.  I assume you 
are really trying to "tokenize" a line of text.

There is a tokenize module included with Python.

Mike Yuen wrote:

> I'm not understanding how "whitespace" works for strings. 
> 
> I thought we could use it like split, lower, etc.
> 
> Can someone provide an example of how this works?
> 
> Thank,
> M
> 
> 
> 
> _______________________________________________
> 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 crapaudada@ifrance.com  Wed Nov 14 18:35:11 2001
From: crapaudada@ifrance.com (crapaudada)
Date: Wed, 14 Nov 2001 19:35:11 +0100
Subject: [Tutor] What is the Python Path in windows 98?
Message-ID: <5.1.0.14.0.20011114192911.025a09e0@df.df.df>

Hello,

I am trying to use Wasp, a template engine written in Python.

In theory, it is platform independent. The documentation says:
"Put Wasp (all the .py files) in any folder as long as it is on your Python 
path."

But I don't know what exactly is the Python Path.

I searched the doc I could find on the web, and with the ActiveState 
distribution. But I couldn't find it.

Anyone has the point?

Thank you very much.

 
______________________________________________________________________________
ifrance.com, l'email gratuit le plus complet de l'Internet !
vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...
http://www.ifrance.com/_reloc/email.emailif




From shalehperry@home.com  Wed Nov 14 18:43:09 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Wed, 14 Nov 2001 10:43:09 -0800 (PST)
Subject: [Tutor] What is the Python Path in windows 98?
In-Reply-To: <5.1.0.14.0.20011114192911.025a09e0@df.df.df>
Message-ID: <XFMail.20011114104309.shalehperry@home.com>

On 14-Nov-2001 crapaudada wrote:
> Hello,
> 
> I am trying to use Wasp, a template engine written in Python.
> 
> In theory, it is platform independent. The documentation says:
> "Put Wasp (all the .py files) in any folder as long as it is on your Python 
> path."
> 
> But I don't know what exactly is the Python Path.
> 
> I searched the doc I could find on the web, and with the ActiveState 
> distribution. But I couldn't find it.
> 

$ python
>>> import sys
>>> sys.path
['', '/usr/lib/python2.1', '/usr/lib/python2.1/plat-linux2', '/usr/lib/python2.\
1/lib-tk', '/usr/lib/python2.1/lib-dynload', '/usr/local/lib/python2.1/site-pac\
kages', '/usr/local/lib/site-python', '/usr/lib/python2.1/site-packages', '/usr\
/lib/site-python']

That is the output on a Debian linux box.  Try that on your machine and it
should give the output you need.



From virketis@fas.harvard.edu  Wed Nov 14 18:48:10 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Wed, 14 Nov 2001 13:48:10 -0500
Subject: [Tutor] What is the Python Path in windows 98?
In-Reply-To: <5.1.0.14.0.20011114192911.025a09e0@df.df.df>
Message-ID: <200111141847.fAEIlTh09149@smtp1.fas.harvard.edu>

The Python path can be found thus:

>>> import sys
>>> sys.path()

# prints out path

>>>sys.path.append("c:/whatever/you/want")

# adds whatever you want to the path

Cheers, 

Pijus

p.s. By the way, this is (to my knowledge) system independent, so path
under win98 is found the same way as under Linux or Mac.
------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis



From pobrien@orbtech.com  Wed Nov 14 19:09:53 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 14 Nov 2001 13:09:53 -0600
Subject: [Tutor] What is the Python Path in windows 98?
In-Reply-To: <200111141847.fAEIlTh09149@smtp1.fas.harvard.edu>
Message-ID: <NBBBIOJPGKJEKIECEMCBOENALBAA.pobrien@orbtech.com>

You can also add an environment variable to your autoexec.bat file, listing
the directories to *add* to the Python path:

SET PYTHONPATH=C:\Code;C:\Zope\lib\python

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."




From crapaudada@ifrance.com  Wed Nov 14 19:20:02 2001
From: crapaudada@ifrance.com (crapaudada)
Date: Wed, 14 Nov 2001 20:20:02 +0100
Subject: [Tutor] What is the Python Path in windows 98?
In-Reply-To: <200111141847.fAEIlTh09149@smtp1.fas.harvard.edu>
References: <5.1.0.14.0.20011114192911.025a09e0@df.df.df>
Message-ID: <5.1.0.14.0.20011114201536.02c0a100@pop.ifrance.com>

I thank you and Mr Perry,

Just a last question:
"sys.path" does work exactly as you say, and I will work again on the sys 
module; but "sys.path()" returns an error message, that I don't understand 
well. It says:
"Traceback (most recent call last):
   File "<pyshell#2>", line 1, in ?
     sys.path()
TypeError: object of type 'list' is not callable"

Is it a misconfiguration of my system?

If not, I don't see why I shouldn't call a list object from the interactive 
prompt. What causes it to fail?

Thanks again.

At 19:48 14/11/01, you wrote:
>The Python path can be found thus:
>
> >>> import sys
> >>> sys.path()
>
># prints out path

 
______________________________________________________________________________
ifrance.com, l'email gratuit le plus complet de l'Internet !
vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...
http://www.ifrance.com/_reloc/email.emailif




From israel@lith.com  Wed Nov 14 19:26:04 2001
From: israel@lith.com (Israel Evans)
Date: Wed, 14 Nov 2001 11:26:04 -0800
Subject: [Tutor] What is the Python Path in windows 98?
Message-ID: <AF020C5FC551DD43A4958A679EA16A15017B3E3D@abbott.lith.com>

    I found that it helps to include a bit before the rest of your python
path to preserve whatever other presets python already has.  In don't know
if this is how it's supposed to be or if it's just me.

My python path goes something like this. ( if I remember correctly, that is.
)

SET PYTHONPATH=%PYTHONPATH%;C:proj\python    (and so on...)

    I had to do this to keep idle working.  It seemed that if I didn't
include that Percenty bit at the front, my pythonpath would make idle's
pythonpath not work.  This way, everyone is happy. 

-----Original Message-----
From: Patrick K. O'Brien [mailto:pobrien@orbtech.com]
Sent: Wednesday, November 14, 2001 11:10 AM
To: PyTutor
Subject: RE: [Tutor] What is the Python Path in windows 98?


You can also add an environment variable to your autoexec.bat file, listing
the directories to *add* to the Python path:

SET PYTHONPATH=C:\Code;C:\Zope\lib\python

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."



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


From scarblac@pino.selwerd.nl  Wed Nov 14 19:24:53 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 14 Nov 2001 20:24:53 +0100
Subject: [Tutor] What is the Python Path in windows 98?
In-Reply-To: <5.1.0.14.0.20011114201536.02c0a100@pop.ifrance.com>; from crapaudada@ifrance.com on Wed, Nov 14, 2001 at 08:20:02PM +0100
References: <5.1.0.14.0.20011114192911.025a09e0@df.df.df> <200111141847.fAEIlTh09149@smtp1.fas.harvard.edu> <5.1.0.14.0.20011114201536.02c0a100@pop.ifrance.com>
Message-ID: <20011114202453.A26448@pino.selwerd.nl>

On  0, crapaudada <crapaudada@ifrance.com> wrote:
> I thank you and Mr Perry,
> 
> Just a last question:
> "sys.path" does work exactly as you say, and I will work again on the sys 
> module; but "sys.path()" returns an error message, that I don't understand 
> well. It says:
> "Traceback (most recent call last):
>    File "<pyshell#2>", line 1, in ?
>      sys.path()
> TypeError: object of type 'list' is not callable"
> 
> Is it a misconfiguration of my system?
> 
> If not, I don't see why I shouldn't call a list object from the interactive 
> prompt. What causes it to fail?

sys.path is a list.

sys.path() tries to call the list.

That fails, since lists aren't callable. Functions and classes are callable,
as well as a few more obscure things.

Calling something runs some code, like the function you are calling. Calling
a class makes a new instance of that class. Calling a list doesn't make sense.


What are you trying to do?

-- 
Remco Gerlich


From ak@silmarill.org  Wed Nov 14 19:29:57 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Wed, 14 Nov 2001 14:29:57 -0500
Subject: [Tutor] retrieving a variable from a function
In-Reply-To: <E16401H-00015i-00@ecosse>
References: <E16401H-00015i-00@ecosse>
Message-ID: <20011114142957.B8348@sill.silmarill.org>

On Wed, Nov 14, 2001 at 04:23:59PM +0300, Cerulean Rodent wrote:
> Heya, 
> 
> Haven't posted in ages - however, today I have yet again been stopped in my tracks by a simple task. 
> Suppose I have a script that has several functions; I need to retrieve some data and store it in a 
> variable _within_ a function, and later use this data in a different function. So far all I get is a name 
> error, since the other function doesn't recognize the bloody variable - there must be a way around it, 
> but my brain cells refuse to strike me with a Coder's Satori. Can anybody help?
> 
> Cheerio, 
> 
> Pope Mickey XXIII, Patron Saint Ov Theriomorphic Memes-----------------------------------------------------

I prefer to either return the variable, or use a class.

def func1():
    var = 1
    return var

def func2(var):
    var2 = var + 2

var = func1()
func2(var)

Or with classes:

class cl:
    def __init__(self):
        self.var = 1

c = cl() # instance of class cl

def func2():
    var2 = c.var + 2



>  
>  
> 
> _______________________________________________
> 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 pobrien@orbtech.com  Wed Nov 14 19:47:31 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Wed, 14 Nov 2001 13:47:31 -0600
Subject: [Tutor] What is the Python Path in windows 98?
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15017B3E3D@abbott.lith.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBOENCLBAA.pobrien@orbtech.com>

I have never found that to be required by IDLE, PythonWin, PyCrust (which I
wrote), Boa, etc. If you go to a dos prompt and type "set" you will see all
your environment variables and their values. If you only have one "SET
PYTHONPATH" statement in your autoexec.bat file, your example should be the
same as without the %PYTHONPATH%.

---
Patrick K. O'Brien
Orbtech
"I am, therefore I think."

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Israel Evans
Sent: Wednesday, November 14, 2001 1:26 PM
To: PyTutor
Subject: RE: [Tutor] What is the Python Path in windows 98?

    I found that it helps to include a bit before the rest of your python
path to preserve whatever other presets python already has.  In don't know
if this is how it's supposed to be or if it's just me.

My python path goes something like this. ( if I remember correctly, that is.
)

SET PYTHONPATH=%PYTHONPATH%;C:proj\python    (and so on...)

    I had to do this to keep idle working.  It seemed that if I didn't
include that Percenty bit at the front, my pythonpath would make idle's
pythonpath not work.  This way, everyone is happy.




From virketis@fas.harvard.edu  Wed Nov 14 20:22:08 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Wed, 14 Nov 2001 15:22:08 -0500
Subject: [Tutor] What is the Python Path in windows 98?
In-Reply-To: <20011114202453.A26448@pino.selwerd.nl>
References: <5.1.0.14.0.20011114201536.02c0a100@pop.ifrance.com>
 <5.1.0.14.0.20011114192911.025a09e0@df.df.df>
 <200111141847.fAEIlTh09149@smtp1.fas.harvard.edu>
 <5.1.0.14.0.20011114201536.02c0a100@pop.ifrance.com>
Message-ID: <200111142021.fAEKLRh01319@smtp1.fas.harvard.edu>

>> "sys.path" does work exactly as you say, and I will work again on the sys 
>> module; but "sys.path()" returns an error message, that I don't understand 

>
>sys.path is a list.
>
>sys.path() tries to call the list.
>
>That fails, since lists aren't callable. Functions and classes are callable,
>as well as a few more obscure things.

Precisely. This was my bad, because I suggested (quite wrongly) to
crapaudada to enter sys.path() myself. I should have thought before I
banged out the command.:) Sorry ...

Pijus
------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis



From israel@lith.com  Wed Nov 14 20:39:08 2001
From: israel@lith.com (Israel Evans)
Date: Wed, 14 Nov 2001 12:39:08 -0800
Subject: [Tutor] two questions..
Message-ID: <AF020C5FC551DD43A4958A679EA16A15017B3E3E@abbott.lith.com>

	

Hello everyone...  I'm stumped by what are probably two simple questions
that may be aimed at OOP more than Python but since I'm using the language,
I'll need to know how python handles these sorts of things.


anyway, here goes...

 1.     If I have a hierarchy of classes, the children of which derive a
particular attribute from an attribute present in the parent, and I want to
set up a distribution pattern for that attribute to determine which children
get what amounts of said attribute, how do I alter that pattern for one
particular child and still save the original pattern for later use.  This
would be something like adding a temporary modifier to the chosen child that
can be removed at a later date.  

    To restate, how does one add a modifier to an object that can later be
removed.  I'd also like to access a list of these modifiers.

2.    This one is really making my head hurt at the moment.   When I have
two objects that come with their own attribute and functions, and make them
work together, that third thing is something like a new object, but what
about the particular point at which the two objects connect?   Take for
example the upper arm and the lower arm.  Where they connect is called the
elbow.  Would this be a separate object?  Would the Arm object be compose of
these along with the hand, wrist and shoulder?  When the lines between
objects get fuzzy, what do you do?


Thanks for any help!

~Israel~ 




From israel@lith.com  Wed Nov 14 21:20:18 2001
From: israel@lith.com (Israel Evans)
Date: Wed, 14 Nov 2001 13:20:18 -0800
Subject: [Tutor] two questions..
Message-ID: <AF020C5FC551DD43A4958A679EA16A15017B3E40@abbott.lith.com>

Thanks,

In addition, how and where would one describe relations between things,
inside the objects themselves or in a sort of wrapper?   I suppose the
problems come when trying to realistically model real world things and their
resulting mechanics, rather than trying to mimic their functionality.

~Israel~

-----Original Message-----
From: Sean 'Shaleh' Perry [mailto:shalehperry@home.com] 
Sent: Wednesday, November 14, 2001 12:49 PM
To: Israel Evans
Cc: [tutor]
Subject: Re: [Tutor] two questions..

> 
> 2.    This one is really making my head hurt at the moment.   When I have
> two objects that come with their own attribute and functions, and make
them
> work together, that third thing is something like a new object, but what
> about the particular point at which the two objects connect?   Take for
> example the upper arm and the lower arm.  Where they connect is called the
> elbow.  Would this be a separate object?  Would the Arm object be compose
of
> these along with the hand, wrist and shoulder?  When the lines between
> objects get fuzzy, what do you do?
> 

sometimes you have to let go of the black and white and use the grey.  Let's
consider your body example in programming.

Say I have a game I am developing and want to represent a humanoid form.
This
humanoid will be injured during the course of the game.  In some games, you
just get one hit and you have to start over so I just have a Humanoid class.

Then let's consider a simple fighting game.  Perhaps an opponent could
target
large items like Arm or Leg or Torso.  So I could have a class for each of
those.  Then consider a really complicated game design where I could use the
Eagle claw grip on an opponents elbow.

The point is your objects should be as granular as you need.  A 3d renderer
trying to make lifelike movement probably has an upper arm connected via an
elbow to a lower arm.  A stick figure just has an arm.

If you step away from the literal the 'glue' may just be the container
class.


From shalehperry@home.com  Wed Nov 14 20:49:18 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Wed, 14 Nov 2001 12:49:18 -0800 (PST)
Subject: [Tutor] two questions..
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15017B3E3E@abbott.lith.com>
Message-ID: <XFMail.20011114124918.shalehperry@home.com>

> 
> 2.    This one is really making my head hurt at the moment.   When I have
> two objects that come with their own attribute and functions, and make them
> work together, that third thing is something like a new object, but what
> about the particular point at which the two objects connect?   Take for
> example the upper arm and the lower arm.  Where they connect is called the
> elbow.  Would this be a separate object?  Would the Arm object be compose of
> these along with the hand, wrist and shoulder?  When the lines between
> objects get fuzzy, what do you do?
> 

sometimes you have to let go of the black and white and use the grey.  Let's
consider your body example in programming.

Say I have a game I am developing and want to represent a humanoid form.  This
humanoid will be injured during the course of the game.  In some games, you
just get one hit and you have to start over so I just have a Humanoid class. 
Then let's consider a simple fighting game.  Perhaps an opponent could target
large items like Arm or Leg or Torso.  So I could have a class for each of
those.  Then consider a really complicated game design where I could use the
Eagle claw grip on an opponents elbow.

The point is your objects should be as granular as you need.  A 3d renderer
trying to make lifelike movement probably has an upper arm connected via an
elbow to a lower arm.  A stick figure just has an arm.

If you step away from the literal the 'glue' may just be the container class.


From shalehperry@home.com  Wed Nov 14 21:40:59 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Wed, 14 Nov 2001 13:40:59 -0800 (PST)
Subject: [Tutor] two questions..
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15017B3E40@abbott.lith.com>
Message-ID: <XFMail.20011114134059.shalehperry@home.com>

On 14-Nov-2001 Israel Evans wrote:
> 
> Thanks,
> 
> In addition, how and where would one describe relations between things,
> inside the objects themselves or in a sort of wrapper?   I suppose the
> problems come when trying to realistically model real world things and their
> resulting mechanics, rather than trying to mimic their functionality.
> 

Hard and fast rules are often wrong.  That said, objects should rarely know
about what they talk to otherwise you create arbitrary dependencies that are
not needed.

The usual approach is for classes to define a standard method name to look for.
 For instance the python's HTMLParser class (import htmllib) takes a formatter
class as an argument.  As long as it supports a few method calls the HTML
parser does not care what it is the formatter is doing.  Formatters have been
written to dump output to files and stdout, display the parsed html as a GUI,
and other tasks.

The real world is a complex and odd place, computers are much nicer (-:  Being
able to think of objects as real things helps us programmers get the job done. 
However we must not become fooled -- it is an illusion we create.


From dsh8290@rit.edu  Wed Nov 14 23:11:16 2001
From: dsh8290@rit.edu (dman)
Date: Wed, 14 Nov 2001 18:11:16 -0500
Subject: [Tutor] two questions..
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15017B3E3E@abbott.lith.com>; from israel@lith.com on Wed, Nov 14, 2001 at 12:39:08PM -0800
References: <AF020C5FC551DD43A4958A679EA16A15017B3E3E@abbott.lith.com>
Message-ID: <20011114181116.A9059@harmony.cs.rit.edu>

On Wed, Nov 14, 2001 at 12:39:08PM -0800, Israel Evans wrote:
| 	
| 
| Hello everyone...  I'm stumped by what are probably two simple questions
| that may be aimed at OOP more than Python but since I'm using the language,
| I'll need to know how python handles these sorts of things.
| 
| 
| anyway, here goes...
| 
|  1.     If I have a hierarchy of classes, the children of which derive a
| particular attribute from an attribute present in the parent, and I want to
| set up a distribution pattern for that attribute to determine which children
| get what amounts of said attribute, how do I alter that pattern for one
| particular child and still save the original pattern for later use.  This
| would be something like adding a temporary modifier to the chosen child that
| can be removed at a later date.  

Some of this is a bit confusing to me :
    if an attribute is defined in a base class, all instances of
    subclasses will have that attribute.

    if that attribute is an *instance attribute* then each instance
    has its own copy and can be changed without affecting other
    instances

    if the attribute is a *class attribute* ("static" in C++ and Java)
    then it is shared by all instances because the attribute belongs
    in the class.
 
|     To restate, how does one add a modifier to an object that can later be
| removed.  I'd also like to access a list of these modifiers.

If you want to restore the old value of a reference, you need to store
the old value somewhere before overwriting it.


Hmm, suppose you had :

class B :
    cmember = 1

class C( B ) :
    def foo( self ) :
        print self.cmember
    def bar( self ) :
        self.cmember = 5
    def baz( self ) :
        del self.cmember

>>> o = C()
>>> o.foo()
1
>>> o.bar()
>>> o.foo()
5
>>> o.baz()
>>> o.foo()
1
>>>


Is this what you are looking for?

What happens here is the class object "B" has an attribute named
"cmember".  In the first call to foo(), the search for self.cmember
finds B.cmember first.  When I called bar() I created a reference in
the instance (not the class) and gave it a value.  Thus the next call
to foo() finds self.cmember first, and never gets to B.cmember (which
hasn't changed).  Then I delete that reference in baz() so that foo()
finds B.cmember like it did the first time.

| 2.    This one is really making my head hurt at the moment.   When I have
| two objects that come with their own attribute and functions, and make them
| work together, that third thing is something like a new object, but what
| about the particular point at which the two objects connect?   Take for
| example the upper arm and the lower arm.  Where they connect is called the
| elbow.  Would this be a separate object?  Would the Arm object be compose of
| these along with the hand, wrist and shoulder?  When the lines between
| objects get fuzzy, what do you do?

I think you mean :

class A :
    def a( self ) :
        print "a"

class B :
    def b( self ) :
        print "b"

class Composer : # note, no inheritance
    def __init__( self ) :
        self._a = A()
        self._b = B()

    def a( self ) :
        print "composer a"
        self._a.a()
        print "composer a some more"

    def b( self ) :
        print "composer b"
        self._b.b()
        print "composer b some more"

o = Composer()

You want to know what the Composer instance is?  It is just an object.
The fact that is uses composition instead of inheritance is mainly an
implementation detail.  Often times, though, composition is preferred
over inheritance because it reduces icky inheritance trees.  In
python, composition is much easier since __getattr__ and __setattr__
can be written to automatically defer implementation to the internal
objects without actually writing all the methods.

I highly recommend the book "Design Patterns" by the Gang of Four (so
they're called, I forget their real names).  It discusses many design
patterns for OO software.  One of the patterns is called "Composite"
which is similar to (though not exactly) what is shown above.

HTH,
-D



From israel@lith.com  Wed Nov 14 23:56:34 2001
From: israel@lith.com (Israel Evans)
Date: Wed, 14 Nov 2001 15:56:34 -0800
Subject: [Tutor] two questions..
Message-ID: <AF020C5FC551DD43A4958A679EA16A15017B3E41@abbott.lith.com>

||  Some of this is a bit confusing to me :

Hmmm, let me try the body analogy, since that seems to be where my head is.
:)

Let's say that you have a formula for specifying what percentage of body fat
that a particular region of the body should have.  All constraints of
minimum and maximum aside, if we wanted to change the weight of the body but
have the specified body part deviate from it's normal fat distribution, how
would this best be set up?   Ok now for D&D analogies...  If you got two
magical rings of Polymorphism, one that made you hugely fat and one that
reduced that annoying wiggly neck wattle, we would need to have some sort of
object that affected the normal way in which calculations are done on our
character.

Could this be done by having the regular calculations for body weight look
for any modifier thingamabobs and if it found some, factor that into the
calculations, and if not, then just do the calculations as normal?



||  You want to know what the Composer instance is?  It is just an object. 
||  The fact that is uses composition instead of inheritance is mainly an
||  implementation detail.  Often times, though, composition is preferred 
||  over inheritance because it reduces icky inheritance trees.  In python,
||  composition is much easier since __getattr__ and __setattr__ 
||  can be written to automatically defer implementation to the internal 
|  objects without actually writing all the methods.

So, if an object is considered (or is focused, or concerned with) two
different parts of two separate things, then I'd make a composite of the two
things?   I understand this concept in respect to multi part objects, but
when it comes to something like a joint which isn't concerned with the
entirety of the two objects that have come together, but the specific points
at which they come together and the functionality that arises out of such a
coupling, my mind seems a little fuzzy.

I think I'll have to check out that design patterns book, I've heard it
mentioned before!

Thanks!

~Israel~


From urnerk@qwest.net  Thu Nov 15 00:47:57 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Wed, 14 Nov 2001 16:47:57 -0800
Subject: [Tutor] two questions..
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15017B3E41@abbott.lith.com>
Message-ID: <4.2.0.58.20011114164515.00c7e8c0@pop3.norton.antivirus>

>
>Could this be done by having the regular calculations for body weight look
>for any modifier thingamabobs and if it found some, factor that into the
>calculations, and if not, then just do the calculations as normal?

Sure, why not?

  >>> class Body:
         def __init__(self):
             self.modifiers = {}  # define thingamabobs here


  >>> b = Body()
  >>> b.modifiers
  {}
  >>> b.modifiers['fat content'] = 20
  >>> class Process:

         def checkfat(self, body):
            bmods = body.modifiers
            if 'fat content' in bmods:  # fat checker
                 if bmods>15:
                    print "Sorry, too fat"
            else:
                print 'OK, normal'      # default even if no value


  >>> p = Process()
  >>> p.checkfat(b)
  Sorry, too fat
  >>> b2 = Body()
  >>> p.checkfat(b2)  # b2 has no fat content thingamabob
  OK, normal

Kirby



From israel@lith.com  Thu Nov 15 01:00:56 2001
From: israel@lith.com (Israel Evans)
Date: Wed, 14 Nov 2001 17:00:56 -0800
Subject: [Tutor] two questions..
Message-ID: <AF020C5FC551DD43A4958A679EA16A15017B3E42@abbott.lith.com>

Thanks!

Talking about this, or at least attempting to describe these sorts of things
to other people really helps the brain!

-----Original Message-----
From: Kirby Urner [mailto:urnerk@qwest.net]
Sent: Wednesday, November 14, 2001 4:48 PM
To: Israel Evans
Cc: [tutor]
Subject: RE: [Tutor] two questions..



>
>Could this be done by having the regular calculations for body weight look
>for any modifier thingamabobs and if it found some, factor that into the
>calculations, and if not, then just do the calculations as normal?

Sure, why not?

  >>> class Body:
         def __init__(self):
             self.modifiers = {}  # define thingamabobs here


  >>> b = Body()
  >>> b.modifiers
  {}
  >>> b.modifiers['fat content'] = 20
  >>> class Process:

         def checkfat(self, body):
            bmods = body.modifiers
            if 'fat content' in bmods:  # fat checker
                 if bmods>15:
                    print "Sorry, too fat"
            else:
                print 'OK, normal'      # default even if no value


  >>> p = Process()
  >>> p.checkfat(b)
  Sorry, too fat
  >>> b2 = Body()
  >>> p.checkfat(b2)  # b2 has no fat content thingamabob
  OK, normal

Kirby


From dsh8290@rit.edu  Thu Nov 15 04:05:27 2001
From: dsh8290@rit.edu (dman)
Date: Wed, 14 Nov 2001 23:05:27 -0500
Subject: [Tutor] two questions..
In-Reply-To: <AF020C5FC551DD43A4958A679EA16A15017B3E41@abbott.lith.com>; from israel@lith.com on Wed, Nov 14, 2001 at 03:56:34PM -0800
References: <AF020C5FC551DD43A4958A679EA16A15017B3E41@abbott.lith.com>
Message-ID: <20011114230527.A9368@harmony.cs.rit.edu>

On Wed, Nov 14, 2001 at 03:56:34PM -0800, Israel Evans wrote:
| 
| ||  Some of this is a bit confusing to me :
| 
| Hmmm, let me try the body analogy, since that seems to be where my head is.
| :)
| 
| Let's say that you have a formula for specifying what percentage of body fat
| that a particular region of the body should have.  All constraints of
| minimum and maximum aside, if we wanted to change the weight of the body but
| have the specified body part deviate from it's normal fat distribution, how
| would this best be set up?   Ok now for D&D analogies...  If you got two
| magical rings of Polymorphism, one that made you hugely fat and one that
| reduced that annoying wiggly neck wattle, we would need to have some sort of
| object that affected the normal way in which calculations are done on our
| character.
| 
| Could this be done by having the regular calculations for body weight look
| for any modifier thingamabobs and if it found some, factor that into the
| calculations, and if not, then just do the calculations as normal?

This can be done, however you are more likely to end up with spaghetti
code (error-prone too) as you increase the number of magic flags the
computation depends on.

For something like this I would recommend the Strategy pattern.
Basically you would define a function that performs the computation
for only a single situation (no magic flags).  You can define any
number of these functions.  Then you give this function to your object
and this function determines how the object behaves.

An example :

def default_strat( weight ) :
    """
    This function is the default strategy we will give our body part.
    Given the weight of the body part, it returns the weight of the
    fat in the body part.
    """
    return (weight * 0.20)
    

class BodyPart :
    def __init__( self , weight ) :
        self.weight = weight # the weight of the body part

    def change_strategy( self , new_strat ) :
        """
        Provide an interface to change the strategy at any time.
        """
        self.strat = new_strat

    def how_fat( self ) :
        """
        Return the weight of the fat in the body part.
        """
        return self.strat( self.weight ) 

def skin_and_bones( weight ) :
    return weight * 0.02

def blubber( weight ) :
    return weight * 0.70

my_gut = BodyPart( 50 ) # you choose the units :-)
print my_gut.how_fat()
my_gut.change_strategy( skin_and_bones )
print my_gut.how_fat()
my_gut.change_strategy( blubber )
print my_gut.how_fat()



The body part itself doesn't know or care how the amount of fat is
determined.  It could be done by consulting an external measurement
device to get real world info on the fly, or it could be as simple as
the expressions above.

This particular incarnation of the Strategy pattern allows the
strategy of the object to be changed at any time.  Simply plug in a
new object that conforms to the interface (takes a numeric argument,
returns a numeric value, each with specified significance) and the
behavior of the object is changed.

Sometimes the object only allows specifying the strategy at creation
time.  For example I recently finished a project that took advantage
of Moshe Zadka's PMS framework.  He has a "Folder" class which has an
external storage ("Server", though it could be local disk) object to
manage the persistant storage of the messages.  There are also
"SortedFolder" and "LimitFolder" classes.  These classes follow the
Decorator pattern to decorate the base folder instance (basically they
wrap a "Folder", could be Sorted or Limited, and alter the view
clients have of the messages contained).  In addition they follow the
Strategy pattern : you pass in a function (at creation time) that
defines how the messages should be sorted or limited (filtered) and
the folder behaves that way.  Another [Sorted|Limit]Folder can be
instantiated with a different function plugged into it and it behaves
differently.  This makes it very easy to plug new functionality into
the system with little modification.

| | You want to know what the Composer instance is?  It is just an object. 
| | The fact that is uses composition instead of inheritance is mainly an
| | implementation detail.  Often times, though, composition is preferred 
| | over inheritance because it reduces icky inheritance trees.  In python,
| | composition is much easier since __getattr__ and __setattr__ 
| | can be written to automatically defer implementation to the internal 
| | objects without actually writing all the methods.
| 
| So, if an object is considered (or is focused, or concerned with) two
| different parts of two separate things, then I'd make a composite of the two
| things?   I understand this concept in respect to multi part objects, but
| when it comes to something like a joint which isn't concerned with the
| entirety of the two objects that have come together, but the specific points
| at which they come together and the functionality that arises out of such a
| coupling, my mind seems a little fuzzy.
 
First you need to specify your goals.  Does this elbow exist solely to
connect the upper arm to the lower arm?  Does it server any other
purpose?  If not, then you can probably forget about it in your
program.  If you are trying to perform real-life simulations or
measurements then you will need it, and it will have the job of
allowing or preventing motion and have the potential to cause pain.

If you simply want to have a "person" then body parts are often
irrelevant -- you don't really need an arm to withdraw funds from your
bank account (simply invoke the right method).  However Quake would
look really funny if the characters had no arms.

When trying to model objects for a software system, consider the data
and the functionality the object will encapsulate.  Don't include it
just because the real world has it.  As Kirby said, objects (in a
computer) are just an illusion anyways (it's all the same bits in the
end, whether you use Python or ASM).

| I think I'll have to check out that design patterns book, I've heard it
| mentioned before!

You won't regret it!

-D



From Maria" <intertorg@mail.com  Thu Nov 15 13:30:51 2001
From: Maria" <intertorg@mail.com (Maria)
Date: Thu, 15 Nov 2001 05:30:51 -0800
Subject: [Tutor] Making over Half Million Dollars every 4 to 5 Months from your Home
Message-ID: <E164Kfr-0006hD-00@mail.python.org>

AS SEEN ON NATIONAL TV: 
Making over Half Million Dollars every 4 to 5 Months from your Home for an
investment of only 
$25 U.S. Dollars expense one time 
THANK'S TO THE COMPUTER AGE AND THE INTERNET! 
================================================== 
BE A MILLIONAIRE LIKE OTHERS WITHIN A YEAR!!! 
Before you say ''Bull'', please read the following. 
This is the letter you have been hearing about on the news lately. Due to
the popularity 
of this letter on the Internet, a national weekly news program recently
devoted an entire 
show to the investigation of this program described below, to see if it
really can make 
people money. The show also investigated whether or not the program was
legal. Their findings 
proved once and for all that there are ''absolutely NO Laws prohibiting
the participation in 
the program and if people can follow the simple instructions, they are
bound to make some 
mega bucks with only $25 out of pocket cost''. DUE TO THE RECENT INCREASE
OF POPULARITY 
& RESPECT THIS PROGRAM HAS ATTAINED, IT IS CURRENTLY WORKING BETTER THAN
EVER. 
This is what one had to say: ''Thanks to this profitable opportunity. I
was approached many times before 
but each time I passed on it. I am so glad I finally joined just to see
what one could expect 
in return for the minimal effort and money required. To my astonishment, I
received 
total $610,470.00 in 21 weeks, with money still coming in." Pam Hedland,
Fort Lee, New Jersey. 
=================================================== 
Here is another testimonial: "This program has been around for a long time
but I never believed 
in it. But one day when I received this again in the mail I decided to
gamble my $25 on it. I 
followed the simple instructions and 3 weeks later the money started to
come in. 
First month I only made $240.00 but the next 2 months after that I made a
total of $290,000.00. 
So far, in the past 8 months by re-entering the program, I have made over
$710,000.00 and I am 
playing it again. The key to success in this program is to follow the
simple steps and NOT change 
anything.'' More testimonials later but first, 
===== PRINT THIS NOW FOR YOUR FUTURE REFERENCE ====== 
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 
If you would like to make at least $500,000 every 4 to 5 months easily And
comfortably, please 
read the following...THEN READ IT AGAIN and AGAIN!!! 
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 
FOLLOW THE SIMPLE INSTRUCTION BELOW AND YOUR FINANCIAL DREAMS WILL COME
TRUE, 
GUARANTEED! 
INSTRUCTIONS: 
=====Order all 5 reports shown on the list below ===== 
For each report, send $5 CASH, THE NAME & NUMBER OF THE REPORT YOU ARE
ORDERING and 
YOUR E-MAIL ADDRESS to the person whose name appears ON THAT LIST next to
the report. 
MAKE SURE YOUR RETURN ADDRESS IS ON YOUR ENVELOPE TOP LEFT CORNER in case
of any mail 
problems. 
=== When you place your order, make sure you order each of the 5 reports. 
You will need all 5 reports so that you can save them on your computer and
resell them. 
YOUR TOTAL COST $5 X 5=$25.00. 
Within a few days you will receive, vie e-mail, each of the 5 reports from
these 5 different individuals. 
Save them on your computer so they will be accessible for you to send to
the 1,000's of people 
who will order them from you. Also make a floppy of these reports and keep
it on your desk in 
case something happen to your computer. 
IMPORTANT - DO NOT alter the names of the people who are listed next to
each report, or 
their sequence on the list, in any way other than what is instructed below
in step 
'' 1 through 6 '' or you will lose out on majority of your profits. Once
you understand 
the way this works, you will also see how it does not work if you change
it. Remember, this 
method has been tested, and if you alter, it will NOT work !!! People have
tried to put their 
friends/relatives names on all five thinking they could get all the money.
But it does not 
work this way. Believe us, we all have tried to be greedy and then nothing
happened. So Do Not 
try to change anything other than what is instructed. Because if you do,
it will not work for 
you. Remember, honesty reaps the reward!!! 
1.... After you have ordered all 5 reports, take this advertisement and
REMOVE the 
name & address of the person in REPORT # 5. This person has made it
through the cycle and 
is no doubt counting their fortune. 
2.... Move the name & address in REPORT # 4 down TO REPORT # 5. 
3.... Move the name & address in REPORT # 3 down TO REPORT # 4. 
4.... Move the name & address in REPORT # 2 down TO REPORT # 3. 
5.... Move the name & address in REPORT # 1 down TO REPORT # 2 
6.... Insert YOUR name & address in the REPORT # 1 Position. 
PLEASE MAKE SURE you copy every name & address ACCURATELY! 
========================================================== 
**** Take this entire letter, with the modified list of names, and save it
on your computer. 
DO NOT MAKE ANY OTHER CHANGES. 
Save this on a disk as well just in case you lose any data. To assist you
with marketing 
your business on the internet, the 5 reports you purchase will provide you
with invaluable 
marketing information which includes how to send bulk e-mails legally,
where to find thousands 
of free classified ads and much more. There are 2 Primary methods to get
this venture going: 
METHOD # 1: BY SENDING BULK E-MAIL LEGALLY 
========================================================== 
Let's say that you decide to start small, just to see how it goes, and we
will assume You and those 
involved 
send out only 5,000 e-mails each. Let's also assume that the mailing
receive only a 0.2% response 
(the response could be much better but lets just say it is only 0.2%. Also
many people will send 
out hundreds of thousands e-mails instead of only 5,000 each). 
Continuing with this example, you send out only 5,000 e-mails. With a 0.2%
response, that is 
only 10 orders for report # 1. Those 10 people responded by sending out
5,000 e-mail each for 
a total of 50,000. Out of those 50,000 e-mails only 0.2% responded with
orders. 
That's=100 people responded and ordered Report # 2. Those 100 people mail
out 5,000 e-mails each 
for a total of 500,000 e-mails. The 0.2% response to that is 1000 orders
for Report # 3. Those 
1000 people send out 5,000 e-mails each for a total of 5 million e-mails
sent out. The 0.2% 
response to that is 10,000 orders for Report # 4. Those 10,000 people send
out 5,000 e-mails 
each for a total of 50,000,000 (50 million) e-mails. The 0.2% response to
that is 100,000 orders 
for Report # 5 THAT'S 100,000 ORDERS TIMES $5 EACH=$500,000.00 (half
million). 
Your total income in this example is: 1..... $50 + 2..... $500 +
3.....$5,000 + 4.... $50,000 + 
5..... $500,000 ....... Grand Total=$555,550.00 
NUMBERS DO NOT LIE. GET A PENCIL & PAPER AND FIGUREOUT THE WORST POSSIBLE
RESPONSES AND 
MATTER HOW YOU CALCULATE IT, YOU WILL STILL MAKE A LOT OF MONEY ! 
========================================================= 
REMEMBER FRIEND, THIS IS ASSUMING ONLY 10 PEOPLE ORDERING OUT OF 5,000 YOU
MAILED TO. 
Dare to think for a moment what would happen if everyone or half or even
one 4th of those 
people mailed 100,000e-mails each or more? There are over 150 million
people on the Internet 
worldwide and counting. Believe me, many people will do just that, and
more! 
METHOD # 2 : BY PLACING FREE ADS ON THE INTERNET 
======================================================= 
Advertising on the net is very very inexpensive and there are hundreds of
FREE places to advertise. 
Placing a lot of free ads on the Internet will easily get a larger
response. We strongly suggest 
you start with Method # 1 and add METHOD # 2 as you go along. For every $5
you receive, all you 
must do is e-mail them the Report they ordered. That's it. Always provide
same day service on 
all orders. This will guarantee that the e-mail they send out, with your
name and address on it, 
will be prompt because they can not advertise until they receive the
report. 
=========== AVAILABLE REPORTS ==================== 
ORDER EACH REPORT BY ITS NUMBER & NAME ONLY. Notes: Always send $5 cash
(U.S. CURRENCY) for 
each Report. 
Checks NOT accepted. Make sure the cash is concealed by wrapping it in at
least 2 sheets of paper. 
On one of those sheets of paper, Write the NUMBER & the NAME of the Report
you are ordering, 
YOUR E-MAIL ADDRESS and your name and postal address. 
PLACE YOUR ORDER FOR THESE REPORTS NOW : 
==================================================== 
REPORT# 1: The Insider's Guide to Advertising for Free on the Net 
Order Report #1 from: 

Marìa Luz Ruiz
P.O Box 3279-1000
San José, Costa Rica
América Central
_____________________________________________ 
REPORT # 2: The Insider's Guide to Sending Bulk e-mail on the Net 
Order Report # 2 from: 

Nada Mahmood 
P.O. Box 5385 
Manama, Bahrain 
Arabian Gulf 


_________________________________________________________ 
REPORT # 3: Secret to Multilevel Marketing on the Net 
Order Report # 3 from : 

Kamalarora 
m237,Vikaspuri, 
Newdelhi_110018 
India 






___________________________________________________________ 
REPORT # 4: How to Become a Millionaire Utilizing MLM & the Net 
Order Report # 4 from: 

Mahdokht Kaz 
1175 Road 6025 
Zinj 360, Bahrain 
Arabian Gulf 
____________________________________________________________ 
REPORT #5: How to Send Out 0ne Million e-mails for Free 
Order Report # 5 from: 

P. Condinho 
2549 Mason Heights 
Mississauga, Ontario 
L5B 2S3, Canada 

____________________________________________________________ 
$$$$$$$$$ YOUR SUCCESS GUIDELINES $$$$$$$$$$$ 
Follow these guidelines to guarantee your success: 
=== If you do not receive at least 10 orders for Report #1 within 2 weeks,
continue sending 
e-mails until you do. === After you have received 10 orders, 2 to 3 weeks
after that you should 
receive 100 orders or more for REPORT # 2. If you did not, continue
advertising or sending 
e-mails until you do. 
=== Once you have received 100 or more orders for Report # 2, YOU CAN
RELAX, because the system 
is already working for you, and the cash will continue to roll in ! THIS
IS IMPORTANT TO 
REMEMBER: Every time your name is moved down on the list, you are placed
in front of a Different 
report. You can KEEP TRACK of your PROGRESS by watching which report
people are ordering from you. 
IF YOU WANT TO GENERATE MORE INCOME SEND ANOTHER BATCH OF E-MAILS AND
START THE 
WHOLE PROCESS AGAIN. 
There is NO LIMIT to the income you can generate from this business !!! 
====================================================== 
FOLLOWING IS A NOTE FROM THE ORIGINATOR OF THIS PROGRAM: You have just
received information 
that can give you financial freedom for the rest of your life, with NO
RISK and JUST A LITTLE 
BIT OF EFFORT. You can make more money in the next few weeks and months
than you have ever 
imagined. 
Follow the program EXACTLY AS INSTRUCTED. Do Not change it in any way. It
works exceedingly well 
as it is now. Remember to e-mail a copy of this exciting report after you
have put your name and 
address in Report #1 and moved others to #2 ...........#5 as instructed
above. One of the people 
you send this to may send out 100,000 or more e-mails and your name will
be on every one of them. 
Remember though, the more you send out the more potential customers you
will reach. So my friend, 
I have given you the ideas, information, materials and opportunity to
become financially independent. 
IT IS UP TO YOU NOW ! 
============ MORE TESTIMONIALS ================ 
"My name is Mitchell. My wife, Jody and I live in Chicago. I am an
accountant with a major 
U.S. Corporation and I make pretty good money. When I received this
program I grumbled to Jody about 
receiving ''junk mail''. I made fun of the whole thing,spouting my
knowledge of the population 
and percentages involved. I ''knew'' it wouldn't work. Jody totally
ignored my supposed 
intelligence and few days later she jumped in with both feet. I made
merciless fun of her, 
and was ready to lay the old ''I told you so'' on her when the thing
didn't work. Well, the 
laugh was on me! Within 3 weeks she had received 50 responses. Within the
next 45 days she had 
Received total $ 147,200.00 ........... all cash! I was shocked. I have
joined Jody in her 
''hobby''. Mitchell Wolf M.D., Chicago, Illinois 
====================================================== 
''Not being the gambling type, it took me several weeks to make up my mind
to participate in this plan. 
But conservative that I am, I decided that the initial investment was so
little that there was 
just no way that I wouldn't get enough orders to at least get my money
back''. '' I was surprised 
when I found my medium size post office box crammed with orders. I made
$319,210.00in the first 
12 weeks. The nice thing about this deal is that it does not matter where
people live. There 
simply isn't a better investment with a faster return and so big." Dan
Sondstrom, Alberta, Canada 
======================================================= 
''I had received this program before. I deleted it, but later I wondered
if I should have given it 
a try. Of course, I had no idea who to contact to get another copy, so I
had to wait until I was 
e-mailed again by someone else.........11 months passed then it luckily
came again...... I 
did not delete this one! I made more than $490,000 on my first try and all
the money came within 
22 weeks." Susan De Suza, New York, N.Y. 
======================================================= 
''It really is a great opportunity to make relatively easy money with
little cost to you. I followed 
the simple instructions carefully and within 10 days the money started to
come in. My first 
month I made $20,560.00 and by the end of third month my total cash count
was $362,840.00. Life 
is beautiful, Thanx to internet.". Fred Dellaca, Westport, New Zealand 
======================================================= 
ORDER YOUR REPORTS TODAY AND GET STARTED ON 'YOUR' ROAD TO FINANCIAL
FREEDOM ! 
======================================================= 
If you have any questions of the legality of this program, contact the
Office of Associate Director 
for Marketing Practices, Federal Trade Commission, Bureau of Consumer
Protection, 
Washington, D.C.


From israel@lith.com  Thu Nov 15 16:13:34 2001
From: israel@lith.com (Israel Evans)
Date: Thu, 15 Nov 2001 08:13:34 -0800
Subject: [Tutor] two questions..
Message-ID: <AF020C5FC551DD43A4958A679EA16A15017B3E43@abbott.lith.com>

   Thank you so much!  You explain this very well!  Now I know I will
definitely have to get that book.

Thanks!

-----Original Message-----
From: dman [mailto:dsh8290@rit.edu]
Sent: Wednesday, November 14, 2001 8:05 PM
To: [tutor]
Subject: Re: [Tutor] two questions..


On Wed, Nov 14, 2001 at 03:56:34PM -0800, Israel Evans wrote:
| 
| ||  Some of this is a bit confusing to me :
| 
| Hmmm, let me try the body analogy, since that seems to be where my head
is.
| :)
| 
| Let's say that you have a formula for specifying what percentage of body
fat
| that a particular region of the body should have.  All constraints of
| minimum and maximum aside, if we wanted to change the weight of the body
but
| have the specified body part deviate from it's normal fat distribution,
how
| would this best be set up?   Ok now for D&D analogies...  If you got two
| magical rings of Polymorphism, one that made you hugely fat and one that
| reduced that annoying wiggly neck wattle, we would need to have some sort
of
| object that affected the normal way in which calculations are done on our
| character.
| 
| Could this be done by having the regular calculations for body weight look
| for any modifier thingamabobs and if it found some, factor that into the
| calculations, and if not, then just do the calculations as normal?

This can be done, however you are more likely to end up with spaghetti
code (error-prone too) as you increase the number of magic flags the
computation depends on.

For something like this I would recommend the Strategy pattern.
Basically you would define a function that performs the computation
for only a single situation (no magic flags).  You can define any
number of these functions.  Then you give this function to your object
and this function determines how the object behaves.

An example :

def default_strat( weight ) :
    """
    This function is the default strategy we will give our body part.
    Given the weight of the body part, it returns the weight of the
    fat in the body part.
    """
    return (weight * 0.20)
    

class BodyPart :
    def __init__( self , weight ) :
        self.weight = weight # the weight of the body part

    def change_strategy( self , new_strat ) :
        """
        Provide an interface to change the strategy at any time.
        """
        self.strat = new_strat

    def how_fat( self ) :
        """
        Return the weight of the fat in the body part.
        """
        return self.strat( self.weight ) 

def skin_and_bones( weight ) :
    return weight * 0.02

def blubber( weight ) :
    return weight * 0.70

my_gut = BodyPart( 50 ) # you choose the units :-)
print my_gut.how_fat()
my_gut.change_strategy( skin_and_bones )
print my_gut.how_fat()
my_gut.change_strategy( blubber )
print my_gut.how_fat()



The body part itself doesn't know or care how the amount of fat is
determined.  It could be done by consulting an external measurement
device to get real world info on the fly, or it could be as simple as
the expressions above.

This particular incarnation of the Strategy pattern allows the
strategy of the object to be changed at any time.  Simply plug in a
new object that conforms to the interface (takes a numeric argument,
returns a numeric value, each with specified significance) and the
behavior of the object is changed.

Sometimes the object only allows specifying the strategy at creation
time.  For example I recently finished a project that took advantage
of Moshe Zadka's PMS framework.  He has a "Folder" class which has an
external storage ("Server", though it could be local disk) object to
manage the persistant storage of the messages.  There are also
"SortedFolder" and "LimitFolder" classes.  These classes follow the
Decorator pattern to decorate the base folder instance (basically they
wrap a "Folder", could be Sorted or Limited, and alter the view
clients have of the messages contained).  In addition they follow the
Strategy pattern : you pass in a function (at creation time) that
defines how the messages should be sorted or limited (filtered) and
the folder behaves that way.  Another [Sorted|Limit]Folder can be
instantiated with a different function plugged into it and it behaves
differently.  This makes it very easy to plug new functionality into
the system with little modification.

| | You want to know what the Composer instance is?  It is just an object. 
| | The fact that is uses composition instead of inheritance is mainly an
| | implementation detail.  Often times, though, composition is preferred 
| | over inheritance because it reduces icky inheritance trees.  In python,
| | composition is much easier since __getattr__ and __setattr__ 
| | can be written to automatically defer implementation to the internal 
| | objects without actually writing all the methods.
| 
| So, if an object is considered (or is focused, or concerned with) two
| different parts of two separate things, then I'd make a composite of the
two
| things?   I understand this concept in respect to multi part objects, but
| when it comes to something like a joint which isn't concerned with the
| entirety of the two objects that have come together, but the specific
points
| at which they come together and the functionality that arises out of such
a
| coupling, my mind seems a little fuzzy.
 
First you need to specify your goals.  Does this elbow exist solely to
connect the upper arm to the lower arm?  Does it server any other
purpose?  If not, then you can probably forget about it in your
program.  If you are trying to perform real-life simulations or
measurements then you will need it, and it will have the job of
allowing or preventing motion and have the potential to cause pain.

If you simply want to have a "person" then body parts are often
irrelevant -- you don't really need an arm to withdraw funds from your
bank account (simply invoke the right method).  However Quake would
look really funny if the characters had no arms.

When trying to model objects for a software system, consider the data
and the functionality the object will encapsulate.  Don't include it
just because the real world has it.  As Kirby said, objects (in a
computer) are just an illusion anyways (it's all the same bits in the
end, whether you use Python or ASM).

| I think I'll have to check out that design patterns book, I've heard it
| mentioned before!

You won't regret it!

-D


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


From discuss@sendme.cz  Thu Nov 15 21:46:34 2001
From: discuss@sendme.cz (A)
Date: Thu, 15 Nov 2001 22:46:34 +0100
Subject: [Tutor] Is it a job for Thread or Process?
Message-ID: <3BF445CA.3859.12160B8@localhost>

Hello,
In my Python script I would like to start one function of this script 
in a different thread or process?
That function sends an email.
Can you please give me an example how I can start a new thread 
or process under Win32 systems?

 Is it better to  use a new thread  or a new process for this task?
Thank you for help.
Ladislav


From printers@sendme.cz  Thu Nov 15 21:48:12 2001
From: printers@sendme.cz (A)
Date: Thu, 15 Nov 2001 22:48:12 +0100
Subject: [Tutor] Is it a job for Thread or Process?
Message-ID: <3BF4462D.18995.122E154@localhost>


Hello,
In my Python script I would like to start one function of this script 
in a different thread or process?
That function sends an email.
Can you please give me an example how I can start a new thread 
or process under Win32 systems?

 Is it better to  use a new thread  or a new process for this task?
Thank you for help.
Ladislav



From ak@silmarill.org  Thu Nov 15 22:02:23 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Thu, 15 Nov 2001 17:02:23 -0500
Subject: [Tutor] Is it a job for Thread or Process?
In-Reply-To: <3BF445CA.3859.12160B8@localhost>
References: <3BF445CA.3859.12160B8@localhost>
Message-ID: <20011115170223.A15055@sill.silmarill.org>

On Thu, Nov 15, 2001 at 10:46:34PM +0100, A wrote:
> Hello,
> In my Python script I would like to start one function of this script 
> in a different thread or process?
> That function sends an email.
> Can you please give me an example how I can start a new thread 
> or process under Win32 systems?
> 
>  Is it better to  use a new thread  or a new process for this task?
> Thank you for help.
> Ladislav

Why use either? Sending a typical e-mail should take 1/10th of a second
or less, I imagine..

> 
> _______________________________________________
> 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 dsh8290@rit.edu  Thu Nov 15 22:20:18 2001
From: dsh8290@rit.edu (dman)
Date: Thu, 15 Nov 2001 17:20:18 -0500
Subject: [Tutor] Is it a job for Thread or Process?
In-Reply-To: <20011115170223.A15055@sill.silmarill.org>; from sill@optonline.net on Thu, Nov 15, 2001 at 05:02:23PM -0500
References: <3BF445CA.3859.12160B8@localhost> <20011115170223.A15055@sill.silmarill.org>
Message-ID: <20011115172018.A12693@harmony.cs.rit.edu>

On Thu, Nov 15, 2001 at 05:02:23PM -0500, Andrei Kulakov wrote:
| On Thu, Nov 15, 2001 at 10:46:34PM +0100, A wrote:
| > Hello,
| > In my Python script I would like to start one function of this script 
| > in a different thread or process?
| > That function sends an email.
| > Can you please give me an example how I can start a new thread 
| > or process under Win32 systems?
| > 
| >  Is it better to  use a new thread  or a new process for this task?
| > Thank you for help.
| > Ladislav
| 
| Why use either? Sending a typical e-mail should take 1/10th of a second
| or less, I imagine..

It depends on the email subsystem and the network.  If you use unix
you can simply pipe to sendmail and forget about it.  With windows you
likely need to make the SMTP connection yourself, and the network and
size of the message has a huge effect.


Might your program need to exit before the email is finished sending?
What happens if the program crashes?  Does the email-sending component
need to report back to the main component?  

If you want the email to be send regardless of the state of the rest
of the system, I think an independent process is a good choice.  If
the email-seding component needs to communicate back with the other
components, then threads are easier to use for that.

HTH,
-D



From financialguide@lycosasia.com  Thu Nov 15 22:11:24 2001
From: financialguide@lycosasia.com (China Guide)
Date: Fri, 16 Nov 2001 06:11:24 +0800
Subject: [Tutor] To : tutor@python.org, China Financial Guide 2002
Message-ID: <326576-2200111415221124700@lycosasia.com>

China Financial Guide 2002 has been published!
=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=3D=3D=3D=3D=3D=3D=3D=3D=3D

We are glad to inform that we have published "China Financial Guide 2002",=
 which lists down all financial institutions (local and foreign) operating=
 in China=2E

China has emerged as the most important market in Asia=2E The attractivene=
ss of China market is further enhanced with China joining the World Trade =
Organization=2E  No organization can afford to ignore this important marke=
t in Asia=2E The vast and untapped China economy provides the best busines=
s opportunity and growth engine for your organization=2E

China Financial Guide 2002 gives you the timely and comprehensive director=
y containing a complete listing of all the local and foreign financial ins=
titutions in China=2E This directory is the key reference guide for both f=
inancial and non-financial organizations worldwide that are interested in =
capturing market shares in China=2E Organizations, government authorities,=
 financial institutions, multinational companies or any companies that are=
 interested in China will find this guide useful=2E

Whether your organization is searching for local financial partners for ti=
e-up or locating the nearest financial institutions in China for your fina=
ncing needs, this directory is a must that provides you with all the relev=
ant information=2E

Who needs this directory:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Financial Institutions
Key master and reference guide for all your important financial contacts i=
n China=2E Search for the right local partners in the financial industry=2E=
 Know who and where other market players have established operations in Ch=
ina=2E

Government / International Bodies
Must have directory to guide all your governmental missions and business r=
elated assignments=2E

Associations
Relevant information for all your members to assist their business develop=
ment efforts in China

Multinational Companies
Important contacts and decision makers for marketing your products and ser=
vices=2E Key contacts for your financial requirements in China=2E

Libraries / Embassies
Key reference materials for users, members and for general enquiries=2E

Exporters, Traders and Manufacturing Companies
Assist your company to sell to potential buyers in the financial industry =
in China=2E Key contacts for your financial requirements in China=2E

Features of China Financial Guide 2002:
=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=3D=3D

1200 pages of handy and useful information=2E
1500 financial institutions=2E  More than 1500 financial institutions cove=
red in the guide=2E
5000 key contacts=2E  More than 5000 decision makers in the financial indu=
stry in China=2E

This bilingual directory consists of useful information on:

=B7=09Addresses
=B7=09Telephone numbers
=B7=09Fax numbers
=B7=09Email addresses
=B7=09Website / URL
=B7=09Key management personnel
=B7=09Financial and other information

Of all (local and foreign) financial players in China namely:

=B7=09Banks
=B7=09Exchanges
=B7=09Insurance Companies
=B7=09Fund Management Companies
=B7=09Trust and Securities Companies
=B7=09Private Equity and Venture Capital Companies=20

Book Specifications:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Title : China Financial Guide 2002, Directory of Local and Foreign Financi=
al Institutions in China
ISBN : 981-04-4115-0
CIP/LC : HG3333, 332=2E102551-dc21, SLS2001026603
Edition : First Edition, 2002
Print Size : A5
Pages : 1,184 pages
Cover : Softcopy
Binding : Perfect String Binding

Selling Price [Total : USD138 per copy]
=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=3D

Selling price of the China Financial Guide 2002:
United States Dollar, USD98 per copy + USD40 per copy for global priority =
shipping and handling charges=2E
[Total: USD138 per copy]

Email Enquiry
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

Email : chinaguide@lycosasia=2Ecom

Order
=3D=3D=3D=3D=3D

Name:________________________________
Company:_____________________________
Delivery Address:_______________________
Postal Code:___________________________
Telephone:____________________________
Facsimile:_____________________________
Country:______________________________
Email:________________________________
Quantity:______________________________
Total Amount:__________________________

Each copy costs USD98 plus USD40 delivery charges (total USD138)=2E  Pleas=
e email us if your organization is keen to purchase a copy of this guide=2E=


Many thanks and regards
Raymond








From NwOrlnsBoy504@aol.com  Fri Nov 16 03:54:19 2001
From: NwOrlnsBoy504@aol.com (NwOrlnsBoy504@aol.com)
Date: Thu, 15 Nov 2001 22:54:19 EST
Subject: [Tutor] I need help
Message-ID: <6a.1682dbb0.2925e7eb@aol.com>

--part1_6a.1682dbb0.2925e7eb_boundary
Content-Type: text/plain; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

I am new at this but I would like to know how to "crack" into a java applet 
game.. is there anyway to beable to do it with Python??

--part1_6a.1682dbb0.2925e7eb_boundary
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: 7bit

<HTML><FONT FACE=arial,helvetica><FONT  SIZE=2>I am new at this but I would like to know how to "crack" into a java applet game.. is there anyway to beable to do it with Python??</FONT></HTML>

--part1_6a.1682dbb0.2925e7eb_boundary--


From ed@iterunet.com  Fri Nov 16 05:05:04 2001
From: ed@iterunet.com (Edy Lie)
Date: Fri, 16 Nov 2001 13:05:04 +0800
Subject: [Tutor] Demonize module
Message-ID: <LHEEKPJKJNOJPGDPPECAKEIMCIAA.ed@iterunet.com>

May I know where can I get daemonize.py ?

Thanks


From toodles@yifan.net  Fri Nov 16 11:19:16 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Fri, 16 Nov 2001 19:19:16 +0800
Subject: [Tutor] Demonize module
References: <LHEEKPJKJNOJPGDPPECAKEIMCIAA.ed@iterunet.com>
Message-ID: <001701c16e90$8b1093f0$0300a8c0@sun>

Hi Edy,

Remember, Vaults of Parnassus is your friend :)

daemonize.py is available at the following page:
http://starship.python.net/crew/jjkunce/
(I hope it's the same one you're looking for)

I just searched Vaults of Parnassus, for future reference, the URL is:
http://www.vex.net/parnassus/

Regards,
Andrew Wilkins


----- Original Message ----- 
From: "Edy Lie" <ed@iterunet.com>
To: "Tutor" <tutor@python.org>
Sent: Friday, November 16, 2001 1:05 PM
Subject: [Tutor] Demonize module


> May I know where can I get daemonize.py ?
> 
> Thanks
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 



From dsh8290@rit.edu  Fri Nov 16 15:44:34 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 16 Nov 2001 10:44:34 -0500
Subject: [Tutor] I need help
In-Reply-To: <6a.1682dbb0.2925e7eb@aol.com>; from NwOrlnsBoy504@aol.com on Thu, Nov 15, 2001 at 10:54:19PM -0500
References: <6a.1682dbb0.2925e7eb@aol.com>
Message-ID: <20011116104433.A12929@harmony.cs.rit.edu>

On Thu, Nov 15, 2001 at 10:54:19PM -0500, NwOrlnsBoy504@aol.com wrote:
| I am new at this but I would like to know how to "crack" into a java applet 
| game.. is there anyway to beable to do it with Python??

You can probably do it with most languages, if you can get the right
bits in the right places.  You'll most likely want lower level stuff
so you can do "random" bit twiddling.  Learn hexadecimal too.

-D



From dsh8290@rit.edu  Fri Nov 16 15:50:43 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 16 Nov 2001 10:50:43 -0500
Subject: [Tutor] I need help
In-Reply-To: <6a.1682dbb0.2925e7eb@aol.com>; from NwOrlnsBoy504@aol.com on Thu, Nov 15, 2001 at 10:54:19PM -0500
References: <6a.1682dbb0.2925e7eb@aol.com>
Message-ID: <20011116105043.B12929@harmony.cs.rit.edu>

On Thu, Nov 15, 2001 at 10:54:19PM -0500, NwOrlnsBoy504@aol.com wrote:
| I am new at this but I would like to know how to "crack" into a java applet 
| game.. is there anyway to beable to do it with Python??


PS. (I should have included this in my previous post)

    You'll get much better help and answers if you are actually trying
    to solve a programming problem.  The people on this list aren't
    very interested in cracking.  Also read ESR's essay
    "How To Become A Hacker"
        http://www.tuxedo.org/~esr/faqs/hacker-howto.html

-D



From lep@aber.ac.uk  Fri Nov 16 18:52:27 2001
From: lep@aber.ac.uk (Leighton Pritchard)
Date: Fri, 16 Nov 2001 18:52:27 +0000
Subject: [Tutor] Problem seeing NT networked drives
Message-ID: <5.1.0.14.0.20011116184457.03097970@pophost.aber.ac.uk>

Hi all,

I'm having trouble viewing shared, networked (WinNT) directories from 
Python. The usual DOS commands work, e.g. :

D:\Temp>dir \\wordsworth\pub\

  Volume in drive \\wordsworth\pub has no label.
  Volume Serial Number is 401B-814E

  Directory of \\wordsworth\pub

14/08/01  15:29         <DIR>          .
14/08/01  15:29         <DIR>          ..
29/10/92  16:55                    296 DERIV.M
03/04/01  13:54                  6,542 MICROS.GFD
14/08/01  15:29         <DIR>          minitab
22/05/01  17:23         <DIR>          Strep IR 3 run 110401
                6 File(s)          6,838 bytes
                          10,592,698,368 bytes free

but from within Python I can't see the directory, and os.path.isdir() 
doesn't seem to want to know. I've checked the FAQ, and searched Google and 
GoogleDeja, but the only advice I can find is to make sure that I'm putting 
all the backslashes in, which I think I am...

 >>> os.path.isdir('\\\\wordsworth\\pub\\')
0
 >>> os.path.isdir('\\\\wordsworth\\pub')
0
 >>> os.path.isdir('//wordsworth/pub/')
0
 >>> os.path.isdir('//wordsworth/pub')
0

Please could someone point me in the right direction for a solution?


-- 
Leighton
E: lep@aber.ac.uk; leighton@widdowquinn.fsnet.co.uk
W: http://users.aber.ac.uk/lep
PGP public key - http://www.keyserver.net (0x47B4A485)



From Bruce.Lee-Shanok@cognos.com  Fri Nov 16 22:00:56 2001
From: Bruce.Lee-Shanok@cognos.com (Lee-Shanok, Bruce)
Date: Fri, 16 Nov 2001 17:00:56 -0500
Subject: [Tutor] Letters & Digits
Message-ID: <FB15E670DA55D51185350008C786514A0140E9CD@sottexch1.cognos.com>

I'm currently doing some manual parsing of a string in Python, and I need to
find a way to make sure it consists only of a particular group of
characters. 

I may also later need to ensure that it does not include any of a number of
characters. 

I know there are constants in Python that define all the digits, letters,
printable characters, etc. What I'm wondering is if there's a clean and easy
way to test each character in a string to see if they match (or do not
match) characters from those lists. So far the best I've been able to come
up with are sequences of for loops, but I'm imagining there must be a better
way.

Cheers,
Bruce

This message may contain privileged and/or confidential information.  If you
have received this e-mail in error or are not the intended recipient, you
may not use, copy, disseminate, or distribute it; do not open any
attachments, delete it immediately from your system and notify the sender by
e-mail promptly that you have done so.  Thank You.


From Charlie@begeistert.org  Fri Nov 16 22:22:10 2001
From: Charlie@begeistert.org (Charlie Clark)
Date: Fri, 16 Nov 2001 23:22:10 +0100
Subject: [Tutor] Help with ODBC, SQL & Unicode
Message-ID: <1005949330_PM_BeOS.Charlie@begeistert.org>

Dear list,

it's been a bit of a struggle this week: databases are not my strong 
point. After a couple of days working out how to set timestamps in an 
SQL-database I'm now closer to understanding parameters. There's a catch 
however.

consider the following bit of code

c.execute('INSERT INTO my_table \ 
		(strHeadline, dtTimestampIn, iMarked)\ 
		VALUES (?, ?, ?)', 
		(headline, time.localtime(time.time()[:6], 1)) 

where c is my cursor object and headline a string and I'm using mxODBC 
for the connection.

This only works for strings which only contain 7-bit ASCII characters. 
But I've got German text which is full of ä, ö, ü and ß. Up until 
now I've been working with formatted strings which avoids this problem 
but is really difficult to use when it comes to setting the date. What's 
the correct way to do this?

Thanx very much

Charlie




From dyoo@hkn.eecs.berkeley.edu  Fri Nov 16 22:42:56 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 16 Nov 2001 14:42:56 -0800 (PST)
Subject: [Tutor] Letters & Digits   [regular expressions]
In-Reply-To: <FB15E670DA55D51185350008C786514A0140E9CD@sottexch1.cognos.com>
Message-ID: <Pine.LNX.4.21.0111161426010.10295-100000@hkn.eecs.berkeley.edu>

On Fri, 16 Nov 2001, Lee-Shanok, Bruce wrote:

> I know there are constants in Python that define all the digits,
> letters, printable characters, etc. What I'm wondering is if there's a
> clean and easy way to test each character in a string to see if they
> match (or do not match) characters from those lists. So far the best
> I've been able to come up with are sequences of for loops, but I'm
> imagining there must be a better way.

Hmmm... I know I should try to resist the urge to mention regular
expressions, but it's too hard!  *grin*


Regular expressions may help you in this case --- they're used to find
specific patterns in text.  Here's one example that may help you:

###
>>> only_digits = re.compile(r"""  ^      # at the very start...           
...                                \d+    # we only want digits!
...                                $      # Even up to the end.      
...                           """, re.VERBOSE)
>>> only_digits.search("42")
<SRE_Match object at 0x8131c70>
>>> only_digits.search("hello")
>>> only_digits.search("he42llo")
>>> only_digits.search("1234567890")
<SRE_Match object at 0x81311e0>
###

The "only_digits" regular expression knows how to recognize a digit
string.  You should be able to modify this example to make it a little
smarter.


You can find out more about regular expressions in the regex HOWTO on
Python.org:

    http://py-howto.sourceforge.net/regex/regex.html


Also, there's a great regular expression tutorial from the Perl folks at:

    http://www.perl.com/CPAN-local/doc/FMTEYEWTK/regexps.html

It's a fairly fun piece to read, and the concepts in the tutorial there
transfers nicely to Python.


Regular expressions are very powerful, and that's the problem: sometimes,
they're just so seductive that they obscure potentially better solutions.


Hope this helps!



From dsh8290@rit.edu  Fri Nov 16 22:44:07 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 16 Nov 2001 17:44:07 -0500
Subject: [Tutor] Letters & Digits
In-Reply-To: <FB15E670DA55D51185350008C786514A0140E9CD@sottexch1.cognos.com>; from Bruce.Lee-Shanok@cognos.com on Fri, Nov 16, 2001 at 05:00:56PM -0500
References: <FB15E670DA55D51185350008C786514A0140E9CD@sottexch1.cognos.com>
Message-ID: <20011116174406.A13758@harmony.cs.rit.edu>

On Fri, Nov 16, 2001 at 05:00:56PM -0500, Lee-Shanok, Bruce wrote:
| I'm currently doing some manual parsing of a string in Python, and I need to
| find a way to make sure it consists only of a particular group of
| characters. 
| 
| I may also later need to ensure that it does not include any of a number of
| characters. 

Learn regular expressions if you don't know them already.

| I know there are constants in Python that define all the digits, letters,
| printable characters, etc. What I'm wondering is if there's a clean and easy
| way to test each character in a string to see if they match (or do not
| match) characters from those lists. So far the best I've been able to come
| up with are sequences of for loops, but I'm imagining there must be a better
| way.

In the string module there are the attributes :

    digits
    uppercase
    lowercase
    whitespace
    punctuation
    printable


You probably want something like :

import re , string
# this is a regex that matches any single character that is not
# printable
nonprintable_ch = re.compile( "[^" + string.printable + "]" )
# this regex matches any sequence of printable characters,
# you can use this if you want to get the "words" out of a string
#   containing non-printable characters
printable_word = re.compile( "[" + string.printable + "]+" )
def contains_only_printable( s ) :
    return nonprintable_re.match( s ) is None

print contains_only_printable( "^B" )
print contains_only_printable( "a" )

$ python2.1 test.py 
0
1


(I created the test file using vim and entered that non-printable
character using the sequence '^Vx02' where '^V' means Ctrl-V)

HTH,
-D



From cliff@ember.com  Fri Nov 16 23:47:47 2001
From: cliff@ember.com (cliff@ember.com)
Date: Fri, 16 Nov 2001 18:47:47 -0500
Subject: [Tutor] Extending using SWIG: typdef-ed types
Message-ID: <3BF55F53.17626.25967D1@localhost>

<color><param>0100,0100,0100</param>I would like to import some existing C functions into Python using 
SWIG.  Many of these have user-defined types in either the 
argument list or as a return value, for example:


/*-------  Sample C header File ----- */


typedef unsigned char int8u;


typedef enum {

NO_ERROR,

ARGUMENT_TOO_LARGE,

} Err;


Err square(int8u* valueP);


/*----- End header File ----- */


When I import the resulting module into Python, I get errors like


>>>square(u)

Traceback (most recent call last):

	File "<<stdin>", line 1 in ?

TypeError: type error.  Expected _int8u_p


I have no idea how to create a type _int8u_p...  :-( As a work-
around, I wrote some glue code that looks like


/*----- Sample C header File ----- */


int8u* createValueP(void);


Err setPValue(int value);


int getPValue(void);


int getErrorValue(Err error);


void freeValueP(int8u* valueP);


/*----- End header File -----*/


So...my questions are: 


1.  Is there some way to use my existing C code without writing all 
of these glue functions  (or reworking it specifically as a Python 
extension)?


2.  If not, do I need to have a function like freeValueP() to free the 
memory allocated in createValueP(), or will Python take care of 
that for me once I eliminate all references to the object created by 
createValueP()?


Many, many thanks!


--Cliff


 




<nofill>




From kalle@gnupung.net  Sat Nov 17 02:36:37 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Sat, 17 Nov 2001 03:36:37 +0100
Subject: [Tutor] I need help
In-Reply-To: <20011116105043.B12929@harmony.cs.rit.edu>
References: <6a.1682dbb0.2925e7eb@aol.com> <20011116105043.B12929@harmony.cs.rit.edu>
Message-ID: <20011117033637.A4265@proton.lysator.liu.se>

[dman]
> On Thu, Nov 15, 2001 at 10:54:19PM -0500, NwOrlnsBoy504@aol.com wrote:
> | I am new at this but I would like to know how to "crack" into a java
> | applet game.. is there anyway to beable to do it with Python??
> 
> 
> PS. (I should have included this in my previous post)
> 
>     You'll get much better help and answers if you are actually trying
>     to solve a programming problem.  The people on this list aren't
>     very interested in cracking.  Also read ESR's essay
>     "How To Become A Hacker"
>         http://www.tuxedo.org/~esr/faqs/hacker-howto.html

Well, I sometimes find bytecode disassembly/editing to be a sort of enjoyable
problem.  Probably not Java applet games, though.

Peace,
  Kalle
-- 
[   International: http://www.gnupung.net/   ]
[ Svenska: http://www.lysator.liu.se/~kalle/ ]


From dyoo@hkn.eecs.berkeley.edu  Sat Nov 17 02:53:07 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 16 Nov 2001 18:53:07 -0800 (PST)
Subject: [Tutor] A Demolished Function
Message-ID: <Pine.LNX.4.21.0111161831300.16239-100000@hkn.eecs.berkeley.edu>

Hi everyone,

I thought I might want to toss this out to the list.  I'm trying to
improve a "conservatively splitting" function.  Examples speak louder than
words, so here goes:


###
>>>                                                      ## Example 1
>>> sir_re = re.compile("sir")
>>> conservativeSplit(sir_re,
                     "five sir four sir three sir two sir one sir")
['five ', 'sir', ' four ', 'sir', ' three ', 'sir',
 ' two ', 'sir', ' one ', 'sir']
>>>                                                      ## Example 2
>>> digit_re = re.compile("\d+")
>>> conservativeSplit(digit_re, "5 sir 4 sir 3 sir 2 sir 1 sir")
['5', ' sir ', '4', ' sir ', '3', ' sir ', '2', ' sir ', '1', ' sir']
###


This function is similar but different from re.split() --- it conserves
the delimiter.  This might be useful if the thing that I'm using to split
my string is itself something I want to keep my eye on.


Here's what my implementation looks like:

###
def conservativeSplit(regex, stuff):
    """Split 'stuff' along 'regex' seams."""
    fragments = []
    while 1:
        match = regex.search(stuff)
        if not match: break
        begin, end = match.span()
        if begin == 0:
            fragments.append(stuff[begin : end])
            stuff = stuff[end :]
        else:
            fragments.append(stuff[0 : begin])
            fragments.append(stuff[begin : end])
            stuff = stuff[end :]
    if stuff:
        fragments.append(stuff)
    return fragments
###

After writing this function, though, I still feel tense and apprehensive.  
Does anyone see any improvements one could make to make the function
easier to read?  Any criticism or dissension would be great.  Thanks!



From allan.crooks@btinternet.com  Sat Nov 17 03:20:14 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Sat, 17 Nov 2001 03:20:14 -0000
Subject: [Tutor] Scheduler / Task List program?
Message-ID: <3BF5D76E.13207.686228@localhost>

Hi,

I was wondering if anyone knew of any text-based program which 
could keep track of appointments and to-do lists and so on?

Why do I ask this non-Python related question here? Because I'm 
hoping that people will point me to something coded in Python. 
What's the point of using something if you can't customise it? :)

Allan.


From virketis@fas.harvard.edu  Sat Nov 17 03:35:08 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Fri, 16 Nov 2001 22:35:08 -0500
Subject: [Tutor] Scheduler / Task List program?
In-Reply-To: <3BF5D76E.13207.686228@localhost>
Message-ID: <200111170334.fAH3YSh26916@smtp1.fas.harvard.edu>

Hey, 

check out http://gomail.dynu.com/. It's a email/scheduler app writen in
Python (read more in the FAQ). In general, I have noted that most "where
can I find ..." questions on this list usually end up refered to the Vaults
of Parnassus, which is where I found GoMail as well, so the address for the
Vaults is http://www.vex.net/parnassus/.

Cheers, 

Pijus
------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis



From dsh8290@rit.edu  Sat Nov 17 04:30:23 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 16 Nov 2001 23:30:23 -0500
Subject: [Tutor] I need help
In-Reply-To: <20011117033637.A4265@proton.lysator.liu.se>; from kalle@gnupung.net on Sat, Nov 17, 2001 at 03:36:37AM +0100
References: <6a.1682dbb0.2925e7eb@aol.com> <20011116105043.B12929@harmony.cs.rit.edu> <20011117033637.A4265@proton.lysator.liu.se>
Message-ID: <20011116233023.A13858@harmony.cs.rit.edu>

On Sat, Nov 17, 2001 at 03:36:37AM +0100, Kalle Svensson wrote:
| [dman]
| > On Thu, Nov 15, 2001 at 10:54:19PM -0500, NwOrlnsBoy504@aol.com wrote:
| > | I am new at this but I would like to know how to "crack" into a java
| > | applet game.. is there anyway to beable to do it with Python??
| > 
| > 
| > PS. (I should have included this in my previous post)
| > 
| >     You'll get much better help and answers if you are actually trying
| >     to solve a programming problem.  The people on this list aren't
| >     very interested in cracking.  Also read ESR's essay
| >     "How To Become A Hacker"
| >         http://www.tuxedo.org/~esr/faqs/hacker-howto.html
| 
| Well, I sometimes find bytecode disassembly/editing to be a sort of enjoyable
| problem.

Sure, but do you do it for education and problem solving or for
cracking?

| Probably not Java applet games, though.

:-).

-D



From myuen@ucalgary.ca  Sat Nov 17 04:32:05 2001
From: myuen@ucalgary.ca (Mike Yuen)
Date: Fri, 16 Nov 2001 21:32:05 -0700 (MST)
Subject: [Tutor] Accessing a tuple element
Message-ID: <Pine.A41.4.10.10111162128550.47814-100000@acs2.acs.ucalgary.ca>

I have a question regarding accessing a tuple within a dictionary.
I've got a whole bunch of points on a matrix inside a dictionary as
follows:
dict {(1, 2): 4, (8, 11): 2, etc etc}
My question is, I would like to access the first and occasionally the
second element of the tuples.

I know I can access a tuple element simply by indexing into it but it
doesn't seem to work if a tuple is a dictionary key.
Does anyone know if there's a way to do this?

Thanks,
M




From ak@silmarill.org  Sat Nov 17 04:45:18 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Fri, 16 Nov 2001 23:45:18 -0500
Subject: [Tutor] Accessing a tuple element
In-Reply-To: <Pine.A41.4.10.10111162128550.47814-100000@acs2.acs.ucalgary.ca>
References: <Pine.A41.4.10.10111162128550.47814-100000@acs2.acs.ucalgary.ca>
Message-ID: <20011116234518.A20459@sill.silmarill.org>

On Fri, Nov 16, 2001 at 09:32:05PM -0700, Mike Yuen wrote:
> I have a question regarding accessing a tuple within a dictionary.
> I've got a whole bunch of points on a matrix inside a dictionary as
> follows:
> dict {(1, 2): 4, (8, 11): 2, etc etc}
> My question is, I would like to access the first and occasionally the
> second element of the tuples.
> 
> I know I can access a tuple element simply by indexing into it but it
> doesn't seem to work if a tuple is a dictionary key.
> Does anyone know if there's a way to do this?

The key should be atomic.. how about {4: (1,2)}? The whole idea of
having a key is being able to say "what data is associated with this
key?".

But if you *really* need this, you can do:

for key in dict.keys():
 elem1 = key[0]
 [do stuff with elem1]


> 
> Thanks,
> M
> 
> 
> 
> _______________________________________________
> 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 Nov 17 06:45:02 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Fri, 16 Nov 2001 22:45:02 -0800
Subject: [Tutor] A Demolished Function
In-Reply-To: <Pine.LNX.4.21.0111161831300.16239-100000@hkn.eecs.berkeley
 .edu>
Message-ID: <4.2.0.58.20011116224326.00c82ac0@pop3.norton.antivirus>

>
>After writing this function, though, I still feel tense and apprehensive.
>Does anyone see any improvements one could make to make the function
>easier to read?  Any criticism or dissension would be great.  Thanks!

Some inconsequential coding changes -- not necessarily easier
to read:

def conservativeSplit(regex, stuff):
     """Split 'stuff' along 'regex' seams."""
     fragments = []
     while 1:
         match = regex.search(stuff)
         if not match: break
         begin, end = match.span()
         if not begin == 0:
             fragments.append(stuff[0 : begin])
         fragments.append(stuff[begin : end])
         stuff = stuff[end :]
     if stuff: fragments.append(stuff)
     return fragments

Kirby



From glingl@aon.at  Sat Nov 17 10:22:07 2001
From: glingl@aon.at (Gregor Lingl)
Date: Sat, 17 Nov 2001 11:22:07 +0100
Subject: [Tutor] A Demolished Function
References: <Pine.LNX.4.21.0111161831300.16239-100000@hkn.eecs.berkeley.edu>
Message-ID: <3BF63A4F.47BD3C1A@rg16.asn-wien.ac.at>


> After writing this function, though, I still feel tense and apprehensive.
> Does anyone see any improvements one could make to make the function
> easier to read?  Any criticism or dissension would be great.  Thanks!

No criticism, no dissension but an alternative solution:

def cSplit(regex,stuff):
    """Split 'stuff' along 'regex' seams."""
    match = regex.search(stuff)
    if not match:
        return [stuff]
    begin, end = match.span()
    if begin == 0:
        return [stuff[begin:end]] + cSplit(regex,stuff[end:])
    else:
        return [stuff[:begin], stuff[begin:end]] + cSplit(regex,stuff[end:])

For those who like recursion. Contains some redundancy -
for sake of readability (??)

Gregor



From DoNotReplyByEmail@yahoo.com  Sat Nov 17 05:19:22 2001
From: DoNotReplyByEmail@yahoo.com (DoNotReplyByEmail@yahoo.com)
Date: Sat, 17 Nov 01 00:19:22 EST
Subject: [Tutor] >>>ADVERTISE TO 11,295,000 PEOPLE FREE!
Message-ID: <3791856948.991306994491@m0.net  Received: from dialup-62.215.274.4.dial1.stamford ([62.215.274.4]  >

Dear tutor@python.org,


            Would you like to send an Email Advertisement to
              OVER 11 MILLION PEOPLE DAILY for FREE?


1) Let's say you... Sell a $24.95 PRODUCT or SERVICE.
2) Let's say you... Broadcast Email to only 500,000 PEOPLE.
3) Let's say you... Receive JUST 1 ORDER for EVERY 2,500 EMAILS.

CALCULATION OF YOUR EARNINGS BASED ON THE ABOVE STATISTICS:

[Day 1]: $4,990  [Week 1]: $34,930  [Month 1]: $139,720

NOTE: (If you do not already have a product or service to sell, we can 
supply you with one).
=========================================================
To find out more information, Do not respond by email.
Instead, please visit our web site at:

http://www.bigcashtoday.com/package1.htm



List Removal Instructions:
We hope you enjoyed receiving this message. However, if you'd rather 
not receive future e-mails of this sort from Internet Specialists, send an
email to freeemailsoftware3@yahoo.com and type "remove" in the 
"subject" line and you will be removed from any future mailings.

We hope you have a great day!
Internet Specialists



From james_fjm@yahoo.com  Sat Nov 17 12:39:35 2001
From: james_fjm@yahoo.com (=?iso-8859-1?q?James=20Foo?=)
Date: Sat, 17 Nov 2001 12:39:35 +0000 (GMT)
Subject: [Tutor] Notes and Yahoo Mails via SMTP to Yahoo Messenger
Message-ID: <20011117123935.56424.qmail@web9601.mail.yahoo.com>

--0-772129864-1006000775=:56327
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit


Hi,

I am looking for any hints that can lead me to a solution for the following scenario using Python:
-- I need to read some messages from Lotus Notes mail as well as from Yahoo mail, and via the SMTP, send them to Yahoo Messenger.

Appreciate your guides.

Thanks so much, and have a good day.

James
Nov 17, 2001 20:39


Have a heart for them, visit http://www.geocities.com/james_fjm/charity.htm


---------------------------------
Do You Yahoo!?
Get personalised at My Yahoo!.
--0-772129864-1006000775=:56327
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

<P>Hi,</P>
<P>I am looking for any hints that can lead me to a solution for the following scenario using Python:<BR>-- I need to read some messages from Lotus Notes mail as well as from Yahoo mail, and via the SMTP, send them to Yahoo Messenger.</P>
<P>Appreciate your guides.</P>
<P>Thanks so much, and have a good day.</P>
<P>James<BR>Nov 17, 2001 20:39</P><BR><BR>Have a heart for them, visit http://www.geocities.com/james_fjm/charity.htm<p><br><hr size=1><b>Do You Yahoo!?</b><br>
Get personalised at <a
href="http://uk.rd.yahoo.com/mail_uk/my?http://uk.my.yahoo.com" target="_blank">My Yahoo!</a>.
--0-772129864-1006000775=:56327--


From gubitz@netcologne.de  Sat Nov 17 16:07:45 2001
From: gubitz@netcologne.de (Hans Gubitz)
Date: Sat, 17 Nov 2001 17:07:45 +0100
Subject: [Tutor] os.system
Message-ID: <20011117170745.A939@redwitz79.de>

Hi,
I want to display a picture on a remote host by
os.system("xv -display host:0.0 picture.jpg")

system execute the command in a subshell.

I don't know how to close this  subshell!

??






-- 
Hans Gubitz <gubitz@netcologne.de>



From dsh8290@rit.edu  Sat Nov 17 16:22:38 2001
From: dsh8290@rit.edu (dman)
Date: Sat, 17 Nov 2001 11:22:38 -0500
Subject: [Tutor] os.system
In-Reply-To: <20011117170745.A939@redwitz79.de>; from gubitz@netcologne.de on Sat, Nov 17, 2001 at 05:07:45PM +0100
References: <20011117170745.A939@redwitz79.de>
Message-ID: <20011117112238.A15866@harmony.cs.rit.edu>

On Sat, Nov 17, 2001 at 05:07:45PM +0100, Hans Gubitz wrote:
| Hi,
| I want to display a picture on a remote host by
| os.system("xv -display host:0.0 picture.jpg")
| 
| system execute the command in a subshell.
| 
| I don't know how to close this  subshell!

The subshell will be closed when the program (xv) terminates.

If you want your program to not wait for it, use the following :


import os

pid = os.fork()
if pid == 0 :
    # this is the child
    os.execv( "xv" , ( "-display" , "host:0.0" , "picture.jpg" ) )
else :
    # this is the parent,
    # nothing special to do
    pass


This is what os.system() does, except that in the parent it waits for
the child to terminate.

HTH,
-D



From myuen@ucalgary.ca  Sun Nov 18 18:49:29 2001
From: myuen@ucalgary.ca (Mike Yuen)
Date: Sun, 18 Nov 2001 11:49:29 -0700 (MST)
Subject: [Tutor] Can't detect empty line
Message-ID: <Pine.A41.4.10.10111181143320.43674-100000@acs2.acs.ucalgary.ca>

I know that I can detect an empty line when reading in a file simply by
going:
if line == '\n':
	# Do stuff

However, i'm having a serious problem trying to detect an empty line.
I'm using Linux and when I do a "cat -ve input".  The line i'm interested
in has a ^M$ implying there's a return character on that empty line.
For some reason, it's reading in the line as if there's stuff on that
empty line.

I've tried to strip, lstrip, etc to clean the line up so I might be able
to better detect an empty line but no luck.

Is there any other way to find detect an empty line?

Thanks,
M




From myuen@ucalgary.ca  Sun Nov 18 18:51:00 2001
From: myuen@ucalgary.ca (Mike Yuen)
Date: Sun, 18 Nov 2001 11:51:00 -0700 (MST)
Subject: [Tutor] Can't detect empty line
Message-ID: <Pine.A41.4.10.10111181150250.22572-100000@acs2.acs.ucalgary.ca>

I know that I can detect an empty line when reading in a file simply by
going:
if line == '\n':
        # Do stuff

However, i'm having a serious problem trying to detect an empty line.
I'm using Linux and when I do a "cat -ve input".  The line i'm interested
in has a ^M$ implying there's a return character on that empty line.
For some reason, it's reading in the line as if there's stuff on that
empty line.

I've tried to strip, lstrip, etc to clean the line up so I might be able
to better detect an empty line but no luck.

Is there any other way to find detect an empty line?

Thanks,
M




From dsh8290@rit.edu  Sun Nov 18 19:34:46 2001
From: dsh8290@rit.edu (dman)
Date: Sun, 18 Nov 2001 14:34:46 -0500
Subject: [Tutor] Can't detect empty line
In-Reply-To: <Pine.A41.4.10.10111181143320.43674-100000@acs2.acs.ucalgary.ca>; from myuen@ucalgary.ca on Sun, Nov 18, 2001 at 11:49:29AM -0700
References: <Pine.A41.4.10.10111181143320.43674-100000@acs2.acs.ucalgary.ca>
Message-ID: <20011118143446.A16100@harmony.cs.rit.edu>

On Sun, Nov 18, 2001 at 11:49:29AM -0700, Mike Yuen wrote:
| I know that I can detect an empty line when reading in a file simply by
| going:
| if line == '\n':
| 	# Do stuff
| 
| However, i'm having a serious problem trying to detect an empty line.
| I'm using Linux and when I do a "cat -ve input".  The line i'm interested
| in has a ^M$ implying there's a return character on that empty line.
| For some reason, it's reading in the line as if there's stuff on that
| empty line.
| 
| I've tried to strip, lstrip, etc to clean the line up so I might be able
| to better detect an empty line but no luck.

This is because *strip() removes all whitespace, including the
newline.

| Is there any other way to find detect an empty line?

You can use


while 1 :
    line = f.readline()
    if not line : break # EOF
    if line.strip() == "" :
        print "line was empty"
    else :
        print "line wasn't empty"


or you could use 


while 1 :
    line = f.readline()
    if not line : break # EOF
    if line.replace( '\r' , '' ) == "\n" :
        print "line was empty"
    else :
        print "line wasn't empty"



HTH,
-D



From karshi.hasanov@utoronto.ca  Sun Nov 18 22:45:38 2001
From: karshi.hasanov@utoronto.ca (Karshi)
Date: Sun, 18 Nov 2001 17:45:38 -0500
Subject: [Tutor] read_help
Message-ID: <20011118224521Z236932-16698+2@bureau8.utcc.utoronto.ca>

Hi all,

 I have a question about  the "read()" method.
For example, if I wanna read the file which has  size=200bytes. I want to 
read only 100bytes by skipping 2 bytes. How do I do it in Python?

---In Matlab it will look like this:
---file=fopen(somefile, 'rb')
---read=fread(file, 100, 2)
Thanks


From rick@niof.net  Sun Nov 18 23:12:13 2001
From: rick@niof.net (Rick Pasotto)
Date: Sun, 18 Nov 2001 18:12:13 -0500
Subject: [Tutor] read_help
In-Reply-To: <20011118224521Z236932-16698+2@bureau8.utcc.utoronto.ca>
References: <20011118224521Z236932-16698+2@bureau8.utcc.utoronto.ca>
Message-ID: <20011118181212.E23616@tc.niof.net>

On Sun, Nov 18, 2001 at 05:45:38PM -0500, Karshi wrote:
> 
> Hi all,
> 
> I have a question about  the "read()" method.  For example, if I wanna
> read the file which has  size=200bytes. I want to read only 100bytes
> by skipping 2 bytes. How do I do it in Python?
> 
> ---In Matlab it will look like this:
> ---file=fopen(somefile, 'rb')
> ---read=fread(file, 100, 2)

>>> f = open('filename','rb')
>>> f.seek(2)
>>> data = f.read(100)

If you're on unix you don't need the 'rb'.

-- 
When under the pretext of fraternity, the legal code imposes
mutual sacrifices on the citizens, human nature is not thereby
abrogated. Everyone will then direct his efforts toward
contributing little to, and taking much from, the common fund of
sacrifices. Now, is it the most unfortunate who gains from this
struggle? Certainly not, but rather the most influential and
calculating.
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net


From alan.gauld@bt.com  Sun Nov 18 23:42:59 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sun, 18 Nov 2001 23:42:59 -0000
Subject: [Tutor] Problem seeing NT networked drives
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0D0@mbtlipnt02.btlabs.bt.co.uk>

> I'm having trouble viewing shared, networked (WinNT) directories from 
> Python. The usual DOS commands work, e.g. :

I suspect you might be best using WSH Filesystem objects
(I assume you are on a Microsoft platform?)

Get winall or the ActiveState Python which inxcludes it 
by default.

Activate WSH support(Active Scripting)

Use the FileSystem COM objects to access your dir.

For more details see Mark Hammonds Win32 book.
Also some past threads on this list include examples 
- search at ActiveStates mirror.

Alan g.


From alan.gauld@bt.com  Sun Nov 18 23:47:08 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sun, 18 Nov 2001 23:47:08 -0000
Subject: [Tutor] Letters & Digits
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0D1@mbtlipnt02.btlabs.bt.co.uk>

> clean and easy way to test each character in a string to 
> see if they match (or do not match) characters from those lists. 

import string
chars_of_interest = string.lowercase + string.digits

for c in myString:
   if c in chars_of_interest: break
   else: # do something

You could also use some of the functional programming 
things like comprehensions or map or filter

Alan g


From alan.gauld@bt.com  Sun Nov 18 23:55:40 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sun, 18 Nov 2001 23:55:40 -0000
Subject: [Tutor] os.system
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0D2@mbtlipnt02.btlabs.bt.co.uk>

> os.system("xv -display host:0.0 picture.jpg")
> I don't know how to close this  subshell!

Use popen to run ps and find the PID then do a 
system() using kill?

OTOH let the user of host:0.0 kill it?

Alan g.


From alan.gauld@bt.com  Mon Nov 19 00:00:38 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 19 Nov 2001 00:00:38 -0000
Subject: [Tutor] os.system
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0D3@mbtlipnt02.btlabs.bt.co.uk>

> pid = os.fork()
> if pid == 0 :
>     # this is the child
>     os.execv( "xv" , ( "-display" , "host:0.0" , "picture.jpg" ) )
> else :
>     # this is the parent,
>     # nothing special to do
>     pass

Rather than pass I guess he should really sleep then run 
kill on pid. This is better than using ps to get the pid 
as I suggested earlier. But how to kill the xv remains. Unless 
he's happy to leave xv up until the python program closes 
in which case ISTR the child process gets bumped too 
- which is probably what you had in mind, whereas I was 
assuming he wanted to kill it sooner...

Hmm, I think I just showed the inner meanderings of my mind!
Its getting late.
:-)

Alan g


From dyoo@hkn.eecs.berkeley.edu  Mon Nov 19 01:33:55 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sun, 18 Nov 2001 17:33:55 -0800 (PST)
Subject: [Tutor] read_help
In-Reply-To: <20011118224521Z236932-16698+2@bureau8.utcc.utoronto.ca>
Message-ID: <Pine.LNX.4.21.0111181704590.19958-100000@hkn.eecs.berkeley.edu>

On Sun, 18 Nov 2001, Karshi wrote:

>  I have a question about  the "read()" method.
> For example, if I wanna read the file which has  size=200bytes. I want to 
> read only 100bytes by skipping 2 bytes. How do I do it in Python?
> 
> ---In Matlab it will look like this:
> ---file=fopen(somefile, 'rb')
> ---read=fread(file, 100, 2)

Hi Karshi,

As far as I know, there's no direct equivalent to Matlab's fread()
function that's described here:

    http://www.mathworks.com/access/helpdesk/help/techdoc/ref/fread.shtml


However, if we want, we can define our own fread() function that works
similarly to the Matlab version:

###
def fread(file, size, skip):
    """Simulates the Matlab fread() function.

       However, does not take into account the 'precision' parameter.  If
       we wanted, perhaps we can use the 'struct' module to do this."""

    file.seek(skip, 1)      ## skip through the file, relative to our
                            ## current position.
    return file.read(size)
###


I'm blatantly ignoring the part about the precision argument that Matlab's
fread() function takes, since I'm not sure if we want to worry about it.  
*grin*

If we wanted to more accurately translate fread(), we can pull the tools
from the 'struct' module to do this:

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


Both seek() and read() have more documentation here:

    http://www.python.org/doc/lib/bltin-file-objects.html

so you can browse through that if you're a person who likes details.  Hope
this helps!



From dyoo@hkn.eecs.berkeley.edu  Mon Nov 19 01:45:36 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sun, 18 Nov 2001 17:45:36 -0800 (PST)
Subject: [Tutor] Letters & Digits   [functional programming]
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0D1@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <Pine.LNX.4.21.0111181735130.19958-100000@hkn.eecs.berkeley.edu>

On Sun, 18 Nov 2001 alan.gauld@bt.com wrote:

> > clean and easy way to test each character in a string to 
> > see if they match (or do not match) characters from those lists. 
> 
> import string
> chars_of_interest = string.lowercase + string.digits
> 
> for c in myString:
>    if c in chars_of_interest: break
>    else: # do something
> 
> You could also use some of the functional programming 
> things like comprehensions or map or filter


One functional function that might be useful is the idea of an "every()"
function that sees if every element in a list passes some test.  For
example, it might be nice to be able to write something like:

###
if every(isEven, [2, 4, 5, 8]):
    print "This can't happen, can it?!"
if every(isPrime, [2, 3, 5, 7]):
    print "These numbers are prime."
###

The nice thing about every() is that it now allows us to test a whole
sequence of things without worrying about loops.  It's a "functional"
approach because we're giving every() a function that tells it what it
means to be a true element.


Here's a sample implementation of the every() function:

###
def every(predicate_function, sequence):
    """Returns 1 if every element in our sequence passes
    through our predicate_function in good shape.  Otherwise,
    return 0."""
    for element in sequence:
        if not predicate_function(element):
            return 0
    return 1
###

and a sample test in the interpreter:

###
>>> def isDigit(s):   
...     return s in ['0', '1', '2', '3', '4', '5', '6',   
...                  '7', '8', '9']   
... 
>>> every(isDigit, "42")
1
>>> every(isDigit, "forty-two")
0
>>> every(isDigit, ['4', '2'])
1
###


Hope this helps!



From wilson@visi.com  Mon Nov 19 02:05:43 2001
From: wilson@visi.com (Timothy Wilson)
Date: Sun, 18 Nov 2001 20:05:43 -0600 (CST)
Subject: [Tutor] Can't make urllib do ftp
Message-ID: <Pine.GSO.4.21.0111181957070.13818-100000@isis.visi.com>

Hi everyone,

I'm messing with the urllib module to retrieve the current weather
conditions from our closest National Weather Service reporting station. The
data is available at
ftp://weather.noaa.gov/data/observations/metar/stations/KSGS.TXT

Unfortunately, I get the following error. This works perfectly when I do
HTTP. The docs indicate that urllib should handle ftp just fine. Any ideas?

wilson@copland:~/python$ python2.1
Python 2.1.1 (#1, Oct 20 2001, 16:44:06)
[GCC 2.95.4 20011006 (Debian prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import urllib
>>> url = "ftp://weather.noaa.gov/data/observations/metar/stations/KSGS.TXT"
>>> f = urllib.urlopen(url)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.1/urllib.py", line 71, in urlopen
    return _urlopener.open(url)
  File "/usr/lib/python2.1/urllib.py", line 176, in open
    return getattr(self, name)(url)
  File "/usr/lib/python2.1/urllib.py", line 427, in open_ftp
    host, path = splithost(url)
  File "/usr/lib/python2.1/urllib.py", line 932, in splithost
    match = _hostprog.match(url)
TypeError: expected string or buffer
>>>

-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 ak@silmarill.org  Mon Nov 19 02:11:46 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Sun, 18 Nov 2001 21:11:46 -0500
Subject: [Tutor] Can't make urllib do ftp
In-Reply-To: <Pine.GSO.4.21.0111181957070.13818-100000@isis.visi.com>
References: <Pine.GSO.4.21.0111181957070.13818-100000@isis.visi.com>
Message-ID: <20011118211146.A4944@sill.silmarill.org>

On Sun, Nov 18, 2001 at 08:05:43PM -0600, Timothy Wilson wrote:
> Hi everyone,
> 
> I'm messing with the urllib module to retrieve the current weather
> conditions from our closest National Weather Service reporting station. The
> data is available at
> ftp://weather.noaa.gov/data/observations/metar/stations/KSGS.TXT
> 
> Unfortunately, I get the following error. This works perfectly when I do
> HTTP. The docs indicate that urllib should handle ftp just fine. Any ideas?
> 
> wilson@copland:~/python$ python2.1
> Python 2.1.1 (#1, Oct 20 2001, 16:44:06)
> [GCC 2.95.4 20011006 (Debian prerelease)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> import urllib
> >>> url = "ftp://weather.noaa.gov/data/observations/metar/stations/KSGS.TXT"
> >>> f = urllib.urlopen(url)
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/lib/python2.1/urllib.py", line 71, in urlopen
>     return _urlopener.open(url)
>   File "/usr/lib/python2.1/urllib.py", line 176, in open
>     return getattr(self, name)(url)
>   File "/usr/lib/python2.1/urllib.py", line 427, in open_ftp
>     host, path = splithost(url)
>   File "/usr/lib/python2.1/urllib.py", line 932, in splithost
>     match = _hostprog.match(url)
> TypeError: expected string or buffer
> >>>
> 
> -Tim

I used ftplib, and it works just fine (although it's a bit odd..).
> 
> --
> 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

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


From wilson@visi.com  Mon Nov 19 02:21:59 2001
From: wilson@visi.com (Timothy Wilson)
Date: Sun, 18 Nov 2001 20:21:59 -0600 (CST)
Subject: [Tutor] Can't make urllib do ftp
In-Reply-To: <20011118211146.A4944@sill.silmarill.org>
Message-ID: <Pine.GSO.4.21.0111182020490.14604-100000@isis.visi.com>

On Sun, 18 Nov 2001, Andrei Kulakov wrote:

> I used ftplib, and it works just fine (although it's a bit odd..).

Yes, I've implemented this with ftplib and it worked fine. I plan to use
this with my students and urllib seems much easier to understand and should
be a lot cleaner to implement. If it works, that is. :-)

-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  Mon Nov 19 02:31:05 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sun, 18 Nov 2001 18:31:05 -0800 (PST)
Subject: [Tutor] Can't make urllib do ftp
In-Reply-To: <Pine.GSO.4.21.0111181957070.13818-100000@isis.visi.com>
Message-ID: <Pine.LNX.4.21.0111181808340.20844-100000@hkn.eecs.berkeley.edu>

On Sun, 18 Nov 2001, Timothy Wilson wrote:

> Hi everyone,
> 
> I'm messing with the urllib module to retrieve the current weather
> conditions from our closest National Weather Service reporting station. The
> data is available at
> ftp://weather.noaa.gov/data/observations/metar/stations/KSGS.TXT
> 
> Unfortunately, I get the following error. This works perfectly when I do
> HTTP. The docs indicate that urllib should handle ftp just fine. Any ideas?

Hmmm... an interesting problem!

###
>>> import urllib
>>> url =
"ftp://weather.noaa.gov/data/observations/metar/stations/KSGS.TXT"
>>> f = urllib.urlopen(url)
>>> f
<addinfourl at 135767660 whose fp = <addclosehook at 135615740 whose fp =
<open file '<socket>', mode 'rb' at 0x8153d60>>>
###


The only hint that I can smell when looking through urllib.py is that
urllib does something unusual if it sees an FTP proxy:

###
## Within urllib.URLOpener.open():
        if self.proxies.has_key(urltype):
            proxy = self.proxies[urltype]
            urltype, proxyhost = splittype(proxy)
            host, selector = splithost(proxyhost)
            url = (host, fullurl) # Signal special case to open_*()
###


That is, if urllib sees a proxy, it will "fix" the url to include that
proxy host information, and that's the only thing I can think of that
triggers your error message that deals with that TypeError:

>   File "/usr/lib/python2.1/urllib.py", line 427, in open_ftp
>     host, path = splithost(url)
>   File "/usr/lib/python2.1/urllib.py", line 932, in splithost
>     match = _hostprog.match(url)
> TypeError: expected string or buffer


Do you know if you have one set up?  Can you check your evironment to see
if you have an "FTP_PROXY" variable?  If so, that can do something
strange.

I'll continue to read through urllib to see what the consequences of
having an FTP proxy are.  Hope this helps!



From dyoo@hkn.eecs.berkeley.edu  Mon Nov 19 02:53:26 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sun, 18 Nov 2001 18:53:26 -0800 (PST)
Subject: [Tutor] Can't make urllib do ftp
In-Reply-To: <Pine.LNX.4.21.0111181808340.20844-100000@hkn.eecs.berkeley.edu>
Message-ID: <Pine.LNX.4.21.0111181837480.20844-100000@hkn.eecs.berkeley.edu>

On Sun, 18 Nov 2001, Danny Yoo wrote:

> That is, if urllib sees a proxy, it will "fix" the url to include that
> proxy host information, and that's the only thing I can think of that
> triggers your error message that deals with that TypeError:
> 
> >   File "/usr/lib/python2.1/urllib.py", line 427, in open_ftp
> >     host, path = splithost(url)
> >   File "/usr/lib/python2.1/urllib.py", line 932, in splithost
> >     match = _hostprog.match(url)
> > TypeError: expected string or buffer
> 
> 
> Do you know if you have one set up?  Can you check your evironment to see
> if you have an "FTP_PROXY" variable?  If so, that can do something
> strange.
> 
> I'll continue to read through urllib to see what the consequences of
> having an FTP proxy are.  Hope this helps!


Ok, I've read through urllib.py a little more, and I'm almost convinced
this problem has to do with FTP proxies, because there's an ugly asymmetry
in the code that handles open_http() and open_ftp():

###
## Within urllib.py
    def open_http(self, url, data=None):
        """Use HTTP protocol."""
        import httplib
        user_passwd = None
        if type(url) is types.StringType:
            host, selector = splithost(url)
            if host:
                user_passwd, host = splituser(host)
                host = unquote(host)
            realhost = host
###

The key point here is that open_http() is aware that if the url is a
tuple, it's HTTP proxy time.  However, there is no analogous code in the
open_ftp() code that checks for 'type(url)', so open_ftp() doesn't take
this possibility into account!


Ugh.  Have you tried urllib2?  urllib2 looks like a rewrite of urllib, and
may be more considerate about proxy situations.  The example in urllib2
shows an example that handles FTP proxying:

###
proxy_support = urllib2.ProxyHandler({"http" : "http://ahad-haam:3128"})
# build a new opener that adds authentication and caching FTP handlers
opener = urllib2.build_opener(proxy_support, authinfo,
urllib2.CacheFTPHandler)
# install it
urllib2.install_opener(opener)
###

You may also want to notify people on comp.lang.python about this problem
with urllib.py, as this does seem asthetically weird to me.  Perhaps I'm
overreacting.



From bwinton@tor.dhs.org  Mon Nov 19 03:52:47 2001
From: bwinton@tor.dhs.org (Blake Winton)
Date: Sun, 18 Nov 2001 22:52:47 -0500
Subject: [Tutor] Problem seeing NT networked drives
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0D0@mbtlipnt02.btlabs.bt.co.uk>
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0D0@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <20011118225247.A15444@tor.dhs.org>

* alan.gauld@bt.com <alan.gauld@bt.com> [011118 18:46]:
> > I'm having trouble viewing shared, networked (WinNT) directories from 
> > Python. The usual DOS commands work, e.g. :
> I suspect you might be best using WSH Filesystem objects
> (I assume you are on a Microsoft platform?)

Oddly enough, the solution was found to be far simpler than
that...  You just need to not expect isdir() to return true
for things which aren't directories.  ;)

There is an ismount() function which returns true for mount
points (like \\computername\sharename).

I remember being quite confused by this the first time I
started messing around with network drive stuff in Python.
Perhaps we could put it in a FAQ somewhere...

Later,
Blake.
-- 
 10:52pm  up 86 days,  6:37,  1 user,  load average: 0.00, 0.00, 0.00


From jaela@shaw.ca  Mon Nov 19 04:36:01 2001
From: jaela@shaw.ca (Jaela Gulamhusein)
Date: Sun, 18 Nov 2001 21:36:01 -0700
Subject: [Tutor] I NEED HELP!!!
Message-ID: <NFBBJDKJALDAJCEIGCFMEEFCCAAA.jaela@shaw.ca>

Hi,

I need to do a program for school, we have to use Prim's Algorithm to sort
an input file and then create a minimum spanning tree and then do a depth
first traversal to output it.  I just started python a couple weeks ago and
am not familiar with what I can do with it.  Also, the input file contains
matrices, the comparison of them and the difference between them becomes the
weight of the each edge on the tree.  I can probably do the algorithm and
the traversal but I'm really confused on how to read the input file in.  Any
help you could give me would be great.

Jaela :)



From dyoo@hkn.eecs.berkeley.edu  Mon Nov 19 06:19:37 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sun, 18 Nov 2001 22:19:37 -0800 (PST)
Subject: [Tutor] I NEED HELP!!!
In-Reply-To: <NFBBJDKJALDAJCEIGCFMEEFCCAAA.jaela@shaw.ca>
Message-ID: <Pine.LNX.4.21.0111182212150.23698-100000@hkn.eecs.berkeley.edu>

On Sun, 18 Nov 2001, Jaela Gulamhusein wrote:

> I need to do a program for school, we have to use Prim's Algorithm to
> sort an input file and then create a minimum spanning tree and then do
> a depth first traversal to output it.  I just started python a couple
> weeks ago and am not familiar with what I can do with it.  Also, the
> input file contains matrices, the comparison of them and the
> difference between them becomes the weight of the each edge on the
> tree.  I can probably do the algorithm and the traversal but I'm
> really confused on how to read the input file in.  Any help you could
> give me would be great.

Hi Jaela,

Since you're doing computer science, I'm assuming you already know another
programming language like C, Pascal, or Java.  If so, then you can
transfer a lot of what you know already toward Python.  One of the the
fastest way to get to speed with Python is to go through the Python
Tutorial, located here:

    http://python.org/doc/current/tut/tut.html

With it, you should be able to read through it with, interpreter in hand,
and start speaking halting pidgin Python.  *grin*

The section on reading files is Section 7:

http://python.org/doc/current/tut/node9.html#SECTION009200000000000000000

When you have any questions, please feel free to ask here on Tutor.  As a
caveat: we can't help too much on core CS topics like Prim's algorithm
since that's schoolwork, but we'd be happy to help you feel familiar with
the Python language.

Best of wishes to you!



From Felix.Toran@esa.int  Mon Nov 19 07:21:38 2001
From: Felix.Toran@esa.int (Felix.Toran@esa.int)
Date: Mon, 19 Nov 2001 08:21:38 +0100
Subject: [Tutor] Scheduler / Task List program?
Message-ID: <41256B09.0026FB6E.00@esahqmail1.hq.esa.fr>


Hi all!

This are newbie questions.

1) I'm learning python since a couple of weeks, but I think the best way to see
if python is good for me is to run examples and examine by myself the power of
the language. I have downloaded the gomail application, and I am interested in
trying it. Please, could someone explain the steps I must follow to install and
run the application?


Thanks to all in advance.
Felix Toran
ftoran@esa.int




From Felix.Toran@esa.int  Mon Nov 19 07:23:41 2001
From: Felix.Toran@esa.int (Felix.Toran@esa.int)
Date: Mon, 19 Nov 2001 08:23:41 +0100
Subject: [Tutor] GUI development
Message-ID: <41256B09.00272AB4.00@esahqmail1.hq.esa.fr>


Hi all,

I am interested in learning the basics of GUI development in python. I'm running
Winpython under Windows 95.
Can someone recommend me links as starting points?

Thanks!
Felix Toran
ftoran@esa.int




From boud@valdyas.org  Mon Nov 19 07:32:11 2001
From: boud@valdyas.org (Boudewijn Rempt)
Date: Mon, 19 Nov 2001 08:32:11 +0100
Subject: [Tutor] GUI development
In-Reply-To: <41256B09.00272AB4.00@esahqmail1.hq.esa.fr>
References: <41256B09.00272AB4.00@esahqmail1.hq.esa.fr>
Message-ID: <200111190732.fAJ7WED25880@calcifer.valdyas.org>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Monday 19 November 2001 08:23, Felix.Toran@esa.int wrote:
> Hi all,
>
> I am interested in learning the basics of GUI development in python. I'm
> running Winpython under Windows 95.
> Can someone recommend me links as starting points?

http://stage.linuxports.com/projects/pyqt/ (and when it's gone
to the printers, perhaps the sysadmin will finally add the
screenshots).

- -- 
Boudewijn Rempt | http://www.valdyas.org
public key at: certserver.pgp.com  or pki.surfnet.nl
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE7+LV7N8fj6DnPxOgRApVKAKCtRixT6fjJj5g5zxrvO2ptYsVPNQCguOSG
Fy926ArTDhBaQSwNfj+CAUo=
=aNpG
-----END PGP SIGNATURE-----


From kalle@gnupung.net  Mon Nov 19 08:46:17 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Mon, 19 Nov 2001 09:46:17 +0100
Subject: [Tutor] GUI development
In-Reply-To: <41256B09.00272AB4.00@esahqmail1.hq.esa.fr>
References: <41256B09.00272AB4.00@esahqmail1.hq.esa.fr>
Message-ID: <20011119094617.A15237@proton.lysator.liu.se>

[Felix.Toran@esa.int]
> I am interested in learning the basics of GUI development in python.
> I'm running Winpython under Windows 95.
> Can someone recommend me links as starting points?

Some online documentation of the Tkinter toolkit, which is distributed with
all Python versions is available on
http://www.secretlabs.com/library/tkinter/introduction/

There's also a book on Tkinter and a book on Win32 programming with Python,
but I've read neither.

Peace,
  Kalle
-- 
[   International: http://www.gnupung.net/   ]
[ Svenska: http://www.lysator.liu.se/~kalle/ ]


From boud@rempt.xs4all.nl  Mon Nov 19 08:49:33 2001
From: boud@rempt.xs4all.nl (Boudewijn Rempt)
Date: Mon, 19 Nov 2001 09:49:33 +0100 (CET)
Subject: [Tutor] GUI development
In-Reply-To: <20011119094617.A15237@proton.lysator.liu.se>
Message-ID: <Pine.LNX.4.33.0111190949060.26439-100000@calcifer.valdyas.org>

On Mon, 19 Nov 2001, Kalle Svensson wrote:

> [Felix.Toran@esa.int]
> > I am interested in learning the basics of GUI development in python.
> > I'm running Winpython under Windows 95.
> > Can someone recommend me links as starting points?
>
> Some online documentation of the Tkinter toolkit, which is distributed with
> all Python versions is available on
> http://www.secretlabs.com/library/tkinter/introduction/
>
> There's also a book on Tkinter and a book on Win32 programming with Python,
> but I've read neither.
>

Grayson's book on Tkinter is really good - well worth buying, _even_ if
you plan on using another toolkit.

Boudewijn Rempt  | http://www.valdyas.org



From karthikg@aztec.soft.net  Mon Nov 19 09:29:43 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Mon, 19 Nov 2001 14:59:43 +0530
Subject: [Tutor] newbie map help
In-Reply-To: <NFBBJDKJALDAJCEIGCFMEEFCCAAA.jaela@shaw.ca>
Message-ID: <NEBBJNMDEKBIBCMCNMBDEEFICJAA.karthikg@aztec.soft.net>

hi all,

I want to split string based on a separator.
i have a list of strings in say list lines.
separator is ","

lines = ["how,are,you,doing","ok fine","Things,seem,ok"]

how do i use map here??

import string
map(string.split, lines) ==> This s'd return me a list of lists.

[["how","are","you","doing"],["ok fine"]..]

How do i specify the separator character to the split function in map?

thanks in advance,
karthik






From wheelege@tsn.cc  Mon Nov 19 10:02:31 2001
From: wheelege@tsn.cc (Glen Wheeler)
Date: Mon, 19 Nov 2001 21:02:31 +1100
Subject: [Tutor] newbie map help
References: <NEBBJNMDEKBIBCMCNMBDEEFICJAA.karthikg@aztec.soft.net>
Message-ID: <016c01c170e2$42249ca0$4ba616ca@ACE>

  Howdy how,

  > how do i use map here??

  Well map takes a function and something to iterate over, then returns a
list.  The problem here is that we need a function that will split a string
with the seperator ",".  As you may have already realised, such a function
is string.split(lines[x], ","), where x is the index number of the list
lines.
  Now you just need something to iterate over, and in this case you want a
bunch of index numbers - range(len(list)) should do fine.
  So we have...

map(lambda x:string.split(lines[x], ","), range(len(lines)))

  Which works fine.  However it looks ugly, and I have somewhat unskillfully
dodged any explanation of lambda...which is deliberate - I will probably end
up confusing you even more :)  Basically it creates a function which can be
passed as an argument to other things, very useful.
  Anywho, there is probably a much cleaner and more elegant way of doing
this, but that is the one I came up with,

  HTH,
  Glen


>
> import string
> map(string.split, lines) ==> This s'd return me a list of lists.
>
> [["how","are","you","doing"],["ok fine"]..]
>
> How do i specify the separator character to the split function in map?
>
> thanks in advance,
> karthik
>
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From karthikg@aztec.soft.net  Mon Nov 19 11:47:52 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Mon, 19 Nov 2001 17:17:52 +0530
Subject: [Tutor] newbie map help
In-Reply-To: <016c01c170e2$42249ca0$4ba616ca@ACE>
Message-ID: <NEBBJNMDEKBIBCMCNMBDOEFKCJAA.karthikg@aztec.soft.net>

thanks!

i got this one to work.

map(lambda line: string.split(line,","),lines)

Obviously every line in lines is getting passed as a parameter to the
anonymous function.

karthik.


-----Original Message-----
From: Glen Wheeler [mailto:wheelege@tsn.cc]
Sent: Monday, November 19, 2001 3:33 PM
To: karthik Guru; tutor@python.org
Subject: Re: [Tutor] newbie map help


  Howdy how,

  > how do i use map here??

  Well map takes a function and something to iterate over, then returns a
list.  The problem here is that we need a function that will split a string
with the seperator ",".  As you may have already realised, such a function
is string.split(lines[x], ","), where x is the index number of the list
lines.
  Now you just need something to iterate over, and in this case you want a
bunch of index numbers - range(len(list)) should do fine.
  So we have...

map(lambda x:string.split(lines[x], ","), range(len(lines)))

  Which works fine.  However it looks ugly, and I have somewhat unskillfully
dodged any explanation of lambda...which is deliberate - I will probably end
up confusing you even more :)  Basically it creates a function which can be
passed as an argument to other things, very useful.
  Anywho, there is probably a much cleaner and more elegant way of doing
this, but that is the one I came up with,

  HTH,
  Glen


>
> import string
> map(string.split, lines) ==> This s'd return me a list of lists.
>
> [["how","are","you","doing"],["ok fine"]..]
>
> How do i specify the separator character to the split function in map?
>
> thanks in advance,
> karthik
>
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From lonetwin@yahoo.com  Mon Nov 19 11:46:43 2001
From: lonetwin@yahoo.com (lonetwin)
Date: Mon, 19 Nov 2001 17:16:43 +0530
Subject: [Tutor] newbie map help
In-Reply-To: <NEBBJNMDEKBIBCMCNMBDEEFICJAA.karthikg@aztec.soft.net>
References: <NEBBJNMDEKBIBCMCNMBDEEFICJAA.karthikg@aztec.soft.net>
Message-ID: <01111917164300.08197@mercury.worli>

Hey Kartik,

On Monday 19 November 2001 14:59, you wrote:
> hi all,
>
> I want to split string based on a separator.
> i have a list of strings in say list lines.
> separator is ","
>
> lines = ["how,are,you,doing","ok fine","Things,seem,ok"]
>
> how do i use map here??

 Re: Couldn't figure out how to do it with map....but with list 
comprehensions (post python2.0 (??)).....:

******************

>>> lines = ["how,are,you,doing","ok fine","Things,seem,ok"]
>>> l = [ x.split(",") for x in lines ]
>>> l
[['how', 'are', 'you', 'doing'], ['ok fine'], ['Things', 'seem', 'ok']]
>>> 

******************

----------------------------------------------
Every oak tree started out as a 
couple of nuts who stood their ground.
                                    Anonymous
----------------------------------------------



From gubitz@netcologne.de  Mon Nov 19 16:13:15 2001
From: gubitz@netcologne.de (Hans Gubitz)
Date: Mon, 19 Nov 2001 17:13:15 +0100
Subject: [Tutor] os.system
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0D3@mbtlipnt02.btlabs.bt.co.uk>
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0D3@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <20011119171315.A9526@redwitz79.de>

Hi,

On Mon, Nov 19, 2001 at 12:00:38AM -0000, alan.gauld@bt.com wrote:
> assuming he wanted to kill it sooner...
> Alan g

I want to show a picture and kill the shell, not as the user on the remote host,
but from the local one.

So I will try to get the pid and kill the process.

-- 
Hans Gubitz <gubitz@netcologne.de>



From alan.gauld@bt.com  Mon Nov 19 17:08:50 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Mon, 19 Nov 2001 17:08:50 -0000
Subject: [Tutor] newbie map help
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0DB@mbtlipnt02.btlabs.bt.co.uk>

> import string
> map(string.split, lines) ==> This s'd return me a list of lists.
> How do i specify the separator character to the split function in map?

map(lambda L, S=',':string.split(L,S), lines)


Should do it.
You use the default argument S=',' to make comma the separator.
Then the lambda returns the result when L is passed by map() to
the lambda at execution.

Alan g


From dyoo@hkn.eecs.berkeley.edu  Mon Nov 19 18:42:55 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 19 Nov 2001 10:42:55 -0800 (PST)
Subject: [Tutor] newbie map help
In-Reply-To: <016c01c170e2$42249ca0$4ba616ca@ACE>
Message-ID: <Pine.LNX.4.21.0111191037240.2768-100000@hkn.eecs.berkeley.edu>

On Mon, 19 Nov 2001, Glen Wheeler wrote:

>   > how do i use map here??
> 
>   Well map takes a function and something to iterate over, then returns a
> list.  The problem here is that we need a function that will split a string
> with the seperator ",".  As you may have already realised, such a function
> is string.split(lines[x], ","), where x is the index number of the list
> lines.
>   Now you just need something to iterate over, and in this case you want a
> bunch of index numbers - range(len(list)) should do fine.
>   So we have...
> 
> map(lambda x:string.split(lines[x], ","), range(len(lines)))
> 
>   Which works fine.  However it looks ugly, and I have somewhat unskillfully
> dodged any explanation of lambda...which is deliberate - I will probably end
> up confusing you even more :)  Basically it creates a function which can be


By the way, if lambda's feel weird, we can avoid them altogether by using
a normal defined function:

###
def commaSplit(mystring):
    return string.split(mystring, ',')

map(commaSplit, lines)
###

Python allows us to define functions practially anywhere, so we don't need
to use lambda in this case.  We use lambda because sometimes it's awkward
to make names up for functions.


Good luck!



From rdsteph@earthlink.net  Mon Nov 19 19:32:55 2001
From: rdsteph@earthlink.net (Ron Stephens)
Date: Mon, 19 Nov 2001 14:32:55 -0500
Subject: [Tutor] Please help me with my first CGI program???
Message-ID: <3BF95E67.F710E8FF@earthlink.net>

Any help would be appreciated. I am getting a KEYERROR when I run my CGI
program as a standalone python program. Maybe its just because the
standalone python program doesn't have the input data from the FORM I
use in my HTML input page to my CGI. Howver, I get no error messages
from actaully running my CGI on the web (just a general serer error),
even though I set sys.stderr = sys.stdout

I know I'm a clueless newbie, but even any general help will be greatly
appreciated. I think I am almost there, but I can't figure out a way to
effectively debug my CGI program.

IDLE gives me the following error message when I run the program in IDLE
as a stand-alone program::

Content-type: text/html
Traceback (most recent call last):
  File "C:/Python21/aaacgi.py", line 26, in ?
    rankings = {"ease of learning" : form['easelearning'].value,
  File "C:\PYTHON21\lib\cgi.py", line 547, in __getitem__
    raise KeyError, key
KeyError: easelearning

The input HTML page is:::

<html><body>
<title>CGI 101</title>
<H1>A first user interaction: forms</H1>
<hr>
<form method=POST action="http://www.awaretek.com/test3.cgi">

Input an integer from 1 to 100, as a weight or relative importance
factor for each of the citeria below. 1 means not very importnat to you,
100 menas extremely important to you


<P><B>ease of learning</B>
    <input type=text name=easelearning>

 <P><B>ease of use</B>
    <input type=text name=easeuse>

 <P><B>speed of program execution</B>
    <input type=text name=speed>

 <P><B>quality of available tools</B>
    <input type=text name=tools>

 <P><B>popularity</B>
    <input type=text name=pop>

 <P><B>power and expressiveness</B>
    <input type=text name=power>

 <P><B>cross-platform</B>
    <input type=text name=cross>

 <P><B>cost</B>
    <input type=text name=cost>
    <input type=submit>
</form>
</BODY></HTML>


The CGIU program follows. The data for FORM is fed into the cgi program
by the HTML FORM above:::

#!/usr/bin/python
#######################################################
# runs on the server, reads form input, prints html;
# url=http://server-name/root-dir/Basics/test3.cgi
#######################################################

import cgi
import string
import sys
sys.stderr = sys.stdout
form = cgi.FieldStorage()            # parse form data
print "Content-type: text/html"      # plus blank line

html = """
<TITLE>test3.cgi</TITLE>
<H1>Greetings</H1>
<HR>
<P>%s</P>
<HR>"""



options = ["Python", "Perl", "Ruby", "Tcl", "JavaScript", "Visual
Basic", "Java", "C++", "C", "Lisp", "Delphi"]
criteria = ["ease of learning", "ease of use", "speed of program
execution", "quality of available tools", "popularity", "power &
expressiveness", "cross platform?", "cost"]

rankings = {"ease of learning":form['easelearning'].value,


"ease of learning" : form['easelearning'].value,
"ease of use" = form['easeuse'].value,
"speed" = form['speed'].value,
"tools" = form['tools'].value,
"pop" = form['pop'].value,
"power" = form['power'].value,
"cross"] = form['cross'].value,
"cost"] = form['cost'].value}

score = {("Python", "ease of learning"):100, ("Python", "ease of
use"):100, ("Python", "speed of program execution"):10, ("Python",
"quality of available tools"):70, ("Python", "popularity"):50,
("Python", "power & expressiveness"):100, ("Python", "cross
platform?"):100, ("Python", "cost"):100,
("Perl", "ease of learning"):50, ("Perl", "ease of use"):90, ("Perl",
"speed of program execution"):30, ("Perl", "quality of available
tools"):50, ("Perl", "popularity"):75, ("Perl", "power &
expressiveness"):100, ("Perl", "cross platform?"):100, ("Perl",
"cost"):100,
("Ruby", "ease of learning"):50, ("Ruby", "ease of use"):100, ("Ruby",
"speed of program execution"):20, ("Ruby", "quality of available
tools"):20, ("Ruby", "popularity"):10, ("Ruby", "power &
expressiveness"):100, ("Ruby", "cross platform?"):80, ("Ruby",
"cost"):100,
("Tcl", "ease of learning"):100, ("Tcl", "ease of use"):100, ("Tcl",
"speed of program execution"):10, ("Tcl", "quality of available
tools"):50, ("Tcl", "popularity"):40, ("Tcl", "power &
expressiveness"):10, ("Tcl", "cross platform?"):100, ("Tcl",
"cost"):100,
("JavaScript", "ease of learning"):70, ("JavaScript", "ease of use"):75,
("JavaScript", "speed of program execution"):10, ("JavaScript", "quality
of available tools"):50, ("JavaScript", "popularity"):100,
("JavaScript", "power & expressiveness"):40, ("JavaScript", "cross
platform?"):50, ("JavaScript", "cost"):100,
("Visual Basic", "ease of learning"):50, ("Visual Basic", "ease of
use"):100, ("Visual Basic", "speed of program execution"):20, ("Visual
Basic", "quality of available tools"):100, ("Visual Basic",
"popularity"):100, ("Visual Basic", "power & expressiveness"):50,
("Visual Basic", "cross platform?"):1, ("Visual Basic", "cost"):1,
("Java", "ease of learning"):15, ("Java", "ease of use"):50, ("Java",
"speed of program execution"):50, ("Java", "quality of available
tools"):100, ("Java", "popularity"):100, ("Java", "power &
expressiveness"):100, ("Java", "cross platform?"):100, ("Java",
"cost"):100,
("C++", "ease of learning"):10, ("C++", "ease of use"):25, ("C++",
"speed of program execution"):90, ("C++", "quality of available
tools"):100, ("C++", "popularity"):100, ("C++", "power &
expressiveness"):100, ("C++", "cross platform?"):100, ("C++",
"cost"):100,
("C", "ease of learning"):15, ("C", "ease of use"):10, ("C", "speed of
program execution"):100, ("C", "quality of available tools"):100, ("C",
"popularity"):100, ("C", "power & expressiveness"):100, ("C", "cross
platform?"):110, ("C", "cost"):100,
("Lisp", "ease of learning"):20, ("Lisp", "ease of use"):30, ("Lisp",
"speed of program execution"):70, ("Lisp", "quality of available
tools"):50, ("Lisp", "popularity"):25, ("Lisp", "power &
expressiveness"):110, ("Lisp", "cross platform?"):80, ("Lisp",
"cost"):90,
("Delphi", "ease of learning"):50, ("Delphi", "ease of use"):110,
("Delphi", "speed of program execution"):85, ("Delphi", "quality of
available tools"):100, ("Delphi", "popularity"):30, ("Delphi", "power &
expressiveness"):100, ("Delphi", "cross platform?"):80, ("Delphi",
"cost"):10}

result = {}
for o in options:
        value = 0
        for c in criteria:

                value = value + rankings[c] * score[o, c]
        result[o] = value

results = result.items()        # A list of tuples (key, value)
results.sort(lambda x, y: -cmp(x[1], y[1]))
                                # Sort the list using the reverse of the

                                # "value" of the entry, so that higher
                                # values come first


print html % ("Hello, %s." % form['easeuse'].value)

print html % form['easeuse'].value








From sstorni2001@terra.com.ar  Mon Nov 19 12:13:00 2001
From: sstorni2001@terra.com.ar (sstorni2001@terra.com.ar)
Date: 19 Nov 2001 09:13:00 -0300
Subject: [Tutor] INVITACION ESPECIAL A PARTICIPAR EN EL PATAGONIA CHALLENGE
Message-ID: <E165u4i-0000zr-00@mail.python.org>

------=_1xNAQHwu_EhWDaHKb_MA
Content-Type: text/plain
Content-Transfer-Encoding: 8bit

--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
(This safeguard is not inserted when using the registered version)
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------

--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
(This safeguard is not inserted when using the registered version)
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------
--------------------------------------------------------------------


------=_1xNAQHwu_EhWDaHKb_MA
Content-Type: text/html
Content-Transfer-Encoding: 8bit

<html>

<head>
<meta http-equiv="Content-Language" content="es-mx">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>Invitación Especial</title>
</head>
<body background="http://artea.com.ar/papeleros/fondo.jpg">

<div align="center">
  <center>
  <table border="2" cellpadding="0" width="650" bordercolor="#FF0000" height="63">
    <tr>
      <td width="100%" height="59">
        <div align="center">
          <table border="0" cellpadding="0" cellspacing="0" width="100%" height="1578">
            <tr>
              <td width="100%" bgcolor="#000000" height="396">
                <div align="center">
                  <table border="0" cellpadding="0" cellspacing="0" width="100%" height="1">
                    <tr>
                      <td width="66%" rowspan="2" height="1">
                        <p align="center"><font color="#FFFFFF"><img border="0" src="http://www.geocities.com/nuestrasmanos2001/Senalandote.jpg" align="right" width="384" height="392"></font></td>
                      <td width="34%" valign="top" height="1" colspan="2"><font color="#FFFFFF"><img border="0" src="http://www.geocities.com/nuestrasmanos2001/Patagonia_Challenge.gif" width="177" height="215"></font></td>
                    </tr>
                    <tr>
                      <td width="3%" valign="top" height="33"></td>
                      <td width="31%" valign="top" height="33"><b><font face="Arial" size="6" color="#FF0000">Invitación
                        Especial !!!!</font></b></td>
                    </tr>
                  </table>
                </div>
              </td>
            </tr>
            <tr>
              <td width="100%" height="19" bgcolor="#FFFFFF"></td>
            </tr>
            <tr>
              <td width="100%" height="1163" bgcolor="#FFFFFF">
                <div align="center">
                  <table border="0" cellpadding="0" cellspacing="0" width="100%" height="1639">
                    <tr>
                      <td width="2%" height="1639"></td>
                      <td width="96%" align="justify" height="1639">
<p><b><font face="Arial" size="3">Estimados Corredores:</font></b></p>
                        <p><i>
<font FACE="Arial" SIZE="2">Soy
<b> </font><font face="Arial" size="3">Sebastián de la Cruz</font><font FACE="Arial" SIZE="2">,</font></b></i>
                        <font FACE="Arial" SIZE="2">no creo que me conozcan en el ambiente de la competición, salvo si han corrido
el <b><i>Raid Gauloises ’95</i></b> en Bariloche, o el <b><i>Eco Challenge</i></b>
de <b>Marruecos ’98</b> o el de <b>Bariloche ’99</b>, o en el <b><i>Elf
Authentic Adventure</i></b> en Brasil ‘2000; o bien sean del ambiente de la
montaña.</font></p>
                        <p><font FACE="Arial" SIZE="2">
Siempre he estado ligado a los deportes de montaña por lo que no me han de
conocer en los escenarios del atletismo. Cuestiones de los tiempos que corren,
ambas disciplinas han confluido felizmente en esto de las Carreras de Aventuras,
una apasionante y explosiva conjunción de deporte y naturaleza.</font></p>
                        <p><font FACE="Arial" SIZE="2">
Me inicié en estas carreras, en la organización para ser más preciso, con el <b><i>Raid
Gauloises</i></b> Argentina 1995. Los precursores. Luego con la aparición en
escena de <b><i>Eco Challenge</i></b> pude participar en 1998 de toda la movida
en Marruecos, para luego asumir más responsabilidades durante el memorable <b><i>Eco
Challenge Argentina 1999</i></b>.</font></p>
                        <p><font FACE="Arial" SIZE="2">
Hace unos diez años hablar de una carrera de expedición era algo difícil de
describir. Hoy las competencias de este tipo están en pleno auge y ahora son
más los que ya saben de qué estamos hablando. Lo que más me gusta de estas competencias es crearlas, organizarlas,
ejecutarlas, filmarlas. No es que me coloque del otro lado del mostrador pero
detrás de un evento hay un gran desafío organizativo que se da cita con los
deportistas el día de la largada. <b> Hacer coincidir todo en el espacio y tiempo
correctos, con la mejor onda: ese es mi puesto.</b></font></p>
                        <p><font FACE="Arial" SIZE="2"><b>
Tras haber organizado grandes eventos con distinguidas figuras como Gérard
Fusil, Mark Burnett o Sebastián Tagle, algunos me preguntan: ¿Por qué no
hacer algo propio?</b></font></p>
                        <p><font FACE="Arial" SIZE="2">Sin el apoyo de sponsors no es fácil pero gracias a mi experiencia en armado de
programas y actividades de turismo de aventura sé que afilando el lápiz es
posible armar un buen evento.</font></p>
                        <p><font FACE="Arial" SIZE="2">
La encuesta realizada por <b> Santiago Storni</b>, principalmente a través de la
revista <i>&quot;al borde&quot;</i>, arroja que algunos interesados no son de
los que quieren correr día y noche como perros sedientos y ganarles a los que
le vienen pisando los talones. Creo que los entiendo perfectamente.<br>
No todos están dispuestos a sufrir demasiado, a no dormir, a padecer penurias,
desgaste y malhumor. Está bien eso de llegar a conocer los propios límites e
incluso superarlos pero... <b> calma, hagamos algo humano, por favor! Algo a lo cual
podamos verle la línea de llegada; si no ¿qué sentido tiene?</b></font></p>
                        <p><font FACE="Arial" SIZE="2">
Por ello hemos diseñado un itinerario que reúne a todos los corredores cada
noche en lugares para comer y tomar algo, y dormir disfrutando de la vida. Con
tiempo para verse las caras, compartir las experiencias del día, las
anécdotas, las penas y las grandes alegrías.<br>
La exigencia de las pruebas durante el día no se prolonga en el tiempo más de
lo que normalmente tomaría hacerlas para una persona de aceptable condición
física. No hay días de más de doce horas de actividad.<br>
Repartidas en un cocktail que en total suma:</p>
<blockquote>
  <b>
  <p>Trek</b>: 122km en los cuales están computados las caminatas por senderos,
  glaciares (6km), cañaverales, filos y terreno montañoso en general.</p>
  <b>
  <p>Canotaje</b>: 63km de los cuales aprox. 30km son por lagos, 15km en ríos
  de dificultad hasta Clase IV y 15km en río de dificultad Clase 1 pero con
  obstáculos.</p>
  <b>
  <p>Bicicleta</b>: 41km. en rutas de ripio, y senderos.</p>
</blockquote>
<p>Mucho del itinerario coincide con el del<i>  <b> Discovery Channel - Eco Challenge
1999</b></i> <b> y <i>Raid Gauloises 1995</i>.</b>&nbsp;</p>
<p>No estoy tratando de &quot;venderles&quot; este evento como el mejor momento de
su vida, abusando de adjetivos ya agotados y prosa que alterna la ecología y el
deporte. Cada persona tiene experiencias únicas, personales, irrepetibles.
Simplemente describiré los ingredientes que estarán en juego.<br>
No empleo frases trilladas como <i>lagos prístinos de verde turquesa, ríos
cristalinos, aire &quot;rico&quot;, bramido del viento en las copas de los
árboles, estrellas tímidas y titilantes, luna majestuosa, condor curioso,
comida caliente entre las manos frías</i>, etc. porque es innecesario. Además
no soy buen poeta.</p>
<p><b>
Este es un producto que puede llamarse &quot;familiar&quot; o de
&quot;amigos&quot;, para que el atleta de élite venga a correr con toda su
familia, señora y los chicos más grandes (mínimo 14 años). O el corredor
consumado (no confundir con consumido) que saca a pasear a sus compañeros de
barrio a la Cordillera de los Andes, ellos que nunca salieron del
&quot;partidito de fulbo&quot; de los domingos.</b></font><b><font face="Arial" size="3">&nbsp;</font></b></p>
<p><b><font face="Arial" size="3"> ¿Quién de estos atletas no se
ha planteado alguna vez poder compartir con los suyos su sapiencia, su
conocimiento y experiencia a lo largo de un evento de varios días,
compartiendo, disfrutando, yendo al ritmo del corazón y no siguiendo la liebre?</font></b>&nbsp;</p>
<p><font FACE="Arial" SIZE="2">Obviamente tampoco pueden ir pescando y siesteando en cada lugar bonito. Hay
horas de cierre para ciertas disciplinas. Si no llegan antes de cierta hora
pasan a la actividad siguiente directamente y también a otra categoría. Ya lo
explicaremos más en detalle en el Reglamento.</font></p>
<p><font FACE="Arial" SIZE="2"><b>
Quienes decidan tomar parte de esta carrera, serán partícipes de una gran
aventura personal y grupal.<br>
Esta vez no se trata de ver quién llega primero; aquí todos pueden llegar.
Alejamos todos los fantasmas previos a la largada y nos preparamos para
disfrutar y pasarla bien. La experiencia fuerte forjará recuerdos inolvidables junto a sus seres
queridos.</b></p>
</font>
<b><i>
<p ALIGN="RIGHT"><font face="Arial" size="3">Sebastián de la Cruz</font></p>
</i></b><i>
<font FACE="Arial" SIZE="2">
<p ALIGN="RIGHT">Pampa Linda, septiembre 2001</p>
<p ALIGN="RIGHT">PATAGONIA ARGENTINA</p>
</font>
<div align="center">
  <table border="2" cellpadding="0" cellspacing="0" width="100%" bordercolor="#FF0000" height="90">
    <tr>
      <td width="100%" align="justify" height="88">
        <div align="justify">
          <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <tr>
              <td width="2%"></td>
              <td width="95%" align="justify"><i>
<font face="Arial" size="3"><b>Todos los que quieran obtener más datos sobre la
carrera (fechas, lugares, costos,etc) comuníquense con Santiago Storni a través
del siguiente mail:</b></font>
</i></td>
              <td width="3%"></td>
            </tr>
          </table>
        </div>
        <p align="center"><a href="mailto:sstorni2001@terra.com.ar"><font face="Arial" size="3"><b>sstorni2001@terra.com.ar</b></font></a></p>
      </td>
    </tr>
  </table>
</div>
</i>
  </center>
                        <p align="right"><b><font face="Verdana" size="2">Espero
                      contar con tu participación!</font></b></td>
  <center>
                      <td width="2%" height="1639"></td>
                    </tr>
                  </table>
                </div>
              </td>
            </tr>
          </table>
        </div>
      </td>
    </tr>
  </table>
  </center>
</div>

</body>

</html>


------=_1xNAQHwu_EhWDaHKb_MA--



From DoNotReplyByEmail@yahoo.com  Mon Nov 19 19:13:02 2001
From: DoNotReplyByEmail@yahoo.com (DoNotReplyByEmail@yahoo.com)
Date: Mon, 19 Nov 01 14:13:02 EST
Subject: [Tutor] >>>ADVERTISE TO 11,295,000 PEOPLE FREE!
Message-ID: <3791856948.991306994491@m0.net  Received: from dialup-62.215.274.4.dial1.stamford ([62.215.274.4]  >

Dear tutor@python.org,

              
                 ***********************************************************
                 Would you like to send an Email Advertisement to
                   OVER 11 MILLION PEOPLE DAILY for FREE?
                 ***********************************************************
 
Do you have a product or service to sell?
Do you want an extra 100 orders per week?

NOTE: (If you do not already have a product or service to sell, we can 
supply you with one).

=========================================================
1) Let's say you... Sell a $24.95 PRODUCT or SERVICE.
2) Let's say you... Broadcast Email to only 500,000 PEOPLE.
3) Let's say you... Receive JUST 1 ORDER for EVERY 2,500 EMAILS.

CALCULATION OF YOUR EARNINGS BASED ON THE ABOVE STATISTICS:

[Day 1]: $4,990  [Week 1]: $34,930  [Month 1]: $139,720

========================================================
To find out more information, Do not respond by email. Instead, Please 
visit our web site at: 

http://www.bigcashtoday.com/package1.htm



List Removal Instructions:
We hope you enjoyed receiving this message. However, if you'd rather 
not receive future e-mails of this sort from Internet Specialists, send an
email to freeemailsoftware3@excite.com and type "remove" in the 
"subject" line and you will be removed from any future mailings.

We hope you have a great day!
Internet Specialists



From jane@jhandcock.freeserve.co.uk  Mon Nov 19 19:49:51 2001
From: jane@jhandcock.freeserve.co.uk (Jane Handcock)
Date: Mon, 19 Nov 2001 19:49:51 -0000
Subject: [Tutor] time delay in graphics loop
Message-ID: <NEBBKOBFALPLCFBNMACBIEEDCAAA.jane@jhandcock.freeserve.co.uk>

Hi

I have just started to use Python and am working through the LiveWires
Python Course.
Can anyone explain why the time delay in the code below works fine (before
the graphics window is filled with blue circles), but the program hangs if I
put the line time.sleep(1) inside the y or x loops?


from livewires import *
import time
begin_graphics()
set_colour(Colour.blue)
time.sleep(5)
for y in range(12):
    for x in range(16):
        circle(x*40+20,y*40+20,20)
end_graphics



From lkvam@venix.com  Mon Nov 19 19:50:01 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Mon, 19 Nov 2001 14:50:01 -0500
Subject: [Tutor] Please help me with my first CGI program???
References: <3BF95E67.F710E8FF@earthlink.net>
Message-ID: <3BF96269.2060808@venix.com>

The Perl CGI module will prompt you for inputs when you run a Perl CGI 
script standalone.  Python isn't as obvious.

form = cgi.FieldStorage()            # parse form data

This does not give you a valid form dictionary when run standalone.  You 
must build the dictionary by hand.  Something along the lines of:

debugging = 1
if debugging:
	form = { 'easelearning' : '1',
		'easeuse' : '2',
...
	}

You could put the debugging code just under the call to FieldStorage. 
Remember to turn off debugging (debugging = 0) before copying this to 
your web server.

Ron Stephens wrote:

> Any help would be appreciated. I am getting a KEYERROR when I run my CGI
> program as a standalone python program. Maybe its just because the
> standalone python program doesn't have the input data from the FORM I
> use in my HTML input page to my CGI. Howver, I get no error messages
> from actaully running my CGI on the web (just a general serer error),
> even though I set sys.stderr = sys.stdout
> 
> I know I'm a clueless newbie, but even any general help will be greatly
> appreciated. I think I am almost there, but I can't figure out a way to
> effectively debug my CGI program.
> 
> IDLE gives me the following error message when I run the program in IDLE
> as a stand-alone program::
> 
> Content-type: text/html
> Traceback (most recent call last):
>   File "C:/Python21/aaacgi.py", line 26, in ?
>     rankings = {"ease of learning" : form['easelearning'].value,
>   File "C:\PYTHON21\lib\cgi.py", line 547, in __getitem__
>     raise KeyError, key
> KeyError: easelearning
> 
> The input HTML page is:::
> 
> <html><body>
> <title>CGI 101</title>
> <H1>A first user interaction: forms</H1>
> <hr>
> <form method=POST action="http://www.awaretek.com/test3.cgi">
> 
> Input an integer from 1 to 100, as a weight or relative importance
> factor for each of the citeria below. 1 means not very importnat to you,
> 100 menas extremely important to you
> 
> 
> <P><B>ease of learning</B>
>     <input type=text name=easelearning>
> 
>  <P><B>ease of use</B>
>     <input type=text name=easeuse>
> 
>  <P><B>speed of program execution</B>
>     <input type=text name=speed>
> 
>  <P><B>quality of available tools</B>
>     <input type=text name=tools>
> 
>  <P><B>popularity</B>
>     <input type=text name=pop>
> 
>  <P><B>power and expressiveness</B>
>     <input type=text name=power>
> 
>  <P><B>cross-platform</B>
>     <input type=text name=cross>
> 
>  <P><B>cost</B>
>     <input type=text name=cost>
>     <input type=submit>
> </form>
> </BODY></HTML>
> 
> 
> The CGIU program follows. The data for FORM is fed into the cgi program
> by the HTML FORM above:::
> 
> #!/usr/bin/python
> #######################################################
> # runs on the server, reads form input, prints html;
> # url=http://server-name/root-dir/Basics/test3.cgi
> #######################################################
> 
> import cgi
> import string
> import sys
> sys.stderr = sys.stdout
> form = cgi.FieldStorage()            # parse form data
> print "Content-type: text/html"      # plus blank line
> 
> html = """
> <TITLE>test3.cgi</TITLE>
> <H1>Greetings</H1>
> <HR>
> <P>%s</P>
> <HR>"""
> 
> 
> 
> options = ["Python", "Perl", "Ruby", "Tcl", "JavaScript", "Visual
> Basic", "Java", "C++", "C", "Lisp", "Delphi"]
> criteria = ["ease of learning", "ease of use", "speed of program
> execution", "quality of available tools", "popularity", "power &
> expressiveness", "cross platform?", "cost"]
> 
> rankings = {"ease of learning":form['easelearning'].value,
> 
> 
> "ease of learning" : form['easelearning'].value,
> "ease of use" = form['easeuse'].value,
> "speed" = form['speed'].value,
> "tools" = form['tools'].value,
> "pop" = form['pop'].value,
> "power" = form['power'].value,
> "cross"] = form['cross'].value,
> "cost"] = form['cost'].value}
> 
> score = {("Python", "ease of learning"):100, ("Python", "ease of
> use"):100, ("Python", "speed of program execution"):10, ("Python",
> "quality of available tools"):70, ("Python", "popularity"):50,
> ("Python", "power & expressiveness"):100, ("Python", "cross
> platform?"):100, ("Python", "cost"):100,
> ("Perl", "ease of learning"):50, ("Perl", "ease of use"):90, ("Perl",
> "speed of program execution"):30, ("Perl", "quality of available
> tools"):50, ("Perl", "popularity"):75, ("Perl", "power &
> expressiveness"):100, ("Perl", "cross platform?"):100, ("Perl",
> "cost"):100,
> ("Ruby", "ease of learning"):50, ("Ruby", "ease of use"):100, ("Ruby",
> "speed of program execution"):20, ("Ruby", "quality of available
> tools"):20, ("Ruby", "popularity"):10, ("Ruby", "power &
> expressiveness"):100, ("Ruby", "cross platform?"):80, ("Ruby",
> "cost"):100,
> ("Tcl", "ease of learning"):100, ("Tcl", "ease of use"):100, ("Tcl",
> "speed of program execution"):10, ("Tcl", "quality of available
> tools"):50, ("Tcl", "popularity"):40, ("Tcl", "power &
> expressiveness"):10, ("Tcl", "cross platform?"):100, ("Tcl",
> "cost"):100,
> ("JavaScript", "ease of learning"):70, ("JavaScript", "ease of use"):75,
> ("JavaScript", "speed of program execution"):10, ("JavaScript", "quality
> of available tools"):50, ("JavaScript", "popularity"):100,
> ("JavaScript", "power & expressiveness"):40, ("JavaScript", "cross
> platform?"):50, ("JavaScript", "cost"):100,
> ("Visual Basic", "ease of learning"):50, ("Visual Basic", "ease of
> use"):100, ("Visual Basic", "speed of program execution"):20, ("Visual
> Basic", "quality of available tools"):100, ("Visual Basic",
> "popularity"):100, ("Visual Basic", "power & expressiveness"):50,
> ("Visual Basic", "cross platform?"):1, ("Visual Basic", "cost"):1,
> ("Java", "ease of learning"):15, ("Java", "ease of use"):50, ("Java",
> "speed of program execution"):50, ("Java", "quality of available
> tools"):100, ("Java", "popularity"):100, ("Java", "power &
> expressiveness"):100, ("Java", "cross platform?"):100, ("Java",
> "cost"):100,
> ("C++", "ease of learning"):10, ("C++", "ease of use"):25, ("C++",
> "speed of program execution"):90, ("C++", "quality of available
> tools"):100, ("C++", "popularity"):100, ("C++", "power &
> expressiveness"):100, ("C++", "cross platform?"):100, ("C++",
> "cost"):100,
> ("C", "ease of learning"):15, ("C", "ease of use"):10, ("C", "speed of
> program execution"):100, ("C", "quality of available tools"):100, ("C",
> "popularity"):100, ("C", "power & expressiveness"):100, ("C", "cross
> platform?"):110, ("C", "cost"):100,
> ("Lisp", "ease of learning"):20, ("Lisp", "ease of use"):30, ("Lisp",
> "speed of program execution"):70, ("Lisp", "quality of available
> tools"):50, ("Lisp", "popularity"):25, ("Lisp", "power &
> expressiveness"):110, ("Lisp", "cross platform?"):80, ("Lisp",
> "cost"):90,
> ("Delphi", "ease of learning"):50, ("Delphi", "ease of use"):110,
> ("Delphi", "speed of program execution"):85, ("Delphi", "quality of
> available tools"):100, ("Delphi", "popularity"):30, ("Delphi", "power &
> expressiveness"):100, ("Delphi", "cross platform?"):80, ("Delphi",
> "cost"):10}
> 
> result = {}
> for o in options:
>         value = 0
>         for c in criteria:
> 
>                 value = value + rankings[c] * score[o, c]
>         result[o] = value
> 
> results = result.items()        # A list of tuples (key, value)
> results.sort(lambda x, y: -cmp(x[1], y[1]))
>                                 # Sort the list using the reverse of the
> 
>                                 # "value" of the entry, so that higher
>                                 # values come first
> 
> 
> print html % ("Hello, %s." % form['easeuse'].value)
> 
> print html % form['easeuse'].value
> 
> 
> 
> 
> 
> 
> 
> _______________________________________________
> 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 lkvam@venix.com  Mon Nov 19 19:54:28 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Mon, 19 Nov 2001 14:54:28 -0500
Subject: [Tutor] time delay in graphics loop
References: <NEBBKOBFALPLCFBNMACBIEEDCAAA.jane@jhandcock.freeserve.co.uk>
Message-ID: <3BF96374.3000708@venix.com>

When you put the sleep inside the y loop, you sleep for 5 seconds 
everytime through the loop, = 60 seconds plus the other processing time.

Within x it is sleeping 12 * 16 * 5 which is a lot of seconds. 
presumably, it is not hung, just much slower than your patience level.

Jane Handcock wrote:

> Hi
> 
> I have just started to use Python and am working through the LiveWires
> Python Course.
> Can anyone explain why the time delay in the code below works fine (before
> the graphics window is filled with blue circles), but the program hangs if I
> put the line time.sleep(1) inside the y or x loops?
> 
> 
> from livewires import *
> import time
> begin_graphics()
> set_colour(Colour.blue)
> time.sleep(5)
> for y in range(12):
>     for x in range(16):
>         circle(x*40+20,y*40+20,20)
> end_graphics
> 
> 
> _______________________________________________
> 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 gubitz@netcologne.de  Mon Nov 19 21:26:29 2001
From: gubitz@netcologne.de (Hans Gubitz)
Date: Mon, 19 Nov 2001 22:26:29 +0100
Subject: [Tutor] os.system
In-Reply-To: <20011117170745.A939@redwitz79.de>
References: <20011117170745.A939@redwitz79.de>
Message-ID: <20011119222629.A11346@redwitz79.de>

Thank you for the hints. What do you think about:


import os, string
class bild:
    def __init__(self, host, bild):
        self.host = host
        self.bild = bild
        kommando = "xv -display %s:0.0 %s&" % (host,bild)
        os.system(kommando)
        self.pid = self.suche()
    def suche(self):
        pr = os.popen("ps axw","r")
        zeilen=pr.readlines()
        print zeilen
        pr.close()
        for zeile in zeilen:
            if string.find(zeile,self.host) >= 0 and string.find(zeile,self.bild) >= 0:
                pid = string.split(zeile," ")[0]
        return int(pid)
    def kill(self):
        os.kill(self.pid,15)

-- 
Hans Gubitz <gubitz@netcologne.de>



From arcege@speakeasy.net  Mon Nov 19 23:12:53 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Mon, 19 Nov 2001 18:12:53 -0500
Subject: [Tutor] os.system
In-Reply-To: <20011119222629.A11346@redwitz79.de>; from gubitz@netcologne.de on Mon, Nov 19, 2001 at 10:26:29PM +0100
References: <20011117170745.A939@redwitz79.de> <20011119222629.A11346@redwitz79.de>
Message-ID: <20011119181253.C1027@speakeasy.net>

On Mon, Nov 19, 2001 at 10:26:29PM +0100, Hans Gubitz wrote:
> Thank you for the hints. What do you think about:
> 
> 
> import os, string
> class bild:
>     def __init__(self, host, bild):
>         self.host = host
>         self.bild = bild
>         kommando = "xv -display %s:0.0 %s&" % (host,bild)
>         os.system(kommando)
>         self.pid = self.suche()
>     def suche(self):
>         pr = os.popen("ps axw","r")
>         zeilen=pr.readlines()
>         print zeilen
>         pr.close()
>         for zeile in zeilen:
>             if string.find(zeile,self.host) >= 0 and string.find(zeile,self.bild) >= 0:
>                 pid = string.split(zeile," ")[0]
>         return int(pid)
>     def kill(self):
>         os.kill(self.pid,15)

You might want to look at the popen2.Popen3 object.  The problem with
your mechanism is that

* not all UNIX systems use "ps axw" for what you wish, and
* if another process of your program, or the same process, calls
  bild() with the same arguments, or if someone calls the same resulting
  command to 'xv', then you could possibly get the wrong pid.

The Popen3 object will give you the pid, and the file objects to and from
the process.  There is a poll() method for you to periodically check to
see if the process had finished - this is probably more of what you want.

class bild:
  def __init__(self, host, bild)
    self.host = host
    self.bild = bild
    cmd = 'xv -display %s:0.0 %s' % (host, bild)
    self.pid = popen2.Popen3(cmd, 0)

  def kill(self):
    sts = self.pid.poll()
    if sts == -1:
      os.kill(self.pid.pid, 15)
      sts = self.pid.wait()  # need this to prevent zombies at least
    return sts

This might be a little more secure for your needs.

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From wilson@visi.com  Tue Nov 20 00:50:25 2001
From: wilson@visi.com (Timothy Wilson)
Date: Mon, 19 Nov 2001 18:50:25 -0600 (CST)
Subject: [Tutor] Parsing non-uniform strings
Message-ID: <Pine.GSO.4.21.0111191841420.19196-100000@isis.visi.com>

Hi everyone,

I'm working up an assignment for my programming students and I'd like to get
some feedback on strategies that could be used to solve this problem.

The basic assignment is to retrieve the current weather conditions from the
National Weather Service's automated stations using the urllib2 module and
display them in some human-readable format. The challenge is that that the
codes are not as uniform as I would like.

The data are given in "METAR" format. (See a description and relevant links
at the Web page I'm working on at
http://www.isd197.org/sibley/cs/icp/assignments/weather_html)

Here are five sample METAR reports from a variety of stations including
South St. Paul, Minnesota; Barrow, Alaska; San Diego, California; Denver,
Colorado; and New York, New York.

2001/11/19,23:56:00,KSGS,192356Z,AUTO,00000KT,10SM,CLR,03/M07,A3019,RMK,AO2
2001/11/19,21:53:00,PABR,192153Z,11019KT,4SM,BLSN,BR,FEW012,OVC038,M17/M18,A2985,RMK,AO2,CIG,12,NE,SLP110,T11671178
2001/11/19,19:57:00,KNKX,191957Z,32007KT,15SM,FEW200,22/09,A3013,RMK,SLP199,T02170094
2001/11/19,21:53:00,KDEN,192153Z,13007KT,10SM,FEW250,11/M07,A3032,RMK,AO2,SLP263,T01061067
2001/11/19,21:51:00,KLGA,192151Z,17008KT,10SM,FEW250,13/10,A2996,RMK,AO2,SLP145,T01330100

You can see that there is some uniformity, but not much. At this point I
would like my students to retrieve the date, time, and temperature. (See my
Web page for details about the particular fields.)

Does anyone have some general advise about parsing data like this? This may
be biting off more than my students are able to chew at this point.

-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  Tue Nov 20 01:02:24 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Mon, 19 Nov 2001 17:02:24 -0800 (PST)
Subject: [Tutor] Parsing non-uniform strings
In-Reply-To: <Pine.GSO.4.21.0111191841420.19196-100000@isis.visi.com>
Message-ID: <XFMail.20011119170224.shalehperry@home.com>

> 
> You can see that there is some uniformity, but not much. At this point I
> would like my students to retrieve the date, time, and temperature. (See my
> Web page for details about the particular fields.)
> 
> Does anyone have some general advise about parsing data like this? This may
> be biting off more than my students are able to chew at this point.
> 

A fellow recently released a program called GoWeather which is a weather app
for the agenda handheld.  It was a combo of a C++ based viewer and a perl based
parser.  You could review how he did it and duplicate it in python.  I suspect
a well written regex along with some other string splitting will tame this one.


From apython101@yahoo.com  Tue Nov 20 01:09:28 2001
From: apython101@yahoo.com (john public)
Date: Mon, 19 Nov 2001 17:09:28 -0800 (PST)
Subject: [Tutor] compiler
In-Reply-To: <E165zIQ-0001N4-00@mail.python.org>
Message-ID: <20011120010928.96854.qmail@web21103.mail.yahoo.com>

 I think I just successfully downloaded python2.1
 So I was going to compile and run "Hello World"
 I can't seem to find the icon to get the compiler  
 up and running. I tried clicking on existing  
 programs that downloaded with python but it brought 
 up my dev c++ compiler not the python compiler.
 Suggestions greatly appreciated.

 Tanks

 

__________________________________________________
Do You Yahoo!?
Find the one for you at Yahoo! Personals
http://personals.yahoo.com


From dsh8290@rit.edu  Tue Nov 20 01:27:37 2001
From: dsh8290@rit.edu (dman)
Date: Mon, 19 Nov 2001 20:27:37 -0500
Subject: [Tutor] compiler
In-Reply-To: <20011120010928.96854.qmail@web21103.mail.yahoo.com>; from apython101@yahoo.com on Mon, Nov 19, 2001 at 05:09:28PM -0800
References: <E165zIQ-0001N4-00@mail.python.org> <20011120010928.96854.qmail@web21103.mail.yahoo.com>
Message-ID: <20011119202737.A16340@harmony.cs.rit.edu>

On Mon, Nov 19, 2001 at 05:09:28PM -0800, john public wrote:
| 
|  I think I just successfully downloaded python2.1
|  So I was going to compile and run "Hello World"
|  I can't seem to find the icon to get the compiler  
|  up and running.

There is no compiler.  Python is interpreted, so there is no
compilation step.  Simply put the directory containing 'python.exe' in
your PATH (this may have been done by the installer, I don't know) and
run
    python myapp.py

where 'myapp.py' is the necessary path to your application's "main"
file.  (there is no "main" function, but the name can still be used
:-).  By "necessary path" I mean whatever relative or absolute path is
needed to identify the file from where you are (in the command
prompt).

|  I tried clicking on existing  
|  programs that downloaded with python but it brought 
|  up my dev c++ compiler not the python compiler.
|  Suggestions greatly appreciated.

This means the file type associates are not correct.  You were double
clicking on .py files, right?  If you want to have double-clicking on
a .py file try executing it, open up explorer and in the "options"
item in the "Tools" menu you can set the association of .py files to
be opened with "python.exe".  (I prefer to have my editor opened, but
you can do what you want with your system)

HTH,
-D



From dsh8290@rit.edu  Tue Nov 20 03:08:38 2001
From: dsh8290@rit.edu (dman)
Date: Mon, 19 Nov 2001 22:08:38 -0500
Subject: FW: Re: [Tutor] compiler
Message-ID: <20011119220838.A16663@harmony.cs.rit.edu>

I think this was meant for the list.


----- Forwarded message from Kirk Bailey <deliberatus@my995internet.com> -----

From: Kirk Bailey <deliberatus@my995internet.com>
Date: Mon, 19 Nov 2001 20:39:16 -0500
To: dman <dsh8290@ritvax.isc.rit.edu>
X-Mailer: Mozilla 4.74 [en] (Win98; U)

Is there nothing that will take a python script, and compile it in
runtime executable code? Python is wonderful, but a executable in
machine language compiled from something is a lot faster, which is VERY
handy if ou use the thing a lot.

dman wrote:
> 
> On Mon, Nov 19, 2001 at 05:09:28PM -0800, john public wrote:
> |
> |  I think I just successfully downloaded python2.1
> |  So I was going to compile and run "Hello World"
> |  I can't seem to find the icon to get the compiler
> |  up and running.
> 
> There is no compiler.  Python is interpreted, so there is no
> compilation step.  Simply put the directory containing 'python.exe' in
> your PATH (this may have been done by the installer, I don't know) and
> run
>     python myapp.py
> 
> where 'myapp.py' is the necessary path to your application's "main"
> file.  (there is no "main" function, but the name can still be used
> :-).  By "necessary path" I mean whatever relative or absolute path is
> needed to identify the file from where you are (in the command
> prompt).
> 
> |  I tried clicking on existing
> |  programs that downloaded with python but it brought
> |  up my dev c++ compiler not the python compiler.
> |  Suggestions greatly appreciated.
> 
> This means the file type associates are not correct.  You were double
> clicking on .py files, right?  If you want to have double-clicking on
> a .py file try executing it, open up explorer and in the "options"
> item in the "Tools" menu you can set the association of .py files to
> be opened with "python.exe".  (I prefer to have my editor opened, but
> you can do what you want with your system)
> 
> HTH,
> -D

-- 
Respectfully,
             -Kirk D Bailey (C)2001
              Addme! icq #27840081
end
      My Sites:
      http://www.howlermonkey.net/ - free REAL email! list service soon!
      http://www.sacredelectron.org/ - Rants! Spleenvents!
      http://www.minorfish.org/ - The list server for some of us!

Message of the week:
R5L9W SDPQW UVN7V RUBWB I6HFP WVCUT VWRVL
W7812 LVH8V JBVK2 3CEJB TO8P3 FHFHG H7BFM
QID68 6DN6F 6M486 YQNCF JECQP 86CNP 86CTT
JIQPF ZPVGV DLFST DBUDI UIFNC BTUBS ETBOE
BTTGV DLUIF NSFBM IBSE!


----- End forwarded message -----


From dsh8290@rit.edu  Tue Nov 20 03:15:40 2001
From: dsh8290@rit.edu (dman)
Date: Mon, 19 Nov 2001 22:15:40 -0500
Subject: [Tutor] Notes and Yahoo Mails via SMTP to Yahoo Messenger
In-Reply-To: <20011117123935.56424.qmail@web9601.mail.yahoo.com>; from james_fjm@yahoo.com on Sat, Nov 17, 2001 at 12:39:35PM +0000
References: <20011117123935.56424.qmail@web9601.mail.yahoo.com>
Message-ID: <20011119221539.A16671@harmony.cs.rit.edu>

On Sat, Nov 17, 2001 at 12:39:35PM +0000, James Foo wrote:
| 
| Hi,
| 
| I am looking for any hints that can lead me to a solution for the
| following scenario using Python: -- I need to read some messages
| from Lotus Notes mail as well as from Yahoo mail

What protocols do these servers support?  POP3 and IMAP4 are the
standard internet mail retrieval protocols, and python has built-in
libraries to deal with these (called poplib and imaplib respectively).

If the servers don't support the open protocol standards, then :

A worst-case scenario for Yahoo would be to build some HTML
interaction software that can submit a form (just a special URL) and
then parse the results to give you the data back.  Basically your
program would appear to be you with a web browser as far as yahoo is
concerned.

For Lotus, it may require learning their protocol (reverse
engineering, most likely) so you can implement it.  If you're lucky
there might be a C or C++ library providing protocol support that you
can wrap to provide a python interface.

| and via the SMTP, send them to Yahoo Messenger.

SMTP is very easy, and python includes the 'smtplib' module so you
don't have to do much work at all.

HTH,
-D



From dsh8290@rit.edu  Tue Nov 20 03:19:13 2001
From: dsh8290@rit.edu (dman)
Date: Mon, 19 Nov 2001 22:19:13 -0500
Subject: FW: Re: [Tutor] compiler
In-Reply-To: <20011119220838.A16663@harmony.cs.rit.edu>; from dsh8290@rit.edu on Mon, Nov 19, 2001 at 10:08:38PM -0500
References: <20011119220838.A16663@harmony.cs.rit.edu>
Message-ID: <20011119221913.B16671@harmony.cs.rit.edu>

| ----- Forwarded message from Kirk Bailey <deliberatus@my995internet.com> -----
| 
| From: Kirk Bailey <deliberatus@my995internet.com>
| Date: Mon, 19 Nov 2001 20:39:16 -0500
| To: dman <dsh8290@ritvax.isc.rit.edu>
| X-Mailer: Mozilla 4.74 [en] (Win98; U)
| 
| Is there nothing that will take a python script, and compile it in
| runtime executable code?

There is Gordon McMillan's "installer" and "py2exe", but they
basically just package up the interpreter and your source into a
single easy-to-install package.

| Python is wonderful, but a executable in machine language compiled
| from something is a lot faster, which is VERY handy if ou use the
| thing a lot.

Not really -- the crux is that python is dynamically typed.  The
compiler would need to be extrememly sophisticated and slow to perform
a complete flow analysis in order to ensure that any given operation
can be optimized (that only, for example, integers, are going to be
added).  Even that is not possible if eval(), or exec are used.
Basically, even if you did compile the python source down to machine
code, it would still need to be linked with the interpreter to handle
the dynamicness and it wouldn't be much, if any, faster.  Python
really isn't too slow anyways.

HTH,
-D



From dsh8290@rit.edu  Tue Nov 20 03:22:06 2001
From: dsh8290@rit.edu (dman)
Date: Mon, 19 Nov 2001 22:22:06 -0500
Subject: [Tutor] os.system
In-Reply-To: <20011119171315.A9526@redwitz79.de>; from gubitz@netcologne.de on Mon, Nov 19, 2001 at 05:13:15PM +0100
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0D3@mbtlipnt02.btlabs.bt.co.uk> <20011119171315.A9526@redwitz79.de>
Message-ID: <20011119222206.C16671@harmony.cs.rit.edu>

On Mon, Nov 19, 2001 at 05:13:15PM +0100, Hans Gubitz wrote:
| Hi,
| 
| On Mon, Nov 19, 2001 at 12:00:38AM -0000, alan.gauld@bt.com wrote:
| > assuming he wanted to kill it sooner...
| > Alan g
| 
| I want to show a picture and kill the shell, not as the user on the
| remote host, but from the local one.

What do you mean by "kill the shell"?  Do you want 'xv' to continue
running without 'sh'?  Or do you want to make 'xv' go away too?  Would
putting a '&' at the end of the command do want you want (run it in
the background, without a controlling tty)?

| So I will try to get the pid and kill the process.

You get the pid as the return value from fork().

-D



From deliberatus@my995internet.com  Tue Nov 20 04:00:52 2001
From: deliberatus@my995internet.com (Kirk Bailey)
Date: Mon, 19 Nov 2001 23:00:52 -0500
Subject: FW: Re: [Tutor] compiler
References: <20011119220838.A16663@harmony.cs.rit.edu>
Message-ID: <3BF9D574.56DD77BB@my995internet.com>

WHOOPS!

sorry. Did not notice there was no replyto field. Just clicked reply and
ran my fingers across the keys.

Hmmm, why do people set up lists this way? I ALWAYS set them up with a
replyto so that a simple click sends to the list, you have to make an
effort to send to a submitter.

A long term goal of mine is to create a python baised simple email list
server with some of the better features I have seen on majordomo,
minorfish, and mailman. For now, simply learning the language is the
task at hand.



dman wrote:
> 
> I think this was meant for the list.
> 
> ----- Forwarded message from Kirk Bailey <deliberatus@my995internet.com> -----
> 
> From: Kirk Bailey <deliberatus@my995internet.com>
> Date: Mon, 19 Nov 2001 20:39:16 -0500
> To: dman <dsh8290@ritvax.isc.rit.edu>
> X-Mailer: Mozilla 4.74 [en] (Win98; U)
> 
> Is there nothing that will take a python script, and compile it in
> runtime executable code? Python is wonderful, but a executable in
> machine language compiled from something is a lot faster, which is VERY
> handy if ou use the thing a lot.
> 
> dman wrote:
> >
> > On Mon, Nov 19, 2001 at 05:09:28PM -0800, john public wrote:
> > |
> > |  I think I just successfully downloaded python2.1
> > |  So I was going to compile and run "Hello World"
> > |  I can't seem to find the icon to get the compiler
> > |  up and running.
> >
> > There is no compiler.  Python is interpreted, so there is no
> > compilation step.  Simply put the directory containing 'python.exe' in
> > your PATH (this may have been done by the installer, I don't know) and
> > run
> >     python myapp.py
> >
> > where 'myapp.py' is the necessary path to your application's "main"
> > file.  (there is no "main" function, but the name can still be used
> > :-).  By "necessary path" I mean whatever relative or absolute path is
> > needed to identify the file from where you are (in the command
> > prompt).
> >
> > |  I tried clicking on existing
> > |  programs that downloaded with python but it brought
> > |  up my dev c++ compiler not the python compiler.
> > |  Suggestions greatly appreciated.
> >
> > This means the file type associates are not correct.  You were double
> > clicking on .py files, right?  If you want to have double-clicking on
> > a .py file try executing it, open up explorer and in the "options"
> > item in the "Tools" menu you can set the association of .py files to
> > be opened with "python.exe".  (I prefer to have my editor opened, but
> > you can do what you want with your system)
> >
> > HTH,
> > -D
> 
> --
> Respectfully,
>              -Kirk D Bailey (C)2001
>               Addme! icq #27840081
> end
>       My Sites:
>       http://www.howlermonkey.net/ - free REAL email! list service soon!
>       http://www.sacredelectron.org/ - Rants! Spleenvents!
>       http://www.minorfish.org/ - The list server for some of us!
> 
> Message of the week:
> R5L9W SDPQW UVN7V RUBWB I6HFP WVCUT VWRVL
> W7812 LVH8V JBVK2 3CEJB TO8P3 FHFHG H7BFM
> QID68 6DN6F 6M486 YQNCF JECQP 86CNP 86CTT
> JIQPF ZPVGV DLFST DBUDI UIFNC BTUBS ETBOE
> BTTGV DLUIF NSFBM IBSE!
> 
> ----- End forwarded message -----
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Respectfully,
             -Kirk D Bailey (C)2001
              Addme! icq #27840081
end
      My Sites:
      http://www.howlermonkey.net/ - free REAL email! list service soon!
      http://www.sacredelectron.org/ - Rants! Spleenvents!
      http://www.minorfish.org/ - The list server for some of us!

Message of the week:
R5L9W SDPQW UVN7V RUBWB I6HFP WVCUT VWRVL
W7812 LVH8V JBVK2 3CEJB TO8P3 FHFHG H7BFM
QID68 6DN6F 6M486 YQNCF JECQP 86CNP 86CTT
JIQPF ZPVGV DLFST DBUDI UIFNC BTUBS ETBOE
BTTGV DLUIF NSFBM IBSE!



From deliberatus@my995internet.com  Tue Nov 20 04:12:23 2001
From: deliberatus@my995internet.com (Kirk Bailey)
Date: Mon, 19 Nov 2001 23:12:23 -0500
Subject: [Tutor] file io and the open() function
References: <20011119220838.A16663@harmony.cs.rit.edu>
Message-ID: <3BF9D827.1F144335@my995internet.com>

A novice approaches the masters and asks:

I want to open a pair of files, read from one, wtite it to another,
appeding data.

The first is a list of local users, as:

me1
me2
him
him28
usfellas
him2
nothome
soandso

I want to append '@' and the text of a variable's contents, crating the
second file and filling it with:

me1@domain.foo
me2@domain.foo
him@domain.foo
him28@domain.foo
usfellas@domain.foo
him2@domain.foo
nothome@domain.foo
soandso@domain.foo

Which will be used as a mailing list to alert users of the system of
upcoming events. 

I wanted to craft this tool to use variables for the 2 files and the
domain name, so it would be a useful general purpose tool for use by
others. Alas, when it tries to open a file with a variable providing the
namer, it halts and catches fire, barfing evilgrams at me.


Also, as I cannot tell in advance howm any entries will be in the source
file, this thing has to work in a loop until the source file is
exausted, then close both files. How do I detet the endoffile and end
politely, instead of running off the end of the thing and tripping an
error?




-- 
Respectfully,
             -Kirk D Bailey (C)2001
              Addme! icq #27840081
end
      My Sites:
      http://www.howlermonkey.net/ - free REAL email! list service soon!
      http://www.sacredelectron.org/ - Rants! Spleenvents!
      http://www.minorfish.org/ - The list server for some of us!

Message of the week:
R5L9W SDPQW UVN7V RUBWB I6HFP WVCUT VWRVL
W7812 LVH8V JBVK2 3CEJB TO8P3 FHFHG H7BFM
QID68 6DN6F 6M486 YQNCF JECQP 86CNP 86CTT
JIQPF ZPVGV DLFST DBUDI UIFNC BTUBS ETBOE
BTTGV DLUIF NSFBM IBSE!



From urnerk@qwest.net  Tue Nov 20 05:34:56 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Mon, 19 Nov 2001 21:34:56 -0800
Subject: [Tutor] Parsing non-uniform strings
In-Reply-To: <Pine.GSO.4.21.0111191841420.19196-100000@isis.visi.com>
Message-ID: <4.2.0.58.20011119211607.00c0b6e0@pop3.norton.antivirus>

At 06:50 PM 11/19/2001 -0600, Timothy Wilson wrote:
>Hi everyone,
>
>I'm working up an assignment for my programming students and I'd like to 
>get some feedback on strategies that could be used to solve this problem.

Getting the data is step 1, parsing the data is step 2.  Some
websites give a lot of formatting, doing the parsing for you,
but making any screen scraping program wade through a lot of
HTML looking for values.

I prefer to just get the metar string, as per your examples.

>Does anyone have some general advise about parsing data like this?
>This may be biting off more than my students are able to chew at
>this point.
>
>-Tim

A key question is whether students in your class have any experience
with regular expressions.  These would make it easier to pick out
strings of the form dd/dd for temperature/dewpoint, each with an
optional M in front (e.g. [M]dd/[M]dd).  Supposedly that's unique
to the metar string, and you could find it like this:

     temp = re.compile(' (M{0,1}[\d]{2})/(M{0,1}[\d]{2}) ')

If a match is found, then match.group(1) will contain the
temperature, and match.group(2) the dew point temperature
(both in Celcius).  Likewise, the sky conditions may be
extracted by building a dictionary, e.g.

     skydict = {"BKN":"Broken","FEW":"Few",
                "OVC":"Overcast","CLR":"Clear",
                "C":"Clear","SCT":"Scattered",
                "VV":"Vertical visibility"}

and then searching on skydict.keys(), one at a time is
easiest:

         for k in self.skydict.keys():
             patt = " ("+k+")"+"([0-9]{3})"
             sky = re.compile(patt)
             match = re.search(sky,self.weather)
             if match:
                 self.report.append("Sky: %s @ %s ft" % \
                      (self.skydict[match.group(1)],\
                       match.group(2)))

Just for fun, I did a passable metar downloader and parser,
as if I were one of your students.  I can send you the full
source by email if you like.

Usage:

   >>> kpdx = metar.Wreport("KPDX") # new report object defined

   >>> kpdx.getdata()  # download data from website using urllib2

   >>> kpdx.weather  # gives the string parsed below
   'KPDX 200355Z 13010KT 10SM SCT070 BKN120 OVC200 12/09 A2988 RMK
   AO2 SLP119 T01170089'

   >>> kpdx.report     # list of data items, could be formatted
   ['Date/Time: 11.20.2001 03:55 GMT', 'Temp: 12 C ', 'Dew: 09 C ',
   'Sky: Overcast @ 200 ft', 'Sky: Scattered @ 070 ft',
   'Sky: Broken @ 120 ft']

Another example:

   >>> ksgs = metar.Wreport("KSGS")
   >>> ksgs.getdata()

   >>> for i in ksgs.report: print i

   Date/Time: 11.20.2001 04:56 GMT
   Temp: 01 C
   Dew: M06 C

   >>> ksgs.weather
   'KSGS 200456Z AUTO 00000KT 10SM CLR 01/M06 A3023 RMK AO2 '

I see a couple bugs.  CLR isn't being picked up, because I'm
looking for the 3-digits that aren't there in this case.  And
I should probably use a minus sign in place of the M for
temperatures.  I'll fix those in my metar.py after posting
this.

Thanks for sharing a fun, educational project.  I learned
a lot.

Kirby




From urnerk@qwest.net  Tue Nov 20 05:44:52 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Mon, 19 Nov 2001 21:44:52 -0800
Subject: [Tutor] file io and the open() function
In-Reply-To: <3BF9D827.1F144335@my995internet.com>
References: <20011119220838.A16663@harmony.cs.rit.edu>
Message-ID: <4.2.0.58.20011119214145.00c16970@pop3.norton.antivirus>

At 11:12 PM 11/19/2001 -0500, Kirk Bailey wrote:

<<SNIP>>


>I wanted to craft this tool to use variables for the 2 files and the
>domain name, so it would be a useful general purpose tool for use by
>others. Alas, when it tries to open a file with a variable providing the
>namer, it halts and catches fire, barfing evilgrams at me.

Something along these lines should do ya.  users.txt contains
the user list (sans @mydomain.com).  Call it whatever.
And name the outfile whatever (I called it emailaddrs.txt):

  >>> def listemails(infile,outfile,domain="mydomain.com"):
          inf = open(infile,'r')
          out = open(outfile,'w')
          for line in inf.readlines():
             addr = line.strip() + "@" + domain
             out.write(addr+"\n")
          inf.close
          out.close

  >>> listemails("users.txt","emailaddrs.txt")

Kirby



From glingl@aon.at  Tue Nov 20 07:04:52 2001
From: glingl@aon.at (Gregor Lingl)
Date: Tue, 20 Nov 2001 08:04:52 +0100
Subject: FW: Re: [Tutor] compiler
References: <20011119220838.A16663@harmony.cs.rit.edu> <20011119221913.B16671@harmony.cs.rit.edu>
Message-ID: <003301c17191$a74491d0$1664a8c0@mega>

BTW there are other people interested in
(and working on) compiling python:

http://homepages.ulb.ac.be/~arigo/psyco/

Maybe there will arise something useful(?)

Gregor


----- Original Message -----
From: "dman" <dsh8290@rit.edu>
To: <tutor@python.org>
Sent: Tuesday, November 20, 2001 4:19 AM
Subject: Re: FW: Re: [Tutor] compiler


> | ----- Forwarded message from Kirk Bailey
<deliberatus@my995internet.com> -----
> |
> | From: Kirk Bailey <deliberatus@my995internet.com>
> | Date: Mon, 19 Nov 2001 20:39:16 -0500
> | To: dman <dsh8290@ritvax.isc.rit.edu>
> | X-Mailer: Mozilla 4.74 [en] (Win98; U)
> |
> | Is there nothing that will take a python script, and compile it in
> | runtime executable code?
>
> There is Gordon McMillan's "installer" and "py2exe", but they
> basically just package up the interpreter and your source into a
> single easy-to-install package.
>
> | Python is wonderful, but a executable in machine language compiled
> | from something is a lot faster, which is VERY handy if ou use the
> | thing a lot.
>
> Not really -- the crux is that python is dynamically typed.  The
> compiler would need to be extrememly sophisticated and slow to perform
> a complete flow analysis in order to ensure that any given operation
> can be optimized (that only, for example, integers, are going to be
> added).  Even that is not possible if eval(), or exec are used.
> Basically, even if you did compile the python source down to machine
> code, it would still need to be linked with the interpreter to handle
> the dynamicness and it wouldn't be much, if any, faster.  Python
> really isn't too slow anyways.
>
> HTH,
> -D
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From dyoo@hkn.eecs.berkeley.edu  Tue Nov 20 10:02:56 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 20 Nov 2001 02:02:56 -0800 (PST)
Subject: FW: Re: [Tutor]         [message of the week]
In-Reply-To: <20011119220838.A16663@harmony.cs.rit.edu>
Message-ID: <Pine.LNX.4.21.0111200135350.21810-100000@hkn.eecs.berkeley.edu>

[Warning: the message below was originally for fun, so I'll show the
general process I used to decypher the message.  Might be useful as an
example of recreational programming.

However, I suddenly lost the thrill of it when I suddently realized what
the coded message below said.  It's a bit obscene.  Whoever's signature it
is, please be aware that there are intelligent and young people here.  
One could say that one nature of this mailing list is curiosity --- please
don't take advantage of that.  Thanks.]

###



Out of morbid curiosity, does anyone know what the heck that message of
the week is at the bottom of that message?

###
Message of the week:

[Hi, it's me speaking.  I've omitted the message.  Tutor is archived at:

    http://mail.python.org/mailman/listinfo/tutor

so if you really do want to decode the original, you can find the message
there.]
###


Let's see... maybe a frequency count of the letters might help.  It might
just be a Caesar substitution cypher.

###
>>> coded_message = """
[Obscured again.  coded_message contains the contents
of all those blocks of letters.]"""
>>> def histogram(stuff):
...     h = {}
...     for s in stuff:
...         h[s] = h.get(s, 0) + 1
...     return h
... 
>>> histogram(coded_message)
{'8': 7, '9': 1, '6': 8, '7': 3, '4': 1, '5': 1, '2': 2, '3': 2, '1': 1,
'J': 4, ' ': 27, '!': 1, 'Z': 1, 'Y': 1, 'V': 11, 'W': 6, 'T': 9, 'U': 7,
'R': 3, 'S': 5, 'P': 7, 'Q': 5, 'N': 6, 'O': 2, 'L': 5, 'M': 3, '\n': 4,
'K': 1, 'H': 5, 'I': 7, 'F': 11, 'G': 3, 'D': 7, 'E': 5, 'B': 12, 'C': 7}
###


Progress.  It might be nice to display this histogram in sorted order.  
Let's print out the first 10 most frequently occuring letters in that
coded message.  It might be useful.

###
>>> items.sort(lambda x, y: -cmp(x[1], y[1]))
>>> print string.join(map(str, items[:10]), '\n')     
(' ', 27)
('B', 12)
('V', 11)
('F', 11)
('T', 9)
('6', 8)
('8', 7)
('U', 7)
('P', 7)
('I', 7)
###

Hmmm... The first three real letters in there are 'B', 'V' and 'F'... and
those letters are adjacent to vowels.  Perhaps every letter has simply
been "rotated" one place...

[At this point, I decoded the message enough to feel a little sick when I 
was able to read some of the words.]



From dyoo@hkn.eecs.berkeley.edu  Tue Nov 20 10:17:59 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 20 Nov 2001 02:17:59 -0800 (PST)
Subject: [Tutor] file io and the open() function
In-Reply-To: <3BF9D827.1F144335@my995internet.com>
Message-ID: <Pine.LNX.4.21.0111200209410.21810-100000@hkn.eecs.berkeley.edu>

On Mon, 19 Nov 2001, Kirk Bailey wrote:

> A novice approaches the masters and asks:
> 
> I want to open a pair of files, read from one, wtite it to another,
> appeding data.

Thus spake the master programmer:

``When you have learned to snatch the error code from the trap frame, it
will be time for you to leave.''

    http://www.canonical.org/~kragen/tao-of-programming.html

*grin*



> I wanted to craft this tool to use variables for the 2 files and the
> domain name, so it would be a useful general purpose tool for use by
> others. Alas, when it tries to open a file with a variable providing
> the namer, it halts and catches fire, barfing evilgrams at me.

Can you show us what sort of brimstone belches from the beast... err...
that is, can you show us an error message?



> Also, as I cannot tell in advance howm any entries will be in the
> source file, this thing has to work in a loop until the source file is
> exausted, then close both files. How do I detet the endoffile and end
> politely, instead of running off the end of the thing and tripping an
> error?

At the very end of a file, readline() will return the empty string
"".  You can use this to your advantage:

###
while 1:
    line = file.readline()
    if not line: break
    ...
###


Alternatively, you can avoid the problem altogether by grabbing your file
as a list of lines, by using readlines():

###
for line in file.readlines():         ## Also look in the docs about
                                      ## xreadlines(), which is better
                                      ## for long files.
   ...
###

For more information about these file methods, you can take a look at:

    http://www.python.org/doc/lib/bltin-file-objects.html


Hope this helps!



From crapaudada@ifrance.com  Tue Nov 20 14:11:35 2001
From: crapaudada@ifrance.com (crapaudada)
Date: Tue, 20 Nov 2001 15:11:35 +0100
Subject: [Tutor] OOP programming principles overview?
Message-ID: <5.1.0.14.0.20011120150337.00accba0@df.df.df>

Hello,

It may be a stupid question of a stupid user.

Here is my problem: I have heard for a long time about "Object Oriented 
Programming", with some odd words like "class" "inheritance", etc, etc...

At this day, even if I have tried some different languages (TCL, a little 
little; Rexx, a little; PHP, a little more), I never used the OOP opptions 
of them, because I never felt the need. For example, in PHP, I only used 
some functionnals options, and not the OOP potential.

I am reading the docs of Python, and the tutorial as well. And I apologize, 
but I don't understand what OOP concepts means, and how they function with 
each other.

So my question is: is there, between Hell (C++) and Paradise (Python), any 
good, accessible, easy document to understand this bloody concept?

Worst of all is that I am sure that it is easy to understand, and I find it 
very frustrating.

Thanks to all of you.

  ___    | Dubuquoy-Portois
<*,*>   | G.-Joachim L.
[`-']   | gjl.dp@laposte.net
-"-"----| <http://allesgut.levillage.org/>
_________________________

 
______________________________________________________________________________
ifrance.com, l'email gratuit le plus complet de l'Internet !
vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...
http://www.ifrance.com/_reloc/email.emailif




From printers@sendme.cz  Tue Nov 20 15:03:37 2001
From: printers@sendme.cz (A)
Date: Tue, 20 Nov 2001 16:03:37 +0100
Subject: [Tutor] Default DNS
Message-ID: <3BFA7ED9.14355.557930@localhost>

Hi,
Is there any possibility in Python  to find out my primary or 
secondary DNS when using Dial Up connection from Windows?
Thank you for help.
Ladislav

I look forward to hearing from you soon.

Best Regards,
Ladislav Blazek( Mr.)

BMA TRADING Ltd.
email: export@sendme.cz
email2: export@bmatrading.com
Fax:/Tel +420 506 447921
Tel:+420 506 447920, +420 602 849309



From alan.gauld@bt.com  Tue Nov 20 16:13:43 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 20 Nov 2001 16:13:43 -0000
Subject: [Tutor] os.system
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0E0@mbtlipnt02.btlabs.bt.co.uk>

Fine, but using fork() as someone else suggested provides 
a neater and reliable way of getting the pid without 
resorting to ps.

Otherwise it looks Ok.

Alan g

> Thank you for the hints. What do you think about:
> 
>     def suche(self):
>         pr = os.popen("ps axw","r")
>         zeilen=pr.readlines()
>         print zeilen
>         pr.close()
>         for zeile in zeilen:
>             if string.find(zeile,self.host) >= 0 and 
> string.find(zeile,self.bild) >= 0:
>                 pid = string.split(zeile," ")[0]
>         return int(pid)



From alan.gauld@bt.com  Tue Nov 20 16:22:18 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 20 Nov 2001 16:22:18 -0000
Subject: [Tutor] compiler
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0E1@mbtlipnt02.btlabs.bt.co.uk>

> Is there nothing that will take a python script, and compile it in
> runtime executable code? Python is wonderful, but a executable in
> machine language compiled from something is a lot faster, 

Actually its not a lot faster. In fact interpreted code can be 
faster than compiled C++ - See The Practice of Programming by 
Kernighan & Pike for an example of Perl being faster than C++

It all depends on the efficiencies of the libraries and how 
much code is actually being interpreted. If you are writing 
GUIs using, say PyQt the bulk of the code is written in C/C++
adf the real performance difference of the program will be 
minimal - especially on a modern fast CPU.

> handy if ou use the thing a lot.

Actually I usually find the ability to instantly change 
the source much more useful...

Of course if you want to write shrinkwrap commercial packages 
where benchmarks asre all important then yes compiled code 
will usually edge ahead but at a huge cost in development 
effort.

BTW Python does compile mnodules that are imported into 
intermediate code - rather like VB or Java or Smalltalk. 
But the compilation is controlled by the interpreter, 
not a separate process.

Alan G


From gubitz@netcologne.de  Tue Nov 20 16:35:13 2001
From: gubitz@netcologne.de (Hans Gubitz)
Date: Tue, 20 Nov 2001 17:35:13 +0100
Subject: [Tutor] os.system
In-Reply-To: <20011119181253.C1027@speakeasy.net>
References: <20011117170745.A939@redwitz79.de> <20011119222629.A11346@redwitz79.de> <20011119181253.C1027@speakeasy.net>
Message-ID: <20011120173513.A16149@redwitz79.de>

On Mon, Nov 19, 2001 at 06:12:53PM -0500, Michael P. Reilly wrote:
> class bild:
>   def __init__(self, host, bild)
>     self.host = host
>     self.bild = bild
>     cmd = 'xv -display %s:0.0 %s' % (host, bild)
>     self.pid = popen2.Popen3(cmd, 0)
> 
>   def kill(self):
>     sts = self.pid.poll()
>     if sts == -1:
>       os.kill(self.pid.pid, 15)
>       sts = self.pid.wait()  # need this to prevent zombies at least
>     return sts
> 
> This might be a little more secure for your needs.
> 
>   -Arcege
> 
> -- 
> +----------------------------------+-----------------------------------+
> | Michael P. Reilly                | arcege@speakeasy.net              |
Your class doesn't work here. self.pid.pid doesn't return the right pid. 
I will read the documentation on Popen3.

Hans
-- 
Hans Gubitz <gubitz@netcologne.de>



From alan.gauld@bt.com  Tue Nov 20 17:16:16 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 20 Nov 2001 17:16:16 -0000
Subject: [Tutor] OOP programming principles overview?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0E3@mbtlipnt02.btlabs.bt.co.uk>

> I am reading the docs of Python, and the tutorial as well. 

Have you tried my online tutor as opposed to  the official 
Python tutor? If not go to:

http://www.freenetpages.co.uk/hp/alan.gauld/

Read the latter sections of Raw Materials, then the OO topic 
and then read through the event handling and Case Study topics
(which use OO).

Reread the python tutor on classes/objects and visit the
http://www.cetus-links.com/

web site for links to all things OO.

Be prepared to unlearn some of what you've already learned
and think about real live objects sending messages to each 
other...

> Worst of all is that I am sure that it is easy to understand, 
> and I find it very frustrating.


It is easy to undestand once you get past the initial hurdle
but there is a pretty big change of thinking about programs 
and their design to ber faced. Some folks just 'get it' and 
others take a long time. Most everybody likes it when they 
get there :-)

Alan G


From r.nyborg@telia.com  Tue Nov 20 21:14:43 2001
From: r.nyborg@telia.com (Robert Nyborg)
Date: Tue, 20 Nov 2001 22:14:43 +0100
Subject: [Tutor] OOP programming principles overview?
References: <5.1.0.14.0.20011120150337.00accba0@df.df.df>
Message-ID: <003501c17208$61a71810$040fa8c0@COMPAQ>

Hi,
Alan Gaulds "Learning to program" made Me see the "light".=20
There is also a nice tutorial on the subject on DevShed=20
http://www.devshed.com/Server_Side/Python/

/RobertN

----- Original Message -----=20
From: "crapaudada" <crapaudada@ifrance.com>
To: <tutor@python.org>
Sent: Tuesday, November 20, 2001 3:11 PM
Subject: [Tutor] OOP programming principles overview?


> Hello,
>=20
> It may be a stupid question of a stupid user.
>=20
> Here is my problem: I have heard for a long time about "Object =
Oriented=20
> Programming", with some odd words like "class" "inheritance", etc, =
etc...
>=20
> At this day, even if I have tried some different languages (TCL, a =
little=20
> little; Rexx, a little; PHP, a little more), I never used the OOP =
opptions=20
> of them, because I never felt the need. For example, in PHP, I only =
used=20
> some functionnals options, and not the OOP potential.
>=20
> I am reading the docs of Python, and the tutorial as well. And I =
apologize,=20
> but I don't understand what OOP concepts means, and how they function =
with=20
> each other.
>=20
> So my question is: is there, between Hell (C++) and Paradise (Python), =
any=20
> good, accessible, easy document to understand this bloody concept?
>=20
> Worst of all is that I am sure that it is easy to understand, and I =
find it=20
> very frustrating.
>=20
> Thanks to all of you.
>=20
>   ___    | Dubuquoy-Portois
> <*,*>   | G.-Joachim L.
> [`-']   | gjl.dp@laposte.net
> -"-"----| <http://allesgut.levillage.org/>
> _________________________
>=20
> =20
> =
_________________________________________________________________________=
_____
> ifrance.com, l'email gratuit le plus complet de l'Internet !
> vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...
> http://www.ifrance.com/_reloc/email.emailif
>=20
>=20
>=20
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor



From dyoo@hkn.eecs.berkeley.edu  Tue Nov 20 23:44:09 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 20 Nov 2001 15:44:09 -0800 (PST)
Subject: [Tutor] Default DNS
In-Reply-To: <3BFA7ED9.14355.557930@localhost>
Message-ID: <Pine.LNX.4.21.0111201528190.4782-100000@hkn.eecs.berkeley.edu>

On Tue, 20 Nov 2001, A wrote:

> Is there any possibility in Python  to find out my primary or 
> secondary DNS when using Dial Up connection from Windows?
> Thank you for help.

Dear Ladislav,

Hello! You might find:

   http://mail.python.org/pipermail/python-win32/2001-September/000135.html

to be what you're looking for.



From urnerk@qwest.net  Wed Nov 21 00:52:33 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Tue, 20 Nov 2001 16:52:33 -0800
Subject: [Tutor] OOP programming principles overview?
In-Reply-To: <5.1.0.14.0.20011120150337.00accba0@df.df.df>
Message-ID: <4.2.0.58.20011120164219.00c11a20@pop3.norton.antivirus>

>
>Worst of all is that I am sure that it is easy to understand, and
>I find it very frustrating.
>
>Thanks to all of you.
>
>  ___    | Dubuquoy-Portois
><*,*>   | G.-Joachim L.
>[`-']   | gjl.dp@laposte.net
>-"-"----| <http://allesgut.levillage.org/>

If you forget about programming for a moment, and just think
of yourself as an instance of the class Human, a subclass of
Mammal, in turn a subclass of Chordate, then you've got the
right frame of mind for OOP.

As an instantiated object, you have a personal dictionary
of one-of-a-kind attributes and tweaked methods, but a lot
you can take for granted (your consciousness thread relies
on an API, like internal digestion, without contributing in
any way to the design, which is inherited).

This "I am an object" paradigm is apropos in Python given
the keyword 'self' (actually, any word will work, as it's
positionally defined, i.e. any string will work if positioned
the same way -- but we use 'self' by convention).

The OOP books I've seen rarely teach the first person approach,
but it's really useful:  "I am an altimeter object, what API
to I export to my clients or users?"...  "I am a [fill in the
blank]".  The class definition is like my blueprint.  I have
properties and methods, accessed as self.property1,
self.property2 and self.method1(args), self.method2(args) etc.

A subclass takes a pre-existing blueprint and says "all of
the above, except over here, I want you to replace the generic
X with Y" and so on, i.e. a subclass further customizes and
refines a superclass, but anything not spelled out simply
defaults to the super's behavior...

Well, lest I spiel on and on, I should self.endchatter().

Kirby






From dyoo@hkn.eecs.berkeley.edu  Wed Nov 21 03:29:02 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 20 Nov 2001 19:29:02 -0800 (PST)
Subject: [Tutor] OOP programming principles overview?  [Complex numbers
 and OOP]
In-Reply-To: <4.2.0.58.20011120164219.00c11a20@pop3.norton.antivirus>
Message-ID: <Pine.LNX.4.21.0111201757120.8241-100000@hkn.eecs.berkeley.edu>

It might help if we browse an extended example that has some of the spirit
of OOP, without jumping directly into OOP syntax.  If we do this, the
concepts might become more clear.


Let's say that we're trying to make a program that helps us compute with
complex numbers.  (Complex numbers are already built into Python, but
they're a great example of the "object" concept --- I can't resist using
them... *grin*)  If complex numbers give you nightmares though, we can
write a different example if you want.

[Warning: very very long example ahead.  I need to read Strunk and White.]


In order to work with complex numbers, we'll need to decide how to
represent them.  Let's handle that first.

###
def makeComplex(real, imag):
    """Creates a structure that represents a complex number."""
    return (real, imag)
###

We've arbitrarily chosen to use a tuple to represent a complex number ---
we could have used a dictionary or list instead... any plain container for
these values would have worked.


Also, it might be nice to write small functions to get at the real() and
imag()inary parts of a complex number.  This is friendly because we allow
users to not have to remember if the first part of a complex number is the
real or imaginary part.

###
def real(c): return c[0]

def imag(c): return c[1]
###


Let's test what we have right now:

###
>>> m = makeComplex(42, -42)
>>> real(m)
42
>>> imag(m)
-42
###


Simple enough.  What sort of things can we use with complex numbers?  We
use numbers in calculation, so it might be good to be able to add() and
multiply() complex numbers together.  Complex numbers have a fairly simple
rule for addition:

###
def add(c1, c2):
    """Return a new complex number that represents the addition of
    two complex numbers c1 and c2"""
    return makeComplex(real(c1) + real(c2),
                       complex(c1) + complex(c2))
###

but the multiply() rule for complex numbers looks quite obscure.  *grin*

###
def multiply(c1, c2):
    """Return the product of two complex numbers c1, c2,
    according to the math rule:
        (A + Bi) * (C + Di) = (A*C - B*D, A*D + B*C)."""
    a, b = real(c1), imag(c1)
    c, d = real(c2), imag(c2)
    return makeComplex(a*c - b*d,
                       a*d + b*c)
###



Let's test out multiply(), since I feel a little nervous about it:

###
>>> forty_five_degrees = makeComplex(0.707, 0.707)
>>> b = makeComplex(1, 0)
>>> for i in range(8):
...     print b
...     b = multiply(b, forty_five_degrees)
... 
(1, 0)
(0.70699999999999996, 0.70699999999999996)
(0.0, 0.99969799999999986)
(-0.70678648599999983, 0.70678648599999983)
(-0.99939609120399975, 0.0)
(-0.70657303648122782, -0.70657303648122782)
(0.0, -0.99909427358445613)
(0.70635965142421042, -0.70635965142421042)
###

Whew.  Ok, that actually worked.  Cool.  As a side note, complex numbers
are pretty neat because we can use them to rotate points in 2d space... if
we intentionally confuse the idea of "complex number" and "coordinate".  
In the example above, I multiplied 'b' repeatedly by 'forty_five_degrees'.  
We can see that 'b' is circling around like a bee.



If this is mostly understandable, then you don't have to worry too much,
because we've just gone through many of the core OOP concepts.  *grin*

OOP is a way of writing programs so that we concentrate on data and the
sort of things this data "knows" how to do.  In some sense, thinking in
OOP is like personifying our programs.  In the example above, we'd say
that all of the definitions that we've written:

###
def makeComplex(real, imag):
    """Creates a structure that represents a complex number."""
    return (real, imag)

def real(c): return c[0]

def imag(c): return c[1]

def add(c1, c2):
    """Return a new complex number that represents the addition of
    two complex numbers c1 and c2"""
    return makeComplex(real(c1) + real(c2),
                       complex(c1) + complex(c2))

def multiply(c1, c2):
    """Return the product of two complex numbers c1, c2,
    according to the math rule:
        (A + Bi) * (C + Di) = (A*C - B*D, A*D + B*C)."""
    a, b = real(c1), imag(c1)
    c, d = real(c2), imag(c2)
    return makeComplex(a*c - b*d,
                       a*d + b*c)
###

are the raw materials for a "class".  In obscure OOP lingo, we've defined
a "constructor" that knows how to make "instances" of a complex number.  
In this light, makeComplex() is a "constructor" of complex numbers.

We've also defined a few functions that work intimately with complex
numbers.  In OOP lingo, these are called "members" of a class.  Dunno why
OOP gives these concepts such wacky names, but that's how it goes...
*grin*


What Python provides is a formal syntax specifically for writing classes.  
Let's take a look and see what a ComplexNumber class might look like if we
use this syntax.

###
class ComplexNumber:
    def __init__(self, real, imag):
        self.data = (real, imag)

    def real(self): return self.data[0]

    def imag(self): return self.data[1]

    def add(self, other):
        return ComplexNumber(self.real() + other.real(),
                             self.imag() + other.imag())

    def multiply(self, other):
        a, b = self.real(), self.imag()
        c, d = other.real(), other.imag()
        return ComplexNumber(a*c - b*d,
                             a*d + b*c)
###

You don't have to understand the syntax yet.  What's important to see is
that the definition here is really quite close to the code we had above.  
If it helps, flip back and forth between the two, to compare the
similarities between the two definitions.  OOP is not a crazy concept ---
it just dresses up very badly sometimes.  *grin*



The big jump to from procedural programming syntax to Object Oriented
syntax is analogous to the jump in English from passive voice to active
voice: instead of emphasizing functions and its arguments:

    In a "procedural" mode of thinking:
        real(c) -->
            Translation: "real() is called on 'c'."

        multiply(c, forty_five_degrees) --> 
            Translation: "multiply() is being called on 'c' and
                          'forty_five_degrees'."


Object oriented languages tend to rearrange the syntax to favor the data:

    In a "OOP" mode of thinking:
        c.real() -->
            Translation: "c calls real() on itself"

        c.multiply(forty_five_degrees) -->
            Translation: "c multiply()ies itself by forty_five_degrees"


I'd better stop at this point; this message is far too long already.  But
hopefully this helps a little bit.  Read Alan's book.  *grin*


Best of wishes!



From deliberatus@my995internet.com  Wed Nov 21 05:32:01 2001
From: deliberatus@my995internet.com (Kirk Bailey)
Date: Wed, 21 Nov 2001 00:32:01 -0500
Subject: [Tutor] file io and the open() function
References: <Pine.LNX.4.21.0111200209410.21810-100000@hkn.eecs.berkeley.edu>
Message-ID: <3BFB3C51.A611CB41@my995internet.com>

Indeed it helps. Thankyou.

Brimstone has been posted in a seperate post.

It is said that even assembly has the Buddha nature, but try not to
program in cobol if you can possibly help it.

Years ago I converted the TAO of programming from plain text to a
executable Ebooklet. Now I think I must do this for html.




Danny Yoo wrote:
> 
> On Mon, 19 Nov 2001, Kirk Bailey wrote:
> 
> > A novice approaches the masters and asks:
> >
> > I want to open a pair of files, read from one, wtite it to another,
> > appeding data.
> 
> Thus spake the master programmer:
> 
> ``When you have learned to snatch the error code from the trap frame, it
> will be time for you to leave.''
> 
>     http://www.canonical.org/~kragen/tao-of-programming.html
> 
> *grin*
> 
> > I wanted to craft this tool to use variables for the 2 files and the
> > domain name, so it would be a useful general purpose tool for use by
> > others. Alas, when it tries to open a file with a variable providing
> > the namer, it halts and catches fire, barfing evilgrams at me.
> 
> Can you show us what sort of brimstone belches from the beast... err...
> that is, can you show us an error message?
> 
> > Also, as I cannot tell in advance howm any entries will be in the
> > source file, this thing has to work in a loop until the source file is
> > exausted, then close both files. How do I detet the endoffile and end
> > politely, instead of running off the end of the thing and tripping an
> > error?
> 
> At the very end of a file, readline() will return the empty string
> "".  You can use this to your advantage:
> 
> ###
> while 1:
>     line = file.readline()
>     if not line: break
>     ...
> ###
> 
> Alternatively, you can avoid the problem altogether by grabbing your file
> as a list of lines, by using readlines():
> 
> ###
> for line in file.readlines():         ## Also look in the docs about
>                                       ## xreadlines(), which is better
>                                       ## for long files.
>    ...
> ###
> 
> For more information about these file methods, you can take a look at:
> 
>     http://www.python.org/doc/lib/bltin-file-objects.html
> 
> Hope this helps!

-- 
Respectfully,
             -Kirk D Bailey (C)2001
              Addme! icq #27840081
end
      My Sites:
      http://www.howlermonkey.net/ - free REAL email! list service soon!
      http://www.sacredelectron.org/ - Rants! Spleenvents!
      http://www.minorfish.org/ - The list server for some of us!

Message of the week:
R5L9W SDPQW UVN7V RUBWB I6HFP WVCUT VWRVL
W7812 LVH8V JBVK2 3CEJB TO8P3 FHFHG H7BFM
QID68 6DN6F 6M486 YQNCF JECQP 86CNP 86CTT
JIQPF ZPVGV DLFST DBUDI UIFNC BTUBS ETBOE
BTTGV DLUIF NSFBM IBSE!


From iriscope@yahoo.co.nz  Wed Nov 21 09:12:01 2001
From: iriscope@yahoo.co.nz (=?iso-8859-1?q?Nathan=20Adams?=)
Date: Wed, 21 Nov 2001 22:12:01 +1300 (NZDT)
Subject: [Tutor] Newbie @ parsing
Message-ID: <20011121091201.43160.qmail@web12706.mail.yahoo.com>

I'm working on an XML app in Python, and have realised
that I do not really know anything about parsing. Does
anyone have/know of any good tutorials that cover the
subject, preferably in Python?

Thank you!

- Nathan




From lha2@columbia.edu  Wed Nov 21 11:58:09 2001
From: lha2@columbia.edu (Lloyd Hugh Allen)
Date: Wed, 21 Nov 2001 06:58:09 -0500
Subject: [Fwd: Re: [Tutor] OOP programming principles overview?  [Complex
 numbersand OOP]]
Message-ID: <3BFB96D1.3BF2657B@mail.verizon.net>

Darn "repy" button.

-------- Original Message --------
From: Lloyd Hugh Allen <vze2f978@mail.verizon.net>
Subject: Re: [Tutor] OOP programming principles overview?  [Complex
numbersand OOP]
To: Danny Yoo <dyoo@hkn.eecs.berkeley.edu>

I originally missed the line "Complex numbers are already built into
Python", so in my head I was all prepared to make a long post. But now
that I see it I'll make a short one.

Just a note between the implementation of complex numbers that's built
in and the one suggested below: it appears (from inspection of results,
not internal code--I'm not that brave right now (nor do I have
sufficient free time)) that rather than storing complex numbers as a
tuple or list, a complex object simply has a "real" attribute and a
"complex" attribute:

>>> type(1+5j)
<type 'complex'>
>>> (1+5j).imag
5.0
>>> (1+5j).real
1.0

which somehow feels nicer to me than having to call imagvar.imag(). It's
a shame that with the built-in, conjugate is still a method--that is, in
order to get the conjugate of 1+5j, you have to

>>> (1+5j).conjugate()
(1-5j)

If anyone out there is interested in doing real math (pardon the pun)
with complex numbers, check out the cmath module.

Just my $0.02.

--Lloyd Hugh Allen

Danny Yoo wrote:
> 
> It might help if we browse an extended example that has some of the spirit
> of OOP, without jumping directly into OOP syntax.  If we do this, the
> concepts might become more clear.
> 
> Let's say that we're trying to make a program that helps us compute with
> complex numbers.  (Complex numbers are already built into Python, but
> they're a great example of the "object" concept --- I can't resist using
> them... *grin*)  If complex numbers give you nightmares though, we can
> write a different example if you want.
> 
> [Warning: very very long example ahead.  I need to read Strunk and White.]
...(sorry for the massive trim, Danny)


From Felix.Toran@esa.int  Wed Nov 21 15:13:53 2001
From: Felix.Toran@esa.int (Felix.Toran@esa.int)
Date: Wed, 21 Nov 2001 16:13:53 +0100
Subject: [Tutor] Applying a mask
Message-ID: <41256B0B.00522C86.00@esahqmail1.hq.esa.fr>


Dear all,

I have a string, containing a 63-digit hexadecimal number. I want to build a
function which extracts bits from that hexadecimal number, and show it as an
integer (unsigned) value.

I plan to apply a mask (63 hex digits), placing ones in the bits I want to
extract and 0 in the rest of them. Then, I want to perform an AND operation, and
shift the result to the rigth, obtaining the base-10 representation of the
desired bits. Since I am very new to Python, I feel confused about how to
implement this (specially, I am not very familiar with how Python store
numbers).

I will appreciate any suggestion you can provide.
Thanks in advance.

Felix Toran.
ftoran@esa.int







From virketis@fas.harvard.edu  Wed Nov 21 15:24:54 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Wed, 21 Nov 2001 10:24:54 -0500
Subject: [Tutor] bound vs. unbound method?
Message-ID: <200111211524.fALFOBM30530@smtp4.fas.harvard.edu>

--=====================_127577535==_.ALT
Content-Type: text/plain; charset="us-ascii"

Hi!

I found a brief mention of bound and unbound methods in Python on
comp.lang.python archives. What is the difference between the two? Here's a
piece of the original message:

******************************* Erik Max Francis wrote *********************

It [Python - added by me] even has both bound and unbound methods, something
which, for instance, C++ does not have: 

>>> class C: 
... def m(self, x): 
... print x 
... 
>>> c = C() 
>>> unbound = C.m 
>>> unbound(c, 1) # must call with `self' argument explicitly 1 
>>> bound = c.m 
>>> bound(1) # `self' argument implied, not needed 1 

****************************************************************************
****

I don't know C++, so the distinction is sort of lost on me. :(

Cheers, 

Pijus
------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis

--=====================_127577535==_.ALT
Content-Type: text/html; charset="us-ascii"

<html>
Hi!<br>
<br>
I found a brief mention of bound and unbound methods in Python on
comp.lang.python archives. What is the difference between the two? Here's
a piece of the original message:<br>
<br>
******************************* Erik Max Francis wrote
*********************<br>
<br>
It [Python - added by me] even has both bound and unbound methods,
something which, for instance, C++ does not have: <br>
<br>
<font color="#800000">&gt;&gt;&gt; class C:</font><font color="#000000">
<br>
... def m(self, x): <br>
... print x <br>
... <br>
</font><font color="#800000">&gt;&gt;&gt; c = C() <br>
&gt;&gt;&gt; unbound = C.m <br>
&gt;&gt;&gt; unbound(c, 1) # must call with `self' argument explicitly 1 <br>
&gt;&gt;&gt; bound = c.m <br>
&gt;&gt;&gt; bound(1) # `self' argument implied, not needed</font><font color="#000000"> 1 <br>
<br>
********************************************************************************<br>
<br>
I don't know C++, so the distinction is sort of lost on me. :(<br>
<br>
Cheers, <br>
<br>
Pijus</font><br>
<div>------------------------------------------------------------</div>
<div>PGP PUBLIC KEY: <a href="http://www.fas.harvard.edu/~virketis/links" EUDORA=AUTOURL>www.fas.harvard.edu/~virketis/links</a></div>
<div>My weblog: <a href="http://www.fas.harvard.edu/~virketis" EUDORA=AUTOURL>www.fas.harvard.edu/~virketis</a></div>
</html>

--=====================_127577535==_.ALT--



From kalle@gnupung.net  Wed Nov 21 16:02:50 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Wed, 21 Nov 2001 17:02:50 +0100
Subject: [Tutor] bound vs. unbound method?
In-Reply-To: <200111211524.fALFOBM30530@smtp4.fas.harvard.edu>
References: <200111211524.fALFOBM30530@smtp4.fas.harvard.edu>
Message-ID: <20011121170250.A16043@proton.lysator.liu.se>

[Pijus Virketis]
> Hi!
> 
> I found a brief mention of bound and unbound methods in Python on
> comp.lang.python archives. What is the difference between the two?
[snip]

Consider a function and a method:

def f(x):
    print x

class C:
    def m(self, x):
        print x

The function takes one argument and prints it, so does the method, if used on
an instance:

>>> c = C()
>>> f(1)
1
>>> c.m(1)
1

This means the first method argument, self, appeared from nowhere.  This is
because the method is bound to the instance c.  When a method is not bound to
any instance, you have to supply all arguments yourself, like:

>>> C.m(c, 1)
1

This also means that c.m and C.m are not the same thing.  They're *almost* the
same, but c.m is bound to the instance c, and C.m is unbound.

Does this help?

Peace,
  Kalle
-- 
[   International: http://www.gnupung.net/   ]
[ Svenska: http://www.lysator.liu.se/~kalle/ ]


From urnerk@qwest.net  Wed Nov 21 16:05:04 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Wed, 21 Nov 2001 08:05:04 -0800
Subject: [Tutor] Applying a mask
In-Reply-To: <41256B0B.00522C86.00@esahqmail1.hq.esa.fr>
Message-ID: <4.2.0.58.20011121075520.00a87960@pop3.norton.antivirus>

At 04:13 PM 11/21/2001 +0100, you wrote:


>Dear all,
>
>I have a string, containing a 63-digit hexadecimal number.
>I want to build a function which extracts bits from that
>hexadecimal number, and show it as an integer (unsigned)
>value.

The long integer is a place to store big hex numbers.
In Python 2.2, we're starting to not need to specify
when an integer is long, with the 'L' suffix.

   >>> myhex = eval('0x'+'A323332BFE23231')
   >>> myhex
   734705982275465777L

eval('0x'+yourstring) will need to be written
eval('0x'+yourstring+'L') if your Python is < 2.2.

Then you can AND this with another long.

   >>> hex2 = eval('0x9234237942')
   >>> result = myhex & hex2
   >>> result
   78184067072L

If you want to convert back to hex, go:

   >>> hex(result)
   '0x1234223000L'

hex returns a string, which you can eval into a
long again if need be.

Shifting left and right is done on the longs, using
the << and >> operators.

Kirby



From kalle@gnupung.net  Wed Nov 21 16:13:19 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Wed, 21 Nov 2001 17:13:19 +0100
Subject: [Tutor] Newbie @ parsing
In-Reply-To: <20011121091201.43160.qmail@web12706.mail.yahoo.com>
References: <20011121091201.43160.qmail@web12706.mail.yahoo.com>
Message-ID: <20011121171318.B16043@proton.lysator.liu.se>

[Nathan Adams]
> I'm working on an XML app in Python, and have realised
> that I do not really know anything about parsing. Does
> anyone have/know of any good tutorials that cover the
> subject, preferably in Python?

http://py-howto.sourceforge.net/xml-howto/xml-howto.html might help.
It describes the two most common ways to parse XML data, SAX and DOM.
I haven't read it in any detail, but at least the SAX part seems to be
fairly complete.

Peace,
  Kalle
-- 
[   International: http://www.gnupung.net/   ]
[ Svenska: http://www.lysator.liu.se/~kalle/ ]


From urnerk@qwest.net  Wed Nov 21 17:20:41 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Wed, 21 Nov 2001 09:20:41 -0800
Subject: [Tutor] OOP programming principles overview?  [Complex
 numbers and OOP]
In-Reply-To: <Pine.LNX.4.21.0111201757120.8241-100000@hkn.eecs.berkeley.
 edu>
References: <4.2.0.58.20011120164219.00c11a20@pop3.norton.antivirus>
Message-ID: <4.2.0.58.20011121091734.00c1d8c0@pop3.norton.antivirus>

Interestingly, as of Python 2.2, you can take ordinary integers
and study them as objects:

  >>> dir(3)
  ['__abs__', '__add__', '__and__', '__class__', '__cmp__', '__coerce__',
  '__delattr__', '__div__', '__divmod__', '__float__', '__floordiv__',
  '__getattribute__', '__hash__', '__hex__', '__init__', '__int__',
  '__invert__', '__long__', '__lshift__', '__mod__', '__mul__', '__neg__',
  '__new__', '__nonzero__', '__oct__', '__or__', '__pos__', '__pow__',
  '__radd__', '__rand__', '__rdiv__', '__rdivmod__', '__reduce__',
  '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__',
  '__ror__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__',
  '__rtruediv__', '__rxor__', '__setattr__', '__str__', '__sub__',
  '__truediv__', '__xor__']
  >>> 3 .__add__
  <method-wrapper object at 0x01300FB0>
  >>> 4 .__add__
  <method-wrapper object at 0x013044E0>
  >>> 5 .__add__(6)
  11

Notice you need to add a space after the integer, before the .
-- otherwise the parser wouldn't understand you don't mean
float.

Such as space is legal even in ordinary circumstances:

  >>> class A:
  	 property = 'ddd'

	
  >>> a = A()
  >>> a.property
  'ddd'
  >>> a .property
  'ddd'

Kirby



From urnerk@qwest.net  Wed Nov 21 17:26:37 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Wed, 21 Nov 2001 09:26:37 -0800
Subject: [Tutor] bound vs. unbound method?
In-Reply-To: <20011121170250.A16043@proton.lysator.liu.se>
References: <200111211524.fALFOBM30530@smtp4.fas.harvard.edu>
 <200111211524.fALFOBM30530@smtp4.fas.harvard.edu>
Message-ID: <4.2.0.58.20011121092532.00c18b20@pop3.norton.antivirus>

Note that in Python 2.2 we're starting to get static
methods, i.e. methods which don't need a self or
instance to work:

  >>> class C:
	def m(a):
	  print a
	m = staticmethod(m)

	
  >>> C.m(5)
  5
  >>> o = C()
  >>> o.m(5)
  5

Guido thinks the syntax is a bit ugly -- dunno if
it's gonna change.

Kirby




From dsh8290@rit.edu  Wed Nov 21 18:46:25 2001
From: dsh8290@rit.edu (dman)
Date: Wed, 21 Nov 2001 13:46:25 -0500
Subject: [Tutor] OOP programming principles overview?  [Complex numbers and OOP]
In-Reply-To: <4.2.0.58.20011121091734.00c1d8c0@pop3.norton.antivirus>; from urnerk@qwest.net on Wed, Nov 21, 2001 at 09:20:41AM -0800
References: <4.2.0.58.20011120164219.00c11a20@pop3.norton.antivirus> <Pine.LNX.4.21.0111201757120.8241-100000@hkn.eecs.berkeley.edu> <4.2.0.58.20011121091734.00c1d8c0@pop3.norton.antivirus>
Message-ID: <20011121134625.A20608@harmony.cs.rit.edu>

On Wed, Nov 21, 2001 at 09:20:41AM -0800, Kirby Urner wrote:
| 
| Interestingly, as of Python 2.2, you can take ordinary integers
| and study them as objects:

You mean, study them as class instances.  Yes, this is one of the
changes made in 2.2 -- types and classes are now instances of
metaclasses (or something like that) and as a result they behave the
same.

See
    http://www.amk.ca/python/2.2/
for an overview of the changes.

-D



From jeff@ccvcorp.com  Wed Nov 21 19:06:01 2001
From: jeff@ccvcorp.com (Jeff Shannon)
Date: Wed, 21 Nov 2001 11:06:01 -0800
Subject: [Tutor] Applying a mask
References: <E166akD-0004q0-00@mail.python.org>
Message-ID: <3BFBFB19.E7A48392@ccvcorp.com>

>
> On Wed, 21 Nov 2001 08:05:04 -0800,
> Kirby Urner <urnerk@qwest.net> wrote:
>
> At 04:13 PM 11/21/2001 +0100, Felix.Toran@esa.int wrote:
>
> >Dear all,
> >
> >I have a string, containing a 63-digit hexadecimal number.
> >I want to build a function which extracts bits from that
> >hexadecimal number, and show it as an integer (unsigned)
> >value.
>
> The long integer is a place to store big hex numbers.
> In Python 2.2, we're starting to not need to specify
> when an integer is long, with the 'L' suffix.
>
>    >>> myhex = eval('0x'+'A323332BFE23231')
>    >>> myhex
>    734705982275465777L
>
> eval('0x'+yourstring) will need to be written
> eval('0x'+yourstring+'L') if your Python is < 2.2.

A simpler, safer way to do this (in just about any version of Python) is
to use the optional base parameter of the int() built-in function:

>>> num = int('beef',16)
>>> num
48879
>>> hexnum = hex(num)
>>> hexnum
'0xbeef'
>>>

Other than that little detail, Kirby's advice is spot-on...  :)

(Any time you use eval(), there's almost always a better way to do what
you want....)

Jeff Shannon
Technician/Programmer
Credit International




From urnerk@qwest.net  Wed Nov 21 19:24:23 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Wed, 21 Nov 2001 11:24:23 -0800
Subject: [Tutor] OOP programming principles overview?  [Complex
 numbers and OOP]
In-Reply-To: <20011121134625.A20608@harmony.cs.rit.edu>
References: <4.2.0.58.20011121091734.00c1d8c0@pop3.norton.antivirus>
 <4.2.0.58.20011120164219.00c11a20@pop3.norton.antivirus>
 <Pine.LNX.4.21.0111201757120.8241-100000@hkn.eecs.berkeley.edu>
 <4.2.0.58.20011121091734.00c1d8c0@pop3.norton.antivirus>
Message-ID: <4.2.0.58.20011121112407.00c1b530@pop3.norton.antivirus>

At 01:46 PM 11/21/2001 -0500, dman wrote:
>On Wed, Nov 21, 2001 at 09:20:41AM -0800, Kirby Urner wrote:
>|
>| Interestingly, as of Python 2.2, you can take ordinary integers
>| and study them as objects:
>
>You mean, study them as class instances.


"class instance" = "object" , no?

Kirby



From scarblac@pino.selwerd.nl  Wed Nov 21 19:32:10 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Wed, 21 Nov 2001 20:32:10 +0100
Subject: [Tutor] OOP programming principles overview?  [Complex numbers and OOP]
In-Reply-To: <4.2.0.58.20011121112407.00c1b530@pop3.norton.antivirus>; from urnerk@qwest.net on Wed, Nov 21, 2001 at 11:24:23AM -0800
References: <4.2.0.58.20011121091734.00c1d8c0@pop3.norton.antivirus> <4.2.0.58.20011120164219.00c11a20@pop3.norton.antivirus> <Pine.LNX.4.21.0111201757120.8241-100000@hkn.eecs.berkeley.edu> <4.2.0.58.20011121091734.00c1d8c0@pop3.norton.antivirus> <20011121134625.A20608@harmony.cs.rit.edu> <4.2.0.58.20011121112407.00c1b530@pop3.norton.antivirus>
Message-ID: <20011121203210.A5170@pino.selwerd.nl>

On  0, Kirby Urner <urnerk@qwest.net> wrote:
> At 01:46 PM 11/21/2001 -0500, dman wrote:
> >On Wed, Nov 21, 2001 at 09:20:41AM -0800, Kirby Urner wrote:
> >|
> >| Interestingly, as of Python 2.2, you can take ordinary integers
> >| and study them as objects:
> >
> >You mean, study them as class instances.
> 
> 
> "class instance" = "object" , no?

Yes and no. Depends on how you define things, etc.

In Python, anything is an object, 1, "whee", [5], etc are all objects.

A class instance is an object that happens to be an instance of some class.

I don't recall your mail exactly, but I think that integers etc are getting
some properties of class instances now (they already were objects).

But I haven't been following 2.2 developments closely.

-- 
Remco Gerlich


From Bruce.Lee-Shanok@cognos.com  Wed Nov 21 19:47:18 2001
From: Bruce.Lee-Shanok@cognos.com (Lee-Shanok, Bruce)
Date: Wed, 21 Nov 2001 14:47:18 -0500
Subject: [Tutor] print without linefeed
Message-ID: <FB15E670DA55D51185350008C786514A0140E9EA@sottexch1.cognos.com>

Hmm.. I can't for the life of me find this documented, which amazes me.

This is going to sound like an incredibly stupid question, but how do I get
print to print something without automatically pasting a linefeed to the
end? :)

Cheers,
Bruce

This message may contain privileged and/or confidential information.  If you
have received this e-mail in error or are not the intended recipient, you
may not use, copy, disseminate, or distribute it; do not open any
attachments, delete it immediately from your system and notify the sender by
e-mail promptly that you have done so.  Thank You.


From shalehperry@home.com  Wed Nov 21 19:52:34 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Wed, 21 Nov 2001 11:52:34 -0800 (PST)
Subject: [Tutor] print without linefeed
In-Reply-To: <FB15E670DA55D51185350008C786514A0140E9EA@sottexch1.cognos.com>
Message-ID: <XFMail.20011121115234.shalehperry@home.com>

On 21-Nov-2001 Lee-Shanok, Bruce wrote:
> Hmm.. I can't for the life of me find this documented, which amazes me.
> 
> This is going to sound like an incredibly stupid question, but how do I get
> print to print something without automatically pasting a linefeed to the
> end? :)
> 

One of my least favourite things about python:

print foo, # print without the newline (note the comma)

it is WAY to easy to miss that comma.


From urnerk@qwest.net  Wed Nov 21 19:59:07 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Wed, 21 Nov 2001 11:59:07 -0800
Subject: [Tutor] OOP programming principles overview?  [Complex
 numbers and OOP]
In-Reply-To: <20011121203210.A5170@pino.selwerd.nl>
References: <4.2.0.58.20011121112407.00c1b530@pop3.norton.antivirus>
 <4.2.0.58.20011121091734.00c1d8c0@pop3.norton.antivirus>
 <4.2.0.58.20011120164219.00c11a20@pop3.norton.antivirus>
 <Pine.LNX.4.21.0111201757120.8241-100000@hkn.eecs.berkeley.edu>
 <4.2.0.58.20011121091734.00c1d8c0@pop3.norton.antivirus>
 <20011121134625.A20608@harmony.cs.rit.edu>
 <4.2.0.58.20011121112407.00c1b530@pop3.norton.antivirus>
Message-ID: <4.2.0.58.20011121115533.00c24ba0@pop3.norton.antivirus>

At 08:32 PM 11/21/2001 +0100, Remco Gerlich wrote:
>On  0, Kirby Urner <urnerk@qwest.net> wrote:
> > At 01:46 PM 11/21/2001 -0500, dman wrote:
> > >On Wed, Nov 21, 2001 at 09:20:41AM -0800, Kirby Urner wrote:
> > >|
> > >| Interestingly, as of Python 2.2, you can take ordinary integers
> > >| and study them as objects:
> > >
> > >You mean, study them as class instances.
> >
> >
> > "class instance" = "object" , no?
>
>Yes and no. Depends on how you define things, etc.
>
>In Python, anything is an object, 1, "whee", [5], etc are all objects.

1 is an instance of the integer class, "whee" an instance of the
string class, and [5] and instance of the list class.  In being
instances, they're likewise objects.

 >>> "whee".upper()
WHEE

>A class instance is an object that happens to be an instance of some class.
>
>I don't recall your mail exactly, but I think that integers etc are getting
>some properties of class instances now (they already were objects).

Yes.  I think it's accurate to say 1 is an instance of the
integer class (given better integration of class and type
models).

When introducing OOP, I think it'll make sense for tutorials
to focus on such primitives as "primitive objects" -- to
look at their methods and properties.

Kirby



From dyoo@hkn.eecs.berkeley.edu  Wed Nov 21 22:27:54 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Wed, 21 Nov 2001 14:27:54 -0800 (PST)
Subject: [Tutor] print without linefeed
In-Reply-To: <FB15E670DA55D51185350008C786514A0140E9EA@sottexch1.cognos.com>
Message-ID: <Pine.LNX.4.21.0111211420290.28442-100000@hkn.eecs.berkeley.edu>

On Wed, 21 Nov 2001, Lee-Shanok, Bruce wrote:

> Hmm.. I can't for the life of me find this documented, which amazes
> me.
> 
> This is going to sound like an incredibly stupid question, but how do
> I get print to print something without automatically pasting a
> linefeed to the end? :)

Python's print statement automatically adds in a line feed without that
trailing comma that Sean talked about.  If you really want more
fine-grained control over standard output, you'll probably want to play
around with the 'sys.stdout' object:

###
>>> import sys
>>> sys.stdout("Hello World\nThis is on another line")
>>> sys.stdout.write("Hello World\nThis is on another line")
Hello World
This is on another line>>> 
###

sys.stdout behaves like a file, so most of the methods in:

    http://www.python.org/doc/lib/bltin-file-objects.html

should work with it.

Also, there's also some good information in the official Python tutorial
here about IO that has some more examples that might be interesting for
you:

    http://www.python.org/doc/current/tut/node9.html


Good luck!



From gjldp@iquebec.com  Wed Nov 21 22:34:50 2001
From: gjldp@iquebec.com (gjldp@iquebec.com)
Date: Wed, 21 Nov 2001 23:34:50 +0100
Subject: [Tutor] Newbie @ parsing
In-Reply-To: <20011121091201.43160.qmail@web12706.mail.yahoo.com>
Message-ID: <5.1.0.14.0.20011121233318.009ef600@pop.iquebec.com>

At 22:12 21/11/01 +1300, you wrote:
>I'm working on an XML app in Python, and have realised
>that I do not really know anything about parsing. Does
>anyone have/know of any good tutorials that cover the
>subject, preferably in Python?

The "http://diveintopython.org/" tutorial contains a whole part about HTML 
parsing, through the SGML library; it may help you, I guess.

 
______________________________________________________________________________
ifrance.com, l'email gratuit le plus complet de l'Internet !
vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...
http://www.ifrance.com/_reloc/email.emailif




From cliff@ember.com  Wed Nov 21 22:37:38 2001
From: cliff@ember.com (cliff@ember.com)
Date: Wed, 21 Nov 2001 17:37:38 -0500
Subject: [Tutor] Importing an extension under Cygwin
Message-ID: <3BFBE662.2197.2097E6F@localhost>

This will sound silly, but how do I import an extension under 
Cygwin?  I have an extension compiled as 'report.so' that I can't 
seem to import.

possibly useful facts:

1.  Python 2.1.1 (#2, Sep 26 2001, 09:32:53)
     [GCC 2.95.3-5 (cygwin special)] on cygwin

2.  $PYTHONPATH does contain the right directory ('.py' files 
in the same directory import just fine.)

3.  The extension loads fine on my Linux machine.

4.  I did recompile the extension under Cygwin using the compiler 
above.

Thanks!

--Cliff





From biz6x6@net  Wed Nov 21 22:14:11 2001
From: biz6x6@net (Please Read IT Carefully!)
Date: 22 Nov 2001 00:14:11 +0200
Subject: [Tutor] ATTENTION! Well-Paid Job in the Internet!
Message-ID: <E166g56-0005xx-00@mail.python.org>

------=_fuLGlGCN~eIozsoRm
Content-Type: text/plain
Content-Transfer-Encoding: 8bit

--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
(This safeguard is not inserted when using the registered version)
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------

--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
(This safeguard is not inserted when using the registered version)
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------
--------------------------------------------------------------------------


------=_fuLGlGCN~eIozsoRm
Content-Type: text/html

<html><head><META HTTP-EQUIV=Content-Type CONTENT=text/html; charset=windows-1251><title>6x6 InterNetwork Group</title></head><body bgcolor=white><center><a name=e><table width=660 cellpadding=0 cellspacing=0 border=0><tr><td height=40><tr><td><font face=verdana size=+2><center><b>Hello!<div align=right><font face=verdana size=+2><a href=#r><b>IN RUSSIAN<tr><td bgcolor=#000066>&nbsp;
<tr><td bgcolor=#ffffcc>&nbsp;<tr><td><font face=verdana size=+1><center><p><br><b>PLEASE EXCUSE THE DISTURBANCE BUT WE CONSIDER IT OUR DUTY TO MAKE YOU AN OFFER THAT WILL HELP YOU BECOME WEALTHIER, FREER AND HAPPIER!<br>&nbsp;<tr><td bgcolor=#000066>&nbsp;
<tr><td><p align=justify><br><font face=verdana size=2 color=#000066>&nbsp;&nbsp;&nbsp;<b>We are offering you a unique business opportunity of the 6x6 system. Anyone able to spend two-three hours a day on business and work on a personal computer is welcome to join us. 
By working with us you can improve your finances or just receive a stable supplementary income and help other people around the world do the same!<br>&nbsp;<tr><td height=40><tr><td><font face=verdana size=+1><center><b>Let's get down to business!<br>&nbsp;<tr><td bgcolor=#000066>&nbsp;
<tr><td><p align=justify><br><font face=verdana size=2>&nbsp;&nbsp;&nbsp;We propose making money on distribution of highly valued consumer products using a six-level marketing network with delivery of goods by the Internet. 
Your work will consist in creating a network of co-workers and using this network to sell the products. In other words, you will need to find other people who would like to engage in this business and sell them the product. 
You will receive a commission for each new person.<br>&nbsp;&nbsp;&nbsp;We give you an opportunity for multiplex income. Your earnings will consist of commissions you earn yourself, as well as a percentage of the commissions earned by your co-workers. 
In other words, you receive a commission for introducing new co-workers, and also when your co-workers introduce new co-workers. Those co-workers you personally brought into the network will be your first level co-workers. 
They will also bring in co-workers and all the co-workers they personally bring in will be your second level co-workers. In your network there may be as many levels as possible but only the first six levels will yield you income, 
in other words you will receive commissions for having personally brought a first level co-worker to do business, when that first level co-worker brings a second level co-worker, etc. to the sixth level. There's no limit to the number of co-workers on each level.<br>
<font color=#000066>&nbsp;&nbsp;&nbsp;<b>Thanks to multiplex income while working just two-three hours a day you can build a network of co-workers very quickly and sell a large enough volume of products to gain considerable monetary income.<br>&nbsp;
<tr><td height=40><tr><td><font face=verdana size=+1><center><b>The product<br>&nbsp;<tr><td bgcolor=#000066>&nbsp;<tr><td><p align=justify><br><font face=verdana size=2>&nbsp;&nbsp;&nbsp;It's no secret that you can make money on the Internet, that's obvious. But how? 
If you type the phrase earnings on the net or something similar into any search engine you'll find thousands of sites dedicated to this topic. But even if you read 99.9 percent of these sites and apply the schemes they offer you will probably not make anything! 
These plans offer earning systems very similar to each other but which make only their creators rich. Nevertheless, many people make a living on the Internet, and live pretty well! Actually it's not as hard as it may seem at first glance, it's not that hard if you choose the right path from the start! 
This can be much more difficult...<br>&nbsp;&nbsp;&nbsp;So allow us to recommend the book by <i>Andrew Lloyd</i> <b>"How to Be Successful in Advertising on the Internet"</b>. The book's author, a London businessman, has long been engaged in business on the Internet and possesses vast experience. 
At one time he used all the main earning systems and tried out all kinds of advertising on the Net himself. He tells about the most effective and best methods in his book.<br>&nbsp;&nbsp;&nbsp;<font color=#000066>This book will be useful primarily for those who are engaged in business on the Internet and want to become successful. 
By reading the book you will find out about the most effective types of advertising on the Internet, where you can buy software at a discount to significantly simplify your life as an Internet entrepreneur and make all types of advertising even more effective, 
how to make the best use of the most recent achievements of e-commerce and net marketing, successfully attract co-workers to the business, build a sales network and sell large volumes of products, and much more.<br>&nbsp;&nbsp;&nbsp;The book is especially recommended for those who are planning 
to engage in business on the Internet but haven't get started, as well as those who have started only recently since it will lead you immediately to the right path and will help you to save time and money and avoid many unpleasant situations. We also strongly recommend the book for those who are already engaged in Internet business but aren't very successful, 
and for those who for one reason or another don't believe in this type of earning. The first group, after reading the book, will immediately see their mistakes and, having corrected them, will achieve success. The second group will understand that they were wrong and will reconsider their attitude 
toward earnings on the Net.<br>&nbsp;&nbsp;&nbsp;<b>Considering the value and usefulness of information contained in the book, it is quite popular throughout the world. The book is available in electronic form in Russian and English on the 
Internet.<br>&nbsp;&nbsp;&nbsp;Our business is international and you can work anywhere on the planet with Internet access and attract clients from any country.<br>&nbsp;<tr><td height=40><tr><td><font face=verdana size=+1><center><b>Earnings<br>&nbsp;
<tr><td bgcolor=#000066>&nbsp;<tr><td><p align=justify><br><font face=verdana size=2>&nbsp;&nbsp;&nbsp;For every co-worker you introduce you will receive a commission of 6 dollars. There's no limit to your earnings; it all depends on your desire to make money. 
But let's get back to the numbers.<br>&nbsp;&nbsp;&nbsp;We'll start from the minimum you could make. Let's say that every month you and all your co-workers attract five people each.<br>&nbsp;
<table width=100% border=0><tr bgcolor=#000066><td><center><font color=#ffffcc face=verdana><b>month</td><td><center><font color=#ffffcc face=verdana><b>co-workers</td><td><center><font color=#ffffcc face=verdana><b>commissions</td>
<tr bgcolor=#ffffcc><td bgcolor=#000066><center><font color=#ffffcc face=verdana><b>1</td><td><center><font color=#000066 face=verdana>5</td><td><center><font color=#000066 face=verdana>$30</td>
<tr bgcolor=#ffffcc><td bgcolor=#000066><center><font color=#ffffcc face=verdana><b>2</td><td><center><font color=#000066 face=verdana>5*5+5=30</td><td><center><font color=#000066 face=verdana>$180</td>
<tr bgcolor=#ffffcc><td bgcolor=#000066><center><font color=#ffffcc face=verdana><b>3</td><td><center><font color=#000066 face=verdana>30*5+5=155</td><td><center><font color=#000066 face=verdana>$930</td>
<tr bgcolor=#ffffcc><td bgcolor=#000066><center><font color=#ffffcc face=verdana><b>4</td><td><center><font color=#000066 face=verdana>155*5+5=780</td><td><center><font color=#000066 face=verdana>$4,680</td>
<tr bgcolor=#ffffcc><td bgcolor=#000066><center><font color=#ffffcc face=verdana><b>5</td><td><center><font color=#000066 face=verdana>780*5+5=3,905</td><td><center><font color=#000066 face=verdana>$23,430</td>
<tr bgcolor=#ffffcc><td bgcolor=#000066><center><font color=#ffffcc face=verdana><b>6</td><td><center><font color=#000066 face=verdana>3,905*5+5=19,530</td><td><center><font color=#000066 face=verdana>$117,180</td>
<tr bgcolor=#ffffcc><td bgcolor=#000066><center><font color=#ffffcc face=verdana><b>total</td><td><center><font color=#000066 face=verdana><b>24,405</td><td><center><font color=#000066 face=verdana><b>$146,430</td></table>
<tr><td height=20><tr><td><p align=justify><font face=verdana size=2><br>&nbsp;&nbsp;&nbsp;In other words, in just six months you will bring in <b>24,405</b> co-workers and make <b>$146,430</b>! 
<font color=#000066>All you need to do it is bring in five co-workers a month!</font><br>&nbsp;&nbsp;&nbsp;This is just a theoretical calculation and practice always differs from theory so no one has achieved such success yet, although maybe you'll get lucky! 
So how much can you make in practice? During the first month you will need to study the main methods of attracting co-workers and master the necessary skills for work, so during this period your earnings will be low. But everything depends on your desire to make 
money. The work is not hard and if you really want to you can bring in five co-workers during the first month, which will account for about 30 percent of the participants. During the second month you will know exactly what to do and will bring in more co-workers than during the first month, usually not less than twice as many, not to 
mention the fact that those co-workers you brought in last month will start working, in other words your earnings will amount to more than $100. If you really tried hard and spent two-three hours on productive work with the business, then starting with the 
third month you will begin to receive monetary rewards worthy of you that will increase each month.<br>&nbsp;&nbsp;&nbsp;But remember that this is not just something for nothing and not a get rich quick scheme; there's no such thing! The 6x6 system 
business is a high-paying job worthy of you that will help you change your life for the better but only if you have a serious attitude. If you really want to become free and financially independent and want to achieve this then you will be successful since 6x6 is the right way! 
If you just think that the whole world should lend you money and you'll just get one million for free then think hard: do such things happen?<br>&nbsp;&nbsp;&nbsp;<font color=#000066><b>Thanks to new developments in e-commerce, network marketing and highly effective advertising methods covered in the book, 
and of course thanks to your own will, you can introduce ten knew co-workers a month and will certainly achieve success!<tr><td height=50><tr><td><font face=verdana size=+1><center><b>How to start<br>&nbsp;<tr><td bgcolor=#000066>&nbsp;<tr><td><p><div align=justify><font face=verdana size=2><br>&nbsp;&nbsp;&nbsp;So, you've firmly decided to 
change your life for the better and become a financially independent person! Congratulations! You have truly chosen the right path!<br><p>&nbsp;&nbsp;&nbsp;1) To start you need to register with the founder of the 6x6 business system. Registration costs $10.<p>&nbsp;&nbsp;&nbsp;Transfer $10 to the account of the 
founder of the 6x6 business system:<blockquote><blockquote><blockquote><blockquote><p><b>1107736234 Igor Tistsenkov<br> Hansapank, Liivalaia 8, 15040 Tallinn, Estonia<br>S.W.I.F.T. code: HABA EE2X</b></blockquote></blockquote></blockquote></blockquote><p>&nbsp;&nbsp;&nbsp;Then send a telegram (or a mail) containing the following:
<blockquote><blockquote><blockquote><blockquote><p>1) This number: <font color=red><b>6x6-000000-z-001</b></font><br>2) Your full name<br>3) E-mail<br></blockquote></blockquote></blockquote></blockquote><p>&nbsp;&nbsp;&nbsp;to the address:<blockquote><blockquote><blockquote><blockquote><b>Igor Tistsenkov<br>Laanemere 20-96<br>13913 Tallinn<br>Estonia</b></blockquote></blockquote></blockquote></blockquote>
<p>&nbsp;&nbsp;&nbsp;2) Within 24 hours you will receive an e-mail message containing your registration number, the information on all co-workers you need to buy a book from, and a full description of the mechanism and all details of the system.<br>&nbsp;&nbsp;&nbsp;3) Immediately by the book from co-workers. The cost is $36. 
Details in the letter.<br>&nbsp;&nbsp;&nbsp;4) When you receive the book start working right away. Success is just around the corner!<p>&nbsp;&nbsp;&nbsp;<font color=#000066><b>P.S. if you have any questions about the 6x6 system don't be shy, send us your questions by e-mail, telegram or by mail and we will be glad to answer them!
<tr><td height=60><tr><td><font face=verdana size=+1><center><b>And now let's start!<p><font color=#000066 size=5><b>We wish You Great Success!!!<tr><td height=40><tr><td bgcolor=#ffffcc>&nbsp;<tr><td bgcolor=#000066>&nbsp;<tr><td><p><br><center><font face=verdana size=1 color=#555555>Copyright © 2000-2001 6x6 InterNetwork Group. All rights reserved. Any changes to the text of this letter and further distribution are punishable by copyright law.</table>
<br><br><br><br><center><a name=r><table width=660 cellpadding=0 cellspacing=0 border=0><tr><td height=60><tr><td><font face=verdana size=+2><center><b>Æåëàåì Âàì ïðèÿòíîãî è óñïåøíîãî äíÿ!<div align=right><font face=verdana size=+2><a href=#e><b>IN ENGLISH<tr><td bgcolor=#000066>&nbsp;<tr><td bgcolor=#ffffcc>&nbsp;
<tr><td><font face=verdana size=+1><center><p><br><b>ÏÐÎÑÈÌ ÏÐÎÙÅÍÈß ÇÀ ÁÅÑÏÎÊÎÉÑÒÂÎ, ÍÎ Ñ×ÈÒÀÅÌ ÑÂÎÈÌ ÄÎËÃÎÌ ÑÄÅËÀÒÜ ÂÀÌ ÎÄÍÎ ÏÐÅÄËÎÆÅÍÈÅ, ÊÎÒÎÐÎÅ ÏÎÌÎÆÅÒ ÂÀÌ ÑÒÀÒÜ ÁÎÃÀ×Å, ÑÂÎÁÎÄÍÅÉ È Ñ×ÀÑÒËÈÂÅÉ!<br>&nbsp;<tr><td bgcolor=#000066>&nbsp;
<tr><td><p align=justify><br><font face=verdana size=2 color=#000066>&nbsp;&nbsp;&nbsp;<b>Ìû ïðåäëàãàåì Âàì óíèêàëüíóþ âîçìîæíîñòü áèçíåñà ïî ñèñòåìå 6õ6. Ñîòðóäíè÷àòü ñ íàìè ìîæåò êàæäûé, êòî ñïîñîáåí óäåëÿòü áèçíåñó 2-3 ÷àñà â äåíü è óìååò ðàáîòàòü íà ïåðñîíàëüíîì êîìïüþòåðå. Ðàáîòàÿ ñ íàìè, Âû ñìîæåòå óëó÷øèòü ñâîå ôèíàíñîâîå ïîëîæåíèå èëè æå 
ïðîñòî ïîëó÷àòü ñòàáèëüíûé äîïîëíèòåëüíûé äîõîä, ïîìîãàÿ äåëàòü òî æå ñàìîå âñåì ëþäÿì ìèðà!<br>&nbsp;<tr><td height=40><tr><td><font face=verdana size=+1><center><b>ÈÒÀÊ, ÑÐÀÇÓ Ê ÄÅËÓ!<br>&nbsp;<tr><td bgcolor=#000066>&nbsp;<tr><td><p align=justify><br><font face=verdana size=2>&nbsp;&nbsp;&nbsp;Ìû ïðåäëàãàåì Âàì çàðàáàòûâàòü íà ðàñïðîñòðàíåíèè ïðîäóêöèè 
âûñîêîé ïîòðåáèòåëüñêîé öåííîñòè ïîñðåäñòâîì 6-òè óðîâíåãî ñåòåâîãî ìàðêåòèíãà ñ äîñòàâêîé òîâàðà ïî êàíàëàì ñâÿçè ñåòè Èíòåðíåò. Âàøà ðàáîòà áóäåò 
çàêëþ÷àòüñÿ â ïîñòðîåíèè ñåòè ñîòðóäíèêîâ è ðåàëèçàöèè ïîñðåäñòâîì íåå ïðîäóêöèè. Ò.å. Âàì íåîáõîäèìî ïðèâëåêàòü ëþäåé, æåëàþùèõ çàíèìàòüñÿ ýòèì áèçíåñîì è ïðîäàâàòü èì òîâàð. Çà êàæäîãî ïðèâëå÷åííîãî ÷åëîâåêà Âû ïîëó÷àåòå êîìèñèîííûå.<br>&nbsp;&nbsp;&nbsp;Ìû ïðåäîñòàâëÿåì Âàì âîçìîæíîñòü ìóëüòèïëåêñíîãî äîõîäà. Âàø çàðàáîòîê áóäåò ñîñòîÿòü èç 
êîìèññèîííûõ, çàðàáîòàííûõ ëè÷íî Âàìè, è ïðîöåíòà îò êîìèññèîííûõ, çàðàáîòàííûõ Âàøèìè ñîòðóäíèêàìè. Ò.å. Âû ïîëó÷àåòå êîìèññèîííûå çà òî, ÷òî ñàìè ïðèâëåêàåòå ñîòðóäíèêîâ, è çà òî, ÷òî Âàøè ñîòðóäíèêè ïðèâëåêàþò ñîòðóäíèêîâ. Òå ñîòðóäíèêè, êîòîðûõ Âû ëè÷íî ïðèâåëè â ñâîþ ñåòü, áóäóò Âàøèìè ñîòðóäíèêàìè 1-ãî óðîâíÿ. Îíè áóäóò òàêæå ïðèâëåêàòü 
ñîòðóäíèêîâ, è âñå ïðèâëå÷åííûå èìè ëè÷íî ñîòðóäíèêè áóäóò Âàøèìè ñîòðóäíèêàìè 2-ãî óðîâíÿ. Âñåãî â Âàøåé ñåòè ìîæåò áûòü ñêîëüêî óãîäíî óðîâíåé, íî îïëà÷èâàþòñÿ òîëüêî ïåðâûå øåñòü, ò.å. Âû ïîëó÷àåòå êîìèññèîíûå çà òî, ÷òî ëè÷íî ïðèâåëè â áèçíåñ ñîòðóäíèêà ïåðâîãî óðîâíÿ, çà òî, ÷òî ñîòðóäíèê ïåðâîãî óðîâíÿ ïðèâåë ñîòðóäíèêà 
âòîðîãî óðîâíÿ è ò.ä. äî øåñòîãî óðîâíÿ. Îãðàíè÷åíèé íà êîëè÷åñòâî ñîòðóäíèêîâ íà êàæäîì óðîâíå íåò.<br><font color=#000066>&nbsp;&nbsp;&nbsp;<b>Áëàãîäàðÿ ìóëüòèïëåêíîìó äîõîäó, Âû ñìîæåòå, ðàáîòàÿ 2-3 ÷àñà â äåíü, â êðàò÷àéøèå ñðîêè ïîñòðîèòü ñåòü ñîòðóäíèêîâ è ïîñðåäñòâîì íåå ðåàëèçîâàòü äîñòàòî÷íîå êîëè÷åñòâî ïðîäóêöèè äëÿ ïîëó÷åíèÿ âûñîêîãî äåíåæíîãî 
âîçíàãðàæäåíèÿ.<br>&nbsp;<tr><td height=40><tr><td><font face=verdana size=+1><center><b>ÏÐÎÄÓÊÖÈß<br>&nbsp;<tr><td bgcolor=#000066>&nbsp;<tr><td><p align=justify><br><font face=verdana size=2>&nbsp;&nbsp;&nbsp;Íå äëÿ êîãî íå ñåêðåò, ÷òî â ñåòè Èíòåðíåò ìîæíî çàðàáàòûâàòü - ýòî î÷åâèäíûé ôàêò. Íî êàê? Åñëè Âû íàáåðåòå â ëþáîé ïîèñêîâîé ñèñòåìå 
ôðàçó çàðàáîòîê â ñåòè èëè ÷òî-òî âðîäå ýòîãî, ïðåä Âàìè ïðåäñòàíóò òûñÿ÷è ñàéòîâ, ïîñâÿùåííûõ ýòîé òåìå. Íî äàæå îçíàêîìèâøèñü ñ ñîäåðæàíèåì 99,9% èç íèõ è ïðîðàáîòàâ ïî ïðåäëàãàåìûì èìè ñõåìàì, Âû âðÿä ëè ÷åãî-íèáóäü çàðàáîòàåòå! Ò.ê. îíè ïðåäëàãàþò âî ìíîãîì ñõîæèå ìåæäó ñîáîé ñèñòåìû çàðàáîòêà, êîòîðûå ïîçâîëÿþò çàðàáîòàòü òîëüêî èõ ñîçäàòåëÿì. 
Íî òåì íå ìåíåå ìíîãèå ëþäè æèâóò çàðàáàòûâàÿ â Èíòåðíåòå è æèâóò äîñòàòî÷íî õîðîøî! È íà ñàìîì äåëå ýòî íå òàê ñëîæíî, êàê ìîæåò 
ïîêàçàòüñÿ íà ïåðâûé âçãëÿä - íå òàê ñëîæíî, åñëè ñðàçó âûáðàòü ïðàâèëüíûé ïóòü! ×òî ìîæåò îêàçàòüñÿ çíà÷èòåëüíî ñëîæíåå...<br>&nbsp;&nbsp;&nbsp; ñâÿçè ñ ýòèì ïîçâîëüòå Âàì ïðåäëîæèòü êíèãó <i>Ýíäðþ Ëëîéäà (Andrew Lloyd)</i> <b>"Êàê äîáèòüñÿ óñïåõà, çàíèìàÿñü ðåêëàìîé â ñåòè Èíòåðíåò"</b>. Àâòîð êíèãè, áèçíåñìåí èç Ëîíäîíà, óæå äîëãîå âðåìÿ óñïåøíî 
çàíèìàåòñÿ áèçíåñîì â Èòåðíåòå è îáëàäàåò îãðîìíûì îïûòîì.  ñâîå âðåìÿ îí ïðîðàáîòàë ïî âñåì îñíîâíûì ñèñòåìàì çàðàáîòêà è ñàì ëè÷íî èñïûòàë âñå âèäû ðåêëàìû â ñåòè. Î ñàìûõ ýôôåêòèâíûõ è ëó÷øèõ èç íèõ îí ðàññêàçàë â ñâîåé êíèãå.<br>&nbsp;&nbsp;&nbsp;<font color=#000066>Ýòà êíèãà â ïåðâóþ î÷åðåäü áóäåò ïîëåçíà âñåì, êòî çàíèìàåòñÿ áèçíåñîì 
â ñåòè Èíòåðíåò è õî÷åò äîáèòüñÿ óñïåõà. Ïðî÷èòàâ åå, Âû óçíàåòå î ñàìûõ ýôôåêòèâíûõ âèäàõ ðåêëàìû Èíòåðíåòà, î òîì ãäå ìîæíî ñî ñêèäêîé ïðåîáðåñòè ïðîãðàììíîå îáåñïå÷åíèå, êîòîðîå çíà÷èòåëüíî îáëåã÷àåò æèçíü èíòåðíåò-ïðåäïðèíèìàòåëÿ è äåëàåò ýòè âèäû ðåêëàìû åùå áîëåå ýôåêòèâíåé, î òîì êàê, îïòèìàëüíî èñïîëüçóÿ ïîñëåäíèå äîñòèæåíèÿ ýëåêòðîííîé êîììåðöèè 
è ñåòåâîãî ìàðêåòèíãà, äîáèòüñÿ óñïåõà â ïðèâëå÷åíèè ñîòðóäíèêîâ â áèçíåñ, ïîñòðîåíèè ñåòè è ðåàëèçàöèè ïîñðåäñòâîì íåå áîëüøèõ îáúåìîâ ïðîäóêöèè è ìíîãîì äðóãîì.<br>&nbsp;&nbsp;&nbsp;Îñîáåííî êíèãà ðåêîìåíäóåòñÿ òåì, êòî ñîáèðàåòñÿ çàíèìàòüñÿ áèçíåñîì â Èíòåðíåòå, íî åùå íå íà÷àë, è òåì, êòî íà÷àë íåäàâíî, ò.ê. îíà íàâåäåò Âàñ ñðàçó íà ïðàâèëüíûé ïóòü 
è ïîçâîëèò Âàì âî ìíîãîì ñýêîíîìèòü âðåìÿ è ñðåäñòâà è èçáåæàòü ìíîãèõ íåïðèÿòíûõ ñèòóàöèé. Òàêæå íàñòîÿòåëüíî ðåêîìåíäóåì êíèãó òåì, êòî óæå çàíèìàåòñÿ èíòåðíåò-áèçíåñîì, íî íèêàê íå ìîæåò äîáèòüñÿ óñïåõà è òåì, êòî ïî êàêèì-ëèáî ïðè÷èíàì âîîáùå íå âåðèò â âîçìîæíîñòü òàêîãî ðîäà çàðàáîòêà, ïåðâûå, ïðî÷èòàâ åå, ñðàçó óâèäÿò ñâîè îøèáêè è, ïåðåñòàâ èõ ñîâåðøàòü, 
äîñòèãíóò óñïåõà, âòîðûå - ïîéìóò, ÷òî îíè çàáëóæäàëèñü, è ïåðåñìîòðÿò ñâîå îòíîøåíèå ê çàðàáîòêó â ñåòè.<br>&nbsp;&nbsp;&nbsp;<b>Ââèäó öåííîñòè è âîñòðåáóåìîñòè èíôîðìàöèè, ñîäåðæàùåéñÿ â êíèãå, îíà ïîëüçóåòñÿ âåëèêîëåïíûì ñïðîñîì âî âñåì ìèðå. Êíèãà ðàñïðîñòðàíÿåòñÿ â ýëåêòðîííîì âèäå íà ðóññêîì è àíãëèéñêîì ÿçûêàõ ïîñðåäñòâîì êàíàëîâ ñâÿçè ñåòè Èíòåðíåò.<br>
&nbsp;&nbsp;&nbsp;Íàø áèçíåñ ìåæäóíàðîäíûé, Âû ìîæåòå ðàáîòàòü èç ëþáîé òî÷êè çåìíîãî øàðà ãäå åñòü äîñòóï â Èíòåðíåò è ïðèâëåêàòü êëèåíòîâ èç ëþáûõ ñòðàí.<br>&nbsp;<tr><td height=40><tr><td><font face=verdana size=+1><center><b>Î ÇÀÐÀÁÎÒÊÅ<br>&nbsp;<tr><td bgcolor=#000066>&nbsp;<tr><td><p align=justify><font face=verdana size=2><br>&nbsp;&nbsp;&nbsp;Çà êàæäîãî 
ïðèâëå÷åííîãî ñîòðóäíèêà Âû ïîëó÷àåòå êîìèññèîííûå â ðàçìåðå 6 äîëëàðîâ ÑØÀ. Íèêàêîãî îãðàíè÷åíèÿ íà çàðàáîòîê íåò - âñå çàâèñèò òîëüêî îò Âàøåãî æåëàíèÿ õîðîøî çàðàáîòàòü. Íî âñå æå êîíêðåòíûå öèôðû.<br>&nbsp;&nbsp;&nbsp;Íà÷íåì ñ ìèíèìóìà, äîïóñòèì ÷òî êàæäûé ìåñÿö Âû è âñå Âàøè ñîòðóäíèêè áóäåòå ïðèâëåêàòü âñåãî ïî 5 ÷åëîâåê.<br>&nbsp;
<table width=100% border=0><tr bgcolor=#000066><td><center><font color=#ffffcc face=verdana><b>ìåñÿö</td><td><center><font color=#ffffcc face=verdana><b>ñîòðóäíèêè</td><td><center><font color=#ffffcc face=verdana><b>êîìèñèîííûå</td>
<tr bgcolor=#ffffcc><td bgcolor=#000066><center><b><font face=verdana color=#ffffcc>1</td><td><center><font color=#000066 face=verdana>5</td><td><center><font color=#000066 face=verdana>$30</td>
<tr bgcolor=#ffffcc><td bgcolor=#000066><center><font color=#ffffcc face=verdana><b>2</td><td><center><font color=#000066 face=verdana>5*5+5=30</td><td><center><font color=#000066 face=verdana>$180</td>
<tr bgcolor=#ffffcc><td bgcolor=#000066><center><font color=#ffffcc face=verdana><b>3</td><td><center><font color=#000066 face=verdana>30*5+5=155</td><td><center><font color=#000066 face=verdana>$930</td>
<tr bgcolor=#ffffcc><td bgcolor=#000066><center><font color=#ffffcc face=verdana><b>4</td><td><center><font color=#000066 face=verdana>155*5+5=780</td><td><center><font color=#000066 face=verdana>$4,680</td>
<tr bgcolor=#ffffcc><td bgcolor=#000066><center><font color=#ffffcc face=verdana><b>5</td><td><center><font color=#000066 face=verdana>780*5+5=3,905</td><td><center><font color=#000066 face=verdana>$23,430</td>
<tr bgcolor=#ffffcc><td bgcolor=#000066><center><font color=#ffffcc face=verdana><b>6</td><td><center><font color=#000066 face=verdana>3,905*5+5=19,530</td><td><center><font color=#000066 face=verdana>$117,180</td>
<tr bgcolor=#ffffcc><td bgcolor=#000066><center><font color=#ffffcc face=verdana><b>âñåãî</td><td><center><font color=#000066 face=verdana><b>24,405</td><td><center><font color=#000066 face=verdana><b>$146,430</td></table>
<tr><td height=20><tr><td><p align=justify><font face=verdana size=2><br>&nbsp;&nbsp;&nbsp;Ò.å. çà 6 ìåñÿöåâ Âû ïðèâëå÷åòå â ñâîþ ñåòü <b>24,405</b> ñîòðóäíèêîâ è çàðàáîòàåòå <b>$146,430</b>! <font color=#000066>Äëÿ ÷åãî Âàì íåîáõîäèìî 
ïðèâëåêàòü âñåãî ïî 5 ñîòðóäíèêîâ â ìåñÿö!</font><br>&nbsp;&nbsp;&nbsp;Ýòî òåîðèòè÷åñêèé ðàñ÷åò, à ïðàêòèêà âñåãäà îòëè÷àåòñÿ îò òåîðèè, ïîýòîìó òàêèõ óñïåõîâ íå äîáèâàëñÿ åùå íèêòî, õîòÿ âîçìîæíî Âàì ïîâåçåò! Íî âñå æå ñêîëüêî ìîæíî çàðàáîòàòü íà ïðàêòèêå. 
 ïåðâûé ìåñÿö Âàì íåîáõîäèìî èçó÷èòü îñíîâíûå ìåòîäû ïðèâëå÷åíèÿ ñîòðóäíèêîâ è ïðåîáðåñòè íåîáõîäèìûå äëÿ ðàáîòû íàâûêè, òàê ÷òî çàðàáîòîê â ýòîò ïåðèîä áóäåò ìèíèìàëåí. Õîòÿ âñå çàâèñèò òîëüêî îò Âàøåãî æåëàíèÿ çàðàáîòàòü, 
ðàáîòà íåñëîæíàÿ è ïðè ñèëüíîì æåëàíèè Âû óæå â ïåðâûé ìåñÿö ïðèâëå÷åòå áîëåå 5 ñîòðóäíèêîâ, ÷òî äåëàþò ïðèìåðíî 30% ó÷àñòíèêîâ. Âî âòîðîì ìåñÿöå Âû óæå áóäåòå òî÷íî çíàòü ÷òî äåëàòü è ïðèâëå÷åòå áîëüøå ñîòðóäíèêîâ ÷åì â ïåðâîì, îáû÷íî íå ìåíåå ÷åì â 2 ðàçà, 
òàêæå â ðàáîòó âîéäóò òå ñîòðóäíèêè, êîòîðûõ Âû ïðèâëåêëè â ïðîøëîì ìåñÿöå, ò.å. Âàø çàðàáîòîê ñîñòàâèò áîëåå $100. Åñëè Âû äåéñòâèòåëüíî ñòàðàëèñü è åæåäíåâíî óäåëÿëè áèçíåñó 2-3 ÷àñà ïðîäóêòèâíîé ðàáîòû, òî íà÷èíàÿ ñ 3-ãî ìåñÿöà Âû 
íà÷íåòå ïîëó÷àòü çà ýòî äîñòîéíîå Âàñ äåíåæíîå âîçíàãðàæäåíèå, êîòîðîå áóäåò åæåìåñÿ÷íî óâåëè÷èâàòüñÿ.<br>&nbsp;&nbsp;&nbsp;Íî ïîìíèòå, ÷òî ýòî íå õàëÿâà è íå ñïîñîá áûñòðîãî îáîãàùåíèÿ - òàêîãî ïðîñòî íå áûâàåò! Áèçíåñ ïî ñèñòåìå 6õ6 - ýòî äîñòîéíàÿ Âàñ âûñîêîîïëà÷èâàåìàÿ ðàáîòà, 
êîòîðàÿ ïîçâîëèò Âàì èçìåíèòü æèçíü ê ëó÷øåìó, íî ëèøü â òîì ñëó÷àå åñëè Âû îòíåñåòåñü ê ýòîé ðàáîòå ñåðüåçíî. Åñëè Âû äåéñòâèòåëüíî õîòèòå ñòàòü ñâîáîäíûì è ôèíàíñîâî íåçàâèñèìûì ÷åëîâåêîì è õîòèòå ýòîãî äîáèòüñÿ - ó Âàñ âñå ïîëó÷èòñÿ, ò.ê. 6õ6 - ïðàâèëüíûé ïóòü! 
Åñëè æå Âû ïðîñòî ñ÷èòàåòå, ÷òî âåñü ìèð çàäîëæàë Âàì äåíåã è Âû íåïðåìåííî ïîëó÷èòå ìèëëèîí íàõàëÿâó - êðåïêî ïîäóìàéòå, ðàçâå òàêîå áûâàåò?<br>&nbsp;&nbsp;&nbsp;<font color=#000066><b>Áëàãîäàðÿ íîâåéøèì ðàçðàáîòêàì ýëåêòðîííîé êîììåðöèè, ñåòåâîãî ìàðêåòèíãà è ýôôåêòèâíåéøèì ñïîñîáàì ðåêëàìû, èçëîæåíûì â êíèãå, è êîíå÷íî æå ñîáñòâåííîìó æåëàíèþ, 
Âû ñìîæåòå åæåìåñÿ÷íî ëè÷íî ïðèâëåêàòü äåñÿòêè íîâûõ ñîòðóäíèêîâ è íåñîìíåííî äîáüåòåñü óñïåõà!<tr><td height=50><tr><td><font face=verdana size=+1><center><b>ÊÀÊ ÍÀ×ÀÒÜ<br>&nbsp;<tr><td bgcolor=#000066>&nbsp;<tr><td><p><div align=justify><font face=verdana size=2><br>&nbsp;&nbsp;&nbsp;Èòàê, Âû òâåðäî 
ðåøèëè èçìåíèòü ñâîþ æèçíü ê ëó÷øåìó è ñòàòü ôèíàíñîâî íåçàâèñèìûì ÷åëîâåêîì! Ïîçäðàâëÿåì! Âû âûáðàëè äåéñòâèòåëüíî âåðíûé ïóòü!<br><p>&nbsp;&nbsp;&nbsp;1) Äëÿ íà÷àëà Âàì íåîáõîäèìî çàðåãèñòðèðîâàòüñÿ ó îñíîâàòåëÿ áèçíåñ ñèñòåìû 6õ6. Ðåãèñòðàöèÿ ïëàòíàÿ, ñòîèìîñòü 10 äîëëàðîâ ÑØÀ. Çàðåãèñòðèðîâàòüñÿ 
ìîæíî äâóìÿ ñïîñîáàìè, âûáåðèòå íàèáîëåå äëÿ Âàñ ïîäõîäÿùèé.<p>&nbsp;&nbsp;&nbsp;A) Äëÿ ëþäåé, ïðîæèâàþùèõ íà òåððèòîðèè Ðîññèè:<p>&nbsp;&nbsp;&nbsp;Ïåðåâåäèòå 300 ðóáëåé òåëåãðàôíûì ïåðåâîäîì íà ñëåäóþùèå ðåêâèçèòû:<blockquote><blockquote><blockquote><blockquote><p><b>Ñàíêò-Ïåòåðáóðã 197342<br>Òèùåíêîâ Èãîðü Àëåêñàíäðîâè÷<br>Äî 
âîñòðåáîâàíèÿ</b></blockquote></blockquote></blockquote></blockquote><p>&nbsp;&nbsp;&nbsp; ñîîáùåíèè, ñîïðîâîæäàþùåì ïåðåâîä, óêàæèòå ñëåäóþùèå äàííûå (â ñëó÷àå íåîáõîäèìîñòè èõ ìîæíî âûñëàòü òåëåãðàììîé íà ýòîò æå àäðåñ):<blockquote><blockquote><blockquote><blockquote><p>1) Ýòîò 
íîìåð: <font color=red><b>6x6-000000-z-001</b></font><br>2) Âàøè Ô.È.Î.<br>3) Âàø e-mail</blockquote></blockquote></blockquote></blockquote><p>&nbsp;&nbsp;&nbsp;B) Äëÿ ëþäåé, ïðîæèâàþùèõ íå íà òåððèòîðèè Ðîññèè:<p>&nbsp;&nbsp;&nbsp;Ïåðåâåäèòå 10 USD íà ñ÷åò îñíîâàòåëÿ áèçíåñ ñèñòåìû 6õ6:<blockquote><blockquote><blockquote><blockquote><p><b>1107736234 Igor 
Tistsenkov<br>Hansapank, Liivalaia 8, 15040 Tallinn, Estonia<br> S.W.I.F.T. code: HABA EE2X</b></blockquote></blockquote></blockquote></blockquote><p>&nbsp;&nbsp;&nbsp;Çàòåì îòïðàâüòå òåëåãðàììó, ñîäåðæàùóþ (â ñëó÷àå íåîáõîäèìîñòè èõ ìîæíî âûñëàòü ÀÂÈÀ ïèñüìîì):<blockquote><blockquote><blockquote><blockquote>1) Ýòîò 
íîìåð: <font color=red><b>6x6-000000-z-001</b></font><br>2) Âàøè Ô.È.Î.<br>3) Âàø e-mail</blockquote></blockquote></blockquote></blockquote><p>&nbsp;&nbsp;&nbsp;íà àäðåñ:<blockquote><blockquote><blockquote><blockquote><b>Igor Tistsenkov<br>Laanemere 20-96<br>13913 Tallinn<br>Estonia</b></blockquote></blockquote></blockquote></blockquote><p>&nbsp;&nbsp;&nbsp;2) Â 
òå÷åíèå ñóòîê Âàì íà e-mail ïðèéäåò ïèñüìî, ñîäåðæàùåå Âàø ðåãèñòðàöèîííûé íîìåð, ðåêâèçèòû âñåõ ñîòðóäíèêîâ, ó êîòîðûõ Âàì íåîáõîäèìî êóïèòü êíèãó, è ïîëíîå îïèñàíèå ìåõàíèçìà è âñåõ òîíêîñòåé ñèñòåìû.<br>&nbsp;&nbsp;&nbsp;3) Ñðàçó êóïèòå êíèãó ó ñîòðóäíèêîâ, ñòîèìîñòü 36 äîëëàðîâ ÑØÀ. Ïîäðîáíåå â ïèñüìå.<br>&nbsp;&nbsp;&nbsp;4) Ïîëó÷èâ êíèãó, 
ñðàçó ïðèñòóïàéòå ê ðàáîòå. Óäà÷à íå çàñòàâèò ñåáÿ æäàòü!<p>&nbsp;&nbsp;&nbsp;<font color=#000066><b>P.S. Åñëè ó Âàñ âîçíèêëè êàêèå-ëèáî âîïðîñû ïî ïîâîäó ñèñòåìû 6õ6 - íå ñòåñíÿéòåñü, ïðèñûëàéòå íàì èõ è ñâîé e-mail òåëåãðàììîé èëè ïî ïî÷òå, è ìû Âàì ñ ðàäîñòüþ íà íèõ îòâåòèì!<tr><td height=60><tr><td><font face=verdana size=+1><center><b>À òåïåðü 
çà äåëî!<p><font color=#000066 size=5><b>Æåëàåì Âàì îãðîìíûõ óñïåõîâ!!!<tr><td height=40><tr><td bgcolor=#ffffcc>&nbsp;<tr><td bgcolor=#000066>&nbsp;<tr><td><p><br><center><font face=verdana size=1 color=#555555>Copyright © 2000-2001 6x6 InterNetwork Group. Âñå ïðàâà çàùèùåíû. Ëþáîå èçìåíåíèå 
òåêñòà ýòîãî ïèñüìà è ïîñëåäóþùåå åãî ðàñïðîñòðàíåíèå ïðåñëåäóåòñÿ ïî çàêîíó îá àâòîðñêèõ ïðàâàõ.<br>&nbsp;</table></body></html>

------=_fuLGlGCN~eIozsoRm--



From deliberatus@my995internet.com  Thu Nov 22 07:41:06 2001
From: deliberatus@my995internet.com (Kirk Bailey)
Date: Thu, 22 Nov 2001 02:41:06 -0500
Subject: [Tutor] latest version and results.
Message-ID: <3BFCAC12.70F527E0@my995internet.com>

ok. here is the latest version of teh script:
-------------isolated bits barrier----------------
#!/usr/local/bin/python
# above line makes the file executable. MAKE SURE the X bit is SET
# on the file's permissions with chmod, such as chmod 755 (filename)!
#
# these next 2 are so the variqbles already have population and type-
strings.
# is this important?
#
# let's get the input from the user.
#
domain = raw_input("What domain name should I add? ")
print "Domain =", domain
infile = raw_input("What file should I read please? ")
print "I will read from a file named ", infile
outfile = raw_input("What file should I write out please? ")
print outfile
print "\n"
print "I will write results to the screen and a file named ", outfile
print "I will read each item in", infile, "and add \'@\' and ", domain,
"to it,"
print "and write the results to", "outfile, and also print them to the
screen."
print

inf = open(infile,"r")
out = open(outfile,"w")

for line in inf.readlines():
        addr = line.strip() + "@" + domain
        print addr
        out.write(addr+"\n")

out.close()
inf.close()

print "All done!"
print "\n"

-------------isolated bits barrier----------------
And it produced these results:
---------------babble------------------

$ ./filedomainadd.py
What domain name should I add? howlermonkey.net
Domain = howlermonkey.net
What file should I read please? list1
I will read from a file named  list1
What file should I write out please? list2
list2


I will write results to the screen and a file named  list2
I will read each item in list1 and add '@' and  howlermonkey.net to it,
and write the results to outfile, and also print them to the screen.

Traceback (innermost last):
  File "./filedomainadd.py", line 26, in ?
    addr = line.strip() + "@" + domain
AttributeError: 'string' object has no attribute 'strip'
$ 
-----------------end-------------------------------

intresting, seems something wants an attribute, and I do not comprehend
what STRIP is or deos, I just took the code offered and implemented it.
WTF, over please?

-- 
Respectfully,
             -Kirk D Bailey (C)2001
              Addme! icq #27840081
end
      My Sites:
      http://www.howlermonkey.net/ - free REAL email! list service soon!
      http://www.sacredelectron.org/ - Rants! Spleenvents!
      http://www.minorfish.org/ - The list server for some of us!

Message of the week:
R5L9W SDPQW UVN7V RUBWB I6HFP WVCUT VWRVL
W7812 LVH8V JBVK2 3CEJB TO8P3 FHFHG H7BFM
QID68 6DN6F 6M486 YQNCF JECQP 86CNP 86CTT
JIQPF ZPVGV DLFST DBUDI UIFNC BTUBS ETBOE
BTTGV DLUIF NSFBM IBSE!


From ak@silmarill.org  Thu Nov 22 07:57:04 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Thu, 22 Nov 2001 02:57:04 -0500
Subject: [Tutor] latest version and results.
In-Reply-To: <3BFCAC12.70F527E0@my995internet.com>
References: <3BFCAC12.70F527E0@my995internet.com>
Message-ID: <20011122025704.A810@sill.silmarill.org>

On Thu, Nov 22, 2001 at 02:41:06AM -0500, Kirk Bailey wrote:
> ok. here is the latest version of teh script:
> -------------isolated bits barrier----------------
> #!/usr/local/bin/python
> # above line makes the file executable. MAKE SURE the X bit is SET
> # on the file's permissions with chmod, such as chmod 755 (filename)!
> #
> # these next 2 are so the variqbles already have population and type-
> strings.
> # is this important?
> #
> # let's get the input from the user.
> #
> domain = raw_input("What domain name should I add? ")
> print "Domain =", domain
> infile = raw_input("What file should I read please? ")
> print "I will read from a file named ", infile
> outfile = raw_input("What file should I write out please? ")
> print outfile
> print "\n"
> print "I will write results to the screen and a file named ", outfile
> print "I will read each item in", infile, "and add \'@\' and ", domain,
> "to it,"
> print "and write the results to", "outfile, and also print them to the
> screen."
> print
> 
> inf = open(infile,"r")
> out = open(outfile,"w")
> 
> for line in inf.readlines():
>         addr = line.strip() + "@" + domain
>         print addr
>         out.write(addr+"\n")
> 
> out.close()
> inf.close()
> 
> print "All done!"
> print "\n"
> 
> -------------isolated bits barrier----------------
> And it produced these results:
> ---------------babble------------------
> 
> $ ./filedomainadd.py
> What domain name should I add? howlermonkey.net
> Domain = howlermonkey.net
> What file should I read please? list1
> I will read from a file named  list1
> What file should I write out please? list2
> list2
> 
> 
> I will write results to the screen and a file named  list2
> I will read each item in list1 and add '@' and  howlermonkey.net to it,
> and write the results to outfile, and also print them to the screen.
> 
> Traceback (innermost last):
>   File "./filedomainadd.py", line 26, in ?
>     addr = line.strip() + "@" + domain
> AttributeError: 'string' object has no attribute 'strip'
> $ 
> -----------------end-------------------------------
> 
> intresting, seems something wants an attribute, and I do not comprehend
> what STRIP is or deos, I just took the code offered and implemented it.
> WTF, over please?

Your interpreter's too old for this code. In version 2.0+, I think, every
string object got a bunch of methods. For example:

Python 2.1.1 (#1, Aug  5 2001, 15:52:58) 
[GCC 2.95.4 20010506 (Debian prerelease)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> s = " test "
>>> s.strip()
'test'

In earlier pythons you'd write import string; string.strip(s) instead.
So, you can either get newer python (or, if you already have one, use it
to run that code), or you can change the code to use string module
instead.
> 
> -- 
> Respectfully,
>              -Kirk D Bailey (C)2001
>               Addme! icq #27840081
> end
>       My Sites:
>       http://www.howlermonkey.net/ - free REAL email! list service soon!
>       http://www.sacredelectron.org/ - Rants! Spleenvents!
>       http://www.minorfish.org/ - The list server for some of us!
> 
> Message of the week:
> R5L9W SDPQW UVN7V RUBWB I6HFP WVCUT VWRVL
> W7812 LVH8V JBVK2 3CEJB TO8P3 FHFHG H7BFM
> QID68 6DN6F 6M486 YQNCF JECQP 86CNP 86CTT
> JIQPF ZPVGV DLFST DBUDI UIFNC BTUBS ETBOE
> BTTGV DLUIF NSFBM IBSE!
> 
> _______________________________________________
> 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 m_konermann@gmx.de  Thu Nov 22 08:24:41 2001
From: m_konermann@gmx.de (Marcus Konermann)
Date: Thu, 22 Nov 2001 09:24:41 +0100
Subject: [Tutor] Tkinter and PythonWin  ?
Message-ID: <3BFCB649.9080901@gmx.de>

Hi @ All

I´m using PythonWin under Windows2000 and want to write a GUI with 
Tkinter, but on the python.org I-Net page is written that Tkinter 
does´nt work under PythonWin. So, can anyone tell me how to install and 
use pythonw.exe ? Are there other programs which work with Tkinter ?

Thanks a lot
Marcus



From dyoo@hkn.eecs.berkeley.edu  Thu Nov 22 08:41:49 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 22 Nov 2001 00:41:49 -0800 (PST)
Subject: [Tutor] latest version and results.
In-Reply-To: <3BFCAC12.70F527E0@my995internet.com>
Message-ID: <Pine.LNX.4.21.0111220030060.2226-100000@hkn.eecs.berkeley.edu>

On Thu, 22 Nov 2001, Kirk Bailey wrote:

[some code cut]
> for line in inf.readlines():
>         addr = line.strip() + "@" + domain
[more code cut]
> 
> Traceback (innermost last):
>   File "./filedomainadd.py", line 26, in ?
>     addr = line.strip() + "@" + domain
> AttributeError: 'string' object has no attribute 'strip'
> $ 
> -----------------end-------------------------------
> 
> intresting, seems something wants an attribute, and I do not
> comprehend what STRIP is or deos, I just took the code offered and
> implemented it. WTF, over please?

Hi Kirk,

The expression:

    line.strip()

means: "Take the string 'line', and strip() from it all whitespace on
either side of it."  It's often used to remove trailing newlines.


However, the line above uses "string method" syntax, and that was
introduced into the Python language around version 1.6.  Older versions of
Python didn't have this syntax, so that's why the AttributeError is being
flagged.  Thankfully, there's an equivalent expression we can use, with
the help of the string module:

    string.strip(line)

With this compatibility correction, your line will look like this:

    addr = string.strip(line) + "@" + domain

and that should work better for you.  However, you might want to see if
upgrading your Python is possible, since there's been quite a few bug
fixes and improvements to the language since 1.52.


For more documentation on string.strip(), you can look at:

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


Good luck to you.



From m_konermann@gmx.de  Thu Nov 22 14:30:06 2001
From: m_konermann@gmx.de (Marcus Konermann)
Date: Thu, 22 Nov 2001 15:30:06 +0100
Subject: [Tutor] Problem with SWIG and Shadow Classes
Message-ID: <3BFD0BEE.5000902@gmx.de>

--------------010708010408010104060307
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hi !

I`ve got a python module, generated with SWIG, named simannealfile.py . 
It is beginning like the following:

# This file was created automatically by SWIG.
import simannealfilec
class simanneal_varlist:
    def __init__(self,*args):
        self.this = apply(simannealfilec.new_simanneal_varlist,args)
        self.thisown = 1

    def __del__(self,simannealfilec=simannealfilec):
        if getattr(self,'thisown',0):
            simannealfilec.delete_simanneal_varlist(self)
...

I imported this File in another Module named mainko.py :

import string,re,sys,glob,operator
import simannealfile


instance1=simannealfile.simulated_annealing()

fx=instance1.optimize()

print 'test=',fx

The mainko.py file is just a dummy to test teh correct function, but 
after executing the following output appers:

Traceback (most recent call last):
  File "c:\programme\python21\pythonwin\pywin\framework\scriptutils.py", 
line 396, in ImportFile
    reload(sys.modules[modName])
  File "C:\Arbeit_Diplomarbeit\__Optimierer\ext1\mainko.py", line 2, in ?
    import simannealfile
  File "C:\Arbeit_Diplomarbeit\__Optimierer\ext1\simannealfile.py", line 
2, in ?
    import simannealfilec
ImportError: No module named simannealfilec

Python seems to have problems finding the file simannealfilec .This file 
is automatically generated by the SWIG Wrapper an no visible.
So, it would be very good, if anyone has got a solution to my problem.

Greetings
Marcus






--------------010708010408010104060307
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<html>
<head>
</head>
<body>
Hi !<br>
<br>
I`ve got a python module, generated with SWIG, named simannealfile.py . It
is beginning like the following:<br>
<br>
<i># This file was created automatically by SWIG.</i><i><br>
</i><i>import simannealfilec</i><i><br>
</i><i>class simanneal_varlist:</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp; def __init__(self,*args):</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.this = apply(simannealfilec.new_simanneal_varlist,args)</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.thisown = 1</i><i><br>
</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp; def __del__(self,simannealfilec=simannealfilec):</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if getattr(self,'thisown',0):</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; simannealfilec.delete_simanneal_varlist(self)</i><br>
...<br>
<br>
I imported this File in another Module named mainko.py :<br>
<br>
<i>import string,re,sys,glob,operator</i><i><br>
</i><i>import simannealfile</i><i><br>
</i><i><br>
</i><i><br>
</i><i>instance1=simannealfile.simulated_annealing()</i><i><br>
</i><i><br>
</i><i>fx=instance1.optimize()</i><i><br>
</i><i><br>
</i><i>print 'test=',fx</i><br>
<br>
The mainko.py file is just a dummy to test teh correct function, but after
executing the following output appers:<br>
<br>
<i>Traceback (most recent call last):</i><i><br>
</i><i>&nbsp; File "c:\programme\python21\pythonwin\pywin\framework\scriptutils.py",
line 396, in ImportFile</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp; reload(sys.modules[modName])</i><i><br>
</i><i>&nbsp; File "C:\Arbeit_Diplomarbeit\__Optimierer\ext1\mainko.py", line
2, in ?</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp; import simannealfile</i><i><br>
</i><i>&nbsp; File "C:\Arbeit_Diplomarbeit\__Optimierer\ext1\simannealfile.py",
line 2, in ?</i><i><br>
</i><i>&nbsp;&nbsp;&nbsp; import simannealfilec</i><i><br>
</i><i>ImportError: No module named simannealfilec<br>
<br>
</i>Python seems to have problems finding the file simannealfilec .This file
is automatically generated by the SWIG Wrapper an no visible. <br>
So, it would be very good, if anyone has got a solution to my problem.<br>
<br>
Greetings<br>
Marcus<br>
<i><br>
<br>
<br>
</i><br>
<br>
</body>
</html>

--------------010708010408010104060307--



From apython101@yahoo.com  Thu Nov 22 15:42:07 2001
From: apython101@yahoo.com (john public)
Date: Thu, 22 Nov 2001 07:42:07 -0800 (PST)
Subject: [Tutor] python
Message-ID: <20011122154207.43980.qmail@web21102.mail.yahoo.com>

  I finally can run python in interactive mode in dos
from the python21 directory. What other modes are
there? Do I run them from DOS or from windows? I have
windows 98. Thanks

__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1


From alan.gauld@bt.com  Thu Nov 22 17:11:06 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 22 Nov 2001 17:11:06 -0000
Subject: [Tutor] Tkinter and PythonWin  ?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0F7@mbtlipnt02.btlabs.bt.co.uk>

> Tkinter, but on the python.org I-Net page is written that Tkinter=20
> does=B4nt work under PythonWin.=20

I think we need to be clear what we mean here.

You can write Tkinter apps using the PythonWin IDE.
You cannot(easily) mix the pythonwin MFC library with Tkinter.

> use pythonw.exe ?=20

pythonw.exe is just a replacement for python.exe that=20
does not open a console window (aka dos box) when you=20
run the program. It comes as part of the Windows install.
You normally run finished Tkkinter apps using pythonw.exe
but use python.exe to develop them - since you can print=20
debugging statements in it.=20

> Are there other programs which work with Tkinter ?

IDLE the other python IDE commonly used does not=20
like Tkinter running its own mainloop() function. You=20
can get round that but personally I just run the=20
program outside IDLE from a DOS box.

Also, in general its a bad idea to mix GUI libraries=20
so don't try to use Tkinter when already using=20
wxPython, PyQt etc etc...

HTH,

Alan G.


From alan.gauld@bt.com  Thu Nov 22 17:20:41 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 22 Nov 2001 17:20:41 -0000
Subject: [Tutor] python
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0F8@mbtlipnt02.btlabs.bt.co.uk>

>   I finally can run python in interactive mode in dos
> from the python21 directory. What other modes are
> there? 

There is 'interpretive mode'(for want of a better term!)
Thats where you run a program written in python under 
the control of the python interpreter. Thus is the file 
is called hello.py you type:

C:> python hello.py

Or from the Start|Run dialog

python hello.py

Or even just

hello.py

Or just double click hello.py in windows explorer

Each of these will start the python interpreter and feed 
it the hello.py file. It will execute the hello.py 
program then exit without going to the >>> prompt 
you have seen so far.


> Do I run them from DOS or from windows? 

Several ways as you can see above.

Mostly you will just double click the file for 
finished programs but during development you 
probably want to use the first option so that 
you can see any error merssages in the DOS box 
after it stops running.

Finally, once you get your program running OK, 
if you don't need a DOS box for user input or 
to display output(say its a GUI app or a pure 
batch processing thing) you can rename the file 
to hello.pyw which starts pythonw.exe instead 
of python.exe. This runs the program without 
starting a DOS box.

HTH,

Alan G.


From glingl@aon.at  Thu Nov 22 22:59:00 2001
From: glingl@aon.at (Gregor Lingl)
Date: Thu, 22 Nov 2001 23:59:00 +0100
Subject: [Tutor] Possibly odd question on everything
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0F8@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <006b01c173a9$462ff5a0$1664a8c0@mega>

Dear Pythonistas!

One often says: in Python everything is an object.

In preparing some lecture for my students I met 
the following:

>>> type(print)
  File "<stdin>", line 1
    type(print)
                 
SyntaxError: invalid syntax

(I didn't know, what to expect)

and also:

>>> type(print 3)
  File "<stdin>", line 1
    type(print 3)
                 
SyntaxError: invalid syntax

(I admit, I expected None)


So there is something, called print-statement,
which doesn't seem to belong to everything
 
Hmmm?
Aren't there languages, where really everything
is an object (maybe Smalltalk, maybe Ruby ...
and what about the equivalence of code and data
in Scheme...?)

Interesting, but perhaps not very important, especially
for the rather pragmatic Python-community

Gregor

P. S.: I am really glad, that there exist such a wonderful
mailing list like this one, where I dare to put questions
thus obscure - without having to be afraid to get
expelled ...





From kalle@gnupung.net  Thu Nov 22 23:59:46 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Fri, 23 Nov 2001 00:59:46 +0100
Subject: [Tutor] Possibly odd question on everything
In-Reply-To: <006b01c173a9$462ff5a0$1664a8c0@mega>
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0F8@mbtlipnt02.btlabs.bt.co.uk> <006b01c173a9$462ff5a0$1664a8c0@mega>
Message-ID: <20011123005946.A29663@proton.lysator.liu.se>

[Gregor Lingl]
> 
> Dear Pythonistas!
> 
> One often says: in Python everything is an object.
> 
> In preparing some lecture for my students I met 
> the following:
[snip]
> >>> type(print 3)
>   File "<stdin>", line 1
>     type(print 3)
>                  
> SyntaxError: invalid syntax
> 
> (I admit, I expected None)
> 
> 
> So there is something, called print-statement,
> which doesn't seem to belong to everything

Well...  The thing is that there are several kinds of statement in Python, and
only expression statements evaluate to something.  The syntax for function
calls:

call:                   primary "(" [argument_list [","]] ")"
argument_list:          positional_arguments ["," keyword_arguments]
                      | keyword_arguments
positional_arguments:   expression ("," expression)*
keyword_arguments:      keyword_item ("," keyword_item)*
keyword_item:           identifier "=" expression

This (sort of) means that a function call consists of a primary (the
function), a left parenthesis, a list of arguments that consist of
expressions, and a right parenthesis.

The arguments must be expressions or "expression statements".
print is a "print statement".
obj, where obj is an object of some kind is an identifier, which is an atom,
which is an expression statement.

Hope this helps, I'm not entirely certain I made things clearer.  Anyway,
check it out on http://www.python.org/doc/current/ref/ if you're curious...

Peace,
  Kalle
-- 
[  Laziness, impatience, hubris:  Pick two!  ]
[   International: http://www.gnupung.net/   ]
[ Svenska: http://www.lysator.liu.se/~kalle/ ]


From urnerk@qwest.net  Fri Nov 23 02:26:08 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Thu, 22 Nov 2001 18:26:08 -0800
Subject: [Tutor] Possibly odd question on everything
In-Reply-To: <006b01c173a9$462ff5a0$1664a8c0@mega>
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0F8@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <4.2.0.58.20011122181511.00950f00@pop3.norton.antivirus>

That's a good question Gregor.

Most primitives, like 'hash', live as builtin functions,
and if you ask for their types, you get something
like:

  >>> type(hash)
  <type 'builtin_function_or_method'>

But 'print' is special in that its appearance constitutes
an executable command -- it doesn't need (won't take)
any arguments.  So

  >>> type(print)

has to be regarded as bad syntax, since 'print' is an
interpretable command as is.

Python keywords may be listed using the keyword module:

   >>> keyword.kwlist
   ['and', 'assert', 'break', 'class', 'continue', 'def', 'del',
   'elif',   'else', 'except', 'exec', 'finally', 'for', 'from',
   'global', 'if', 'import', 'in', 'is', 'lambda', 'not', 'or',
   'pass', 'print', 'raise', 'return', 'try', 'while', 'yield']

None of these have a type per se.  They're part of the
syntax, but don't behave like objects.  Neither do the
operators, unless imported as objects from the operator
module.  E.g. you can't go type(+) or type(==).

Kirby



From apython101@yahoo.com  Fri Nov 23 02:55:08 2001
From: apython101@yahoo.com (john public)
Date: Thu, 22 Nov 2001 18:55:08 -0800 (PST)
Subject: [Tutor] "hello world"
In-Reply-To: <E166xDq-0007BV-00@mail.python.org>
Message-ID: <20011123025508.46925.qmail@web21109.mail.yahoo.com>

 I finally found python shell but I am still cannot
save a program.

I am using this tutorial

http://us.f211.mail.yahoo.com/ym/login?.rand=8j7cu55rufoat

Here are the directions from the tutorial.

Creating and Running Programs 
Go into IDLE if you are not already. Go to File then
New Window. In this window type the following: 
print "Hello, World!"

First save the program. Go to File then Save. Save it
as 'hello.py'. (If you want you can save it to some
other directory than the default.) Now that it is
saved it can be run. 

Next run the program by going to Edit then Run script.
This will output Hello, World! on the *Python Shell*
window. 


Here is what happened when I followed the directions


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
>>>  print "hello, world!"
  File "C:/Python21/Tools/idle/'hello.py'", line 1
    Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32
bit (Intel)] on win32
             ^
SyntaxError: invalid syntax

 Can some one tell me what I did wrong?

 thanx




__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1


From deliberatus@my995internet.com  Fri Nov 23 06:51:56 2001
From: deliberatus@my995internet.com (Kirk Bailey)
Date: Fri, 23 Nov 2001 01:51:56 -0500
Subject: [Tutor] command line arguements
Message-ID: <3BFDF20C.4E2E56F0@my995internet.com>

OK, here ya go. Slightly deeper sorcery time.

A script is to be fed data, which is an incoming email. This is piped to
it in the time honored tradition by a declaration in the aliases file,
such as:

mylist:"|/pathtoprogram/programname mylist" 

The data arrives at the program through <stdin> and is read as a normal
input if I have this right. I also want it to read the command line
arguement (in this case the word mylist which follows the program name,
and is handed to it by the opsys as a command line arguement).

how does one tell a python program to pay attention to command line
data? I can do this in a shell script, and a few other languages, but do
not yet comprehend it in python.



-- 
Respectfully,
             -Kirk D Bailey (C)2001
              Addme! icq #27840081
end
      My Sites:
      http://www.howlermonkey.net/ - free REAL email! list service soon!
      http://www.sacredelectron.org/ - Rants! Spleenvents!
      http://www.minorfish.org/ - The list server for some of us!

Message of the week:
R5L9W SDPQW UVN7V RUBWB I6HFP WVCUT VWRVL
W7812 LVH8V JBVK2 3CEJB TO8P3 FHFHG H7BFM
QID68 6DN6F 6M486 YQNCF JECQP 86CNP 86CTT
JIQPF ZPVGV DLFST DBUDI UIFNC BTUBS ETBOE
BTTGV DLUIF NSFBM IBSE!


From glingl@aon.at  Fri Nov 23 07:03:23 2001
From: glingl@aon.at (Gregor Lingl)
Date: Fri, 23 Nov 2001 08:03:23 +0100
Subject: [Tutor] "hello world"
References: <20011123025508.46925.qmail@web21109.mail.yahoo.com>
Message-ID: <001801c173ec$f15944c0$1664a8c0@mega>

Dear John!

This odd behaviour results from a misunderstanding:

If you follow the description of your tutorial, you will have
opened two windows:

1. The one for the python-shell
2. The anotherone for hello.py (which acts merely like an editor-window).

Now you have to save the content of the editor-window und to
RUN the script from THAT WINDOW.

Only the output will appear in the interactive Python-Shell window.

You apparently tried tu Run the scriopt from the shell. This asked you
first to save its content und you saved the following (or similar) to your
file:

Python 2.2b2 (#26, Nov 16 2001, 11:44:11) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.8 -- press F1 for help
>>> print "Hello world!"
Hello world!
>>> 

Then you tried to execute this file, which - of course - is no valid
Python program and already at 
Python 2.  
the first Syntax-Error occurs.

So, go to the edit-window for hello.py an do there according to your 
 tutorials description:

Menu - Edit - Run Script

and look at the shell:

>>>
Hello world!


now type Enter and you will arrive at the interactive prompt again!

>>>

Hope that helps! Hope you will be familiar with Python+IDLE soon

Gregor



----- Original Message ----- 
From: "john public" <apython101@yahoo.com>
To: <tutor@python.org>
Sent: Friday, November 23, 2001 3:55 AM
Subject: [Tutor] "hello world"


> I finally found python shell but I am still cannot
> save a program.
> 
> I am using this tutorial
> 
> http://us.f211.mail.yahoo.com/ym/login?.rand=8j7cu55rufoat
> 
> Here are the directions from the tutorial.
> 
> Creating and Running Programs 
> Go into IDLE if you are not already. Go to File then
> New Window. In this window type the following: 
> print "Hello, World!"
> 
> First save the program. Go to File then Save. Save it
> as 'hello.py'. (If you want you can save it to some
> other directory than the default.) Now that it is
> saved it can be run. 
> 
> Next run the program by going to Edit then Run script.
> This will output Hello, World! on the *Python Shell*
> window. 
> 
> 
> Here is what happened when I followed the directions
> 
> 
> 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
> >>>  print "hello, world!"
>   File "C:/Python21/Tools/idle/'hello.py'", line 1
>     Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32
> bit (Intel)] on win32
>              ^
> SyntaxError: invalid syntax
> 
>  Can some one tell me what I did wrong?
> 
>  thanx
> 
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
> http://geocities.yahoo.com/ps/info1
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
> 



From karthikg@aztec.soft.net  Fri Nov 23 08:12:40 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Fri, 23 Nov 2001 13:42:40 +0530
Subject: [Tutor] Adding a bound method dynamically (newbie)
In-Reply-To: <3BFA7ED9.14355.557930@localhost>
Message-ID: <NEBBJNMDEKBIBCMCNMBDIEKOCJAA.karthikg@aztec.soft.net>

hi all,

say i have a class

class Test:

    def __init__(self):
        self.name="Python"
        self.age=100
    def func(self):
        print 'func'

Now in another script i want to do

def boundMethod():
	//s'd've access to name and age i defined earlier

and then i w'd like to do

t = Test()
t.salary = 10000

and then

t.func2 = boundMethod

This does'nt work because boundMethod does'nt've an access to the "self"
Basically i want this call to work

t.func2(). I don't want to do t.func2(t) and thereby giving access to the
instance.

Another question:

when i did a dir(<class-name>) => it gave a list of the methods associated
with the class irrespective of wether it is a bound method or not.

when i did a dir(<instance of class>) => it gave a list of the instance
attributes associated with the class
Now i might have methods which are bound so s'd'nt dir(<instance>) indicate
that those bound methods can also be invoked on the instance? Basically i
w'd like to know as to why dir() behaves that way.
Then there's a vars() :-(...confusing!
I remeber having coming across something like vars() looks for __members__
...am not sure what that stands for.

l =[]
dir(l) => lists all the instance method of l. I want to give that kind of a
functionality to my class instance as well.

what s'd i be doing?.
Hope i have managed to convey my queries in a proper way.

thanks in advance,
karhik.







From dyoo@hkn.eecs.berkeley.edu  Fri Nov 23 08:59:09 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 23 Nov 2001 00:59:09 -0800 (PST)
Subject: [Tutor] latest version and results. (fwd)
Message-ID: <Pine.LNX.4.21.0111230057430.15250-100000@hkn.eecs.berkeley.edu>

Hi Kirk,

I'm forwarding your message to the rest of Tutor.  I'm glad to hear that
your program is working well now!


---------- Forwarded message ----------
Date: Thu, 22 Nov 2001 23:48:17 -0500
From: Kirk Bailey <deliberatus@my995internet.com>
To: Danny Yoo <dyoo@hkn.eecs.berkeley.edu>
Subject: Re: [Tutor] latest version and results.

SUCCESS!

OK, here is what worked:
-----------------------------------------------------------------------
#!/usr/local/bin/python
# above line makes the file executable. MAKE SURE the X bit is SET
# on the file's permissions with chmod, such as chmod 755 (filename)!
#
# Listmaker V:1.0.0
# (C)2001 Howlermonkey Email Services Co
# Free for use under the GNU PGL, so feel free!
#
import string;
#
# let's get the input from the user.
#
domain = raw_input("What domain name should I add? ")
print "Domain =", domain
infile = raw_input("What file should I read please? ")
print "I will read from a file named ", infile
outfile = raw_input("What file should I write out please? ")
print outfile
print "\n"
print "I will write results to the screen and a file named ", outfile
print "I will read each item in", infile, "and add \'@\' and ", domain,
"to it,"
print "and write the results to", "outfile, and also print them to the
screen."
print

inf = open(infile,"r")
out = open(outfile,"w")

for addr in inf.readlines():
        addr2=string.strip(addr)
        addr =  addr2 + "@" + domain
        print addr
        out.write(addr +"\n")

out.close()
inf.close()


print "All done!"
print "\n"
----------------------------------------------------------------------

This script accepted a list of users of my server as

-----------------------------------------------------

3d
4email
4mail
aaa78a
achenor
adammann21
adenshire
akenarong
aksan
amberdz
andrewcostigan
andyheys
archangel
armandi
aryazamani
athiestnick
babs
babybear
badbaddolemite
badferret
baggend
bald17
basic
bcaraco
beastyo
becky
beelzebub
benja
benjobee
billygames
-----------------------------------------

and produced this result:

-----------------------------------------

3d@howlermonkey.net
4email@howlermonkey.net
4mail@howlermonkey.net
aaa78a@howlermonkey.net
achenor@howlermonkey.net
adammann21@howlermonkey.net
adenshire@howlermonkey.net
akenarong@howlermonkey.net
aksan@howlermonkey.net
amberdz@howlermonkey.net
andrewcostigan@howlermonkey.net
andyheys@howlermonkey.net
archangel@howlermonkey.net
armandi@howlermonkey.net
aryazamani@howlermonkey.net
athiestnick@howlermonkey.net
babs@howlermonkey.net
babybear@howlermonkey.net
badbaddolemite@howlermonkey.net
badferret@howlermonkey.net
baggend@howlermonkey.net
bald17@howlermonkey.net
basic@howlermonkey.net
bcaraco@howlermonkey.net
beastyo@howlermonkey.net
becky@howlermonkey.net
beelzebub@howlermonkey.net
benja@howlermonkey.net
benjobee@howlermonkey.net
billygames@howlermonkey.net

------------------------------------
which is only the first page. 

These quotes are not screen output quotes, but listings of the source
and result file contents.

It works! thank you!

Sure, I can pretty up the prompting a little, but the tool now works. By
cd to /usr/home and doing a ls > list I can create a list of all users
on the server, and then can convert this to an email address list for a
newsletter. Is this of use to anyone? There it is, clip it and use it.




me
you
critter
david1
cobmaster
foo

and produced this result:
------------------------------------



Danny Yoo wrote:
> 
> On Thu, 22 Nov 2001, Kirk Bailey wrote:
> 
> [some code cut]
> > for line in inf.readlines():
> >         addr = line.strip() + "@" + domain
> [more code cut]
> >
> > Traceback (innermost last):
> >   File "./filedomainadd.py", line 26, in ?
> >     addr = line.strip() + "@" + domain
> > AttributeError: 'string' object has no attribute 'strip'
> > $
> > -----------------end-------------------------------
> >
> > intresting, seems something wants an attribute, and I do not
> > comprehend what STRIP is or deos, I just took the code offered and
> > implemented it. WTF, over please?
> 
> Hi Kirk,
> 
> The expression:
> 
>     line.strip()
> 
> means: "Take the string 'line', and strip() from it all whitespace on
> either side of it."  It's often used to remove trailing newlines.
> 
> However, the line above uses "string method" syntax, and that was
> introduced into the Python language around version 1.6.  Older versions of
> Python didn't have this syntax, so that's why the AttributeError is being
> flagged.  Thankfully, there's an equivalent expression we can use, with
> the help of the string module:
> 
>     string.strip(line)
> 
> With this compatibility correction, your line will look like this:
> 
>     addr = string.strip(line) + "@" + domain
> 
> and that should work better for you.  However, you might want to see if
> upgrading your Python is possible, since there's been quite a few bug
> fixes and improvements to the language since 1.52.
> 
> For more documentation on string.strip(), you can look at:
> 
>     http://www.python.org/doc/lib/module-string.html
> 
> Good luck to you.

-- 
Respectfully,
             -Kirk D Bailey (C)2001
              Addme! icq #27840081
end
      My Sites:
      http://www.howlermonkey.net/ - free REAL email! list service soon!
      http://www.sacredelectron.org/ - Rants! Spleenvents!
      http://www.minorfish.org/ - The list server for some of us!



From ak@silmarill.org  Fri Nov 23 03:11:11 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Thu, 22 Nov 2001 22:11:11 -0500
Subject: [Tutor] "hello world"
In-Reply-To: <20011123025508.46925.qmail@web21109.mail.yahoo.com>
References: <E166xDq-0007BV-00@mail.python.org>
 <20011123025508.46925.qmail@web21109.mail.yahoo.com>
Message-ID: <20011122221111.A4691@sill.silmarill.org>

On Thu, Nov 22, 2001 at 06:55:08PM -0800, john public wrote:
>  I finally found python shell but I am still cannot
> save a program.
> 
> I am using this tutorial
> 
> http://us.f211.mail.yahoo.com/ym/login?.rand=8j7cu55rufoat
> 
> Here are the directions from the tutorial.
> 
> Creating and Running Programs 
> Go into IDLE if you are not already. Go to File then
> New Window. In this window type the following: 
> print "Hello, World!"
> 
> First save the program. Go to File then Save. Save it
> as 'hello.py'. (If you want you can save it to some
> other directory than the default.) Now that it is
> saved it can be run. 
> 
> Next run the program by going to Edit then Run script.
> This will output Hello, World! on the *Python Shell*
> window. 
> 
> 
> Here is what happened when I followed the directions
> 
> 
> 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
> >>>  print "hello, world!"
>   File "C:/Python21/Tools/idle/'hello.py'", line 1
>     Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32
> bit (Intel)] on win32
>              ^
> SyntaxError: invalid syntax
> 
>  Can some one tell me what I did wrong?
> 
>  thanx

I don't know about idle, but you can make a file using notepad, type in
one line in it: print "hello, world!" and save it under any name with
.py extension. Then run it from ms-dos prompt like this: python
filename.py


 - Andrei

> 
> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
> http://geocities.yahoo.com/ps/info1
> 
> _______________________________________________
> 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 dyoo@hkn.eecs.berkeley.edu  Fri Nov 23 10:10:10 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 23 Nov 2001 02:10:10 -0800 (PST)
Subject: [Tutor] Possibly odd question on everything
In-Reply-To: <006b01c173a9$462ff5a0$1664a8c0@mega>
Message-ID: <Pine.LNX.4.21.0111230101290.15250-100000@hkn.eecs.berkeley.edu>

> One often says: in Python everything is an object.
>
> In preparing some lecture for my students I met 
> the following:
> 
> >>> type(print)
>   File "<stdin>", line 1
>     type(print)
>                  
> SyntaxError: invalid syntax
> 
> (I didn't know, what to expect)


There are some things that are treated as pure syntax --- they're so built
into the core language of Python that they don't qualify as expressions.  
Here's another example:

###
>>> type(and)
  File "<stdin>", line 1
    type(and)
           ^
SyntaxError: invalid syntax
###

That is, in Python, trying to use an "and" in some other way besides a
logical expression will be flagged as bad syntax.  In the Scheme language,
these things are called "special forms" or "statements".  They're called
this because they have exceptional behavior.


I guess something analogous to this in a human sense would be the greeting
"Hello!".  Would "Hello!" qualify as a subject, verb, or object?  Not all
English sentences follow Subject Verb Object syntax, and so there are
special rules for things like "Hello!".  Same thing with computer
languages: not everything is uniform.


Here' another example that involves a print statement that looks like it
should work, but doesn't:

###
>>> map(print, range(42))
  File "<stdin>", line 1
    map(print, range(42))
            ^
SyntaxError: invalid syntax
>>> map(lambda x: print x, range(42))
  File "<stdin>", line 1
    map(lambda x: print x, range(42))
                      ^
SyntaxError: invalid syntax
###

Neither version works because 'print' is not an function, but it's own
"print statement".

'print' has special, relaxed rules --- we can use it without parentheses,
and if a comma follows it, 'print' doesn't skip a line.  These sort of
rules are "special" and apply only to 'print', and as a plus, it makes
'print' easier to use for newcomers to Python.  But as a consequence,
'print' can't participate directly in places where Python expects an
function.  Something of a shame.



Your question touches on the distinction programmers use when they say
"statement" instead of "expression".  Most languages try to keep the kind
of different statements down to a small, easy-to-remember core.


> So there is something, called print-statement, which doesn't seem to
> belong to everything

Yes, exactly.  A language's design often determines what things need
special rules.  For example, Alan's example with '+':

###
>>> +
  File "<stdin>", line 1
    +
    ^
SyntaxError: invalid syntax
###


doesn't apply in the Scheme language:

###
dyoo@coffeetable:~$ guile
guile> +
#<primitive-procedure +>
###





> Aren't there languages, where really everything is an object (maybe
> Smalltalk, maybe Ruby ... and what about the equivalence of code and
> data in Scheme...?)

It's true that everything in Scheme can be considered as a big, nested
list, but it is the interpretation of certain parts of that list that
involve special rules.


> Interesting, but perhaps not very important, especially for the rather
> pragmatic Python-community

This stuff is very interesting!  I was just reading about it tonight in
SICP:

    http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-25.html#%_chap_4

That chapter 4 is all about interpretation and the hassles of special
forms in Scheme.  In particular, there's a Scheme function in that chapter
called "EVAL" that has to take into account the special forms.  It's
basically a big chained IF statement: "Does this thing look like a
variable?  Does it look like an assignment?  An if?"


Hope this helps!




From lonetwin@yahoo.com  Fri Nov 23 10:18:41 2001
From: lonetwin@yahoo.com (lonetwin)
Date: Fri, 23 Nov 2001 15:48:41 +0530
Subject: [Tutor] Passing values of a list as arguments
Message-ID: <01112315484101.11409@mercury.worli>

Hi all,
    I just can't figure out to do this:
====================
def somefunc(arg1, arg2=None)
    if not arg2:
        arg2 = someOtherValue
    ....
    ....
    ....

if __name__ == '__main__':
    somefunc(sys.argv)
====================
    I hope you see my problem, I want to pass the values of sys.argv (or any 
list for that matter) as arguments to somefunction, without resorting to 
something like:
====================
def somefunc(list)
    arg1, arg2 = list[1], list[2] or someOtherValue
    ....
    ....
    ....

if __name__ == '__main__':
    somefunc(sys.argv)
====================
    ....which I think is kinda ugly for more that 3 arg values (python sure 
does makes one *very* picky :))

Peace
Steve
-- 
----------------------------------------------
Every oak tree started out as a 
couple of nuts who stood their ground.
                                    Anonymous
----------------------------------------------



From dyoo@hkn.eecs.berkeley.edu  Fri Nov 23 10:19:32 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 23 Nov 2001 02:19:32 -0800 (PST)
Subject: [Tutor] Passing values of a list as arguments
In-Reply-To: <01112315484101.11409@mercury.worli>
Message-ID: <Pine.LNX.4.21.0111230213560.15250-100000@hkn.eecs.berkeley.edu>

On Fri, 23 Nov 2001, lonetwin wrote:

> Hi all,
>     I just can't figure out to do this:
> ====================
> def somefunc(arg1, arg2=None)
>     if not arg2:
>         arg2 = someOtherValue
>     ....
>     ....
>     ....
> 
> if __name__ == '__main__':
>     somefunc(sys.argv)
> ====================
>     I hope you see my problem, I want to pass the values of sys.argv (or any 
> list for that matter) as arguments to somefunction, without resorting to 
> something like:
> ====================
> def somefunc(list)
>     arg1, arg2 = list[1], list[2] or someOtherValue
>     ....
>     ....
>     ....
> 
> if __name__ == '__main__':
>     somefunc(sys.argv)
> ====================
>
>     ....which I think is kinda ugly for more that 3 arg values (python
> sure does makes one *very* picky :))


I see!  Yes, you can do this by using apply().  Here's a toy example:

###
>>> def add(x, y=None):
...     if y == None: y = 0
...     return x + y
... 
>>> apply(add, [1, 2])
3
>>> apply(add, [1])
1
###

apply() is specifically designed for this kind of stuff, where the second
argument is a list that will be used for the arguments of a function.  You
can see more about apply() here:

    http://python.org/doc/current/lib/built-in-funcs.html

Python has an alterative way of doing this as of 2.0, by using starred
notation.  Take a look at:

    http://python.org/2.0/new-python.html#SECTION0001010000000000000000

for an explanation about it.


Good luck!



From toodles@yifan.net  Fri Nov 23 10:25:30 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Fri, 23 Nov 2001 18:25:30 +0800
Subject: [Tutor] Passing values of a list as arguments
References: <01112315484101.11409@mercury.worli>
Message-ID: <002c01c17409$3419ac70$0300a8c0@sun>

Hi Steve

*brings relevant part to top*

> ====================
> def somefunc(list)
>     arg1, arg2 = list[1], list[2] or someOtherValue

Here you can use list-unpacking. As long as the length of the list is the
same as the amount of variables you are assigning to, you may use the
following:

arg1,arg2,...,argN = list
(though you probably shouldn't use the name "list", as it's a built-in)

HTH
Andrew

> Hi all,
>     I just can't figure out to do this:
> ====================
> def somefunc(arg1, arg2=None)
>     if not arg2:
>         arg2 = someOtherValue
>     ....
>     ....
>     ....
>
> if __name__ == '__main__':
>     somefunc(sys.argv)
> ====================
>     I hope you see my problem, I want to pass the values of sys.argv (or
any
> list for that matter) as arguments to somefunction, without resorting to
> something like:
>     ....
>     ....
>     ....
>
> if __name__ == '__main__':
>     somefunc(sys.argv)
> ====================
>     ....which I think is kinda ugly for more that 3 arg values (python
sure
> does makes one *very* picky :))
>
> Peace
> Steve
> --
> ----------------------------------------------
> Every oak tree started out as a
> couple of nuts who stood their ground.
>                                     Anonymous
> ----------------------------------------------
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>



From alan.gauld@bt.com  Fri Nov 23 12:26:26 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 23 Nov 2001 12:26:26 -0000
Subject: [Tutor] command line arguements
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C0FB@mbtlipnt02.btlabs.bt.co.uk>

> how does one tell a python program to pay attention to command line
> data? 

Try looking at my tutor on:

http://www.freenetpages.co.uk/hp/alan.gauld

Under 'Talking to the user'. The bottom half talks about 
command line args.

The short answer is to look at the argv variable 
in the sys module :-)

Alan g.


From tonycervone@netzero.net  Fri Nov 23 16:37:09 2001
From: tonycervone@netzero.net (tonycervone)
Date: Fri, 23 Nov 2001 11:37:09 -0500
Subject: [Tutor] how does one poll the keyboard?
Message-ID: <000801c1743d$19c73fc0$1088f4d1@w9y5d5>

This is a multi-part message in MIME format.

------=_NextPart_000_0005_01C17413.2FC49EA0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

 How does one poll the keyboard with Python to see if a specific key( =
that I choose to define as the key to press) has been pressed while a =
program is running?  I guess the script would poll the keyboard and run =
in the background of a main program.Of course, the script could not have =
an indefinite loop so as to prevent the program from running. The =
program will then quickly run the script and if the key has been pressed =
a message will appear that such a key has been pressed.=20
thanks.
PS. I have now most books on Python; yet I still feel that the indices =
are not comprehensive enough for novices.  I know that this is a general =
statement, but for this particular question , for example, I could not =
find anything in the back of the books. the books are: The quick Python =
Book, Python Standard Library, learn to Program using Python, and the =
big Core Python Programming. Considering the number of pages( a lot), =
they all seem to lack easy and comprehensive indices. The examples in =
the books, too, have very small type and assume some intuition about how =
Python works . This is not meant as a criticism, but constructive =
observations that should help authors who want to reach a wider general =
want to be audience. The folks are among the best, most knowlegeable and =
kind helpers I have found. So keep up the good work.


  tony

------=_NextPart_000_0005_01C17413.2FC49EA0
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#ffffff>
<DIV><FONT face=3DArial size=3D2>&nbsp;How does one poll the keyboard =
with Python to=20
see if a specific key( that I choose to define as the key to press) has =
been=20
pressed while a program is running?&nbsp; I guess the script would poll =
the=20
keyboard and run in the background of a main program.Of course, the =
script could=20
not have an indefinite loop so as to prevent the program from running. =
The=20
program will then quickly run the script and if the key has been pressed =
a=20
message will appear that such a key has been pressed. </FONT></DIV>
<DIV><FONT face=3DArial size=3D2>thanks.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>PS. I have now most books on Python; =
yet I still=20
feel that the indices are not comprehensive enough for novices.&nbsp; I =
know=20
that this is a general statement, but for this particular question , for =

example, I could not find anything in the back of the books. the books =
are: The=20
quick Python Book, Python Standard Library, learn to Program using =
Python, and=20
the big Core Python Programming. Considering the number of pages( a =
lot), they=20
all seem to lack easy and comprehensive indices. The examples in the =
books, too,=20
have very small type and assume some intuition about how Python =
works&nbsp;.=20
This is not meant as a criticism, but constructive observations that =
should help=20
authors who want to reach a wider general want to be audience. The folks =
are=20
among the best, most knowlegeable and kind helpers I have found. So keep =
up the=20
good work.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;&nbsp;tony</FONT></DIV></BODY></HTML>

------=_NextPart_000_0005_01C17413.2FC49EA0--

----------------------------------------------------
Sign Up for NetZero Platinum Today
Only $9.95 per month!
http://my.netzero.net/s/signup?r=platinum&refcd=PT97


From urnerk@qwest.net  Fri Nov 23 16:46:17 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Fri, 23 Nov 2001 08:46:17 -0800
Subject: [Tutor] Adding a bound method dynamically (newbie)
In-Reply-To: <NEBBJNMDEKBIBCMCNMBDIEKOCJAA.karthikg@aztec.soft.net>
References: <3BFA7ED9.14355.557930@localhost>
Message-ID: <4.2.0.58.20011123083047.019b1df0@pop3.norton.antivirus>

Hi karhik --


>t.func2(). I don't want to do t.func2(t) and thereby giving access to the
>instance.

You can poke your new bound method into the class definition,
not into the instance.  For example:

  >>> class Test2:

      def __init__(self):
         self.name="Python"
         self.age=100
      def func(self):
         print 'func'


  >>> t = Test2()
  >>> t.salary = 12000
  >>> def taxes(self):
         return self.salary/10.0  # note 'self'

  >>> Test2.taxes = taxes  # add method to class
  >>> dir(t)               # shows up in instance...
  ['__doc__', '__init__', '__module__', 'age', 'func', 'name',
  'salary', 'taxes']

  >>> t.taxes
  <bound method Test.taxes of <__main__.Test object at 0x0121F710>>

  >>> t.taxes              # ...as a new bound method...

  >>> t.taxes()            # and is usable with no args
  1200.0

If you don't want the bound method to persist after using it,
delete it:

  >>> del(Test2.taxes)

  >>> dir(t)
  ['__doc__', '__init__', '__module__', 'age', 'func', 'name',
  'salary']

Inserting a method into the class makes sense, because that's
the place in memory where methods get defined.  The instances
are just little dictionaries with pointers to all the
functionality in the class.

>Another question:
>
>when i did a dir(<class-name>) => it gave a list of the methods
>associated with the class irrespective of wether it is a bound
>method or not.
>
>when i did a dir(<instance of class>) => it gave a list of the
>instance attributes associated with the class Now i might have
>methods which are bound so s'd'nt dir(<instance>) indicate that
>those bound methods can also be invoked on the instance?
>Basically i w'd like to know as to why dir() behaves that way.

Note that if you poke your new methods into the class, not the
instance, then you'll have it listed in the dir(instance) as
well as the dir(class).

If you want hooks to more class infrastructure, there's a new
universal object in Python 2.2 that you're free to inherit from,
called object (lowercase):

  >>> class Test(object):

       def __init__(self):
           self.name="Python"
           self.age=100
       def func(self):
           print 'func'


  >>> t = Test()
  >>> dir(t)
  ['__class__', '__delattr__', '__dict__', '__getattribute__',
  '__hash__', '__init__', '__module__', '__new__', '__reduce__',
  '__repr__', '__setattr__', '__str__', '__weakref__', 'age', 'func',
  'name']

The basic class that doesn't inherit from object has few
members:

  >>> dir(Test2)
  ['__doc__', '__init__', '__module__', 'func']

And the instances of Test2 add just what you specify as unique
to the instance:

  >>> m = Test2()
  >>> m.salary = 10000
  >>> dir(m)
  ['__doc__', '__init__', '__module__', 'age', 'func', 'name',
  'salary']

If your dir() is behaving differently than the above, you might
be using one of the Pythons that got much less wordy with the
dir().  Tim Peters added back more functionality so that dir()
searches up the class inheritance tree for a cumulative list.
All of the above is in Python 2.2.

Kirby



From ak@silmarill.org  Fri Nov 23 17:08:32 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Fri, 23 Nov 2001 12:08:32 -0500
Subject: [Tutor] how does one poll the keyboard?
In-Reply-To: <000801c1743d$19c73fc0$1088f4d1@w9y5d5>
References: <000801c1743d$19c73fc0$1088f4d1@w9y5d5>
Message-ID: <20011123120832.B7549@sill.silmarill.org>

On Fri, Nov 23, 2001 at 11:37:09AM -0500, tonycervone wrote:
>  How does one poll the keyboard with Python to see if a specific key( that I choose to define as the key to press) has been pressed while a program is running?  I guess the script would poll the keyboard and run in the background of a main program.Of course, the script could not have an indefinite loop so as to prevent the program from running. The program will then quickly run the script and if the key has been pressed a message will appear that such a key has been pressed. 
> thanks.
> PS. I have now most books on Python; yet I still feel that the indices are not comprehensive enough for novices.  I know that this is a general statement, but for this particular question , for example, I could not find anything in the back of the books. the books are: The quick Python Book, Python Standard Library, learn to Program using Python, and the big Core Python Programming. Considering the number of pages( a lot), they all seem to lack easy and comprehensive indices. The examples in the books, too, have very small type and assume some intuition about how Python works . This is not meant as a criticism, but constructive observations that should help authors who want to reach a wider general want to be audience. The folks are among the best, most knowlegeable and kind helpers I have found. So keep up the good work.
> 
> 
>   tony

This is in the FAQ -
http://www.python.org/cgi-bin/faqw.py?req=edit&file=faq04.074.htp

Not that I blame you for not finding it - I had to ask on a newsgroup,
too.. I think faq needs some sort of keywords system - even though I
remembered this entry it took me a few tries to hit on the right search
words to find it.

To keep it from blocking, use threads or select module.

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


From alan.gauld@bt.com  Fri Nov 23 17:11:35 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 23 Nov 2001 17:11:35 -0000
Subject: [Tutor] how does one poll the keyboard?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C106@mbtlipnt02.btlabs.bt.co.uk>

>   How does one poll the keyboard with Python to see if a specific key 
>  ( that I choose to define as the key to press) has been pressed while  
>  a program is running?   
> ....
>  could not find anything in the back of the books. the books are:  
>  ....,Learn to Program using Python, ....

Look at the Event Driven Programming chapter. It covers 
how to do that in DOS and UNIX and within a Tkinter GUI....

 >  lack easy and comprehensive indices.  

The publisher does the indices in my experience...

>  The examples in the books, too, have very small type  

Hmm, I got criticised by several reviewers coz the type 
was too big! Certainly Core Python has pretty big type...

>  and assume some intuition about how Python works .  

If you have specific issues with my book please mail me 
offline coz I hope someday to do a second edition - so all 
feedback is useful input.

Alan G
Author of Learn to Program using Python :-)


From glingl@aon.at  Fri Nov 23 17:26:40 2001
From: glingl@aon.at (Gregor Lingl)
Date: Fri, 23 Nov 2001 18:26:40 +0100
Subject: [Tutor] how does one poll the keyboard?
References: <000801c1743d$19c73fc0$1088f4d1@w9y5d5>
Message-ID: <002401c17444$035cdc20$1664a8c0@mega>

This is a multi-part message in MIME format.

------=_NextPart_000_0021_01C1744C.64F07020
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Dear Tony!

Your problem seems to have a platform-specific
character.
Maybe the following points to a solution of your
problem (i. e. if you are using Windows). It uses
the msvcrt-module contained in the windows-distribution.

import msvcrt
while 1:
    a =3D  msvcrt.getch()
    if a =3D=3D chr(13): break
    print a

This is a slightliy modified snippet from Python 2.1 - Bible
(p. 669) which in my opinion is worth reading (or at least=20
using).

However, if you already are stuffed with Python literature:
there is also an example in Lundh's Python Standard Library
on msvcrt. Could be found for example in the index under the
keyword:

    kbhit function, using the msvcrt module=20
         and, 233

Hope that helps

Gregor
  ----- Original Message -----=20
  From: tonycervone=20
  To: Tutor@python.org=20
  Sent: Friday, November 23, 2001 5:37 PM
  Subject: [Tutor] how does one poll the keyboard?


   How does one poll the keyboard with Python to see if a specific key( =
that I choose to define as the key to press) has been pressed while a =
program is running?  I guess the script would poll the keyboard and run =
in the background of a main program.Of course, the script could not have =
an indefinite loop so as to prevent the program from running. The =
program will then quickly run the script and if the key has been pressed =
a message will appear that such a key has been pressed.=20
  thanks.
  PS. I have now most books on Python; yet I still feel that the indices =
are not comprehensive enough for novices.  I know that this is a general =
statement, but for this particular question , for example, I could not =
find anything in the back of the books. the books are: The quick Python =
Book, Python Standard Library, learn to Program using Python, and the =
big Core Python Programming. Considering the number of pages( a lot), =
they all seem to lack easy and comprehensive indices. The examples in =
the books, too, have very small type and assume some intuition about how =
Python works . This is not meant as a criticism, but constructive =
observations that should help authors who want to reach a wider general =
want to be audience. The folks are among the best, most knowlegeable and =
kind helpers I have found. So keep up the good work.


    tony

------=_NextPart_000_0021_01C1744C.64F07020
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#ffffff>
<DIV><FONT face=3D"Courier New" size=3D2>Dear Tony!</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Your problem seems to have a=20
platform-specific</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>character.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Maybe the following&nbsp;points =
to a=20
solution of your</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>problem (i. e. if you are using =
Windows).=20
It uses</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>the msvcrt-module contained in =
the=20
windows-distribution.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>import msvcrt</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>while 1:</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; a =3D =
</FONT>&nbsp;<FONT=20
face=3D"Courier New" size=3D2>msvcrt.getch()</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; if a =3D=3D =
chr(13):=20
break</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; print =
a</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>This is a slightliy modified =
snippet from=20
Python 2.1 - Bible</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>(p. 669) which in my opinion is =
worth=20
reading (or at least </FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>using).</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>However, if you already are =
stuffed with=20
Python literature:</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>there is also an example in =
Lundh's Python=20
Standard Library</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>on msvcrt. Could be found for =
example in=20
the index under the</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>keyword:</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&nbsp;&nbsp;&nbsp; kbhit =
function, using=20
the msvcrt module </FONT></DIV>
<DIV><FONT face=3D"Courier New"=20
size=3D2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; and, =
233</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Hope that helps</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Gregor</FONT></DIV>
<BLOCKQUOTE dir=3Dltr=20
style=3D"PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; =
BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>From:</B>=20
  <A title=3Dtonycervone@netzero.net=20
  href=3D"mailto:tonycervone@netzero.net">tonycervone</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>To:</B> <A title=3DTutor@python.org =

  href=3D"mailto:Tutor@python.org">Tutor@python.org</A> </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Sent:</B> Friday, November 23, 2001 =
5:37=20
  PM</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Subject:</B> [Tutor] how does one =
poll the=20
  keyboard?</DIV>
  <DIV><BR></DIV>
  <DIV><FONT face=3DArial size=3D2>&nbsp;How does one poll the keyboard =
with Python=20
  to see if a specific key( that I choose to define as the key to press) =
has=20
  been pressed while a program is running?&nbsp; I guess the script =
would poll=20
  the keyboard and run in the background of a main program.Of course, =
the script=20
  could not have an indefinite loop so as to prevent the program from =
running.=20
  The program will then quickly run the script and if the key has been =
pressed a=20
  message will appear that such a key has been pressed. </FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>thanks.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>PS. I have now most books on Python; =
yet I still=20
  feel that the indices are not comprehensive enough for novices.&nbsp; =
I know=20
  that this is a general statement, but for this particular question , =
for=20
  example, I could not find anything in the back of the books. the books =
are:=20
  The quick Python Book, Python Standard Library, learn to Program using =
Python,=20
  and the big Core Python Programming. Considering the number of pages( =
a lot),=20
  they all seem to lack easy and comprehensive indices. The examples in =
the=20
  books, too, have very small type and assume some intuition about how =
Python=20
  works&nbsp;. This is not meant as a criticism, but constructive =
observations=20
  that should help authors who want to reach a wider general want to be=20
  audience. The folks are among the best, most knowlegeable and kind =
helpers I=20
  have found. So keep up the good work.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial=20
size=3D2>&nbsp;&nbsp;tony</FONT></DIV></BLOCKQUOTE></BODY></HTML>

------=_NextPart_000_0021_01C1744C.64F07020--



From glingl@aon.at  Fri Nov 23 20:47:51 2001
From: glingl@aon.at (Gregor Lingl)
Date: Fri, 23 Nov 2001 21:47:51 +0100
Subject: [Tutor] Mistery - Help!
Message-ID: <001501c17460$1e90e7e0$1664a8c0@mega>

This is a multi-part message in MIME format.

------=_NextPart_000_0012_01C17468.802C1D00
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Dear Pythonistas!

Problem-Description (questions ca 35 lines below):

I have a well working Active-Python 2.1 installation in C:\Python21
This includes the installation of Tkinter and IDLE.
Starting IDLE loads the Python2.1.1-Interpreter into the shell.

Now I additionally installed Python2.2b2 from python.org. into=20
C:\Betas\Python22
This works well including (its own copy of) IDLE

BUT NOW the Python2.1 - IDLE (C:\Python21\Tools\idle\idle.pyw)
shows the following strange behaviour:

1. It starts up with the wrong interpreter:

Python 2.2b2 (#26, Nov 16 2001, 11:44:11) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
IDLE 0.8 -- press F1 for help
>>>=20

2. It uses a mixed sys.path:

>>> import sys
>>> sys.path
['C:\\Python21\\Tools\\idle', 'C:\\Python21\\Tools\\idle', =
'C:\\Betas\\Python22\\DLLs', 'C:\\Betas\\Python22\\lib', =
'C:\\Betas\\Python22\\lib\\lib-tk', 'C:\\Betas\\Python22', =
'C:\\Betas\\Python22\\lib\\site-packages']

Moreover several things don't work properly anymore, especially one
cannot close IDLE via the File-menu. Instead the following error-message =
occurs:

>>> Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Betas\Python22\lib\lib-tk\Tkinter.py", line 1292, in __call__
    return apply(self.func, args)
  File "C:\Python21\Tools\idle\PyShell.py", line 421, in close
    return PyShellEditorWindow.close(self)
TypeError: unbound method close() must be called with =
PyShellEditorWindow instance as first argument (got PyShell instance =
instead)

>>>

So here my QUESTIONS:

Where does IDLE get the information from concerning the Interpreter to =
use and also
the information converning the path?
NOTE 1: My Path (DOS-Shell) contains only C:\Python21 and NOT =
C:\Betas\Python22
NOTE 2: After deinstalling Python2.2b2 IDLE works as before (with =
Python2.1.1)

What changes are performed on my system through installing Python2.2b2?
=20
Are there configuration files, which can be edited to repair this =
situation?
If you don't know the answer, where should I look for it?

Gregor


------=_NextPart_000_0012_01C17468.802C1D00
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#ffffff>
<DIV><FONT face=3D"Courier New" size=3D2>Dear Pythonistas!</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Problem-Description (questions =
ca 35 lines=20
below):</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>I have a well working =
Active-Python 2.1=20
installation in C:\Python21</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>This includes the installation =
of Tkinter=20
and IDLE.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Starting IDLE loads the=20
Python2.1.1-Interpreter into the shell.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Now I additionally installed =
Python2.2b2=20
from python.org. into </FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>C:\Betas\Python22</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>This works well including (its =
own copy of)=20
IDLE</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>BUT NOW the Python2.1 - IDLE=20
(C:\Python21\Tools\idle\idle.pyw)</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>shows the following strange=20
behaviour:</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>1. It starts up with the wrong=20
interpreter:</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Python 2.2b2 (#26, Nov 16 2001, =
11:44:11)=20
[MSC 32 bit (Intel)] on win32<BR>Type "copyright", "credits" or =
"license" for=20
more information.<BR>IDLE 0.8 -- press F1 for help<BR>&gt;&gt;&gt; =
</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>2. It uses a mixed =
sys.path:</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&gt;&gt;&gt; import =
sys<BR>&gt;&gt;&gt;=20
sys.path<BR>['C:\\Python21\\Tools\\idle', 'C:\\Python21\\Tools\\idle',=20
'C:\\Betas\\Python22\\DLLs', 'C:\\Betas\\Python22\\lib',=20
'C:\\Betas\\Python22\\lib\\lib-tk', 'C:\\Betas\\Python22',=20
'C:\\Betas\\Python22\\lib\\site-packages']<BR></FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Moreover several things don't =
work properly=20
anymore, especially one</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>cannot close IDLE via the =
File-menu.=20
Instead the following error-message occurs:</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&gt;&gt;&gt; Exception in =
Tkinter=20
callback<BR>Traceback (most recent call last):<BR>&nbsp; File=20
"C:\Betas\Python22\lib\lib-tk\Tkinter.py", line 1292, in=20
__call__<BR>&nbsp;&nbsp;&nbsp; return apply(self.func, args)<BR>&nbsp; =
File=20
"C:\Python21\Tools\idle\PyShell.py", line 421, in =
close<BR>&nbsp;&nbsp;&nbsp;=20
return PyShellEditorWindow.close(self)<BR>TypeError: unbound method =
close() must=20
be called with PyShellEditorWindow instance as first argument (got =
PyShell=20
instance instead)</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>&gt;&gt;&gt;</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>So here my =
QUESTIONS:</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Where does IDLE get the =
information from=20
concerning the Interpreter to use and also</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>the information converning the=20
path?</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>NOTE 1: My Path (DOS-Shell) =
contains only=20
C:\Python21 and NOT C:\Betas\Python22</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>NOTE 2: After deinstalling =
Python2.2b2 IDLE=20
works as before (with Python2.1.1)</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>What changes are performed on =
my system=20
through installing Python2.2b2?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Are there configuration files, =
which can be=20
edited to repair this situation?</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>If you don't know the answer, =
where should=20
I look for it?</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Gregor</FONT></DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>&nbsp;</DIV></FONT></BODY></HTML>

------=_NextPart_000_0012_01C17468.802C1D00--



From glingl@aon.at  Fri Nov 23 21:05:36 2001
From: glingl@aon.at (Gregor Lingl)
Date: Fri, 23 Nov 2001 22:05:36 +0100
Subject: [Tutor] SOLUTION for Mystery FOUND!
Message-ID: <002201c17462$98fb0810$1664a8c0@mega>

This is a multi-part message in MIME format.

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

Dear Pythonistas!

This concerns the problem posted half an hour before:

The following made the repair:

Changed the connection between .pyw-files and the
open-ing program from C:\Betas\Python22\pythonw.exe
to C:\Python21\pythonw.exe

Now BOTH installations WORK WELL.

Sorry for the inconvenience!

Gregor

------=_NextPart_000_001F_01C1746A.FAA0C480
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#ffffff>
<DIV><FONT face=3D"Courier New" size=3D2>Dear Pythonistas!</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>This concerns the problem =
posted half an=20
hour before:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>The following made the =
repair:</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Changed the connection between =
.pyw-files=20
and the</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>open-ing program from=20
C:\Betas\Python22\pythonw.exe</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>to =
C:\Python21\pythonw.exe</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Now BOTH =
installations&nbsp;WORK=20
WELL.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Sorry for the =
inconvenience!</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>Gregor</FONT></DIV></BODY></HTML>

------=_NextPart_000_001F_01C1746A.FAA0C480--



From glingl@aon.at  Fri Nov 23 21:31:15 2001
From: glingl@aon.at (Gregor Lingl)
Date: Fri, 23 Nov 2001 22:31:15 +0100
Subject: [Tutor] Questions further thinking
Message-ID: <004601c17466$2e67b800$1664a8c0@mega>

This is a multi-part message in MIME format.

------=_NextPart_000_0043_01C1746E.8FED6950
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Dear Pythonistas!

Sometimes formulating a question initiates
some (sometimes unconscious) thoughts in ones=20
own brain - often with a short delay -=20
so one can find the answer *on oneselfs own*
(this formulation is hardly correct?)

Certainly some of you also experienced this.
Regards!

Gregor

------=_NextPart_000_0043_01C1746E.8FED6950
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#ffffff>
<DIV><FONT face=3D"Courier New" size=3D2>Dear Pythonistas!</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Sometimes formulating a =
question=20
initiates</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>some (sometimes unconscious) =
thoughts in=20
ones </FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>own brain - often with =
</FONT><FONT=20
face=3D"Courier New" size=3D2>a short delay - </FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>so one can find the answer *on =
oneselfs=20
own*</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>(this </FONT><FONT =
face=3D"Courier New"=20
size=3D2>formulation is hardly correct?)</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Certainly some of you also =
experienced=20
this.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Regards!</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>Gregor</FONT></DIV></BODY></HTML>

------=_NextPart_000_0043_01C1746E.8FED6950--



From lkvam@venix.com  Fri Nov 23 15:11:25 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Fri, 23 Nov 2001 10:11:25 -0500
Subject: [Tutor] time delay in graphics loop
References: <NEBBKOBFALPLCFBNMACBOEEECAAA.jane@jhandcock.freeserve.co.uk>
Message-ID: <3BFE671D.20205@venix.com>

This is a multi-part message in MIME format.
--------------040005060607060308080902
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit

Sorry for the delay.  I have not been using Tkinter, and my Python 
configuration for Tkinter was not working.  It took some time to get 
that fixed, and then the Thanksgiving Day Holiday intervened.

When I put time time.sleep(1) in the "y loop", the program draws the 
circles after about 13 seconds by my watch.  This is close to what we 
would expect: (12 * 1) second delay.

Moving the 1 second sleep into the "x loop" should give us (12 * 16 * 1) 
seconds of delay = 192 seconds.  When I run it here, I get 194 seconds 
by my watch.

With no sleep, the screen comes up very quickly on my system, within a 
second.

I am running Win NT 4.  My desktop experience is primarily Windows and 
Linux.  I would expect similar results on Linux.  I've enclosed my copy 
of the script.  If your results are radically different, I would expect 
some kind of problem with your computer setup.

Jane Handcock wrote:

> Lloyd,
> 
> Thank you for your reply, but surely if I put time.sleep(1) in the outer
> loop it should work quite quickly??
> ie
> ....
> for y in range(12):
> 	time.sleep(1)
>       for x in range(16):
>           circle(x*40+20,y*40+20,20)
> ....
> 
> Jane
> 
> -----Original Message-----
> From: Lloyd Kvam [mailto:lkvam@venix.com]
> Sent: 19 November 2001 19:54
> To: Jane Handcock
> Cc: tutor@python.org
> Subject: Re: [Tutor] time delay in graphics loop
> 
> 
> When you put the sleep inside the y loop, you sleep for 5 seconds
> everytime through the loop, = 60 seconds plus the other processing time.
> 
> Within x it is sleeping 12 * 16 * 5 which is a lot of seconds.
> presumably, it is not hung, just much slower than your patience level.
> 
> Jane Handcock wrote:
> 
> 
>>Hi
>>
>>I have just started to use Python and am working through the LiveWires
>>Python Course.
>>Can anyone explain why the time delay in the code below works fine (before
>>the graphics window is filled with blue circles), but the program hangs if
>>
> I
> 
>>put the line time.sleep(1) inside the y or x loops?
>>
>>
>>from livewires import *
>>import time
>>begin_graphics()
>>set_colour(Colour.blue)
>>time.sleep(5)
>>for y in range(12):
>>    for x in range(16):
>>        circle(x*40+20,y*40+20,20)
>>end_graphics
>>
>>
>>_______________________________________________
>>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
> 
> 
> 


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

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

--------------040005060607060308080902
Content-Type: text/plain;
 name="live_circle.py"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="live_circle.py"

from livewires import *
import time
begin_graphics()
set_colour(Colour.blue)
for y in range(12):
    for x in range(16):
        time.sleep(1)
        circle(x*40+20,y*40+20,20)
end_graphics

--------------040005060607060308080902--



From rick@niof.net  Fri Nov 23 15:50:17 2001
From: rick@niof.net (Rick Pasotto)
Date: Fri, 23 Nov 2001 10:50:17 -0500
Subject: [Tutor] modifying Tkinter OptionMenus
Message-ID: <20011123105016.A8375@tc.niof.net>

How do I change what options an OptionMenu displays? How do I specify
those options from a list? How do I know when the user has made a
selection (there doesn't seem to be a command option)?

The documentation that I can find doesn't even mention OptionMenus and
all the references seem to indicate that the options must be hard coded.
The function that creates an OptionMenu uses positional arguments
instead of keyword arguments.

-- 
If you start with the already absurd assumption that the
government is the morally active force and that the nation is
passive, are you not putting morals, doctrines, opinions, wealth,
everything that makes up the life of the individual at the mercy
of the men who one after another come to power?
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net


From dsh8290@rit.edu  Fri Nov 23 16:41:25 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 23 Nov 2001 11:41:25 -0500
Subject: [Tutor] command line arguements
In-Reply-To: <3BFDF20C.4E2E56F0@my995internet.com>; from deliberatus@my995internet.com on Fri, Nov 23, 2001 at 01:51:56AM -0500
References: <3BFDF20C.4E2E56F0@my995internet.com>
Message-ID: <20011123114125.A23637@harmony.cs.rit.edu>

On Fri, Nov 23, 2001 at 01:51:56AM -0500, Kirk Bailey wrote:
| OK, here ya go. Slightly deeper sorcery time.
...
| how does one tell a python program to pay attention to command line
| data? I can do this in a shell script, and a few other languages, but do
| not yet comprehend it in python.

$ cat args.py

import sys
print sys.argv

$ python args.py
['args.py']

$ python args.py a b c
['args.py', 'a', 'b', 'c']

$ python args.py abc def g
['args.py', 'abc', 'def', 'g']

$ 


Also check out the getopt module for parsing options (eg -o or
--option or --option=value or --option value).

-D



From dsh8290@rit.edu  Fri Nov 23 17:00:19 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 23 Nov 2001 12:00:19 -0500
Subject: [Tutor] how does one poll the keyboard?
In-Reply-To: <000801c1743d$19c73fc0$1088f4d1@w9y5d5>; from tonycervone@netzero.net on Fri, Nov 23, 2001 at 11:37:09AM -0500
References: <000801c1743d$19c73fc0$1088f4d1@w9y5d5>
Message-ID: <20011123120019.B23637@harmony.cs.rit.edu>

On Fri, Nov 23, 2001 at 11:37:09AM -0500, tonycervone wrote:
| How does one poll the keyboard with Python to see if a specific key(
| that I choose to define as the key to press) has been pressed while a
| program is running?  I guess the script would poll the keyboard and
| run in the background of a main program.Of course, the script could
| not have an indefinite loop so as to prevent the program from running.
| The program will then quickly run the script and if the key has been
| pressed a message will appear that such a key has been pressed.

Is this the sort of thing you are looking for?

(untested, but should give the idea)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

import sys
import threading

# this is to signal when the key_pressed flag has useful data,
# it will be "set" to indicate that the key_pressed flag has been set
# accordingly
data_ready = threading.Event()

class KeyboardPoller( threading.Thread ) :
    def run( self ) :
        global key_pressed
        ch = sys.stdin.read( 1 ) 
        if ch == 'K' : # the key you are interested in
            key_pressed = 1
        else :
            key_pressed = 0
        data_ready.set()

def main() :
    poller = KeyboardPoller()
    poller.start()

    # check the flag in a manner that is not blocking
    while not data_ready.isSet() :
        print "doing something (main loop)"

    if key_pressed :
        print "You pressed the magic key!"
    print "all done now"

if __name__ == "__main__" :
    main()

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



What this does is create a thread that reads in a single character of
input (it could read more if you want it to).  When that character is
read (the input blocks until data is ready) it is compared against
some constant and the 'key_pressed' flag is set to true if it matches.
Then the threading.Event instance's flag is set to true to indicate
that it is safe for the main thread to read the value of the
key_pressed variable.  If the main thread tries to read the value
prior to that, the semantics are undefined (it might not exist, it
might exist but have only part of its value, etc).


It is likely simpler for your script to simply request input at the
right time and just wait for the input to exist.  You are aware that
input is buffered, right?  You can type stuff into the console at any
time and the program will read it in, in order, when it wants to.

HTH,
-D



From james2dope@yahoo.com  Fri Nov 23 22:58:37 2001
From: james2dope@yahoo.com (james middendorff)
Date: Fri, 23 Nov 2001 14:58:37 -0800 (PST)
Subject: [Tutor] question?
In-Reply-To: <E167DJa-00050r-00@mail.python.org>
Message-ID: <20011123225837.47417.qmail@web13906.mail.yahoo.com>

--0-579576916-1006556317=:41616
Content-Type: text/plain; charset=us-ascii


hello,

I know this may sound weird but I was wondering if there was some sort of online class that would give you assignments for learning python to help me learn because I have read "Learn to program with python" and its hard for me to think of applications to make, so if there was some sort of structured class where someone said or e-mailed me or something and said please work on this I think that would help me learn to program alot better.

Thanks 

James


"I would kill everyone in this room
    for a drop of sweet beer."
     ----Homer Simpson----


---------------------------------
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
--0-579576916-1006556317=:41616
Content-Type: text/html; charset=us-ascii

<P>hello,</P>
<P>I know this may sound weird but I was wondering if there was some sort of online class that would give you assignments for learning python to help me learn because I have read "Learn to program with python" and its hard for me to think of applications to make, so if there was some sort of structured class where someone said or e-mailed me or something and said please work on this I think that would help me learn to program alot better.</P>
<P>Thanks </P>
<P>James</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>
<a href="http://geocities.yahoo.com/ps/info1">Yahoo! GeoCities</a> - quick and easy web site hosting, just $8.95/month.
--0-579576916-1006556317=:41616--


From jeff@ccvcorp.com  Fri Nov 23 23:05:17 2001
From: jeff@ccvcorp.com (Jeff Shannon)
Date: Fri, 23 Nov 2001 15:05:17 -0800
Subject: [Tutor] how does one poll the keyboard?
References: <E167P3D-0000RH-00@mail.python.org>
Message-ID: <3BFED62D.96AF213F@ccvcorp.com>

> On Fri, 23 Nov 2001 12:08:32 -0500,
> Andrei Kulakov <sill@optonline.net> wrote:
>
> On Fri, Nov 23, 2001 at 11:37:09AM -0500, tonycervone wrote:
> >  How does one poll the keyboard with Python to see if a specific key( that I choose to define as the key to press) has been pressed while a program is running?  I guess the script would poll the keyboard and run in the background of a main program.Of course, the script could not have an indefinite loop so as to prevent the program from running. The program will then quickly run the script and if the key has been pressed a message will appear that such a key has been pressed.
> >   tony
>
> This is in the FAQ -
> http://www.python.org/cgi-bin/faqw.py?req=edit&file=faq04.074.htp
>
> Not that I blame you for not finding it - I had to ask on a newsgroup,
> too.. I think faq needs some sort of keywords system - even though I
> remembered this entry it took me a few tries to hit on the right search
> words to find it.

Actually, it *has* a keywords system, at least the online version...

http://www.python.org/cgi-bin/faqw.py

Searching for "keyboard polling" with the "Keywords (any)" option selected, selected, pulled up two FAQ items, one of which was pertinent (i.e., use the msvcrt module for kbhit() and getch() functions).

Also, the ActiveState distribution comes with the help as a .chm file, which is fully indexed and searchable by keywords.  This may or may not be available separately, I'm not sure... but it is *very* useful!  :)

Jeff Shannon
Technician/Programmer
Credit International




From ak@silmarill.org  Fri Nov 23 23:03:02 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Fri, 23 Nov 2001 18:03:02 -0500
Subject: [Tutor] question?
In-Reply-To: <20011123225837.47417.qmail@web13906.mail.yahoo.com>
References: <E167DJa-00050r-00@mail.python.org>
 <20011123225837.47417.qmail@web13906.mail.yahoo.com>
Message-ID: <20011123180302.A9394@sill.silmarill.org>

On Fri, Nov 23, 2001 at 02:58:37PM -0800, james middendorff wrote:
> 
> hello,
> 
> I know this may sound weird but I was wondering if there was some sort of online class that would give you assignments for learning python to help me learn because I have read "Learn to program with python" and its hard for me to think of applications to make, so if there was some sort of structured class where someone said or e-mailed me or something and said please work on this I think that would help me learn to program alot better.
> 
> Thanks 
> 
> James

Sure - I can do that.. Work on pygame. Make a game sort of like fantasy
general, or civilization, or heroes of might and magic. Links to
tutorials and docs are at www.pygame.org.

 - Andrei

> 
> 
> "I would kill everyone in this room
>     for a drop of sweet beer."
>      ----Homer Simpson----
> 
> 
> ---------------------------------
> Do You Yahoo!?
> Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.

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


From dyoo@hkn.eecs.berkeley.edu  Fri Nov 23 23:04:13 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 23 Nov 2001 15:04:13 -0800 (PST)
Subject: [Tutor] Questions further thinking
In-Reply-To: <004601c17466$2e67b800$1664a8c0@mega>
Message-ID: <Pine.LNX.4.21.0111231450490.23530-100000@hkn.eecs.berkeley.edu>

On Fri, 23 Nov 2001, Gregor Lingl wrote:

> Dear Pythonistas!
> 
> Sometimes formulating a question initiates some (sometimes
> unconscious) thoughts in ones own brain - often with a short delay -
> so one can find the answer *on oneselfs own* (this formulation is
> hardly correct?)
> 
> Certainly some of you also experienced this. Regards!


Yes.  *grin*


Have you ever seen the book "How To Solve It --- A New Aspect of
Mathematical Method", by George Polya?  It talks about techniques of
solving problems, and it's a great book to read.  Curiously enough, one of
the chapters talks about "Subconscious work".  Here's a quote:

"""One evening I wished to discuss with a friend a certain author but I
could not remember fairly well one of his stories.  I remembered also some
story about the author himself whic I wanted to tell; I rememberd, in
fact, everything except the name.  Repeatedly, I tried to recollect that
name but all in vain.  The next morning, as soon as I though of the
annoyance of the evening before, the name occurred to me without any
effort.

The reader, very likely, remembers some similar experience of his own.  
And, if he is a passionate problem solver, he has probably had some
similar experience with problems.  It often happens that you have no
success at all with a problem; you work very hard yet without finding
anything.  But when you come back to the problem after a night's rest, or
a few days' interruption, a bright idea appears and you solve the problem
easily."""


Ideas need time to bubble and brew, it seems.



From ak@silmarill.org  Fri Nov 23 23:08:19 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Fri, 23 Nov 2001 18:08:19 -0500
Subject: [Tutor] how does one poll the keyboard?
In-Reply-To: <3BFED62D.96AF213F@ccvcorp.com>
References: <E167P3D-0000RH-00@mail.python.org> <3BFED62D.96AF213F@ccvcorp.com>
Message-ID: <20011123180819.A9456@sill.silmarill.org>

On Fri, Nov 23, 2001 at 03:05:17PM -0800, Jeff Shannon wrote:
> > On Fri, 23 Nov 2001 12:08:32 -0500,
> > Andrei Kulakov <sill@optonline.net> wrote:
> >
> > On Fri, Nov 23, 2001 at 11:37:09AM -0500, tonycervone wrote:
> > >  How does one poll the keyboard with Python to see if a specific key( that I choose to define as the key to press) has been pressed while a program is running?  I guess the script would poll the keyboard and run in the background of a main program.Of course, the script could not have an indefinite loop so as to prevent the program from running. The program will then quickly run the script and if the key has been pressed a message will appear that such a key has been pressed.
> > >   tony
> >
> > This is in the FAQ -
> > http://www.python.org/cgi-bin/faqw.py?req=edit&file=faq04.074.htp
> >
> > Not that I blame you for not finding it - I had to ask on a newsgroup,
> > too.. I think faq needs some sort of keywords system - even though I
> > remembered this entry it took me a few tries to hit on the right search
> > words to find it.
> 
> Actually, it *has* a keywords system, at least the online version...
> 
> http://www.python.org/cgi-bin/faqw.py
> 
> Searching for "keyboard polling" with the "Keywords (any)" option selected, selected, pulled up two FAQ items, one of which was pertinent (i.e., use the msvcrt module for kbhit() and getch() functions).

Doh.. I missed that option, sorry. It really ought to be on by default..

> 
> Also, the ActiveState distribution comes with the help as a .chm file, which is fully indexed and searchable by keywords.  This may or may not be available separately, I'm not sure... but it is *very* useful!  :)

chm is windows help file isn't it?


> 
> Jeff Shannon
> Technician/Programmer
> Credit International
> 
> 
> 
> _______________________________________________
> 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 dyoo@hkn.eecs.berkeley.edu  Fri Nov 23 23:09:45 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 23 Nov 2001 15:09:45 -0800 (PST)
Subject: [Tutor] question?
In-Reply-To: <20011123225837.47417.qmail@web13906.mail.yahoo.com>
Message-ID: <Pine.LNX.4.21.0111231504550.23530-100000@hkn.eecs.berkeley.edu>

On Fri, 23 Nov 2001, james middendorff wrote:

> I know this may sound weird but I was wondering if there was some sort
> of online class that would give you assignments for learning python to
> help me learn because I have read "Learn to program with python" and
> its hard for me to think of applications to make, so if there was some
> sort of structured class where someone said or e-mailed me or
> something and said please work on this I think that would help me
> learn to program alot better.

Ah!  You might want to look at the problems in Useless Python:

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

Rob Andrews has been accumulating problems that people can work on to
apply their Python skills:

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

Pick one and run with it.  *grin* Or look at some of the scripts that
people here have been writing, and your muse may tap you on your shoulder.



From wilson@visi.com  Fri Nov 23 23:15:48 2001
From: wilson@visi.com (Timothy Wilson)
Date: Fri, 23 Nov 2001 17:15:48 -0600 (CST)
Subject: [Tutor] question?
In-Reply-To: <20011123225837.47417.qmail@web13906.mail.yahoo.com>
Message-ID: <Pine.GSO.4.21.0111231714570.28749-100000@isis.visi.com>

On Fri, 23 Nov 2001, james middendorff wrote:

> I know this may sound weird but I was wondering if there was some sort of online class that would give you assignments for learning python to help me learn because I have read "Learn to program with python" and its hard for me to think of applications to make, so if there was some sort of structured class where someone said or e-mailed me or something and said please work on this I think that would help me learn to program alot better.

Feel free to try the assignments I've got posted at my class Web site at
http://www.isd197.org/sibley/cs/icp/

-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 myuen@ucalgary.ca  Sat Nov 24 07:51:43 2001
From: myuen@ucalgary.ca (Mike Yuen)
Date: Sat, 24 Nov 2001 00:51:43 -0700 (MST)
Subject: [Tutor] Parsing C++ into Python
Message-ID: <Pine.A41.4.10.10111240049130.72006-100000@acs2.acs.ucalgary.ca>

I want to write a program where I want to borrow most of the tricks that
Python offers but I want to write the core feature of my program with C++.
How do I do this?  Can someone point me to some sample code that shows me
how to mix the two languages.  I've looked on the 'Net unsucessfully.

Thanks,
M




From ak@silmarill.org  Sat Nov 24 07:57:59 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Sat, 24 Nov 2001 02:57:59 -0500
Subject: [Tutor] Parsing C++ into Python
In-Reply-To: <Pine.A41.4.10.10111240049130.72006-100000@acs2.acs.ucalgary.ca>
References: <Pine.A41.4.10.10111240049130.72006-100000@acs2.acs.ucalgary.ca>
Message-ID: <20011124025759.A10922@sill.silmarill.org>

On Sat, Nov 24, 2001 at 12:51:43AM -0700, Mike Yuen wrote:
> I want to write a program where I want to borrow most of the tricks that
> Python offers but I want to write the core feature of my program with C++.
> How do I do this?  Can someone point me to some sample code that shows me
> how to mix the two languages.  I've looked on the 'Net unsucessfully.
> 
> Thanks,
> M

Mark Lutz' ORA book _Programming Python_ has a chapter on C integration,
I think most of the concepts can be used for C++. It's a good book, too,
if a bit terse..

> 
> 
> 
> _______________________________________________
> 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 Nov 24 19:30:19 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Sat, 24 Nov 2001 11:30:19 -0800
Subject: [Tutor] question?
In-Reply-To: <20011123225837.47417.qmail@web13906.mail.yahoo.com>
References: <E167DJa-00050r-00@mail.python.org>
Message-ID: <4.2.0.58.20011124112031.00c1b670@pop3.norton.antivirus>

Hi James --

I don't know if you like math or not, but my approach to programming
is to use math as grist for the mill.  Pick up just about any math
book, and you'll find it brimming with programming challenges.  That
most of these books don't present their topics is terms of programming
is all the more useful, as coming up with the Python interpretations
is left to you, the reader -- not too many hints from the authors.

To take a simple example:  suppose your goal was to print Pascal's
Triangle to any depth.  It looks like this:

                          1
                        1   1
                      1   2   1
                    1   3   3   1
                  1   4   6   4   1
                 1  5   10  10  5   1

Every row is the sum of terms to the above left and right.
Acceptable output would be a list of lists, e.g.:

[[1],[1,1],[1,2,1],[1,3,3,1],[1,4,6,4,1]...]

which you could then work on formatting for printing as a
separate problem.  The first problem is just to get the
numbers.

If you know something about Pascal's Triangle, you know there's
a way to get the entries with simply the row and column numbers
as inputs, e.g. you can write a function:

    >>> pascal([3,1])
    3

That's taking the top row as row 0, and the first column as
column 0.

But even if you don't have this short cut handy, it's good
exercise to derive each row from the row above -- good
practice with lists and indexes etc.

That's just one of a gazillion examples.  It's nothing new to
use math to teach programming.  The trick is to turn it around
and use programming to learn math at the same time.  The two
subjects naturally go together, and whichever side you get
stronger in, you can use as leverage to improve your
comprehension of the other -- a neck and neck race between
your programming skills and your math skills, in which you
become the inevitable winner.

For more along these lines, see my:
   http://www.inetarena.com/~pdx4d/ocn/cp4e.html

Lots of examples there, including the Pascal thing, plus some
stuff about fractals, quaternions, vectors, L-system turtle
graphics, polyhedra, phi, continued fractions... lotsa fun!,
and all using Python as the primary language.

Kirby

At 02:58 PM 11/23/2001 -0800, james middendorff wrote:

>hello,
>
>I know this may sound weird but I was wondering if there was some sort of 
>online class that would give you assignments for learning python to help 
>me learn because I have read "Learn to program with python" and its hard 
>for me to think of applications to make, so if there was some sort of 
>structured class where someone said or e-mailed me or something and said 
>please work on this I think that would help me learn to program alot better.
>
>Thanks
>
>James



From tor@agent.creson.com  Sat Nov 24 10:41:55 2001
From: tor@agent.creson.com (Tor Stormwall)
Date: Sat, 24 Nov 2001 11:41:55 +0100 (CET)
Subject: [Tutor] if file == exists, then dont copy it
Message-ID: <20011124113022.E11791-100000@bossen.myhome.my>

Hi!

I'm trying to write a section in a piece of code that
if a file exists with a given name it will copy the file
to that name. For example, file1 to my_new_file

I've got the name config_file_named defined as TEST3, like this:
config_file_name = "TEST3"

I've imported exists from os.path.
The code should  act something like:
if file: then do not copy, else copy the file.


The code looks like this:
    from os.path import exists
    verbose=1 # is it here?
    force=0   # are whe gonna force? noo
    if exists(config_file_name) and not force:
        if verbose: print file, ' is already created'
        else:
            print "copying file"
            os.system('cp MYFILE ' + config_file_name)



The program seem to skip everything after force=0 and
then exit.



Best Regards,
Tor Stormwall

* - - - - - - - - - - - - - - - - - - - - - - - - - - - - *
|   M A Y   T H E   S O U R C E   B E   W I T H   Y O U   |
|						          |
| Tor Stormwall			mailto:tor@stormwall.org  |
| http://www.creson.com/~tor  				  |
| 						   	  |
| http://www.sslug.dk		http://www.stormwall.org  |
| http://www.FreeBSD.org	http://www.muf.se         |
|							  |
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - *



From Pjotr <pjotr@poland.com>  Sat Nov 24 20:14:20 2001
From: Pjotr <pjotr@poland.com> (Pjotr)
Date: Sat, 24 Nov 2001 21:14:20 +0100
Subject: [Tutor] Problem with "elif"
Message-ID: <1083244389.20011124211420@poland.com>

Hello!
I started learning Python, using Python 2.1.1 and Ivan Van Laningham's
book "Teach yoursefl Python...".  I have a problem with instruction
"elif":
>>> y = 1900
>>> leap = "no"
>>> if y % 400 == 0 :
        leap = "yes"
    elif y % 100 == 0 :
            
IndentationError: unindent does not match any outer indentation level (line 3)
>>> 

What's up? This example is from Laningham's book and everything should
be OK. Please help me!
-- 
Best regards
Pjotr
________________________
&&& pjotr@poland.com &&&



---
"W pustyni i w puszczy" juz  na kasetach VIDEO. Podaruj swojemu dziecku przygode !
http://www.w-pustyni-i-w-puszczy.pl


From alan.gauld@bt.com  Sat Nov 24 17:29:01 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sat, 24 Nov 2001 17:29:01 -0000
Subject: [Tutor] question?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C109@mbtlipnt02.btlabs.bt.co.uk>

> I know this may sound weird but I was wondering if 
> there was some sort of online class that would give 
> you assignments for learning python 

Try the Useless Python page which has several challenges 
waiting top be done. Plus some excercises that have solutions 
to compare against.

> I have read "Learn to program with python" 

OK, Did you try the excercise in the book?
There are around 50 excercises/projects within 
the text of the book, ranging from simple 
arithmetic and file handling to writing games 
and databases.

In particular both Case Studies conclude with 
suggestions for projects building on the Case 
study baseline.

> structured class where someone said or e-mailed me 
> or something and said please work on this 

Useless Python is probably closest with its challenges.

Alan G.


From alan.gauld@bt.com  Sat Nov 24 17:33:39 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sat, 24 Nov 2001 17:33:39 -0000
Subject: [Tutor] Parsing C++ into Python
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C10A@mbtlipnt02.btlabs.bt.co.uk>

> Python offers but I want to write the core feature of my 
> program with C++. How do I do this?  

Depending on your experience with C++ the answer is yes.

Assuming you are comfortable with C++ then virtually any 
of the more advanced Python books(*) include examples of both 
embedding Python into C/C++ programs and writing extensions 
to Python in C. There are also web sites to say how to 
embed Python in Delphi programs too.

In fact I'm sure there is a specialist area of the Python 
web site dedicated to this.

Alan G

(*)Programming Python by Lutz springs immediately to 
my mind as one example...


From urnerk@qwest.net  Sat Nov 24 22:06:03 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Sat, 24 Nov 2001 14:06:03 -0800
Subject: [Tutor] if file == exists, then dont copy it
In-Reply-To: <20011124113022.E11791-100000@bossen.myhome.my>
Message-ID: <4.2.0.58.20011124140256.00c1ac90@pop3.norton.antivirus>

>
>
>The program seem to skip everything after force=0 and
>then exit.

Seems like the exists() thing is always returning
false.

You should say what platform and give an example of a
file parameter you're passing that you know exists.

If you're in Windows and using a backslash, you need
to escape it with another backslash, or use r for
'raw'.  E.g.

   >>> exists(r"c:\My Documents\fft.pdf")  # OK
   1
   >>> exists("c:\\My Documents\\fft.pdf")  # OK
   1
   >>> exists("c:\My Documents\fft.pdf")  # oops
   0

This could be the kind of problem you're having.  If
it's UNIX, yet other issues might be to blame.

Kirby



From ak@silmarill.org  Sat Nov 24 23:06:17 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Sat, 24 Nov 2001 18:06:17 -0500
Subject: [Tutor] Problem with "elif"
In-Reply-To: <1083244389.20011124211420@poland.com>
References: <1083244389.20011124211420@poland.com>
Message-ID: <20011124180617.A14001@sill.silmarill.org>

On Sat, Nov 24, 2001 at 09:14:20PM +0100, Pjotr wrote:
> Hello!
> I started learning Python, using Python 2.1.1 and Ivan Van Laningham's
> book "Teach yoursefl Python...".  I have a problem with instruction
> "elif":
> >>> y = 1900
> >>> leap = "no"
> >>> if y % 400 == 0 :
>         leap = "yes"
>     elif y % 100 == 0 :
>             
> IndentationError: unindent does not match any outer indentation level (line 3)
> >>> 
> 
> What's up? This example is from Laningham's book and everything should
> be OK. Please help me!

Here's how it looks here:

>>> y = 1900
>>> leap = "no"
>>> if y % 400 == 0 :
...  leap = "yes"
... elif y % 100 == 0 :
...  leap = "no"
... 
>>> leap
'no'
>>> 

When you hit enter after the first ':', interpreter should print three
dots to indicate that you're entering a block.. or what's it called.
Anyway, I'm not quite sure what's wrong on your end but note that by
convention, you shouldn't leave a space before the ':'. It don't cause
an error but this is a matter of good style..

> -- 
> Best regards
> Pjotr
> ________________________
> &&& pjotr@poland.com &&&
> 
> 
> 
> ---
> "W pustyni i w puszczy" juz  na kasetach VIDEO. Podaruj swojemu dziecku przygode !
> http://www.w-pustyni-i-w-puszczy.pl
> 
> _______________________________________________
> 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 shalehperry@home.com  Sat Nov 24 21:22:00 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Sat, 24 Nov 2001 13:22:00 -0800 (PST)
Subject: [Tutor] if file == exists, then dont copy it
In-Reply-To: <20011124113022.E11791-100000@bossen.myhome.my>
Message-ID: <XFMail.20011124132200.shalehperry@home.com>

> 
> The code looks like this:
>     from os.path import exists
>     verbose=1 # is it here?
>     force=0   # are whe gonna force? noo
>     if exists(config_file_name) and not force:
>         if verbose: print file, ' is already created'
>         else:
>             print "copying file"
>             os.system('cp MYFILE ' + config_file_name)
> 
> 
> 
> The program seem to skip everything after force=0 and
> then exit.
> 

Not sure if this is your email client or your code, but the else should be
under the first if, not the second one.


From shalehperry@home.com  Sat Nov 24 21:24:42 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Sat, 24 Nov 2001 13:24:42 -0800 (PST)
Subject: [Tutor] Problem with "elif"
In-Reply-To: <1083244389.20011124211420@poland.com>
Message-ID: <XFMail.20011124132442.shalehperry@home.com>

On 24-Nov-2001 Pjotr wrote:
> Hello!
> I started learning Python, using Python 2.1.1 and Ivan Van Laningham's
> book "Teach yoursefl Python...".  I have a problem with instruction
> "elif":
>>>> y = 1900
>>>> leap = "no"
>>>> if y % 400 == 0 :
>         leap = "yes"
>     elif y % 100 == 0 :
>             
> IndentationError: unindent does not match any outer indentation level (line
> 3)
>>>> 
> 
> What's up? This example is from Laningham's book and everything should
> be OK. Please help me!


>>> y = 1900
>>> if y % 400 == 0:
...     leap = 'yes' 
... elif y % 100 == 0:
...     leap = 'yes'
... else:
...     leap = 'no'
... 
>>> leap
'yes'
>>> 

If your email is accurate, you have the elif one char over further than it
should be.  The i in if and the e in elif should be in the same column.


From dsh8290@rit.edu  Sat Nov 24 22:30:56 2001
From: dsh8290@rit.edu (dman)
Date: Sat, 24 Nov 2001 17:30:56 -0500
Subject: [Tutor] Problem with "elif"
In-Reply-To: <1083244389.20011124211420@poland.com>; from pjotr@poland.com on Sat, Nov 24, 2001 at 09:14:20PM +0100
References: <1083244389.20011124211420@poland.com>
Message-ID: <20011124173056.A26098@harmony.cs.rit.edu>

On Sat, Nov 24, 2001 at 09:14:20PM +0100, Pjotr wrote:
| Hello!
| I started learning Python, using Python 2.1.1 and Ivan Van Laningham's
| book "Teach yoursefl Python...".  I have a problem with instruction
| "elif":
| >>> y = 1900
| >>> leap = "no"
| >>> if y % 400 == 0 :
|         leap = "yes"
|     elif y % 100 == 0 :
|             
| IndentationError: unindent does not match any outer indentation level (line 3)
| >>> 
| 
| What's up? This example is from Laningham's book and everything should
| be OK. Please help me!

I notice that in your cut-n-paste above, there is no prompt in front
of the lines following the 'if'.  Here is an example that works, and
that doesn't work, for me (python 2.1.1 also) :

>>> if 1 :
...     print "hello"
... elif 2 :
...     print "world"
... 
hello
>>> 


>>> if 1 :
...     print "hello"
...  elif 2 :
  File "<stdin>", line 3
    elif 2 :
           ^
IndentationError: unindent does not match any outer indentation level
>>> 



Notice that in the second example the 'e' in "elif" is not in the same
column as the 'i' in "if".  This is what the error message is trying
to say.

HTH,
-D



From dyoo@hkn.eecs.berkeley.edu  Sun Nov 25 05:13:24 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sat, 24 Nov 2001 21:13:24 -0800 (PST)
Subject: [Tutor] Announcement: recent change in mailing list config
Message-ID: <Pine.LNX.4.21.0111242101050.6862-100000@hkn.eecs.berkeley.edu>

Hi everyone,

I've recently adjusted the configuration of the Mailman software that
maintains the Tutor mailing list: now only subscribers can post to Tutor.

Previously, the software would stop suspicious "spam" looking messages,
but it would still allow people from outside to post with little
restriction.  This was great because it was casual for people from outside
to post to Tutor.  Unfortunately, it's hasn't been so great because
spammers have been hitting us.

I should have announced this change earlier on the Tutor list, and I must
apologize for making the change so abruptly.  The configuration change
does make the list more closed, and does make certain things more annoying
for people.  On the other hand, we shouldn't see spam any more.

Again, my apolgies for the inconvenience.



From mascher@crg.ha.nw.schule.de  Sun Nov 25 22:04:32 2001
From: mascher@crg.ha.nw.schule.de (Christian Mascher)
Date: Sun, 25 Nov 2001 23:04:32 +0100
Subject: [Tutor] Problem with "elif"
References: <E1682eT-0002Hp-00@mail.python.org>
Message-ID: <3C016AF0.218680F0@gmx.de>

Pjotr <pjotr@poland.com> wrote:
> I started learning Python, using Python 2.1.1 and Ivan Van Laningham's
> book "Teach yoursefl Python...".  I have a problem with instruction
> "elif":
> >>> y = 1900
> >>> leap = "no"
> >>> if y % 400 == 0 :
>         leap = "yes"
>     elif y % 100 == 0 :
> 
> IndentationError: unindent does not match any outer indentation level (line 3)
> >>>
> 
> What's up? This example is from Laningham's book and everything should
> be OK. Please help me!

This is a feature from IDLE which has bothered me as well already, but
easy to explain I hope:
The if-statement starts with no indentation. Because you type it in
IDLE,
you have the shell-prompt '>>> ' on the first line. Although these are
four characters, they don't count for the indentation. So you shouldn't
align the elif with the if that you see on the screen, but with an
imaginary if at no indentaion level. Because all following lines have no
prompt (in IDLE-shell) they seem to start 4 characters earlier. In a
script-window you don't get this problem and also not in the simple
shell (command-line) where a '... '-prompt is inserted in every line
following the line with if.

paste from IDLE

>>> if 1==1:
	print 'bla'
elif 1==1:
	print 'blub'
else:
	print 'aha'

	
bla
>>> 

paste from shell:
>>> if 1:
...     print 'bla'
... elif 1:
...     print 'blub'
...
bla
>>>



HTH
Christian



From alan.gauld@bt.com  Sun Nov 25 22:52:11 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Sun, 25 Nov 2001 22:52:11 -0000
Subject: [Tutor] Problem with "elif"
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk>

> >>> y = 1900
> >>> leap = "no"
> >>> if y % 400 == 0 :
>         leap = "yes"
>     elif y % 100 == 0 :
>             
> IndentationError: unindent does not match any outer 
> indentation level (line 3)

This looks like you are using IDLE - coz there are no ... prompts.

In that case  you should NOT have indented the elif - even tho it looks OK.

This is coz IDLE sees the initial 'if' as being at the beginning of the
line, so the elif must be too.

Personally I always feel this is a bug in the IDLE Shell, it should
line up visually, but sadly it doesn't. (At least in V0.6)

See my session below:
>>> y = 1900
>>> leap = 'no'
>>> if y % 400 == 0:
	leap = 'y'
elif y % 100 == 0:
	leap = 'n'

	
>>> leap
'n'
>>> y = 2000
>>> if y % 400 == 0:
	leap = 'y'
elif y % 100 == 0:
	leap = 'n'

	
>>> leap
'y'

Yes, I agree, this is a very confusing foible of IDLE.

Alan g.


From ak@silmarill.org  Sun Nov 25 23:04:13 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Sun, 25 Nov 2001 18:04:13 -0500
Subject: [Tutor] Problem with "elif"
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk>
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <20011125180413.A19978@sill.silmarill.org>

On Sun, Nov 25, 2001 at 10:52:11PM +0000, alan.gauld@bt.com wrote:
> > >>> y = 1900
> > >>> leap = "no"
> > >>> if y % 400 == 0 :
> >         leap = "yes"
> >     elif y % 100 == 0 :
> >             
> > IndentationError: unindent does not match any outer 
> > indentation level (line 3)
> 
> This looks like you are using IDLE - coz there are no ... prompts.

I never used it, but this sucks.. *Especially* cause it'd be really easy
to fix.

 - Andrei



From dsh8290@rit.edu  Mon Nov 26 03:20:28 2001
From: dsh8290@rit.edu (dman)
Date: Sun, 25 Nov 2001 22:20:28 -0500
Subject: [Tutor] Problem with "elif"
In-Reply-To: <20011125180413.A19978@sill.silmarill.org>; from sill@optonline.net on Sun, Nov 25, 2001 at 06:04:13PM -0500
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk> <20011125180413.A19978@sill.silmarill.org>
Message-ID: <20011125222027.A27092@harmony.cs.rit.edu>

On Sun, Nov 25, 2001 at 06:04:13PM -0500, Andrei Kulakov wrote:
| On Sun, Nov 25, 2001 at 10:52:11PM +0000, alan.gauld@bt.com wrote:
| > > >>> y = 1900
| > > >>> leap = "no"
| > > >>> if y % 400 == 0 :
| > >         leap = "yes"
| > >     elif y % 100 == 0 :
| > >             
| > > IndentationError: unindent does not match any outer 
| > > indentation level (line 3)
| > 
| > This looks like you are using IDLE - coz there are no ... prompts.
| 
| I never used it, but this sucks.. *Especially* cause it'd be really easy
| to fix.

Yeah!

Try running :

import sys
sys.ps2 = '... '


Then try entering that 'if' statement.  You can probably search
through the IDLE sources (I would use 'grep' but if you are on windows
without cygwin, good luck) to find "sys.ps2" and fix the prompt.

-D

-- 

Even youths grow tired and weary,
    and young men stumble and fall;
but those who hope in the Lord 
    will renew their strength.
They will soar on wings like eagles;
    they will run and not grow weary,
    they will walk and not be faint.

        Isaiah 40:31



From ak@silmarill.org  Mon Nov 26 03:27:33 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Sun, 25 Nov 2001 22:27:33 -0500
Subject: [Tutor] Problem with "elif"
In-Reply-To: <20011125222027.A27092@harmony.cs.rit.edu>
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk>
 <20011125180413.A19978@sill.silmarill.org>
 <20011125222027.A27092@harmony.cs.rit.edu>
Message-ID: <20011125222733.A20757@sill.silmarill.org>

On Sun, Nov 25, 2001 at 10:20:28PM -0500, dman wrote:
> On Sun, Nov 25, 2001 at 06:04:13PM -0500, Andrei Kulakov wrote:
> | On Sun, Nov 25, 2001 at 10:52:11PM +0000, alan.gauld@bt.com wrote:
> | > > >>> y = 1900
> | > > >>> leap = "no"
> | > > >>> if y % 400 == 0 :
> | > >         leap = "yes"
> | > >     elif y % 100 == 0 :
> | > >             
> | > > IndentationError: unindent does not match any outer 
> | > > indentation level (line 3)
> | > 
> | > This looks like you are using IDLE - coz there are no ... prompts.
> | 
> | I never used it, but this sucks.. *Especially* cause it'd be really easy
> | to fix.
> 
> Yeah!
> 
> Try running :
> 
> import sys
> sys.ps2 = '... '
> 
> 
> Then try entering that 'if' statement.  You can probably search
> through the IDLE sources (I would use 'grep' but if you are on windows
> without cygwin, good luck) to find "sys.ps2" and fix the prompt.
> 
> -D

Well, I don't use windows myself, so I was more like meaning that its
authors should fix it up, or something :P.

> 
> -- 
> 
> Even youths grow tired and weary,
>     and young men stumble and fall;
> but those who hope in the Lord 
>     will renew their strength.
> They will soar on wings like eagles;
>     they will run and not grow weary,
>     they will walk and not be faint.
> 
>         Isaiah 40:31
> 
> 
> _______________________________________________
> 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 dsh8290@rit.edu  Mon Nov 26 03:46:19 2001
From: dsh8290@rit.edu (dman)
Date: Sun, 25 Nov 2001 22:46:19 -0500
Subject: [Tutor] Problem with "elif"
In-Reply-To: <20011125222733.A20757@sill.silmarill.org>; from sill@optonline.net on Sun, Nov 25, 2001 at 10:27:33PM -0500
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk> <20011125180413.A19978@sill.silmarill.org> <20011125222027.A27092@harmony.cs.rit.edu> <20011125222733.A20757@sill.silmarill.org>
Message-ID: <20011125224619.A27150@harmony.cs.rit.edu>

On Sun, Nov 25, 2001 at 10:27:33PM -0500, Andrei Kulakov wrote:
| On Sun, Nov 25, 2001 at 10:20:28PM -0500, dman wrote:
| > On Sun, Nov 25, 2001 at 06:04:13PM -0500, Andrei Kulakov wrote:
| > | On Sun, Nov 25, 2001 at 10:52:11PM +0000, alan.gauld@bt.com wrote:
...
| > | > This looks like you are using IDLE - coz there are no ... prompts.
| > | 
| > | I never used it, but this sucks.. *Especially* cause it'd be really easy
| > | to fix.
...
| > You can probably search through the IDLE sources (I would use
| > 'grep' but if you are on windows without cygwin, good luck) to
| > find "sys.ps2" and fix the prompt.
| 
| Well, I don't use windows myself, 

Neither do I when I can help it :-).

| so I was more like meaning that its authors should fix it up, or
| something :P.

They should, but why wait for a new release?  This is what Open Source
is about :-).  You found a bug, you fix the bug (on your system), then
you hope the maintainers include the fix in the next release.

(For example, when I had to use windows I found out that mutt saved
attachments by opening the file in text mode.  Windows thus took great
pleasure in destroying the file (by adding CR characters).  I fixed it
in my copy so I could continute to use mutt, and then reported it to
the developers.  I think the current version shipping with cygwin (it
wasn't even shipped when I installed it) is fixed.)

-D

-- 

If your company is not involved in something called "ISO 9000" you probably
have no idea what it is.  If your company _is_ involved in ISO 9000 then you
definitely have no idea what it is.
                                (Scott Adams - The Dilbert principle)



From ak@silmarill.org  Mon Nov 26 04:50:37 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Sun, 25 Nov 2001 23:50:37 -0500
Subject: [Tutor] Problem with "elif"
In-Reply-To: <20011125224619.A27150@harmony.cs.rit.edu>
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk>
 <20011125180413.A19978@sill.silmarill.org>
 <20011125222027.A27092@harmony.cs.rit.edu>
 <20011125222733.A20757@sill.silmarill.org>
 <20011125224619.A27150@harmony.cs.rit.edu>
Message-ID: <20011125235037.A20889@sill.silmarill.org>

On Sun, Nov 25, 2001 at 10:46:19PM -0500, dman wrote:
> 
> They should, but why wait for a new release?  This is what Open Source
> is about :-).  You found a bug, you fix the bug (on your system), then
> you hope the maintainers include the fix in the next release.
> 
> (For example, when I had to use windows I found out that mutt saved
> attachments by opening the file in text mode.  Windows thus took great
> pleasure in destroying the file (by adding CR characters).  I fixed it
> in my copy so I could continute to use mutt, and then reported it to
> the developers.  I think the current version shipping with cygwin (it
> wasn't even shipped when I installed it) is fixed.)
> 
> -D

Hmm, I set sys.ps2 = "..." but it still don't show the dots.. 

>>> sys.ps2 = "..."
>>> if 1:
        do this
        
SyntaxError: invalid syntax
>>> if 1:
        print "yes"
else:
        print "no"

        
yes


> 
> -- 
> 
> If your company is not involved in something called "ISO 9000" you probably
> have no idea what it is.  If your company _is_ involved in ISO 9000 then you
> definitely have no idea what it is.
>                                 (Scott Adams - The Dilbert principle)
> 
> 
> _______________________________________________
> 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 dyoo@hkn.eecs.berkeley.edu  Mon Nov 26 06:20:32 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Sun, 25 Nov 2001 22:20:32 -0800 (PST)
Subject: [Tutor] Really Newbie! (fwd)
Message-ID: <Pine.LNX.4.21.0111252217360.2237-100000@hkn.eecs.berkeley.edu>

Hi Jeff,

You probably meant to post on the Tutor mailing list.  You can do this by
emailing "tutor@python.org".  The email "tutor-admin@python.org" only goes
to the admins here.

I'll forward your message to the rest of the list.

Good luck to you!


---------- Forwarded message ----------
Date: Sun, 25 Nov 2001 19:16:05 -0500
From: Jeff Jones <thejoness3@home.com>
To: tutor-admin@python.org
Subject: Really Newbie!

Hello,

I am a real newbie to the programming world; therefore, I have a million
questions. I will start with just a few. First, I am using O'Reilly's
Learning Python and the book tells me (as well as other tutorials) that I
need to set my system environment path. However, I am am not exactly sure
what the outcome of performing this action will be. Should it allow me to
run python modules and programs from the C:\ prompt? Secondly, What are
the major differences between the different text editors? Which one might
you recommend to a newbie? Thank you, in advance, to anyone that takes the
time to help the ignorant.

Jeff Jones



From ak@silmarill.org  Mon Nov 26 06:34:53 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Mon, 26 Nov 2001 01:34:53 -0500
Subject: [Tutor] Really Newbie! (fwd)
In-Reply-To: <Pine.LNX.4.21.0111252217360.2237-100000@hkn.eecs.berkeley.edu>
References: <Pine.LNX.4.21.0111252217360.2237-100000@hkn.eecs.berkeley.edu>
Message-ID: <20011126013453.A21488@sill.silmarill.org>

On Sun, Nov 25, 2001 at 10:20:32PM -0800, Danny Yoo wrote:
> 
> Hi Jeff,
> 
> You probably meant to post on the Tutor mailing list.  You can do this by
> emailing "tutor@python.org".  The email "tutor-admin@python.org" only goes
> to the admins here.
> 
> I'll forward your message to the rest of the list.
> 
> Good luck to you!
> 
> 
> ---------- Forwarded message ----------
> Date: Sun, 25 Nov 2001 19:16:05 -0500
> From: Jeff Jones <thejoness3@home.com>
> To: tutor-admin@python.org
> Subject: Really Newbie!
> 
> Hello,
> 
> I am a real newbie to the programming world; therefore, I have a million
> questions. I will start with just a few. First, I am using O'Reilly's
> Learning Python and the book tells me (as well as other tutorials) that I
> need to set my system environment path. However, I am am not exactly sure
> what the outcome of performing this action will be. Should it allow me to
> run python modules and programs from the C:\ prompt? 

Yes.

Secondly, What are
> the major differences between the different text editors? Which one might
> you recommend to a newbie? 

The 2 most popular editors are vim (www.vim.org) and emacs (emacs.org).
I personally prefer vim, which is incidentally is also scriptable in
python, unlike emacs. However, both are rather complex, so if you don't
figure them out right away, you should probably use one of those
slightly souped-up editors like notepad+ or ultraedit.. They're almost
as simple as notepad but give you extra niceties like syntax
highlighting, etc.

Thank you, in advance, to anyone that takes the
> time to help the ignorant.
> 
> Jeff Jones
> 
> 
> _______________________________________________
> 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 dyoo@hkn.eecs.berkeley.edu  Mon Nov 26 09:19:55 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 26 Nov 2001 01:19:55 -0800 (PST)
Subject: [Tutor] Really Newbie! (fwd)
Message-ID: <Pine.LNX.4.21.0111260117570.6427-100000@hkn.eecs.berkeley.edu>

Hi Kirk,

Errr... I think you meant to post this on Tutor too.  Now I'm starting to
feel like a traffic cop or something.  *grin* Let me forward this to Jeff
and the others on Tutor.


---------- Forwarded message ----------
Date: Mon, 26 Nov 2001 01:36:56 -0500
From: Kirk Bailey <deliberatus@my995internet.com>
To: Danny Yoo <dyoo@hkn.eecs.berkeley.edu>
Subject: Re: [Tutor] Really Newbie! (fwd)

Hi!

Danny Yoo wrote:
> 
> Hi Jeff,
> 
> You probably meant to post on the Tutor mailing list.  You can do this by
> emailing "tutor@python.org".  The email "tutor-admin@python.org" only goes
> to the admins here.
> 
> I'll forward your message to the rest of the list.
> 
> Good luck to you!
> 
> ---------- Forwarded message ----------
> Date: Sun, 25 Nov 2001 19:16:05 -0500
> From: Jeff Jones <thejoness3@home.com>
> To: tutor-admin@python.org
> Subject: Really Newbie!
> 
> Hello,
> 
> I am a real newbie to the programming world; therefore, I have a million
> questions. I will start with just a few. First, I am using O'Reilly's
> Learning Python and the book tells me (as well as other tutorials) that I
> need to set my system environment path.

Well, that's one way to do it.

Open a msdos window, and you can issue commands to dos to set variables
in the environment. You can use EDIT to modify autoexec.bat to do this
for you at boot. But a simpler way is to create a bach file to start up
python. 

I created this batch file in c:\windows, and it is called 'python.bat'.
it says exactly this:

cd c:\python21
python

When I open the windows, it fires up python on command.

To create this file, in the msdos window, type the words EDIT
python.bat[enter key].
BOOM. There's the program, and an empty screen. type those lines, then
[ALT]-F and there's a menu. Click on SAVE. If the mouse is not being
freindly, use the up and down arrows to select, then press [enter].

Then do it again, but select EXIT. Now type the word python.

cool.



 However, I am am not exactly sure
> what the outcome of performing this action will be. Should it allow me to
> run python modules and programs from the C:\ prompt? Secondly, What are
> the major differences between the different text editors? Which one might
> you recommend to a newbie? Thank you, in advance, to anyone that takes the
> time to help the ignorant.
> 
> Jeff Jones
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

-- 
Respectfully,
             -Kirk D Bailey (C)2001
              Addme! icq #27840081
end
      My Sites:
      http://www.howlermonkey.net/ - free REAL email! list service soon!
      http://www.sacredelectron.org/ - Rants! Spleenvents!
      http://www.minorfish.org/ - The list server for some of us!



From thejoness3@home.com  Mon Nov 26 15:47:24 2001
From: thejoness3@home.com (Jeff Jones)
Date: Mon, 26 Nov 2001 10:47:24 -0500
Subject: [Tutor] Re: Really Newbie!
Message-ID: <000e01c17691$a4eb3ce0$fe2c0d18@grapid1.mi.home.com>

This is a multi-part message in MIME format.

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

Thanks for your help. More questions to come...

------=_NextPart_000_000B_01C17667.BBC14880
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>Thanks for your help. More questions to =

come...</FONT></DIV></BODY></HTML>

------=_NextPart_000_000B_01C17667.BBC14880--



From jeff@ccvcorp.com  Mon Nov 26 17:17:24 2001
From: jeff@ccvcorp.com (Jeff Shannon)
Date: Mon, 26 Nov 2001 09:17:24 -0800
Subject: [Tutor] how does one poll the keyboard?
References: <E167gAw-00046w-00@mail.python.org>
Message-ID: <3C027924.1EFEDD5@ccvcorp.com>

> On Fri, 23 Nov 2001 18:08:19 -0500,
> Andrei Kulakov <sill@optonline.net> wrote:
>
> On Fri, Nov 23, 2001 at 03:05:17PM -0800, Jeff Shannon wrote:
> >
> > Actually, it *has* a keywords system, at least the online version...
>
> Doh.. I missed that option, sorry. It really ought to be on by default..

Yeah, it should be.  Perhaps we should bug the python.org maintainers?  :)

> >
> > Also, the ActiveState distribution comes with the help as a .chm file, which is fully indexed and searchable by keywords.  This may or may not be available separately, I'm not sure... but it is *very* useful!  :)
>
> chm is windows help file isn't it?

Yes, .chm is microsoft's "compiled html" help file, and it does require using MSIE (bleah).  Obviously, this does no good for Linux/Mac users, but it *does* make it worth having IE installed, for Windows users.

Jeff Shannon
Technician/Programmer
Credit International




From programer@iquebec.com  Mon Nov 26 16:22:41 2001
From: programer@iquebec.com (programer@iquebec.com)
Date: Mon, 26 Nov 2001 17:22:41 +0100
Subject: [Tutor] Vim scripting using Python? (Was "Re: Really Newbie!")
In-Reply-To: <20011126013453.A21488@sill.silmarill.org>
References: <Pine.LNX.4.21.0111252217360.2237-100000@hkn.eecs.berkeley.edu>
 <Pine.LNX.4.21.0111252217360.2237-100000@hkn.eecs.berkeley.edu>
Message-ID: <5.1.0.14.0.20011126172025.00a34ec0@pop3.norton.antivirus>

I know Vim, but I didn't know that it should be driven through Python-scripts.

May you give some URL about it, please?

Thanks in advance.

At 01:34 26/11/01 -0500, you wrote:
>The 2 most popular editors are vim (www.vim.org) and emacs (emacs.org).
>I personally prefer vim, which is incidentally is also scriptable in
>python, unlike emacs. However, both are rather complex, so if you don't
>figure them out right away, you should probably use one of those
>slightly souped-up editors like notepad+ or ultraedit.. They're almost
>as simple as notepad but give you extra niceties like syntax
>highlighting, etc.


__________________________
       |
  ___  | Dubuquoy-Portois
<*,*> | G.-Joachim L.
[`-'] | gjldp@iquebec.com
-"-"----| <http://www.chez.com/gjldp/>
_________________________

 
______________________________________________________________________________
ifrance.com, l'email gratuit le plus complet de l'Internet !
vos emails depuis un navigateur, en POP3, sur Minitel, sur le WAP...
http://www.ifrance.com/_reloc/email.emailif




From dsh8290@rit.edu  Mon Nov 26 18:39:27 2001
From: dsh8290@rit.edu (dman)
Date: Mon, 26 Nov 2001 13:39:27 -0500
Subject: [Tutor] how does one poll the keyboard?
In-Reply-To: <3C027924.1EFEDD5@ccvcorp.com>; from jeff@ccvcorp.com on Mon, Nov 26, 2001 at 09:17:24AM -0800
References: <E167gAw-00046w-00@mail.python.org> <3C027924.1EFEDD5@ccvcorp.com>
Message-ID: <20011126133927.A27578@harmony.cs.rit.edu>

On Mon, Nov 26, 2001 at 09:17:24AM -0800, Jeff Shannon wrote:
| > On Fri, 23 Nov 2001 18:08:19 -0500, Andrei Kulakov <sill@optonline.net> wrote:
| > chm is windows help file isn't it?
| 
| Yes, .chm is microsoft's "compiled html" help file, and it does
| require using MSIE (bleah).  Obviously, this does no good for
| Linux/Mac users, but it *does* make it worth having IE installed,
| for Windows users.

Is it possible to not have IE installed, and windows to run?

-D

(the sig is randomly chosen)

-- 

Bugs come in through open windows. Keep Windows shut!



From dsh8290@rit.edu  Mon Nov 26 18:43:24 2001
From: dsh8290@rit.edu (dman)
Date: Mon, 26 Nov 2001 13:43:24 -0500
Subject: [Tutor] Problem with "elif"
In-Reply-To: <20011125235037.A20889@sill.silmarill.org>; from sill@optonline.net on Sun, Nov 25, 2001 at 11:50:37PM -0500
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk> <20011125180413.A19978@sill.silmarill.org> <20011125222027.A27092@harmony.cs.rit.edu> <20011125222733.A20757@sill.silmarill.org> <20011125224619.A27150@harmony.cs.rit.edu> <20011125235037.A20889@sill.silmarill.org>
Message-ID: <20011126134324.B27578@harmony.cs.rit.edu>

On Sun, Nov 25, 2001 at 11:50:37PM -0500, Andrei Kulakov wrote:
| On Sun, Nov 25, 2001 at 10:46:19PM -0500, dman wrote:

| > They should, but why wait for a new release?  This is what Open Source
| > is about :-).  You found a bug, you fix the bug (on your system), then
| > you hope the maintainers include the fix in the next release.
|
| Hmm, I set sys.ps2 = "..." but it still don't show the dots.. 
| 
| >>> sys.ps2 = "..."
| >>> if 1:
|         do this
|         
| SyntaxError: invalid syntax
| >>> if 1:
|         print "yes"
| else:
|         print "no"
| 
|         
| yes

IDLE must be more broken than I thought.  I tested it with the
interpreter running directly from a shell.  I don't have the idle
package installed.

-D


-- 

Contrary to popular belief, Unix is user friendly.
It just happens to be selective about who it makes friends with.
                                               -- Dave Parnas



From dsh8290@rit.edu  Mon Nov 26 18:48:01 2001
From: dsh8290@rit.edu (dman)
Date: Mon, 26 Nov 2001 13:48:01 -0500
Subject: [Tutor] Vim scripting using Python? (Was "Re: Really Newbie!")
In-Reply-To: <5.1.0.14.0.20011126172025.00a34ec0@pop3.norton.antivirus>; from programer@iquebec.com on Mon, Nov 26, 2001 at 05:22:41PM +0100
References: <Pine.LNX.4.21.0111252217360.2237-100000@hkn.eecs.berkeley.edu> <Pine.LNX.4.21.0111252217360.2237-100000@hkn.eecs.berkeley.edu> <20011126013453.A21488@sill.silmarill.org> <5.1.0.14.0.20011126172025.00a34ec0@pop3.norton.antivirus>
Message-ID: <20011126134801.C27578@harmony.cs.rit.edu>

On Mon, Nov 26, 2001 at 05:22:41PM +0100, programer@iquebec.com wrote:
| At 01:34 26/11/01 -0500, Andrei wrote:
| >The 2 most popular editors are vim (www.vim.org) and emacs (emacs.org).
| >I personally prefer vim, which is incidentally is also scriptable in
| >python, unlike emacs. However, both are rather complex, so if you don't
| >figure them out right away, you should probably use one of those
| >slightly souped-up editors like notepad+ or ultraedit.. They're almost
| >as simple as notepad but give you extra niceties like syntax
| >highlighting, etc.
|
| I know Vim, but I didn't know that it should be driven through
| Python-scripts.
| 
| May you give some URL about it, please?

:help python

vim must have been compiled with python support enabled.  It can also
be scripted using perl, ruby, or tcl.

See 

:version

Look for "+python".  If you see "-python" then your copy was compiled
without python support.


-D

(wow, the sigs are just a list of strings in a python script, and one
is chosen using randmon.choice().  In the last several messages I've
posted the sigs are actually related to the message)

-- 

(E)ighteen (M)egs (A)nd (C)onstantly (S)wapping



From urnerk@qwest.net  Mon Nov 26 20:14:56 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Mon, 26 Nov 2001 12:14:56 -0800
Subject: [Tutor] IDLE as battery included
In-Reply-To: <20011126134324.B27578@harmony.cs.rit.edu>
References: <20011125235037.A20889@sill.silmarill.org>
 <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk>
 <20011125180413.A19978@sill.silmarill.org>
 <20011125222027.A27092@harmony.cs.rit.edu>
 <20011125222733.A20757@sill.silmarill.org>
 <20011125224619.A27150@harmony.cs.rit.edu>
 <20011125235037.A20889@sill.silmarill.org>
Message-ID: <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus>

>
>IDLE must be more broken than I thought.  I tested it with the
>interpreter running directly from a shell.  I don't have the idle
>package installed.
>
>-D

For all of its faults, I still consider IDLE one of those
"batteries included" features.  For someone just trying to
learn some Python, who isn't already a Vim or Emacs user,
adding these high end editors to the learning curve is just
a distraction.  IDLE gives you keyword color coding and
a shell.  It's adequate, not stellar.  Gets the job done.

That cut 'n paste weirdness had never come up for me before
cuz I'm always encapsulating code inside a def or class,
and every line under a def or class is by definition indented,
with if: clause stuff indented even more.  So if I paste
from an IDLE window to the shell, the indented lines might
move left a bit, but the function still works.  If not,
hitting return on any line repeats the function further down,
and this likely fixes the "extra space on the first line"
problem (different problem from the one described).

I encourage writing with the shell open and interacting
directly with code chunks in a neighboring module window,
using the reload cycle to debug, and passing parameters
directly to functions/classes to test the pieces.  I think
novices coming from Basic or whatever are likely to waste
to much time thinking in terms of scripts which prompt for
all the inputs, or have to execute top to bottom.  I find
it much cooler to treat my modules as mini-APIs and to
interact with the contents dynamically, without the script
orientation.  Saves a lot of time.

PyCrust, another GUI shell, is coming along.  It doesn't
include a text editor though.  Lots of folks use Scintilla
for Python.  There's a whole tier of middle-range program
editors, many of them easier to learn than either Vim or
Emacs, worth checking out, if you outgrow IDLE's "enough
to get you going" capabilities.

Kirby



From ak@silmarill.org  Mon Nov 26 22:01:20 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Mon, 26 Nov 2001 17:01:20 -0500
Subject: [Tutor] Vim scripting using Python? (Was "Re: Really Newbie!")
In-Reply-To: <20011126134801.C27578@harmony.cs.rit.edu>
References: <Pine.LNX.4.21.0111252217360.2237-100000@hkn.eecs.berkeley.edu>
 <Pine.LNX.4.21.0111252217360.2237-100000@hkn.eecs.berkeley.edu>
 <20011126013453.A21488@sill.silmarill.org>
 <5.1.0.14.0.20011126172025.00a34ec0@pop3.norton.antivirus>
 <20011126134801.C27578@harmony.cs.rit.edu>
Message-ID: <20011126170120.A23859@sill.silmarill.org>

On Mon, Nov 26, 2001 at 01:48:01PM -0500, dman wrote:
> On Mon, Nov 26, 2001 at 05:22:41PM +0100, programer@iquebec.com wrote:
> | At 01:34 26/11/01 -0500, Andrei wrote:
> | >The 2 most popular editors are vim (www.vim.org) and emacs (emacs.org).
> | >I personally prefer vim, which is incidentally is also scriptable in
> | >python, unlike emacs. However, both are rather complex, so if you don't
> | >figure them out right away, you should probably use one of those
> | >slightly souped-up editors like notepad+ or ultraedit.. They're almost
> | >as simple as notepad but give you extra niceties like syntax
> | >highlighting, etc.
> |
> | I know Vim, but I didn't know that it should be driven through
> | Python-scripts.
> | 
> | May you give some URL about it, please?
> 
> :help python
> 
> vim must have been compiled with python support enabled.  It can also
> be scripted using perl, ruby, or tcl.

In addition: in debian, you have a package vim-python, although you might want
to get vim6, with folds and special support for python indenting style (put
this in your vimrc):

augroup Python
    au!
    au BufNewFile *.py 0read ~/.templates/python.py
    " see also :help smartindent , cinwords
    au FileType python set autoindent smartindent sts=4 sw=4 tw=80 fo=croq

    " turn off the C preprocessor indenting
    " (allow comments in Python to be indented properly)
    au FileType python inoremap # X^H#
    au FileType python set foldenable
augroup END


> 
> See 
> 
> :version
> 
> Look for "+python".  If you see "-python" then your copy was compiled
> without python support.
> 
> 
> -D
> 
> (wow, the sigs are just a list of strings in a python script, and one
> is chosen using randmon.choice().  In the last several messages I've
> posted the sigs are actually related to the message)
> 
> -- 
> 
> (E)ighteen (M)egs (A)nd (C)onstantly (S)wapping
> 
> 
> _______________________________________________
> 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 ak@silmarill.org  Mon Nov 26 22:09:59 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Mon, 26 Nov 2001 17:09:59 -0500
Subject: [Tutor] IDLE as battery included
In-Reply-To: <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus>
References: <20011125235037.A20889@sill.silmarill.org>
 <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk>
 <20011125180413.A19978@sill.silmarill.org>
 <20011125222027.A27092@harmony.cs.rit.edu>
 <20011125222733.A20757@sill.silmarill.org>
 <20011125224619.A27150@harmony.cs.rit.edu>
 <20011125235037.A20889@sill.silmarill.org>
 <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus>
Message-ID: <20011126170959.B23859@sill.silmarill.org>

On Mon, Nov 26, 2001 at 12:14:56PM -0800, Kirby Urner wrote:
> 
> >
> >IDLE must be more broken than I thought.  I tested it with the
> >interpreter running directly from a shell.  I don't have the idle
> >package installed.
> >
> >-D
> 
> For all of its faults, I still consider IDLE one of those
> "batteries included" features.  For someone just trying to
> learn some Python, who isn't already a Vim or Emacs user,
> adding these high end editors to the learning curve is just
> a distraction.  IDLE gives you keyword color coding and
> a shell.  It's adequate, not stellar.  Gets the job done.

I think it'd be preferable to use some simple notepad-like editor with
syntax colors. I think notepad+ and ultraedit both have that.

> 
> That cut 'n paste weirdness had never come up for me before

The problem is that when you type in blocks, they're unaligned, and that
just don't look right. 

Besides, when a newbie is trying to follow the book and it don't work,
that ain't good either :P.

 - Andrei

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


From van@lindbergs.org  Mon Nov 26 21:51:54 2001
From: van@lindbergs.org (VanL)
Date: Mon, 26 Nov 2001 14:51:54 -0700
Subject: [Tutor] Getopt difficulty
Message-ID: <3C02B97A.8030604@lindbergs.org>

Hello,

I am trying to use getopt to get options that might have spaces.  For 
example:

#!/usr/bin/env python

import getopt,  sys

def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'sr', ['search', 
'replace'])
        print opts
        print args
       
    except: print "Exception getting opts and args"
   
if __name__ == '__main__': main()

Example run:

% ./s2.py -s "foo bar" -r foobar
[('-s', '')]
['foo bar', '-r', 'foobar']

What I *want* is this:

% ./s2.py -s "foo bar" -r foobar
[('-s', 'foo bar'), ('-r', 'foobar')]
[]

Any ideas?

Thanks,

VanL



From dsh8290@rit.edu  Mon Nov 26 23:01:26 2001
From: dsh8290@rit.edu (dman)
Date: Mon, 26 Nov 2001 18:01:26 -0500
Subject: [Tutor] Getopt difficulty
In-Reply-To: <3C02B97A.8030604@lindbergs.org>; from van@lindbergs.org on Mon, Nov 26, 2001 at 02:51:54PM -0700
References: <3C02B97A.8030604@lindbergs.org>
Message-ID: <20011126180126.A28144@harmony.cs.rit.edu>

On Mon, Nov 26, 2001 at 02:51:54PM -0700, VanL wrote:
| Hello,
| 
| I am trying to use getopt to get options that might have spaces.  For 
| example:

You mean, options that have arguments.

|         opts, args = getopt.getopt(sys.argv[1:], 'sr', ['search', 'replace'])
                                                    ^^          ^^         ^^

>From the documentation :


getopt(args, options[, long_options])
    Parses command line options and parameter list. args is the
    argument list to be parsed, without the leading reference to the
    running program. Typically, this means "sys.argv[1:]". options is
    the string of option letters that the script wants to recognize,
    with options that require an argument followed by a colon (":";
    i.e., the same format that Unix getopt() uses).

    long_options, if specified, must be a list of strings with the
    names of the long options which should be supported. The leading
    '--' characters should not be included in the option name. Long
    options which require an argument should be followed by an equal
    sign ("=").  To accept only long options, options should be an
    empty string. Long options on the command line can be recognized
    so long as they provide a prefix of the option name that matches
    exactly one of the accepted options. For example, it long_options
    is ['foo', 'frob'], the option --fo will match as --foo, but --f
    will not match uniquely, so GetoptError will be raised.


instead you should try

    opts, args = getopt.getopt(sys.argv[1:], 's:r:', ['search=', 'replace='])


HTH,
-D

-- 

Python is executable pseudocode. Perl is executable line noise.



From dyoo@hkn.eecs.berkeley.edu  Mon Nov 26 23:03:48 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 26 Nov 2001 15:03:48 -0800 (PST)
Subject: [Tutor] Getopt difficulty
In-Reply-To: <3C02B97A.8030604@lindbergs.org>
Message-ID: <Pine.LNX.4.21.0111261459060.21685-100000@hkn.eecs.berkeley.edu>

On Mon, 26 Nov 2001, VanL wrote:

> I am trying to use getopt to get options that might have spaces.  For 
> example:
> 
> #!/usr/bin/env python
> 
> import getopt,  sys
> 
> def main():
>     try:
>         opts, args = getopt.getopt(sys.argv[1:], 'sr', ['search', 
> 'replace'])
>         print opts
>         print args
>        
>     except: print "Exception getting opts and args"
>    
> if __name__ == '__main__': main()

According to:

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

if you want to allow your options to take in an additional argument,
you'll want to append a ':' colon, like this.

###
opts, args = getopt.getopt(sys.argv[1:], 's:r:',
                           ['search', 'replace'])
###

It's not exactly a matter of spacing, but of getopt's surprise: it didn't
expect to read in an option with an argument.  Seen in this light, when we
had done:

> % ./s2.py -s "foo bar" -r foobar

It had thought that "foo bar" was the name of your file, and so it ignored
the rest of the arguments.


Hopet his helps!



From urnerk@qwest.net  Mon Nov 26 23:16:56 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Mon, 26 Nov 2001 15:16:56 -0800
Subject: [Tutor] IDLE as battery included
In-Reply-To: <20011126170959.B23859@sill.silmarill.org>
References: <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus>
 <20011125235037.A20889@sill.silmarill.org>
 <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk>
 <20011125180413.A19978@sill.silmarill.org>
 <20011125222027.A27092@harmony.cs.rit.edu>
 <20011125222733.A20757@sill.silmarill.org>
 <20011125224619.A27150@harmony.cs.rit.edu>
 <20011125235037.A20889@sill.silmarill.org>
 <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus>
Message-ID: <4.2.0.58.20011126150040.00a3cf00@pop3.norton.antivirus>

At 05:09 PM 11/26/2001 -0500, Andrei Kulakov wrote:

>I think it'd be preferable to use some simple notepad-like editor with
>syntax colors. I think notepad+ and ultraedit both have that.

Perhaps.  Ultraedit looks good, but you'd have to set it up
for Python I think (maybe setup file is sharable? -- someone
has it?) -- not one of the canned languages, at least not
on the web page I saw.  Costs $30 (IDLE free).  Notepad+ has
its limitations too.

The thing about IDLE is it has access to a primitive graphical
debugger (not industrial strength by any means, but a beginner
is still able to learn from it), is aware of the Python path
(go Open Module and enter just the module name, and it'll
get retrieved, if anywhere on the path).  Plus you can execute
a .py file by going Ctrl-5 in the text editor window.  In
other words, it works more intimately with Python, and as a
shell.

With these editors, you still want to have a shell open (a
Python shell, not an Xterm or OS window), so you can do the
reload/interact cycle.

> >
> > That cut 'n paste weirdness had never come up for me before
>
>The problem is that when you type in blocks, they're unaligned, and that
>just don't look right.

When you type the blocks directly at the IDLE prompt, it's
not a problem.  When I go:

 >>> def f(x):

and hit enter, the cursor goes to the next line and sits under
the f, indented, waiting for a next line.

It's cutting and pasting that might be a problem.  If I cut

def fib():
     """
     Simple generator from documentation:  yield
     successive Fibonacci numbers
     """
     a, b = 0, 1
     while 1:
        yield b
        a, b = b, a+b

and paste it to the >>>, I get:

 >>> def fib():
     """
     Simple generator from documentation:  yield
     successive Fibonacci numbers
     """
     a, b = 0, 1
     while 1:
        yield b
        a, b = b, a+b

Now if I go and insert spaces in front of lines below the
def, it still works, cuz what's already seen as indented
by IDLE, is indented even more by me.

>Besides, when a newbie is trying to follow the book and it don't work,
>that ain't good either :P.
>
>  - Andrei

Yeah, this I agree with.  Pitfalls.  IDLE should be fixed
and/or other shells developed.  I'm just not sure I'd
counsel newbies to foresake IDLE in favor of the options
mentioned above.  It still has quite a bit going for it.

Ultimately, it's not an either/or proposition.  Use IDLE
sometimes, but find a good program editor, preferably one
you can use with other languages too, since Python
shouldn't be the only language you ever use.

Kirby



From dsh8290@rit.edu  Mon Nov 26 23:25:51 2001
From: dsh8290@rit.edu (dman)
Date: Mon, 26 Nov 2001 18:25:51 -0500
Subject: [Tutor] IDLE as battery included
In-Reply-To: <4.2.0.58.20011126150040.00a3cf00@pop3.norton.antivirus>; from urnerk@qwest.net on Mon, Nov 26, 2001 at 03:16:56PM -0800
References: <20011125235037.A20889@sill.silmarill.org> <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk> <20011125180413.A19978@sill.silmarill.org> <20011125222027.A27092@harmony.cs.rit.edu> <20011125222733.A20757@sill.silmarill.org> <20011125224619.A27150@harmony.cs.rit.edu> <20011125235037.A20889@sill.silmarill.org> <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus> <20011126170959.B23859@sill.silmarill.org> <4.2.0.58.20011126150040.00a3cf00@pop3.norton.antivirus>
Message-ID: <20011126182551.A28164@harmony.cs.rit.edu>

On Mon, Nov 26, 2001 at 03:16:56PM -0800, Kirby Urner wrote:
| At 05:09 PM 11/26/2001 -0500, Andrei Kulakov wrote:
 
| >The problem is that when you type in blocks, they're unaligned, and that
| >just don't look right.
| 
| When you type the blocks directly at the IDLE prompt, it's
| not a problem.  When I go:
| 
|  >>> def f(x):
[...]

It's not "def" and "class" blocks that are the problem, but blocks
like "if-else" and "try-except" - blocks that have more than one line
at the least level of indent.  You have to type the "elif", "else",
and "except" such that it _looks_ too much dedented but it really
isn't.

-D

-- 

(E)ighteen (M)egs (A)nd (C)onstantly (S)wapping



From ak@silmarill.org  Mon Nov 26 23:31:43 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Mon, 26 Nov 2001 18:31:43 -0500
Subject: [Tutor] IDLE as battery included
In-Reply-To: <4.2.0.58.20011126150040.00a3cf00@pop3.norton.antivirus>
References: <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus>
 <20011125235037.A20889@sill.silmarill.org>
 <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk>
 <20011125180413.A19978@sill.silmarill.org>
 <20011125222027.A27092@harmony.cs.rit.edu>
 <20011125222733.A20757@sill.silmarill.org>
 <20011125224619.A27150@harmony.cs.rit.edu>
 <20011125235037.A20889@sill.silmarill.org>
 <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus>
 <4.2.0.58.20011126150040.00a3cf00@pop3.norton.antivirus>
Message-ID: <20011126183143.A24328@sill.silmarill.org>

On Mon, Nov 26, 2001 at 03:16:56PM -0800, Kirby Urner wrote:
> At 05:09 PM 11/26/2001 -0500, Andrei Kulakov wrote:
> 
> >I think it'd be preferable to use some simple notepad-like editor with
> >syntax colors. I think notepad+ and ultraedit both have that.
> 
> Perhaps.  Ultraedit looks good, but you'd have to set it up
> for Python I think (maybe setup file is sharable? -- someone
> has it?) -- not one of the canned languages, at least not
> on the web page I saw.  Costs $30 (IDLE free).  Notepad+ has
> its limitations too.
> 
> The thing about IDLE is it has access to a primitive graphical
> debugger (not industrial strength by any means, but a beginner
> is still able to learn from it), is aware of the Python path
> (go Open Module and enter just the module name, and it'll
> get retrieved, if anywhere on the path).  Plus you can execute
> a .py file by going Ctrl-5 in the text editor window.  In
> other words, it works more intimately with Python, and as a
> shell.
> 
> With these editors, you still want to have a shell open (a
> Python shell, not an Xterm or OS window), so you can do the
> reload/interact cycle.

I don't know why, but I prefer to have a second shell open anyway to run
scripts in even though they can be run from inside vim. I guess it's
cause I want it open to use mutt when new mail comes in, and occasional
file management, and that sort of thing..

> 
> >>
> >> That cut 'n paste weirdness had never come up for me before
> >
> >The problem is that when you type in blocks, they're unaligned, and that
> >just don't look right.
> 
> When you type the blocks directly at the IDLE prompt, it's
> not a problem.  When I go:
> 
> >>> def f(x):
> 
> and hit enter, the cursor goes to the next line and sits under
> the f, indented, waiting for a next line.
> 
> It's cutting and pasting that might be a problem.  If I cut
> 
> def fib():
>     """
>     Simple generator from documentation:  yield
>     successive Fibonacci numbers
>     """
>     a, b = 0, 1
>     while 1:
>        yield b
>        a, b = b, a+b
> 
> and paste it to the >>>, I get:
> 
> >>> def fib():
>     """
>     Simple generator from documentation:  yield
>     successive Fibonacci numbers
>     """
>     a, b = 0, 1
>     while 1:
>        yield b
>        a, b = b, a+b
> 
> Now if I go and insert spaces in front of lines below the
> def, it still works, cuz what's already seen as indented
> by IDLE, is indented even more by me.

You're right, it's much better with functions, so the only problem is
with if/else blocks, where if isn't aligned with else. It's not nearly
as bad as I thought at first, since you don't need to use if/else blocks
very often outside of functions.

> 
> >Besides, when a newbie is trying to follow the book and it don't work,
> >that ain't good either :P.
> >
> > - Andrei
> 
> Yeah, this I agree with.  Pitfalls.  IDLE should be fixed
> and/or other shells developed.  I'm just not sure I'd
> counsel newbies to foresake IDLE in favor of the options
> mentioned above.  It still has quite a bit going for it.
> 
> Ultimately, it's not an either/or proposition.  Use IDLE
> sometimes, but find a good program editor, preferably one
> you can use with other languages too, since Python
> shouldn't be the only language you ever use.

I don't know about emacs, but vim can do everything much better than
idle, except for debugging, so I'd use it exclusively (and I do). But
then again, I never like debuggers so it's a matter of taste I suppose.

> 
> Kirby
> 
> 
> _______________________________________________
> 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  Tue Nov 27 00:16:26 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Mon, 26 Nov 2001 16:16:26 -0800
Subject: [Tutor] IDLE as battery included
In-Reply-To: <20011126183143.A24328@sill.silmarill.org>
References: <4.2.0.58.20011126150040.00a3cf00@pop3.norton.antivirus>
 <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus>
 <20011125235037.A20889@sill.silmarill.org>
 <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk>
 <20011125180413.A19978@sill.silmarill.org>
 <20011125222027.A27092@harmony.cs.rit.edu>
 <20011125222733.A20757@sill.silmarill.org>
 <20011125224619.A27150@harmony.cs.rit.edu>
 <20011125235037.A20889@sill.silmarill.org>
 <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus>
 <4.2.0.58.20011126150040.00a3cf00@pop3.norton.antivirus>
Message-ID: <4.2.0.58.20011126161132.00c46c40@pop3.norton.antivirus>

>
>I don't know about emacs, but vim can do everything much better than
>idle, except for debugging, so I'd use it exclusively (and I do). But
>then again, I never like debuggers so it's a matter of taste I suppose.

I've tried Vi in Linux but I'm not up on Vim for Windows.  Probably
I'll download Vim 6.0 for Win from http://vim.sourceforge.net/index.php
in the near future and give it another try.  I wonder what additional
configuation I'll need to do, if any, to make it a good Python editor
(keyword coding etc.)....

Kirby



From ak@silmarill.org  Tue Nov 27 00:37:27 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Mon, 26 Nov 2001 19:37:27 -0500
Subject: [Tutor] IDLE as battery included
In-Reply-To: <4.2.0.58.20011126161132.00c46c40@pop3.norton.antivirus>
References: <20011125235037.A20889@sill.silmarill.org>
 <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk>
 <20011125180413.A19978@sill.silmarill.org>
 <20011125222027.A27092@harmony.cs.rit.edu>
 <20011125222733.A20757@sill.silmarill.org>
 <20011125224619.A27150@harmony.cs.rit.edu>
 <20011125235037.A20889@sill.silmarill.org>
 <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus>
 <4.2.0.58.20011126150040.00a3cf00@pop3.norton.antivirus>
 <4.2.0.58.20011126161132.00c46c40@pop3.norton.antivirus>
Message-ID: <20011126193727.A24580@sill.silmarill.org>

On Mon, Nov 26, 2001 at 04:16:26PM -0800, Kirby Urner wrote:
> 
> >
> >I don't know about emacs, but vim can do everything much better than
> >idle, except for debugging, so I'd use it exclusively (and I do). But
> >then again, I never like debuggers so it's a matter of taste I suppose.
> 
> I've tried Vi in Linux but I'm not up on Vim for Windows.  Probably
> I'll download Vim 6.0 for Win from http://vim.sourceforge.net/index.php
> in the near future and give it another try.  I wonder what additional
> configuation I'll need to do, if any, to make it a good Python editor
> (keyword coding etc.)....
> 
> Kirby

Just this:

augroup Python
    au!
    au BufNewFile *.py 0read ~/.templates/python.py
    " see also :help smartindent , cinwords
    au FileType python set autoindent smartindent sts=4 sw=4 tw=80 fo=croq

    " turn off the C preprocessor indenting
    " (allow comments in Python to be indented properly)
    au FileType python inoremap # #
    au FileType python set foldenable
augroup END

Put it in your vimrc and you're all set. Well, you can add a mapping to run it
under python, and so on but even though I have that I hardly ever use it. 

The thing about vi/vim is that once you use it extensively for a few weeks,
you begin to work in batches - first you type in a lot of text, then you
go to command mode and do command maniulation, and so on - and that's
much more efficient than "normal" editing. If you switch back and forth
all the time, it's not that much better.. Also, it takes quite a bit of
time to get a good feel for using number-command, i.e. you want to go 5
lines down and 4 columns to the right, so you need to hit 5j4l, but when
I first started using it, I would have to count lines - now I can often
type it without thinking at all. But as one dude I know said, it takes
5+ years to *really* learn a sophisticated editor like vim or emacs. For
me, it's 3 years and counting, and there's still many commands and
options that I know of, but my fingers don't have them memorized - and
that's what it takes to really use them well.

> 

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


From dsh8290@rit.edu  Tue Nov 27 00:39:27 2001
From: dsh8290@rit.edu (dman)
Date: Mon, 26 Nov 2001 19:39:27 -0500
Subject: [Tutor] IDLE as battery included
In-Reply-To: <4.2.0.58.20011126161132.00c46c40@pop3.norton.antivirus>; from urnerk@qwest.net on Mon, Nov 26, 2001 at 04:16:26PM -0800
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk> <20011125180413.A19978@sill.silmarill.org> <20011125222027.A27092@harmony.cs.rit.edu> <20011125222733.A20757@sill.silmarill.org> <20011125224619.A27150@harmony.cs.rit.edu> <20011125235037.A20889@sill.silmarill.org> <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus> <4.2.0.58.20011126150040.00a3cf00@pop3.norton.antivirus> <20011126183143.A24328@sill.silmarill.org> <4.2.0.58.20011126161132.00c46c40@pop3.norton.antivirus>
Message-ID: <20011126193927.A28471@harmony.cs.rit.edu>

On Mon, Nov 26, 2001 at 04:16:26PM -0800, Kirby Urner wrote:
| 
| >
| >I don't know about emacs, but vim can do everything much better than
| >idle, except for debugging, so I'd use it exclusively (and I do). But
| >then again, I never like debuggers so it's a matter of taste I suppose.
| 
| I've tried Vi in Linux but I'm not up on Vim for Windows.  Probably
| I'll download Vim 6.0 for Win from http://vim.sourceforge.net/index.php
| in the near future and give it another try.  I wonder what additional
| configuation I'll need to do, if any, to make it a good Python editor
| (keyword coding etc.)....

If you want I'll send you my .vimrc.  I haven't found any editor or
IDE that I like better.

-D

-- 

It took the computational power of three Commodore 64s to fly to the moon.
It takes at least a 486 to run Windows 95.
Something is wrong here.



From dyoo@hkn.eecs.berkeley.edu  Tue Nov 27 01:02:22 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Mon, 26 Nov 2001 17:02:22 -0800 (PST)
Subject: [Tutor] Biology and introductory programming?
Message-ID: <Pine.LNX.4.21.0111261630590.24196-100000@hkn.eecs.berkeley.edu>

Hi everyone,

Just out of curiosity, how many of us here have an interest in
"bioinformatics"?  I've just bought the book "Beginning Perl for
Bioinformatics", and it appears to be an introductory test for biologists
who are trying to smash their brains against Perl.  *grin*


In all seriousness though, it looks like a great book for people who
haven't programmed before.  Kirby has mentioned using Python to play
around with mathematical ideas; the same synergy would probably work with
molecular biology too.  Using molecular biology as a motivater for
learning a programming language looks really exciting!


For example, we can start talking about a DNA fragment:

###
dna = "ATTAAGCATTAAA"
###


and show how we can "mutate" such an example by zapping it:

###
def mutate(dna):
    """Introduce a single point mutation into a sequence of dna."""
    bases = ['A', 'T', 'G', 'C']
    position_of_mutation = random.randrange(len(dna))
    original_nucleotide = dna[position_of_mutation]
    bases.remove(original_nucleotide)
    return (dna[:position_of_mutation]
            + random.choice(bases)
            + dna[position_of_mutation + 1:])
###


Here's an test of the DNA mutation:

###
>>> mutate('AAAAA')                             ## Zap!
'AAACA'
>>> mutate(mutate('AAAAA'))
'AATCA'
>>> mutate(mutate(mutate('AAAAA')))
'ATAGG'
###


Molecular biology is very much about structure and sequences, so this sort
of stuff seems easy to approach from a programming standpoint.



From urnerk@qwest.net  Tue Nov 27 01:20:49 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Mon, 26 Nov 2001 17:20:49 -0800
Subject: [Tutor] IDLE as battery included
In-Reply-To: <20011126193727.A24580@sill.silmarill.org>
References: <4.2.0.58.20011126161132.00c46c40@pop3.norton.antivirus>
 <20011125235037.A20889@sill.silmarill.org>
 <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk>
 <20011125180413.A19978@sill.silmarill.org>
 <20011125222027.A27092@harmony.cs.rit.edu>
 <20011125222733.A20757@sill.silmarill.org>
 <20011125224619.A27150@harmony.cs.rit.edu>
 <20011125235037.A20889@sill.silmarill.org>
 <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus>
 <4.2.0.58.20011126150040.00a3cf00@pop3.norton.antivirus>
 <4.2.0.58.20011126161132.00c46c40@pop3.norton.antivirus>
Message-ID: <4.2.0.58.20011126171942.00a86100@pop3.norton.antivirus>

>
>Just this:
>
>augroup Python
>     au!


What's this "au" language?  Looks like French.  Do
we have to program Vim in French then (I'm rusty)?

Kirby



From urnerk@qwest.net  Tue Nov 27 01:25:44 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Mon, 26 Nov 2001 17:25:44 -0800
Subject: [Tutor] Biology and introductory programming?
In-Reply-To: <Pine.LNX.4.21.0111261630590.24196-100000@hkn.eecs.berkeley
 .edu>
Message-ID: <4.2.0.58.20011126172131.00a86440@pop3.norton.antivirus>

>
>In all seriousness though, it looks like a great book for people who
>haven't programmed before.  Kirby has mentioned using Python to play
>around with mathematical ideas; the same synergy would probably work with
>molecular biology too.  Using molecular biology as a motivater for
>learning a programming language looks really exciting!

Isn't there some molecule viewer with a Python API out
there?  Lemme google a sec (also downloading Vim 6.0 in
the background)...

Seen this page?
http://www.scripps.edu/pub/olson-web/people/sanner/html/talks/PSB2001talk.html

PMV is the program I was thinking of.  Anyone on here
played with it?  Not me (yet), to the best of my
recollection.


Kirby




From ak@silmarill.org  Tue Nov 27 01:30:19 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Mon, 26 Nov 2001 20:30:19 -0500
Subject: [Tutor] IDLE as battery included
In-Reply-To: <4.2.0.58.20011126171942.00a86100@pop3.norton.antivirus>
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk>
 <20011125180413.A19978@sill.silmarill.org>
 <20011125222027.A27092@harmony.cs.rit.edu>
 <20011125222733.A20757@sill.silmarill.org>
 <20011125224619.A27150@harmony.cs.rit.edu>
 <20011125235037.A20889@sill.silmarill.org>
 <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus>
 <4.2.0.58.20011126150040.00a3cf00@pop3.norton.antivirus>
 <4.2.0.58.20011126161132.00c46c40@pop3.norton.antivirus>
 <4.2.0.58.20011126171942.00a86100@pop3.norton.antivirus>
Message-ID: <20011126203018.A24962@sill.silmarill.org>

On Mon, Nov 26, 2001 at 05:20:49PM -0800, Kirby Urner wrote:
> 
> >
> >Just this:
> >
> >augroup Python
> >    au!
> 
> 
> What's this "au" language?  Looks like French.  Do
> we have to program Vim in French then (I'm rusty)?
> 
> Kirby

                                                        *:au* *:autocmd*
:au[tocmd] [group] {event} {pat} [nested] {cmd}
                        Add {cmd} to the list of commands that Vim will
                        execute automatically on {event} for a file matching
                        {pat}.  Vim always adds the {cmd} after existing
                        autocommands, so that the autocommands execute in the
                        order in which they were given.  See |autocmd-nested|
                        for [nested].

> 

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


From virketis@fas.harvard.edu  Tue Nov 27 01:32:11 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Mon, 26 Nov 2001 20:32:11 -0500
Subject: [Tutor] Biology and introductory programming?
In-Reply-To: <Pine.LNX.4.21.0111261630590.24196-100000@hkn.eecs.berkeley
 .edu>
Message-ID: <200111270131.fAR1VQl07415@smtp2.fas.harvard.edu>

>Just out of curiosity, how many of us here have an interest in
>"bioinformatics"?  I've just bought the book "Beginning Perl for
>Bioinformatics", and it appears to be an introductory test for biologists
>who are trying to smash their brains against Perl.  *grin*

Thanks for the book reference. I'll pass it along to all the tentative
programmers/biologists here.:) Over the past year, I have been writting far
more biology-related code than I bargained for ... :) I am an economics
student myself, so alot of the underlying heuristics was foreign to me. The
stuff that people (my grad student friends, mostly) around here are
interested in is actually not pure molecular biology per se, but its
applications: tree phylogeny, Bayseian inference for dating splits in plant
species and such. Mac is (was?) the platform of choice before, but now a
lot of bio people are learning Unix/Solaris/Linux and getting into
computational science. I try to tout Python as the first language par
excellence.:)

Cheers,

Pijus
------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis



From urnerk@qwest.net  Tue Nov 27 01:42:57 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Mon, 26 Nov 2001 17:42:57 -0800
Subject: [Tutor] IDLE as battery included
In-Reply-To: <4.2.0.58.20011126171942.00a86100@pop3.norton.antivirus>
References: <20011126193727.A24580@sill.silmarill.org>
 <4.2.0.58.20011126161132.00c46c40@pop3.norton.antivirus>
 <20011125235037.A20889@sill.silmarill.org>
 <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk>
 <20011125180413.A19978@sill.silmarill.org>
 <20011125222027.A27092@harmony.cs.rit.edu>
 <20011125222733.A20757@sill.silmarill.org>
 <20011125224619.A27150@harmony.cs.rit.edu>
 <20011125235037.A20889@sill.silmarill.org>
 <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus>
 <4.2.0.58.20011126150040.00a3cf00@pop3.norton.antivirus>
 <4.2.0.58.20011126161132.00c46c40@pop3.norton.antivirus>
Message-ID: <4.2.0.58.20011126173511.00a84dc0@pop3.norton.antivirus>

At 05:20 PM 11/26/2001 -0800, Kirby Urner wrote:


>>Just this:
>>
>>augroup Python
>>     au!
>
>
>What's this "au" language?  Looks like French.  Do
>we have to program Vim in French then (I'm rusty)?
>
>Kirby

Anyway, I followed your instructions and the syntax
highlighting appears to work great, though I might
want to change the colors (to match IDLE's :-D).
Also, I went into python.vim in the syntax folder
and added 'yield' as a keyword (2.2).

... I see this color schemes thing, which lets me
pick from a list.  Very cool to have "convert to HTML"
reproduce those colors faithfully.  So is there a way
to duplicate the IDLE colors, e.g. keywords are orange,
strings forest green?  White background?  Clues?

Kirby



From ak@silmarill.org  Tue Nov 27 01:49:39 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Mon, 26 Nov 2001 20:49:39 -0500
Subject: [Tutor] IDLE as battery included
In-Reply-To: <4.2.0.58.20011126173511.00a84dc0@pop3.norton.antivirus>
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C10B@mbtlipnt02.btlabs.bt.co.uk>
 <20011125180413.A19978@sill.silmarill.org>
 <20011125222027.A27092@harmony.cs.rit.edu>
 <20011125222733.A20757@sill.silmarill.org>
 <20011125224619.A27150@harmony.cs.rit.edu>
 <20011125235037.A20889@sill.silmarill.org>
 <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus>
 <4.2.0.58.20011126150040.00a3cf00@pop3.norton.antivirus>
 <4.2.0.58.20011126161132.00c46c40@pop3.norton.antivirus>
 <4.2.0.58.20011126173511.00a84dc0@pop3.norton.antivirus>
Message-ID: <20011126204938.A25147@sill.silmarill.org>

On Mon, Nov 26, 2001 at 05:42:57PM -0800, Kirby Urner wrote:
> At 05:20 PM 11/26/2001 -0800, Kirby Urner wrote:
> 
> 
> >>Just this:
> >>
> >>augroup Python
> >>    au!
> >
> >
> >What's this "au" language?  Looks like French.  Do
> >we have to program Vim in French then (I'm rusty)?
> >
> >Kirby
> 
> Anyway, I followed your instructions and the syntax
> highlighting appears to work great, though I might
> want to change the colors (to match IDLE's :-D).
> Also, I went into python.vim in the syntax folder
> and added 'yield' as a keyword (2.2).
> 
> ... I see this color schemes thing, which lets me
> pick from a list.  Very cool to have "convert to HTML"
> reproduce those colors faithfully.  So is there a way
> to duplicate the IDLE colors, e.g. keywords are orange,
> strings forest green?  White background?  Clues?
> 
> Kirby

I changed some colors but I don't remember how.. But you can go to Edit
-> color scheme menu and choose a few preset color schemes. Maybe you'll
like one of them better than others.

> 

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


From dsh8290@rit.edu  Tue Nov 27 01:57:34 2001
From: dsh8290@rit.edu (dman)
Date: Mon, 26 Nov 2001 20:57:34 -0500
Subject: [Tutor] IDLE as battery included
In-Reply-To: <4.2.0.58.20011126173511.00a84dc0@pop3.norton.antivirus>; from urnerk@qwest.net on Mon, Nov 26, 2001 at 05:42:57PM -0800
References: <20011125180413.A19978@sill.silmarill.org> <20011125222027.A27092@harmony.cs.rit.edu> <20011125222733.A20757@sill.silmarill.org> <20011125224619.A27150@harmony.cs.rit.edu> <20011125235037.A20889@sill.silmarill.org> <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus> <4.2.0.58.20011126150040.00a3cf00@pop3.norton.antivirus> <4.2.0.58.20011126161132.00c46c40@pop3.norton.antivirus> <4.2.0.58.20011126171942.00a86100@pop3.norton.antivirus> <4.2.0.58.20011126173511.00a84dc0@pop3.norton.antivirus>
Message-ID: <20011126205734.A28649@harmony.cs.rit.edu>

On Mon, Nov 26, 2001 at 05:42:57PM -0800, Kirby Urner wrote:
| At 05:20 PM 11/26/2001 -0800, Kirby Urner wrote:
| 
| >>Just this:
| >>
| >>augroup Python
| >>     au!
| >
| >
| >What's this "au" language?  Looks like French.  Do
| >we have to program Vim in French then (I'm rusty)?

It is "vi(m) script".  Use ":help <cmd>" to see more details on it
(such as what Andrei posted).

| Anyway, I followed your instructions and the syntax
| highlighting appears to work great, though I might
| want to change the colors (to match IDLE's :-D).
| Also, I went into python.vim in the syntax folder
| and added 'yield' as a keyword (2.2).

This is part of the power of Open Source - you can fix your own copy.
This will likely be fixed in the next release also, since Neil
Schemenauer is the maintainer of that syntax file.

| ... I see this color schemes thing, which lets me
| pick from a list.  Very cool to have "convert to HTML"
| reproduce those colors faithfully.  So is there a way
| to duplicate the IDLE colors, e.g. keywords are orange,
| strings forest green?  White background?  Clues?

See the "highlight" command.  For me, I like a black background with a
not-quite-white foreground.  In my .vimrc I have

    highlight Normal guibg=black guifg=grey90
    set background=dark

the first line says that the highlighting for items that are in the
"Normal" group should have black as the background and grey90 as the
foreground.  That only affects the gui though, if vim is run in a
console it has no control over that (my gnome-terminal has the same
settings though).  The second line tells it to adjust the palette used
for coloring so that it is readable with a dark background.  You can
see the effect by switching between "bg=dark" and "bg=light", try it
with each background.

I am certain that you can specifiy the colors to use for any given
highlight group to get the colors you prefer.  I see the command
"colorscheme" mentioned right below the "highlight" command in the
help file.  That will likely be helpful to you as well.

-D

-- 

If your company is not involved in something called "ISO 9000" you
probably have no idea what it is.  If your company _is_ involved in ISO
9000 then you definitely have no idea what it is.
                                (Scott Adams - The Dilbert principle)



From tescoil@irtc.net  Tue Nov 27 02:07:35 2001
From: tescoil@irtc.net (Tesla Coil)
Date: Mon, 26 Nov 2001 20:07:35 -0600
Subject: [Tutor] Biology and introductory programming?
References: <Pine.LNX.4.21.0111261630590.24196-100000@hkn.eecs.berkeley.edu>
Message-ID: <3C02F567.267D0757@irtc.net>

On 26 Nov 2001, Danny Yoo wrote:
> Just out of curiosity, how many of us here have an 
> interest in "bioinformatics"?  I've just bought the
> book "Beginning Perl for Bioinformatics", and it
> appears to be an introductory test for biologists
> who are trying to smash their brains against Perl.
>  *grin*

Have you seen http://biopython.org ?



From mgoodfellow@usa.net  Tue Nov 27 02:10:11 2001
From: mgoodfellow@usa.net (Michael Goodfellow)
Date: 26 Nov 2001 21:10:11 EST
Subject: [Tutor] Re: Editors - IDLE
Message-ID: <20011127021011.24504.qmail@uadvg009.cms.usa.net>

Nice, free editor:
  =

http://www.jedit.org/

And there's a plugin to do FTP and WebDAV, I believe.  =

 =




____________________________________________________________________
Get free e-mail and a permanent address at http://www.amexmail.com/?A=3D1=



From urnerk@qwest.net  Tue Nov 27 02:53:22 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Mon, 26 Nov 2001 18:53:22 -0800
Subject: [Tutor] IDLE as battery included
In-Reply-To: <20011126205734.A28649@harmony.cs.rit.edu>
References: <4.2.0.58.20011126173511.00a84dc0@pop3.norton.antivirus>
 <20011125180413.A19978@sill.silmarill.org>
 <20011125222027.A27092@harmony.cs.rit.edu>
 <20011125222733.A20757@sill.silmarill.org>
 <20011125224619.A27150@harmony.cs.rit.edu>
 <20011125235037.A20889@sill.silmarill.org>
 <4.2.0.58.20011126120409.00c3ac20@pop3.norton.antivirus>
 <4.2.0.58.20011126150040.00a3cf00@pop3.norton.antivirus>
 <4.2.0.58.20011126161132.00c46c40@pop3.norton.antivirus>
 <4.2.0.58.20011126171942.00a86100@pop3.norton.antivirus>
 <4.2.0.58.20011126173511.00a84dc0@pop3.norton.antivirus>
Message-ID: <4.2.0.58.20011126184801.00a85730@pop3.norton.antivirus>

>
>I am certain that you can specifiy the colors to use for any given
>highlight group to get the colors you prefer.  I see the command
>"colorscheme" mentioned right below the "highlight" command in the
>help file.  That will likely be helpful to you as well.
>
>-D

Thanks to you and Andrei for tech and moral support. Vim is
fun.

I hacked together some silliness to ease the transition.
IDLE.vim, in the colors folder, now appears on the colors
selection list.  With Python syntax enabled, it makes
everything look comfortably IDLE-like.  It's not meant
for use as a generic color-scheme though -- just an
idiosyncratic "enhancement" for personal use.

=======
" Vim color file
" Maintainer:   Kirby Urner <urnerk@qwest.net>
" Last Change:  2001 Nov 26

" This is the IDLE color scheme.  It's a quick hack to make Python
" files have colors similar to the ones we find in IDLE.

hi clear Normal
set bg&

" Remove all existing highlighting and set the defaults.
hi clear

" Load the syntax highlighting defaults, if it's enabled.
if exists("syntax_on")
   syntax reset
endif

let colors_name = "IDLE"
hi pythonStatement         guifg=#FF6600
hi pythonConditional      guifg=#FF6600
hi pythonOperator         guifg=#FF6600
hi pythonPreCondit        guifg=#FF6600
hi pythonRepeat           guifg=#FF6600
hi pythonComment          guifg=#FF0000
hi pythonString           guifg=#339900
hi pythonFunction         guifg=#0000CC
" vim: sw=2

=======

Kirby



From dsh8290@rit.edu  Tue Nov 27 03:18:07 2001
From: dsh8290@rit.edu (dman)
Date: Mon, 26 Nov 2001 22:18:07 -0500
Subject: [Tutor] Re: Editors - IDLE
In-Reply-To: <20011127021011.24504.qmail@uadvg009.cms.usa.net>; from mgoodfellow@usa.net on Mon, Nov 26, 2001 at 09:10:11PM -0500
References: <20011127021011.24504.qmail@uadvg009.cms.usa.net>
Message-ID: <20011126221807.B28913@harmony.cs.rit.edu>

On Mon, Nov 26, 2001 at 09:10:11PM -0500, Michael Goodfellow wrote:
| Nice, free editor:
|   
| http://www.jedit.org/

It has a plugin to embed Jython, the Python interpreter written in
Java.  This allows scripting the editor with Python, similar to what
vim does.  The main downside is the overhead of Java.  I have no
personal experience with this editor, though.

-D

-- 

If any of you lacks wisdom, he should ask God, who gives generously to
all without finding fault, and it will be given to him.  But when he
asks he must believe and not doubt, because he who doubts is like a wave
of the sea, blown and tossed by the wind.
        James 1:5-6



From ylee12@uiuc.edu  Tue Nov 27 03:32:03 2001
From: ylee12@uiuc.edu (Young-Jin Lee)
Date: Mon, 26 Nov 2001 21:32:03 -0600
Subject: [Tutor] [Q] list and loop
Message-ID: <019a01c176f4$14ccabe0$95757e82@visit2>

Hi, I'd like to how to effectively create a list out of two lists.
I have two lists, list1 = [ 1, 2, 3, 4, 5, .... 10] and list = [ 10, 20, 30,
40, .., 100]. I want to create another list out of these two lists such that
list3 = [ (1,10), (2,20), (3,30), ..., (10, 100)].
I think there must be an elegant way in python using for loop, but I
couldn't figure it out.
Thanks in advance.

YJ



From mark21rowe@yahoo.com  Tue Nov 27 03:37:31 2001
From: mark21rowe@yahoo.com (Mark Rowe)
Date: Mon, 26 Nov 2001 19:37:31 -0800 (PST)
Subject: [Tutor] [Q] list and loop
In-Reply-To: <019a01c176f4$14ccabe0$95757e82@visit2>
Message-ID: <20011127033731.97837.qmail@web13806.mail.yahoo.com>

 
 

__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1


From mark21rowe@yahoo.com  Tue Nov 27 03:37:35 2001
From: mark21rowe@yahoo.com (Mark Rowe)
Date: Mon, 26 Nov 2001 19:37:35 -0800 (PST)
Subject: [Tutor] [Q] list and loop
In-Reply-To: <019a01c176f4$14ccabe0$95757e82@visit2>
Message-ID: <20011127033735.4559.qmail@web13805.mail.yahoo.com>

Hey,

That can be done as follows:

list1 = range(1, 11)
list2 = range(10, 110, 10)
list3 = zip(list1, list2)

Mark Rowe

__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1


From karthikg@aztec.soft.net  Tue Nov 27 03:57:56 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Tue, 27 Nov 2001 09:27:56 +0530
Subject: [Tutor] [Q] list and loop
In-Reply-To: <NEBBJNMDEKBIBCMCNMBDIEPGCJAA.karthikg@aztec.soft.net>
Message-ID: <NEBBJNMDEKBIBCMCNMBDMEPGCJAA.karthikg@aztec.soft.net>

try this,

map(None,list1,list2)

karthik


-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Young-Jin Lee
Sent: Tuesday, November 27, 2001 9:02 AM
To: tutor@python.org
Subject: [Tutor] [Q] list and loop


Hi, I'd like to how to effectively create a list out of two lists.
I have two lists, list1 = [ 1, 2, 3, 4, 5, .... 10] and list = [ 10, 20, 30,
40, .., 100]. I want to create another list out of these two lists such that
list3 = [ (1,10), (2,20), (3,30), ..., (10, 100)].
I think there must be an elegant way in python using for loop, but I
couldn't figure it out.
Thanks in advance.

YJ


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



From urnerk@qwest.net  Tue Nov 27 05:05:47 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Mon, 26 Nov 2001 21:05:47 -0800
Subject: [Tutor] [Q] list and loop
In-Reply-To: <019a01c176f4$14ccabe0$95757e82@visit2>
Message-ID: <4.2.0.58.20011126205909.00a80510@pop3.norton.antivirus>

>
>I think there must be an elegant way in python using for loop, but I
>couldn't figure it out.
>Thanks in advance.
>
>YJ

Yeah, zip is what you want:

   >>> list1 = [1,2,3,4]
   >>> list2 = [10,20,30,40]
   >>> zip(list1,list2)
   [(1, 10), (2, 20), (3, 30), (4, 40)]

A way to do it with list comprehension would be:

   >>> [(list1[i],list2[i]) for i in range(len(list1))]
   [(1, 10), (2, 20), (3, 30), (4, 40)]

In a classic loop:

   >>> def mkzip(list1,list2):
           output = []
           for i in range(len(list1)):
              output.append((list1[i],list2[i]))
           return output

   >>> mkzip(list1,list2)
   [(1, 10), (2, 20), (3, 30), (4, 40)]

And then there's the fine map solution already posted:

   >>> map(None,list1,list2)
   [(1, 10), (2, 20), (3, 30), (4, 40)]

All of these assume your lists are the same length.
If not, you have more work to do.

Kirby




From pythonpython@hotmail.com  Tue Nov 27 06:28:44 2001
From: pythonpython@hotmail.com (HY)
Date: Tue, 27 Nov 2001 15:28:44 +0900
Subject: [Tutor] (no subject)
Message-ID: <OE58frY7eRFQ8gLSoX700005cf6@hotmail.com>

Could you please tell me where I can get detailed info on PyGreSQL?


From pythonpython@hotmail.com  Tue Nov 27 06:34:08 2001
From: pythonpython@hotmail.com (HY)
Date: Tue, 27 Nov 2001 15:34:08 +0900
Subject: [Tutor] module for dbase?
Message-ID: <OE56J9sgg2sdsTYIemR0000a379@hotmail.com>

Is there a python module for dBase files?


From urnerk@qwest.net  Tue Nov 27 06:49:01 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Mon, 26 Nov 2001 22:49:01 -0800
Subject: [Tutor] module for dbase?
In-Reply-To: <OE56J9sgg2sdsTYIemR0000a379@hotmail.com>
Message-ID: <4.2.0.58.20011126224302.00a8fc40@pop3.norton.antivirus>

At 03:34 PM 11/27/2001 +0900, you wrote:
>Is there a python module for dBase files?

Yes, I've seen one somewhere.  Maybe didn't handle all
the latest field types.  Let's see if I can find
it.... Well, here's a useful post by Alex Martelli,
a Python guru:

http://aspn.activestate.com/ASPN/Mail/Message/python-list/758062

And here's more than you wanted to know on the structure
of DBFs, just in case you end up wanting to roll your
own.

Kirby




From lep@aber.ac.uk  Tue Nov 27 10:20:52 2001
From: lep@aber.ac.uk (Leighton Pritchard)
Date: Tue, 27 Nov 2001 10:20:52 +0000
Subject: [Tutor] Re: Biology and introductory programming?
In-Reply-To: <E168XWX-0004sF-00@mail.python.org>
Message-ID: <5.1.0.14.0.20011127095644.03051b50@pophost.aber.ac.uk>

At 20:59 26/11/01, you wrote:
[Danny]
>Just out of curiosity, how many of us here have an interest in
>"bioinformatics"?

It's been my day-job for the last six years <grin>. As a word, it doesn't 
half cover a lot of ground, from designing algorithms, to performing 
web-based searches.

>Using molecular biology as a motivater for
>learning a programming language looks really exciting!

You'd be surprised how many molecular biologists are still put off by it, 
or the thought of anything maths-based :(. At our university we're trying 
to stress to the undergrads the mathematical aspects as much as possible in 
the courses, and the better students are 'getting it', but many still just 
moan.

On the other hand, the only reason I started to program was because no-one 
else had written the software I wanted. Bioinformatics was the only 
motivator for programming that I had :)

For motivated students, though, I think it's a very good idea. In order to 
represent the concepts of mutation or whatever in a program, they have to 
understand it enough to represent it in an abstract manner. If the language 
itself doesn't get in the way of this understanding, I can see it being 
very helpful.

Finding the staff to teach it might be difficult, mind...

>For example, we can start talking about a DNA fragment:
>[snip] and show how we can "mutate" such an example by zapping it:

As it happens, my current work involves simulating error-prone PCR, which 
does pretty much that - only in a slightly more complicated way :). There's 
a fair amount of (not great) code, so I'll not post it here. My boss might 
not be happy if I did that, either...

>Molecular biology is very much about structure and sequences, so this sort
>of stuff seems easy to approach from a programming standpoint.

Have you seen BioPython? http://biopython.org/ They've covered most of the 
routine ground, especially concerning BLAST searches and the like.

[Kirby]
>PMV is the program I was thinking of.  Anyone on here
>played with it?  Not me (yet), to the best of my
>recollection.

I've not played with it yet, but I'm off to the Scripps website to see what 
it's like...


-- 
Dr Leighton Pritchard AMRSC
T44, Cledwyn Building
Institute of Biological Sciences
University of Wales, Aberystwyth, SY23 3DD
Tel 01970 622353    ext. 2353
PGP public key - http://www.keyserver.net (0x47B4A485)



From alan.gauld@bt.com  Tue Nov 27 12:00:40 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 27 Nov 2001 12:00:40 -0000
Subject: [Tutor] Really Newbie! (fwd)
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C10F@mbtlipnt02.btlabs.bt.co.uk>

> I created this batch file in c:\windows, and it is called 
> 'python.bat'.
> it says exactly this:
> 
> cd c:\python21
> python
> 
> When I open the windows, it fires up python on command.

Unfortunately it also makes the current directory C:\python21
This means if you try to open a file it will look in the 
python21 directory unless you give the full path.

If you set the PATH in AUTOEXEC you get the ability to start 
python from any directory and it will look in that directory 
for files etc - this makes for a much more flexible 
environment IMHO.

Batch files are useful but they aren't always the best solution.

Alan G.


From alan.gauld@bt.com  Tue Nov 27 12:34:14 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 27 Nov 2001 12:34:14 -0000
Subject: [Tutor] IDLE as battery included
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C113@mbtlipnt02.btlabs.bt.co.uk>

> time to get a good feel for using number-command, i.e. you 
> want to go 5 lines down and 4 columns to the right, so you 
> need to hit 5j4l, 

Personally I hardly ever use number commands except for 
trivial distances. For navigating within a line I use f and t
and for moving over lines I use / or ?

If you are using number targets then turning on line numbering 
helps a lot - then you can just use G....

:set nu

A 10 year vi user :-)
And 12 year emacser... :-)

Alan G.


From alan.gauld@bt.com  Tue Nov 27 17:23:59 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Tue, 27 Nov 2001 17:23:59 -0000
Subject: [Tutor] [Q] list and loop
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C11E@mbtlipnt02.btlabs.bt.co.uk>

> I have two lists, list1 = [ 1, 2, 3, 4, 5, .... 10] and list 
> = [ 10, 20, 30,
> 40, .., 100]. I want to create another list out of these two 
> lists such that
> list3 = [ (1,10), (2,20), (3,30), ..., (10, 100)].

list3 = map(None,list1,list2)

Alan G.


From pablo.prieto@dulcesol.es  Tue Nov 27 20:34:35 2001
From: pablo.prieto@dulcesol.es (Pablo Prieto)
Date: Tue, 27 Nov 2001 20:34:35 -0000
Subject: [Tutor] [Q] list and loop
Message-ID: <000b01c17782$ed89a800$156710ac@pablo>

Hello!

I'm Pablo, from Spain.

How can I give time-slices of processing to the OS when I'm stuck in a very
cost-time loop?. I mean, not to freeze the system (NT, you know) while the
loop is on.

By example, something like the function doEvents() in VB

so it would be:

for i in range[NUMBER]:
    aVeryTimeExpensiveFunction()
    doEvents()

Is there an equivalent to doEvents() in Python?

Thanks in advance!!!

Yours sincerely,

Pablo Prieto.



From dsh8290@rit.edu  Tue Nov 27 20:24:10 2001
From: dsh8290@rit.edu (dman)
Date: Tue, 27 Nov 2001 15:24:10 -0500
Subject: [Tutor] Re: how do I sleep?
In-Reply-To: <000b01c17782$ed89a800$156710ac@pablo>; from pablo.prieto@dulcesol.es on Tue, Nov 27, 2001 at 08:34:35PM +0000
References: <000b01c17782$ed89a800$156710ac@pablo>
Message-ID: <20011127152410.B7792@harmony.cs.rit.edu>

On Tue, Nov 27, 2001 at 08:34:35PM +0000, Pablo Prieto wrote:
| Hello!
| 
| I'm Pablo, from Spain.

Hi Pablo.  Just a tip : when posting a question start by composing a
new message with a relevant Subject: line, rather than replying to an
unrelated message.

| How can I give time-slices of processing to the OS when I'm stuck in a very
| cost-time loop?. I mean, not to freeze the system (NT, you know) while the
| loop is on.

What you are looking for is the sleep() function in the time module.
So you would have :

import time
# a long loop
while 1 :
    print "this takes lots of time ;-)"
    time.sleep( 5 )  # 5 seconds, approximately


The disadvantage of doing this is that your long loop now takes a lot
more time (as measured by a clock on the wall).  I don't know about
NT, but a decent kernel will perform the time-slicing between
processes on its own.  For example, if on my linux box I make an
infinite loop (say  'while 1 : pass'), my CPU will be maxed out.  Now
if I try and do something else in another process, that infinite loop
in python only gets part of the CPU and my other stuff gets enough CPU
to run with very little noticeable degradation of performance.

HTH,
-D

-- 

(E)scape (M)eta (A)lt (C)ontrol (S)hift



From fabianchong@softhome.net  Tue Nov 27 14:05:15 2001
From: fabianchong@softhome.net (fabianchong@softhome.net)
Date: Tue, 27 Nov 2001 22:05:15 +0800
Subject: [Tutor] basic command
Message-ID: <003601c1774c$8c19b780$8640bad2@oemcomputer>

This is a multi-part message in MIME format.

------=_NextPart_000_0033_01C1778F.980249C0
Content-Type: text/plain;
	charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable

what is the basic command for python and they function

------=_NextPart_000_0033_01C1778F.980249C0
Content-Type: text/html;
	charset="Windows-1252"
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.4207.2601" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2>what is the basic command for python and they=20
function</FONT></DIV></BODY></HTML>

------=_NextPart_000_0033_01C1778F.980249C0--



From dyoo@hkn.eecs.berkeley.edu  Tue Nov 27 20:46:03 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 27 Nov 2001 12:46:03 -0800 (PST)
Subject: [Tutor] basic command
In-Reply-To: <003601c1774c$8c19b780$8640bad2@oemcomputer>
Message-ID: <Pine.LNX.4.21.0111271238460.17883-100000@hkn.eecs.berkeley.edu>

On Tue, 27 Nov 2001 fabianchong@softhome.net wrote:

> what is the basic command for python and they function

Hi Fabian,


There are a few basic commands that we use when we interact with Python.  
Here's a web site that contains links to a bunch of introduction tutorials
to Python:

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

All of the links there are quite good, especially Alan Gauld's "Learning
to Program" web site:

    http://www.freenetpages.co.uk/hp/alan.gauld/

If you read through any of the tutorials there, you should get a feel for
Python basics.



If English is not your primary language, you may find the "Non-English
Python Resources" to be a useful link for you:

    http://python.org/doc/NonEnglish.html


Is there anything in particular that you'd like to hear more about?  
Please feel free to ask questions here.



From krishnag@purdue.edu  Tue Nov 27 21:29:47 2001
From: krishnag@purdue.edu (ganapathy)
Date: Tue, 27 Nov 2001 16:29:47 -0500
Subject: [Tutor] (no subject)
Message-ID: <002001c1778a$a681a130$790da695@inradyCL114B>

This is a multi-part message in MIME format.

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

Hi,
How do I create a two dimensional list?
                                                                        =
Ganapathy

------=_NextPart_000_001D_01C17760.BA93F8F0
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.4134.600" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>How do I create a two dimensional=20
list?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>&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
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
Ganapathy</FONT></DIV></BODY></HTML>

------=_NextPart_000_001D_01C17760.BA93F8F0--



From lkvam@venix.com  Tue Nov 27 23:23:20 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Tue, 27 Nov 2001 18:23:20 -0500
Subject: [Tutor] (no subject)
References: <002001c1778a$a681a130$790da695@inradyCL114B>
Message-ID: <3C042068.6080702@venix.com>

 >>> d2_list = [ ['C'+str(a)+'_R'+str(b) for a in range(3)] for b in range(4)]
 >>> d2_list
[['C0_R0', 'C1_R0', 'C2_R0'], ['C0_R1', 'C1_R1', 'C2_R1'], ['C0_R2', 'C1_R2', 'C2_R2'], ['C0_R3', 'C1_R3', 'C2_R3']]

This generated a 3-column by 4 row matrix style list.  If you really meant a list
of pairs:
 >>> zip((1,2,3),(4,5,6))
[(1, 4), (2, 5), (3, 6)]

You can create a list element by element:
d2_list = [
	[1,2,3],
	[21,22,23],
	[31,32,33],
	]

I have kind of mixed tuples and lists.  Tuples use parentheses as "delimiters" whereas
lists use square brackets.  Lists are mutable.  Tuples are not.  They are both sequence
types and support most of the same operators.


ganapathy wrote:

> Hi,
> 
> How do I create a two dimensional list?
> 
>                                                                         
> Ganapathy
> 


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

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



From virketis@fas.harvard.edu  Tue Nov 27 23:38:52 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Tue, 27 Nov 2001 18:38:52 -0500
Subject: [Tutor] (no subject)
In-Reply-To: <002001c1778a$a681a130$790da695@inradyCL114B>
Message-ID: <200111272338.fARNc7l07281@smtp2.fas.harvard.edu>

--=====================_11117444==_.ALT
Content-Type: text/plain; charset="us-ascii"

Hi,

I am not quite sure what you mean by "two-dimensional" list, so I'll just show
what I would think of as a 2D list myself. Consider this:

>>> L = [[1, 2, 3], [4, 5,6], [7, 8, 9]]

This list of three list could be seen as a rough replication of the matrix:

1 2 3
4 5 6
7 8 9

The list can be indexed somewhat like a matrix:

>>> print L[1][2]
2

We asked for the first row and second column, and got the right number. This
could do the job for you. However, this list-array is not quite as neat to
work
with as a Matlab matrix, for instance, partly because it was intended to be a
more general thing than that. For real mathematical array implemention, check
out the Numeric Python module http://numpy.sourceforge.net/. There is also an
array datatype available through the array.py module, but at first glance it
seems like a subset of the list datatype. NumPy is probably the way to go.

Cheers, 

Pijus
------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis

--=====================_11117444==_.ALT
Content-Type: text/html; charset="us-ascii"

<html>
Hi,<br>
<br>
I am not quite sure what you mean by &quot;two-dimensional&quot; list, so
I'll just show what I would think of as a 2D list myself. Consider
this:<br>
<br>
&gt;&gt;&gt; L = [[1, 2, 3], [4, 5,6], [7, 8, 9]]<br>
<br>
This list of three list could be seen as a rough replication of the
matrix:<br>
<br>
1 2 3<br>
4 5 6<br>
7 8 9<br>
<br>
The list can be indexed somewhat like a matrix:<br>
<br>
&gt;&gt;&gt; print L[1][2]<br>
2<br>
<br>
We asked for the first row and second column, and got the right number.
This could do the job for you. However, this list-array is not quite as
neat to work with as a Matlab matrix, for instance, partly because it was
intended to be a more general thing than that. For real mathematical
array implemention, check out the Numeric Python module
<a href="http://numpy.sourceforge.net/" eudora="autourl"><font color="#0000FF"><u>http://numpy.sourceforge.net/</a></font></u><font color="#000000">.
There is also an array datatype available through the array.py module,
but at first glance it seems like a subset of the list datatype. NumPy is
probably the way to go.<br>
<br>
Cheers, <br>
<br>
Pijus</font><br>
<div>------------------------------------------------------------</div>
<div>PGP PUBLIC KEY:
<a href="http://www.fas.harvard.edu/~virketis/links" EUDORA=AUTOURL>www.fas.harvard.edu/~virketis/links</a></div>
<div>My weblog:
<a href="http://www.fas.harvard.edu/~virketis" EUDORA=AUTOURL>www.fas.harvard.edu/~virketis</a></div>
</html>

--=====================_11117444==_.ALT--



From ak@silmarill.org  Tue Nov 27 23:44:09 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Tue, 27 Nov 2001 18:44:09 -0500
Subject: [Tutor] IDLE as battery included
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66C113@mbtlipnt02.btlabs.bt.co.uk>
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C113@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <20011127184409.A28794@sill.silmarill.org>

On Tue, Nov 27, 2001 at 12:34:14PM -0000, alan.gauld@bt.com wrote:
> > time to get a good feel for using number-command, i.e. you 
> > want to go 5 lines down and 4 columns to the right, so you 
> > need to hit 5j4l, 
> 
> Personally I hardly ever use number commands except for 
> trivial distances. For navigating within a line I use f and t
> and for moving over lines I use / or ?

Well, I use number commands for up to 7x movements, and /, ? and f, w
for the rest.. Also, {} and () are indispensible.

> 
> If you are using number targets then turning on line numbering 
> helps a lot - then you can just use G....
> 
> :set nu

Yes, that's a good idea.. gg is even better, no reaching for the shift
button ;P Too bad nu takes up alot of space on the left. 7 spaces even
when the highest line nubmer takes only 2 spaces! I hope this can be
changed somehow..

> 
> A 10 year vi user :-)
> And 12 year emacser... :-)
> 
> Alan G.

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


From dsh8290@rit.edu  Wed Nov 28 00:02:07 2001
From: dsh8290@rit.edu (dman)
Date: Tue, 27 Nov 2001 19:02:07 -0500
Subject: [Tutor] IDLE as battery included
In-Reply-To: <20011127184409.A28794@sill.silmarill.org>; from sill@optonline.net on Tue, Nov 27, 2001 at 06:44:09PM -0500
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C113@mbtlipnt02.btlabs.bt.co.uk> <20011127184409.A28794@sill.silmarill.org>
Message-ID: <20011127190207.A8678@harmony.cs.rit.edu>

On Tue, Nov 27, 2001 at 06:44:09PM -0500, Andrei Kulakov wrote:
| On Tue, Nov 27, 2001 at 12:34:14PM -0000, alan.gauld@bt.com wrote:

| > If you are using number targets then turning on line numbering 
| > helps a lot - then you can just use G....
| > 
| > :set nu
| 
| Yes, that's a good idea.. gg is even better, no reaching for the shift
| button ;P Too bad nu takes up alot of space on the left. 7 spaces even
| when the highest line nubmer takes only 2 spaces! I hope this can be
| changed somehow..

This is one of the main reasons I don't use that feature.  Also, I'm
not used to seeing the numbers on the left.

However, there was a patch posted to vim-dev recently to allow
adjusting the width of the column used for the numbers.  Care to test
it :-)?

| > A 10 year vi user :-)
| > And 12 year emacser... :-)

Is this in parallel or in series?  I learned 'vi' first, but I only
knew the basics and Sun's /bin/vi is horrible for coding.  Then I used
emacs for a while, but switched to vim when my labs were in a room
with windows and we weren't allowed to install anything (vim fits on a
floppy).  I very quickly forgot most of the emacs commands I knew, and
I also learned how to configure vim for comfortable coding.  I've
since tried some IDEs like Code Warrior, JBuilder, NetBeans, and Source
Navigator, but vim is still the best (IMO, obviously).

-D

-- 

The heart is deceitful above all things
    and beyond cure.
    Who can understand it?

I the Lord search the heart
    and examine the mind,
to reward a man according to his conduct,
    according to what his deeds deserve.

        Jeremiah 17:9-10



From ak@silmarill.org  Wed Nov 28 00:07:50 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Tue, 27 Nov 2001 19:07:50 -0500
Subject: [Tutor] IDLE as battery included
In-Reply-To: <20011127190207.A8678@harmony.cs.rit.edu>
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C113@mbtlipnt02.btlabs.bt.co.uk>
 <20011127184409.A28794@sill.silmarill.org>
 <20011127190207.A8678@harmony.cs.rit.edu>
Message-ID: <20011127190750.A28920@sill.silmarill.org>

On Tue, Nov 27, 2001 at 07:02:07PM -0500, dman wrote:
> On Tue, Nov 27, 2001 at 06:44:09PM -0500, Andrei Kulakov wrote:
> | On Tue, Nov 27, 2001 at 12:34:14PM -0000, alan.gauld@bt.com wrote:
> 
> | > If you are using number targets then turning on line numbering 
> | > helps a lot - then you can just use G....
> | > 
> | > :set nu
> | 
> | Yes, that's a good idea.. gg is even better, no reaching for the shift
> | button ;P Too bad nu takes up alot of space on the left. 7 spaces even
> | when the highest line nubmer takes only 2 spaces! I hope this can be
> | changed somehow..
> 
> This is one of the main reasons I don't use that feature.  Also, I'm
> not used to seeing the numbers on the left.
> 
> However, there was a patch posted to vim-dev recently to allow
> adjusting the width of the column used for the numbers.  Care to test
> it :-)?

Well, I'd rather have it grow to the width of the widest line number..
If there's 100 lines, it should be 3 spaces wide, and so on. This patch
only lets you hard-set it?

> 
> | > A 10 year vi user :-)
> | > And 12 year emacser... :-)
> 
> Is this in parallel or in series?  I learned 'vi' first, but I only
> knew the basics and Sun's /bin/vi is horrible for coding.  Then I used
> emacs for a while, but switched to vim when my labs were in a room
> with windows and we weren't allowed to install anything (vim fits on a
> floppy).  I very quickly forgot most of the emacs commands I knew, and
> I also learned how to configure vim for comfortable coding.  I've
> since tried some IDEs like Code Warrior, JBuilder, NetBeans, and Source
> Navigator, but vim is still the best (IMO, obviously).
> 
> -D
> 
> -- 
> 
> The heart is deceitful above all things
>     and beyond cure.
>     Who can understand it?
> 
> I the Lord search the heart
>     and examine the mind,
> to reward a man according to his conduct,
>     according to what his deeds deserve.
> 
>         Jeremiah 17:9-10
> 
> 
> _______________________________________________
> 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 dsh8290@rit.edu  Wed Nov 28 00:13:37 2001
From: dsh8290@rit.edu (dman)
Date: Tue, 27 Nov 2001 19:13:37 -0500
Subject: [Tutor] IDLE as battery included
In-Reply-To: <20011127190750.A28920@sill.silmarill.org>; from sill@optonline.net on Tue, Nov 27, 2001 at 07:07:50PM -0500
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C113@mbtlipnt02.btlabs.bt.co.uk> <20011127184409.A28794@sill.silmarill.org> <20011127190207.A8678@harmony.cs.rit.edu> <20011127190750.A28920@sill.silmarill.org>
Message-ID: <20011127191337.A8716@harmony.cs.rit.edu>

On Tue, Nov 27, 2001 at 07:07:50PM -0500, Andrei Kulakov wrote:
| On Tue, Nov 27, 2001 at 07:02:07PM -0500, dman wrote:
| > On Tue, Nov 27, 2001 at 06:44:09PM -0500, Andrei Kulakov wrote:
| > | On Tue, Nov 27, 2001 at 12:34:14PM -0000, alan.gauld@bt.com wrote:
| > 
| > | > If you are using number targets then turning on line numbering 
| > | > helps a lot - then you can just use G....
| > | > 
| > | > :set nu
| > | 
| > | Yes, that's a good idea.. gg is even better, no reaching for the shift
| > | button ;P Too bad nu takes up alot of space on the left. 7 spaces even
| > | when the highest line nubmer takes only 2 spaces! I hope this can be
| > | changed somehow..
| > 
| > This is one of the main reasons I don't use that feature.  Also, I'm
| > not used to seeing the numbers on the left.
| > 
| > However, there was a patch posted to vim-dev recently to allow
| > adjusting the width of the column used for the numbers.  Care to test
| > it :-)?
| 
| Well, I'd rather have it grow to the width of the widest line number..

Sure.

| If there's 100 lines, it should be 3 spaces wide, and so on. This patch
| only lets you hard-set it?

http://groups.yahoo.com/group/vimdev/message/26349

That's what it looks like, but I bet you could write some autocommands
that would make it grow :-).  I don't know which events need to be
caught (or if they are even available right now) but the vim list
could help with that.

-D

-- 

the nice thing about windoze is - it does not just crash,
it displays a dialog box and lets you press 'ok' first.



From mark21rowe@yahoo.com  Wed Nov 28 02:00:42 2001
From: mark21rowe@yahoo.com (Mark Rowe)
Date: Tue, 27 Nov 2001 18:00:42 -0800 (PST)
Subject: [Tutor] (no subject)
In-Reply-To: <200111272338.fARNc7l07281@smtp2.fas.harvard.edu>
Message-ID: <20011128020042.11352.qmail@web13804.mail.yahoo.com>

--- Pijus Virketis <virketis@fas.harvard.edu> wrote:
> Hi,
> 
> I am not quite sure what you mean by
> "two-dimensional" list, so I'll just show
> what I would think of as a 2D list myself. Consider
> this:
> 
> >>> L = [[1, 2, 3], [4, 5,6], [7, 8, 9]]
> 
> This list of three list could be seen as a rough
> replication of the matrix:
> 
> 1 2 3
> 4 5 6
> 7 8 9
> 
> The list can be indexed somewhat like a matrix:
> 
> >>> print L[1][2]
> 2
> 
> We asked for the first row and second column, and
> got the right number. This
> could do the job for you.
[snip]
> Cheers, 
> 
> Pijus
> 

That would actually return 6 in the example that you
used.  This is because sequences are indexed starting
at zero.  Therefore you were probably looking for:

>>> print L[0][1]
2

Mark Rowe

__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1


From virketis@fas.harvard.edu  Wed Nov 28 02:15:33 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Tue, 27 Nov 2001 21:15:33 -0500
Subject: [Tutor] (no subject)
In-Reply-To: <20011128020042.11352.qmail@web13804.mail.yahoo.com>
References: <200111272338.fARNc7l07281@smtp2.fas.harvard.edu>
Message-ID: <200111280214.fAS2Eml17624@smtp2.fas.harvard.edu>

>That would actually return 6 in the example that you
>used.  This is because sequences are indexed starting
>at zero.  Therefore you were probably looking for 

:) Oops. Good call. This goes to show how even a few hours of VB will screw
you over... Now excuse me while I go hide somewhere, red with shame.

-PV 
------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis



From fpeavy@pop.net  Wed Nov 28 02:31:24 2001
From: fpeavy@pop.net (Frank Peavy)
Date: Tue, 27 Nov 2001 18:31:24 -0800
Subject: [Tutor] Newbie: New install of Python 2.1: Syntax Error
Message-ID: <5.1.0.14.0.20011127182504.00aa6710@mail45566.popserver.pop.net>

Using IDLE
Win 98SE installation

I keep getting a syntax error when I try to run the "hello world" program 
listed at the bottom.
In looking through the TUTOR archives I noticed a solution related to 
sys.path that I tried, thinking
that the problems may be related(see below). I thought the problem might be 
related to a PATH problem, but was unsure.
********************************************************
 >>> python hello1.py
SyntaxError: invalid syntax
 >>> import sys
 >>> sys.path()
Traceback (most recent call last):
   File "<pyshell#4>", line 1, in ?
     sys.path()
TypeError: object of type 'list' is not callable
********************************************************
My py below
********************************************************
# File: hello1.py

from Tkinter import *

root = Tk()

w = Label(root, text="Hello, world!")
w.pack()

root.mainloop()



From ak@silmarill.org  Wed Nov 28 03:01:20 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Tue, 27 Nov 2001 22:01:20 -0500
Subject: [Tutor] Newbie: New install of Python 2.1: Syntax Error
In-Reply-To: <5.1.0.14.0.20011127182504.00aa6710@mail45566.popserver.pop.net>
References: <5.1.0.14.0.20011127182504.00aa6710@mail45566.popserver.pop.net>
Message-ID: <20011127220120.A30070@sill.silmarill.org>

On Tue, Nov 27, 2001 at 06:31:24PM -0800, Frank Peavy wrote:
> Using IDLE
> Win 98SE installation
> 
> I keep getting a syntax error when I try to run the "hello world" program 
> listed at the bottom.
> In looking through the TUTOR archives I noticed a solution related to 
> sys.path that I tried, thinking
> that the problems may be related(see below). I thought the problem might be 
> related to a PATH problem, but was unsure.
> ********************************************************
> >>> python hello1.py

You're making a common mistake here - confusing two separate
environments - msdos prompt and python shell. Msdos prompt looks like
this:
C:>
Python shell looks like this:
>>>

To run a python script called hello1.py, you should go to msdos prompt
(it's in your start menu/programs, at the bottom). Then you go to the
dir where that file is, and type python hello1.py.

> SyntaxError: invalid syntax
> >>> import sys
> >>> sys.path()
> Traceback (most recent call last):
>   File "<pyshell#4>", line 1, in ?
>     sys.path()
> TypeError: object of type 'list' is not callable

You shouldn't have typed '()' at the end. '()' is something you put at
the end of a function - a python object that *does* something (i.e.
performs some action). sys.path is a not a function, it's a list - it
simply *holds* some values:

>>> import sys
>>> sys.path
['', '/home/sill/.bin', '/usr/local/lib/python2.1',
'/usr/local/lib/python2.1/plat-linux2',
'/usr/local/lib/python2.1/lib-tk',
'/usr/local/lib/python2.1/lib-dynload',
'/usr/local/lib/python2.1/site-packages', '/usr/local/lib/site-python']


> ********************************************************
> My py below
> ********************************************************
> # File: hello1.py
> 
> from Tkinter import *
> 
> root = Tk()
> 
> w = Label(root, text="Hello, world!")
> w.pack()
> 
> root.mainloop()
> 
> 
> _______________________________________________
> 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 allan.crooks@btinternet.com  Wed Nov 28 03:49:22 2001
From: allan.crooks@btinternet.com (Allan Crooks)
Date: Wed, 28 Nov 2001 03:49:22 -0000
Subject: [Tutor] Language parsing
Message-ID: <3C045EC2.30086.2F21AC3@localhost>

Hi,

I'm planning to write a program which uses configuration files 
similar to those of fetchmail (an example of which can be found 
here: http://www.tuxedo.org/~esr/fetchmail/fetchmail-man.html#24)

I was wondering if anyone could recommend tools to help me 
process the configuration file (something which would require me to 
define a grammar and so on), or whether it's a lot easier to write 
my own parser?

I should point out that I what I intend to write would actually be a 
replacement for fetchmail, so if I could find some simple tool to 
understand it's syntax as well, that would be wonderful. :)

Allan.


From dsh8290@rit.edu  Wed Nov 28 04:32:25 2001
From: dsh8290@rit.edu (dman)
Date: Tue, 27 Nov 2001 23:32:25 -0500
Subject: [Tutor] Language parsing
In-Reply-To: <3C045EC2.30086.2F21AC3@localhost>; from allan.crooks@btinternet.com on Wed, Nov 28, 2001 at 03:49:22AM +0000
References: <3C045EC2.30086.2F21AC3@localhost>
Message-ID: <20011127233225.A9325@harmony.cs.rit.edu>

On Wed, Nov 28, 2001 at 03:49:22AM +0000, Allan Crooks wrote:
| Hi,
| 
| I'm planning to write a program which uses configuration files 
| similar to those of fetchmail (an example of which can be found 
| here: http://www.tuxedo.org/~esr/fetchmail/fetchmail-man.html#24)
| 
| I was wondering if anyone could recommend tools to help me 
| process the configuration file (something which would require me to 
| define a grammar and so on), 

SPARK is pretty popular.  There are others too, just search for "lex"
in the Vaults of Parnassus.

| or whether it's a lot easier to write my own parser?

No.

In my Comp. Sci. 4 class we had a project to make an interpreter in
C++ for a language that was ridiculously simple.  It took quite a bit
of effort in design and implementation (also not using regexes because
I didn't know them at the time, nor do I know of any C++ regex
libraries now).

The following year in my Prog. Lang. Concepts class we were introduced
to Lex and Yacc and given the assignment (not project) to make a
calculator that would support C-style comments and be flexible about
whitespace in the same way all modern programming languages are.
These requirements are extremely similar to the interpreter from CS4,
except the input rules were less strict (the CS4 project required
whitespace around all tokens, etc).  It only took a couple of hours
to implement this program in C because lex and yacc did all the hard
work of parsing and tokenizing the input.

The moral is to go with a parser-generator, don't reinvent the wheel.

(unless the grammar is so ridiculously simple that it isn't a wheel,
but merely a spoke)

| I should point out that I what I intend to write would actually be a 
| replacement for fetchmail, so if I could find some simple tool to 
| understand it's syntax as well, that would be wonderful. :)

The more consistent a grammar is, the easier it is to make a parser.
The fetchmailconf grammar is pretty loose, but I don't think it will
too bad since most of the looseness is in noise words.

HTH,
-D

-- 

the nice thing about windoze is - it does not just crash,
it displays a dialog box and lets you press 'ok' first.



From dyoo@hkn.eecs.berkeley.edu  Wed Nov 28 05:45:05 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Tue, 27 Nov 2001 21:45:05 -0800 (PST)
Subject: [Tutor] Language parsing
In-Reply-To: <20011127233225.A9325@harmony.cs.rit.edu>
Message-ID: <Pine.LNX.4.21.0111272136140.23002-100000@hkn.eecs.berkeley.edu>

On Tue, 27 Nov 2001, dman wrote:

> On Wed, Nov 28, 2001 at 03:49:22AM +0000, Allan Crooks wrote:
>
> | I'm planning to write a program which uses configuration files 
> | similar to those of fetchmail (an example of which can be found 
> | here: http://www.tuxedo.org/~esr/fetchmail/fetchmail-man.html#24)
> | 
> | I was wondering if anyone could recommend tools to help me 
> | process the configuration file (something which would require me to 
> | define a grammar and so on), 
> 
> SPARK is pretty popular.  There are others too, just search for "lex"
> in the Vaults of Parnassus.

SPARK is pretty nice; it's the tool I used to parse propositional phrases
in one of my side projects:

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

One caveat: test your grammar as you work with SPARK.  I think that its
error messages need some... improvement.


Another popular parser tool is YAPPS:

    http://theory.stanford.edu/~amitp/Yapps

and as a side note, Amit Patel's web site is very very cool; he has a lot
of game programming information on his page.



From kimtitu@yahoo.com  Wed Nov 28 07:13:18 2001
From: kimtitu@yahoo.com (Titu Kim)
Date: Tue, 27 Nov 2001 23:13:18 -0800 (PST)
Subject: [Tutor] transform html to pdf
Message-ID: <20011128071318.77923.qmail@web14704.mail.yahoo.com>

Hi,
   I am wondering how to transform a complete html
into downloadable pdf file? If i have a string that is
a complete html page, how can i deal with this
problem? I look at reportlab's examples but there are
not many of them. 

Thanks.

Kim Titu

__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1


From virketis@fas.harvard.edu  Wed Nov 28 07:21:11 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Wed, 28 Nov 2001 02:21:11 -0500
Subject: [Tutor] transform html to pdf
In-Reply-To: <20011128071318.77923.qmail@web14704.mail.yahoo.com>
Message-ID: <200111280720.fAS7KSE23548@smtp3.fas.harvard.edu>

>   I am wondering how to transform a complete html
>into downloadable pdf file? If i have a string that is
>a complete html page, how can i deal with this
>problem? I look at reportlab's examples but there are
>not many of them. 

Hm, doesn't LaTeX have utilities that convert from HMTL to TeX and then to
PDF rather nicely? If you have access to these programs, you could just
call them from Python, using it as the "glue" language. I am not that
familiar with how well Python interacts with LaTeX though, so this is just
an idea rather than a fully informed piece of advice.:)

Pijus
------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis



From kimtitu@yahoo.com  Wed Nov 28 07:32:57 2001
From: kimtitu@yahoo.com (Titu Kim)
Date: Tue, 27 Nov 2001 23:32:57 -0800 (PST)
Subject: [Tutor] transform html to pdf
In-Reply-To: <200111280720.fAS7KSE23548@smtp3.fas.harvard.edu>
Message-ID: <20011128073257.89335.qmail@web14702.mail.yahoo.com>

My html string is created via cgi. So i wish to create
a pdf file that can be downloaded while displaying the
the html page via browser. Calling Latex is a good
approach for me too. Any idea? Thanks.
--- Pijus Virketis <virketis@fas.harvard.edu> wrote:
> >   I am wondering how to transform a complete html
> >into downloadable pdf file? If i have a string that
> is
> >a complete html page, how can i deal with this
> >problem? I look at reportlab's examples but there
> are
> >not many of them. 
> 
> Hm, doesn't LaTeX have utilities that convert from
> HMTL to TeX and then to
> PDF rather nicely? If you have access to these
> programs, you could just
> call them from Python, using it as the "glue"
> language. I am not that
> familiar with how well Python interacts with LaTeX
> though, so this is just
> an idea rather than a fully informed piece of
> advice.:)
> 
> Pijus
>
------------------------------------------------------------
> PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
> My weblog: www.fas.harvard.edu/~virketis
> 


__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1


From virketis@fas.harvard.edu  Wed Nov 28 07:42:44 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Wed, 28 Nov 2001 02:42:44 -0500
Subject: [Tutor] transform html to pdf
In-Reply-To: <20011128073257.89335.qmail@web14702.mail.yahoo.com>
References: <200111280720.fAS7KSE23548@smtp3.fas.harvard.edu>
Message-ID: <200111280742.fAS7g0E25518@smtp3.fas.harvard.edu>

Titu,

>My html string is created via cgi. So i wish to create
>a pdf file that can be downloaded while displaying the
>the html page via browser. Calling Latex is a good
>approach for me too. Any idea? Thanks.

In that case, do check out casehttp://home.planet.nl/~faase009/html2tex.html. 

-P
------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis



From shalehperry@home.com  Wed Nov 28 06:52:23 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Tue, 27 Nov 2001 22:52:23 -0800 (PST)
Subject: [Tutor] Language parsing
In-Reply-To: <3C045EC2.30086.2F21AC3@localhost>
Message-ID: <XFMail.20011127225223.shalehperry@home.com>

import ConfigParser

print ConfigParser.__doc__

Configuration file parser.

A setup file consists of sections, lead by a "[section]" header,
and followed by "name: value" entries, with continuations and such in
the style of RFC 822.

The option values can contain format strings which refer to other values in
the same section, or values in a special [DEFAULT] section.
....
....

you get:

[home]
server = mail.home
user = bob
interval = 5

[hotmail]
server = hotmail.com
user = bill
interval = 12

it is real simple to read and use.


From pablo.prieto@dulcesol.es  Wed Nov 28 10:07:21 2001
From: pablo.prieto@dulcesol.es (Pablo Prieto)
Date: Wed, 28 Nov 2001 10:07:21 -0000
Subject: [Tutor] Re: how do I sleep?
Message-ID: <002e01c177f4$78294260$156710ac@pablo>

Hello again.

>Hi Pablo.  Just a tip : when posting a question start by composing a
>new message with a relevant Subject: line, rather than replying to an
>unrelated message.

Sorry. I forgot to changed it and I sent it .

>import time
># a long loop
>while 1 :
>    print "this takes lots of time ;-)"
>    time.sleep( 5 )  # 5 seconds, approximately
>
>
>The disadvantage of doing this is that your long loop now takes a lot
>more time (as measured by a clock on the wall).  I don't know about
>NT, but a decent kernel will perform the time-slicing between
>processes on its own.

I'm sure you know enough about NT to know it's an indecent kernel :)
Anyway, there must be a way to give control to the NT otherwise it would be
unusable a serious Python program in NT (not to talk about '95 flavour
O.S.'s).

I think I'm gonna search in the API. I'll tell you if something good
happens.

Pablo.



From alan.gauld@bt.com  Wed Nov 28 11:00:44 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Wed, 28 Nov 2001 11:00:44 -0000
Subject: [Tutor] IDLE as battery included
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C121@mbtlipnt02.btlabs.bt.co.uk>

> | > A 10 year vi user :-)
> | > And 12 year emacser... :-)
> 
> Is this in parallel or in series?  

Parallel.

I tend to use emacs for heavy text creation and vi/vim for 
text editing - search and movement etc is much nicer in vi.

Emacs is also better for C/C++ coding with the built in 
integration with gdb and the coompiler(next error etc).


> emacs for a while, but switched to vim when my labs were in a room
> with windows and we weren't allowed to install anything 

I started using vim(as opposed to vi) when I got a PC. For some 
reason emacs doesn't feel right on a PC - which is odd given 
that vi uses the OS commands much more than emacs does!

I now use NTnot which is a lightweight emacs for NT (notgnu 
being the generic version name) but it doesn't syntax color :-(

But vim is now my most commonly used editor on the PC, 
NTnot only gets started if I'm going to do some very long 
plain text work - or something which will require fancy macros, 
vim's macro capabilities are much harder for casual use than 
emacs' C-X (.

BTW I just downloaded vim6 as a result of this thread.
Wow! Lots of changes, nearly all good. 'dired' for vi, 
folding, and color schemes - thanks Kirby for IDLE.vim :-)

Alan G.


From pablo.prieto@dulcesol.es  Wed Nov 28 12:59:47 2001
From: pablo.prieto@dulcesol.es (Pablo Prieto)
Date: Wed, 28 Nov 2001 12:59:47 -0000
Subject: RV: [Tutor] transform html to pdf
Message-ID: <004a01c1780c$8ecee930$156710ac@pablo>

-----Mensaje original-----
De: Pablo Prieto <pablo.prieto@dulcesol.es>
Para: Pijus Virketis <virketis@fas.harvard.edu>
Fecha: miércoles 28 de noviembre de 2001 9:58
Asunto: RE: [Tutor] transform html to pdf


>>>My html string is created via cgi. So i wish to create
>>>a pdf file that can be downloaded while displaying the
>>>the html page via browser. Calling Latex is a good
>>>approach for me too. Any idea? Thanks.
>
>Hi!
>
>I use htmldoc (www.easysw.com)
>
>I think it is in Linux too.
>
>Can be used in interactive mode or batch mode. In VB I call it in this way:
>
>directorio = directory (I use the same location for both .html and
.ps/.pdf)
>fichero = file (I use the same name)
>
>#Landscape PS
>            Shell("c:\archivos de programa\htmldoc\htmldoc.exe --webpage "
&
>_
>                "--no-title --footer . " & "--top 5mm --bottom 5mm --left
>5mm " & _
>                "--landscape -t ps2 -f " & directorio & fichero & ".ps " &
>directorio & _
>                fichero & ".html")
>
>#Portrait PDF
>            Shell("c:\archivos de programa\htmldoc\htmldoc.exe --webpage "
&
>_
>                "--no-title --footer . " & "--top 5mm --bottom 5mm --left
>5mm -f " & _
>                directorio & fichero & ".pdf " & directorio & fichero &
>".html")
>
>#Portrait PS
>            Shell("c:\archivos de programa\htmldoc\htmldoc.exe --webpage "
&
>_
>                "--no-title --footer . " & "--top 5mm --bottom 5mm --left
>5mm -t " & _
>                "ps2 -f " & directorio & fichero & ".ps " & directorio &
>fichero & ".html")
>
>#Landscape PDF
>            Shell("c:\archivos de programa\htmldoc\htmldoc.exe --webpage "
&
>_
>                "--no-title --footer . " & "--top 5mm --bottom 5mm --left
>5mm " & _
>                "--landscape -f " & directorio & fichero & ".pdf " &
>directorio & _
>                fichero & ".html")
>



From Bruce.Lee-Shanok@cognos.com  Wed Nov 28 16:23:08 2001
From: Bruce.Lee-Shanok@cognos.com (Lee-Shanok, Bruce)
Date: Wed, 28 Nov 2001 11:23:08 -0500
Subject: [Tutor] PyList_Append "MemoryError"
Message-ID: <FB15E670DA55D51185350008C786514A0140EA7C@sottexch1.cognos.com>

Hi all,

	I'm trying to append an object to a PyList, so I'm just calling:

	status = PyList_Append(myList,o);

	However, PyList is returning a -1, and the exception I'm getting is
"MemoryError". Now, I'm fairly certainl that myList is a valid list. o is a
PyObject type, and I wanted to delve deeper to try and see what exactly was
wrong... is there any way I can print feedback regarding the contents/status
of a PyObject? Moreover, does anyone have any clues as to what this
"MemoryError" might mean?

Thanks,
Bruce

This message may contain privileged and/or confidential information.  If you
have received this e-mail in error or are not the intended recipient, you
may not use, copy, disseminate, or distribute it; do not open any
attachments, delete it immediately from your system and notify the sender by
e-mail promptly that you have done so.  Thank You.


From glingl@aon.at  Wed Nov 28 17:02:44 2001
From: glingl@aon.at (Gregor Lingl)
Date: Wed, 28 Nov 2001 18:02:44 +0100
Subject: [Tutor] Remind me of ...
Message-ID: <002701c1782e$7f663d00$1664a8c0@mega>

This is a multi-part message in MIME format.

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

Dear Pythonistas!

Several weeks (months) ago somebody (maybe Danny Yoo?
or Alan Gauld?) posted a reference to an interactive=20
online-text-game concerning aspects of computer programming.
Then I didn' know how to use it properly, didn't have
much time and left it.

Now I came across something similar in German and I'd
like to compare those two. But I can' remember neither
the name of the thing nor the reference to it.

Does anybody have it ready?=20

Gregor

------=_NextPart_000_0024_01C17836.E102F8C0
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#ffffff>
<DIV><FONT face=3D"Courier New" size=3D2>Dear Pythonistas!</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Several weeks (months) ago =
somebody (maybe=20
Danny Yoo?</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>or Alan Gauld?) </FONT><FONT=20
face=3D"Courier New" size=3D2>posted a reference to an interactive =
</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>online-text-game </FONT><FONT=20
face=3D"Courier New" size=3D2>concerning aspects of computer=20
programming.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Then I didn' know how to use it =
properly,=20
didn't have</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>much time and left =
it.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Now I came across something =
similar in=20
German and I'd</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>like to compare those two. But =
I can'=20
remember neither</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2>the name of the thing nor the =
reference to=20
it.</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" size=3D2>Does&nbsp;anybody have it=20
ready?&nbsp;</FONT></DIV>
<DIV><FONT face=3D"Courier New" size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D"Courier New" =
size=3D2>Gregor</FONT></DIV></BODY></HTML>

------=_NextPart_000_0024_01C17836.E102F8C0--



From dsh8290@rit.edu  Wed Nov 28 17:32:24 2001
From: dsh8290@rit.edu (dman)
Date: Wed, 28 Nov 2001 12:32:24 -0500
Subject: [Tutor] Re: how do I sleep?
In-Reply-To: <002e01c177f4$78294260$156710ac@pablo>; from pablo.prieto@dulcesol.es on Wed, Nov 28, 2001 at 10:07:21AM +0000
References: <002e01c177f4$78294260$156710ac@pablo>
Message-ID: <20011128123224.B9614@harmony.cs.rit.edu>

On Wed, Nov 28, 2001 at 10:07:21AM +0000, Pablo Prieto wrote:
| Hello again.
| 
| >Hi Pablo.  Just a tip : when posting a question start by composing a
| >new message with a relevant Subject: line, rather than replying to an
| >unrelated message.
| 
| Sorry. I forgot to changed it and I sent it .

Ok, not that big of a deal (if you don't make a habit of it).

| >import time
| ># a long loop
| >while 1 :
| >    print "this takes lots of time ;-)"
| >    time.sleep( 5 )  # 5 seconds, approximately
| >
| >
| >The disadvantage of doing this is that your long loop now takes a lot
| >more time (as measured by a clock on the wall).  I don't know about
| >NT, but a decent kernel will perform the time-slicing between
| >processes on its own.
| 
| I'm sure you know enough about NT to know it's an indecent kernel :)

yeah :-).

| Anyway, there must be a way to give control to the NT otherwise it would be
| unusable a serious Python program in NT (not to talk about '95 flavour
| O.S.'s).
| 
| I think I'm gonna search in the API. I'll tell you if something good
| happens.

I'm not aware of anything like that (in Python or C) other than
"sleep".  If you sleep, then your process isn't doing anything and the
kernel will (should!) give the CPU to another process that is doing
something.  That's what you're looking for, right?

-D

-- 

Contrary to popular belief, Unix is user friendly.
It just happens to be selective about who it makes friends with.
                                               -- Dave Parnas



From fpeavy@pop.net  Wed Nov 28 17:34:26 2001
From: fpeavy@pop.net (Frank Peavy)
Date: Wed, 28 Nov 2001 09:34:26 -0800
Subject: [Tutor] Getting Started; Syntax Error; Bad Command or File Name
In-Reply-To: <E169851-00014Q-00@mail.python.org>
Message-ID: <5.1.0.14.0.20011128092717.00ab17a0@mail45566.popserver.pop.net>

>On Tue, Nov 27, 2001 at 06:31:24PM -0800, Frank Peavy wrote:
> > Using IDLE
> > Win 98SE installation
> >
> > I keep getting a syntax error when I try to run the "hello world" program
> > listed at the bottom.
> > In looking through the TUTOR archives I noticed a solution related to
> > sys.path that I tried, thinking
> > that the problems may be related(see below). I thought the problem 
> might be
> > related to a PATH problem, but was unsure.
> > ********************************************************
> > >>> python hello1.py

Andrei Kulakov wrote:
>You're making a common mistake here - confusing two separate
>environments - msdos prompt and python shell. Msdos prompt looks like
>this:
>C:>
>Python shell looks like this:
> >>>
>
>To run a python script called hello1.py, you should go to msdos prompt
>(it's in your start menu/programs, at the bottom). Then you go to the
>dir where that file is, and type python hello1.py.
>
> > ********************************************************
> > My py below
> > ********************************************************
> > # File: hello1.py
> >
> > from Tkinter import *
> >
> > root = Tk()
> >
> > w = Label(root, text="Hello, world!")
> > w.pack()
> >
> > root.mainloop()
> >

Andrei,
First of all, I hope I am doing this correctly(by responding in this manner).
This is what I did:
1) Start>Programs>MSDOS prompt
2) in the MSDOS box I cd\ to where the hello1.py is located
3) typed:  python hello1.py

4) response was: BAD COMMAND or FILE NAME

Any suggestions?




From urnerk@qwest.net  Wed Nov 28 18:07:40 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Wed, 28 Nov 2001 10:07:40 -0800
Subject: [Tutor] Getting Started; Syntax Error; Bad Command or File
 Name
In-Reply-To: <5.1.0.14.0.20011128092717.00ab17a0@mail45566.popserver.pop
 .net>
References: <E169851-00014Q-00@mail.python.org>
Message-ID: <4.2.0.58.20011128100016.00c3cc50@pop3.norton.antivirus>

>
>Andrei,
>First of all, I hope I am doing this correctly(by responding in this manner).
>This is what I did:
>1) Start>Programs>MSDOS prompt
>2) in the MSDOS box I cd\ to where the hello1.py is located
>3) typed:  python hello1.py
>
>4) response was: BAD COMMAND or FILE NAME
>
>Any suggestions?

Frank --

Easiest to put a path to Python in your AUTOEXEC.BAT and
reboot.

Another option is to write a batch file named PYTHON.BAT in
your subdirectory containing .py files that reads:

    c:\python\python %1 %2
    ^^^^^^^^^^^^^^^^
     whatever is the real path to Python

then go >>> python hello1.py [optional parameter]

In any case, what's happening is your python.exe is in
one directory, and your hello1.py is in another, and
there's no "glue" in your setup to find them.

You can also just go:

    >>> c:\python\python hello1.py

using the real path.  This is only tricky if your real
path contains spaces, e.g. my Python is in
D:\program files\python22\ -- so I have to use quotes.
We hope you didn't get so fancy.

As a final remark, if you're really just starting Python,
and want to learn it well, then my advice is you postpone
the Tk stuff for another time.  Tk is a separate language,
to which Python interfaces by means of the Tkinter module.
It's neither the only graphical widgets toolkit Python
can use, nor necessarily the optimum, but in either case,
you're making the learning curve twice as steep by trying
to grapple with Tk and Python at the same time.

In pure Python, helloworld.py is just:

    print "Hello World"

... quick and easy.

Kirby



From printers@sendme.cz  Wed Nov 28 21:56:20 2001
From: printers@sendme.cz (A)
Date: Wed, 28 Nov 2001 22:56:20 +0100
Subject: [Tutor] KOMODO not working properly
Message-ID: <3C056B94.15574.247DE4@localhost>

Does anyone use KOMODO by ActiveState to write programs 
together with Python and particularly with wxPython?
What experience do you have? It does not work properly for me.
Thanks for reply
Ladislav



From virketis@fas.harvard.edu  Wed Nov 28 22:24:36 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Wed, 28 Nov 2001 17:24:36 -0500
Subject: [Tutor] KOMODO not working properly
In-Reply-To: <3C056B94.15574.247DE4@localhost>
Message-ID: <200111282223.fASMNnl06904@smtp2.fas.harvard.edu>

I have Komodo installed. Works just fine here ... Can you describe what
kinds of problems you're running into?

Pijus

At 10:56 PM 11/28/2001 +0100, you wrote:
>Does anyone use KOMODO by ActiveState to write programs 
>together with Python and particularly with wxPython?
>What experience do you have? It does not work properly for me.
>Thanks for reply
>Ladislav
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor
> 
------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis



From kimtitu@yahoo.com  Wed Nov 28 22:24:59 2001
From: kimtitu@yahoo.com (Titu Kim)
Date: Wed, 28 Nov 2001 14:24:59 -0800 (PST)
Subject: RV: [Tutor] transform html to pdf
In-Reply-To: <004a01c1780c$8ecee930$156710ac@pablo>
Message-ID: <20011128222459.76569.qmail@web14708.mail.yahoo.com>

Thanks for all the information. I appreciate your
help.

Kim Titu
--- Pablo Prieto <pablo.prieto@dulcesol.es> wrote:
> 
> -----Mensaje original-----
> De: Pablo Prieto <pablo.prieto@dulcesol.es>
> Para: Pijus Virketis <virketis@fas.harvard.edu>
> Fecha: miércoles 28 de noviembre de 2001 9:58
> Asunto: RE: [Tutor] transform html to pdf
> 
> 
> >>>My html string is created via cgi. So i wish to
> create
> >>>a pdf file that can be downloaded while
> displaying the
> >>>the html page via browser. Calling Latex is a
> good
> >>>approach for me too. Any idea? Thanks.
> >
> >Hi!
> >
> >I use htmldoc (www.easysw.com)
> >
> >I think it is in Linux too.
> >
> >Can be used in interactive mode or batch mode. In
> VB I call it in this way:
> >
> >directorio = directory (I use the same location for
> both .html and
> .ps/.pdf)
> >fichero = file (I use the same name)
> >
> >#Landscape PS
> >            Shell("c:\archivos de
> programa\htmldoc\htmldoc.exe --webpage "
> &
> >_
> >                "--no-title --footer . " & "--top
> 5mm --bottom 5mm --left
> >5mm " & _
> >                "--landscape -t ps2 -f " &
> directorio & fichero & ".ps " &
> >directorio & _
> >                fichero & ".html")
> >
> >#Portrait PDF
> >            Shell("c:\archivos de
> programa\htmldoc\htmldoc.exe --webpage "
> &
> >_
> >                "--no-title --footer . " & "--top
> 5mm --bottom 5mm --left
> >5mm -f " & _
> >                directorio & fichero & ".pdf " &
> directorio & fichero &
> >".html")
> >
> >#Portrait PS
> >            Shell("c:\archivos de
> programa\htmldoc\htmldoc.exe --webpage "
> &
> >_
> >                "--no-title --footer . " & "--top
> 5mm --bottom 5mm --left
> >5mm -t " & _
> >                "ps2 -f " & directorio & fichero &
> ".ps " & directorio &
> >fichero & ".html")
> >
> >#Landscape PDF
> >            Shell("c:\archivos de
> programa\htmldoc\htmldoc.exe --webpage "
> &
> >_
> >                "--no-title --footer . " & "--top
> 5mm --bottom 5mm --left
> >5mm " & _
> >                "--landscape -f " & directorio &
> fichero & ".pdf " &
> >directorio & _
> >                fichero & ".html")
> >
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1


From urnerk@qwest.net  Thu Nov 29 00:58:51 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Wed, 28 Nov 2001 16:58:51 -0800
Subject: [Tutor] Re: Thanks for your help  :-)
In-Reply-To: <5.1.0.14.0.20011128103022.00a602e0@mail45566.popserver.pop
 .net>
References: <4.2.0.58.20011128100016.00c3cc50@pop3.norton.antivirus>
 <5.1.0.14.0.20011128092717.00ab17a0@mail45566.popserver.pop .net>
 <E169851-00014Q-00@mail.python.org>
Message-ID: <4.2.0.58.20011128164740.0159de60@pop3.norton.antivirus>

>
>1) Since I would like to do development for the Windows environment, would 
>you recommend something other than Tkinter? And, how can I find out about 
>the other libraries(?).?


wxPython is worth a look.  http://wxpython.org/  It's not just for
Windows.

>I think I heard something about PMW(I think Python Mega Widgets), but 
>there are very few tutorials about any of the other 
>tools/libraries/languages. Considering the fact that I am a newbie, I 
>would like to select a tool set that would allow me the most 
>flexibility(including cross platform).

PMW is based on Tk/Tkinter, but does a lot of the work to expand
the widgets set.  If you decide to go with Tk, PMW is definitely
worth adding to your toolkit.

http://pmw.sourceforge.net/doc/starting.html

>2) Based on the solution the two of you provided, it appears that PYTHON 
>pys run in MSDOS mode.
>What about Windows XP?

The easiest way to *start* learning Python, in my opinion, is
to go with the "batteries included" GUI, called IDLE.  It's a
Tk app, and paradoxically that makes it unsuitable for Tk work.

Or, if in Windows, use the ActivePython installation, which is
quite good as well, better in some ways.

I've heard nothing to suggest that either of these has any
problems on XP, but I'm not the one to ask.

In general, when learning Python at first, I suggest not
spending a whole lot of time in a DOS box.  The reason to go
there is if you're trying to run a Tk/PMW app.  But as I was
saying, I think that should be for later (unless, that is,
you're already a quite experienced programmer in some other
language and are ready to dive into GUI-style, events-based
OO right out of the gate).

>3) My intent is to try to develop apps that will be cross 
>platform(although my first target would be the Windows environment). This 
>batch file solution that you provided, seems to be a Windows thing, not a 
>Linux/Unix thing. Will this hinder my ability to produce cross platform 
>applications?
>I know this question is very advanced but I would like to get it right, up 
>front.

Linux is similar, except you can use ! "bang" notation at the top
of a program to tell the OS what interpreter to use.  Then you
can make the programs executables directly, so a single command
(the name of the program), with optional arguments, will work.

>4) Also, I would like to distribute my apps standalone.

You'll have to bundle your app with the Python interpreter if
you can't assume the target machines have Python installed.

>5) I also have some question related to how to approach a PYTHON 
>project(taking into consideration OO). I would like to produce re-usable 
>code, instead of one time only code.

As a learner, you should accept the idea of writing lots of
throwaway code, useful for the learning process, but not
necessarily worth keeping as is.

>Sorry for all the questions. I wasn't sure if I should send these to the 
>"tutor" e-mail address or to you specifically. How do most people ask 
>their questions? Do they pose and respond to them via "tutor" or directly 
>to the person that responded? Which is the best way to handle this? Please 
>advise.

Whatever works for you.

Kirby



From kalle@gnupung.net  Thu Nov 29 01:05:58 2001
From: kalle@gnupung.net (Kalle Svensson)
Date: Thu, 29 Nov 2001 02:05:58 +0100
Subject: [Tutor] Re: Thanks for your help  :-)
In-Reply-To: <4.2.0.58.20011128164740.0159de60@pop3.norton.antivirus>
References: <4.2.0.58.20011128100016.00c3cc50@pop3.norton.antivirus> <5.1.0.14.0.20011128092717.00ab17a0@mail45566.popserver.pop <E169851-00014Q-00@mail.python.org> <4.2.0.58.20011128164740.0159de60@pop3.norton.antivirus>
Message-ID: <20011129020557.B17719@proton.lysator.liu.se>

[Kirby Urner]
> >Sorry for all the questions. I wasn't sure if I should send these to the 
> >"tutor" e-mail address or to you specifically. How do most people ask 
> >their questions? Do they pose and respond to them via "tutor" or directly 
> >to the person that responded? Which is the best way to handle this? Please 
> >advise.
> 
> Whatever works for you.

Well, I suggest you send your questions to the list.  That way, many people
read your questions and you have a better chance of getting a fast response.

Peace,
  Kalle
-- 
[  Laziness, impatience, hubris:  Pick two!  ]
[   International: http://www.gnupung.net/   ]
[ Svenska: http://www.lysator.liu.se/~kalle/ ]


From ak@silmarill.org  Thu Nov 29 01:47:15 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Wed, 28 Nov 2001 20:47:15 -0500
Subject: [Tutor] Getting Started; Syntax Error; Bad Command or File Name
In-Reply-To: <5.1.0.14.0.20011128092717.00ab17a0@mail45566.popserver.pop.net>
References: <E169851-00014Q-00@mail.python.org>
 <5.1.0.14.0.20011128092717.00ab17a0@mail45566.popserver.pop.net>
Message-ID: <20011128204715.B1169@sill.silmarill.org>

On Wed, Nov 28, 2001 at 09:34:26AM -0800, Frank Peavy wrote:
> 
> >On Tue, Nov 27, 2001 at 06:31:24PM -0800, Frank Peavy wrote:
> >> Using IDLE
> >> Win 98SE installation
> >>
> >> I keep getting a syntax error when I try to run the "hello world" program
> >> listed at the bottom.
> >> In looking through the TUTOR archives I noticed a solution related to
> >> sys.path that I tried, thinking
> >> that the problems may be related(see below). I thought the problem 
> >might be
> >> related to a PATH problem, but was unsure.
> >> ********************************************************
> >> >>> python hello1.py
> 
> Andrei Kulakov wrote:
> >You're making a common mistake here - confusing two separate
> >environments - msdos prompt and python shell. Msdos prompt looks like
> >this:
> >C:>
> >Python shell looks like this:
> >>>>
> >
> >To run a python script called hello1.py, you should go to msdos prompt
> >(it's in your start menu/programs, at the bottom). Then you go to the
> >dir where that file is, and type python hello1.py.
> >
> >> ********************************************************
> >> My py below
> >> ********************************************************
> >> # File: hello1.py
> >>
> >> from Tkinter import *
> >>
> >> root = Tk()
> >>
> >> w = Label(root, text="Hello, world!")
> >> w.pack()
> >>
> >> root.mainloop()
> >>
> 
> Andrei,
> First of all, I hope I am doing this correctly(by responding in this 
> manner).
> This is what I did:
> 1) Start>Programs>MSDOS prompt
> 2) in the MSDOS box I cd\ to where the hello1.py is located

If this a typo, never mind, but if not, the actual cd command looks like 
C:\ cd python [if your script is in a directory python]

> 3) typed:  python hello1.py
> 
> 4) response was: BAD COMMAND or FILE NAME

Yes, this means python isn't in the PATH. Please refer to what other
people recommended 'cause I haven't used windows in quite some time and
I forgot how to work with paths there..

Although if I remember right, it's easier to simply associate python
with .py extension (it's done somewhere in options in explorer), and
then you'd simply click on that file in explorer and it'd run. But you
also have to put this line at the end of each script:

raw_input("Hit any key to exit..")

The reason you need it is that normally ms-dos program will run and
immediately close on exit, so all you see is a window that flashes
before your eyes and disappears before you can read it. This command
will pause it until you hit any key.

Does anyone remember how to associate python with .py extension?

> 
> Any suggestions?
> 
> 
> 
> _______________________________________________
> 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 dsh8290@rit.edu  Thu Nov 29 04:10:52 2001
From: dsh8290@rit.edu (dman)
Date: Wed, 28 Nov 2001 23:10:52 -0500
Subject: [Tutor] Re: Thanks for your help  :-)
In-Reply-To: <4.2.0.58.20011128164740.0159de60@pop3.norton.antivirus>; from urnerk@qwest.net on Wed, Nov 28, 2001 at 04:58:51PM -0800
References: <4.2.0.58.20011128100016.00c3cc50@pop3.norton.antivirus> <5.1.0.14.0.20011128092717.00ab17a0@mail45566.popserver.pop.net> <E169851-00014Q-00@mail.python.org> <5.1.0.14.0.20011128103022.00a602e0@mail45566.popserver.pop.net> <4.2.0.58.20011128164740.0159de60@pop3.norton.antivirus>
Message-ID: <20011128231052.A10552@harmony.cs.rit.edu>

On Wed, Nov 28, 2001 at 04:58:51PM -0800, Kirby Urner wrote:
| 
| >
| >1) Since I would like to do development for the Windows environment, would 
| >you recommend something other than Tkinter? And, how can I find out about 
| >the other libraries(?).?
| 
| wxPython is worth a look.  http://wxpython.org/  It's not just for
| Windows.

In addition, PyGTK is very nice, especially when used in conjuction
with glade and libglade.  However, I don't have any experience with it
on a MS platform, so I don't know what sort of hoops need to be jumped
through to set it up.

Personally GTK (and GNOME) is my favorite toolkit, but I will be
giving wxPython a serious look at some point.

| >Sorry for all the questions. I wasn't sure if I should send these to the 
| >"tutor" e-mail address or to you specifically. How do most people ask 
| >their questions? Do they pose and respond to them via "tutor" or directly 
| >to the person that responded? Which is the best way to handle this? Please 
| >advise.

Send to the list unless you think your question is inappropriate for
the list and should be viewed only by one person.  "two are better
than one" and when you send questions to the list you get many people
to look at it and assist.

-D

-- 

If we claim to be without sin, we deceive ourselves and the truth is not
in us.
        I John 1:8



From rufmetal@rogers.com  Thu Nov 29 04:04:18 2001
From: rufmetal@rogers.com (Chris Keelan)
Date: Wed, 28 Nov 2001 23:04:18 -0500
Subject: [Tutor] transform html to pdf
In-Reply-To: <20011128073257.89335.qmail@web14702.mail.yahoo.com>
References: <20011128073257.89335.qmail@web14702.mail.yahoo.com>
Message-ID: <20011129041506.YKUM1625.fep03-mail.bloor.is.net.cable.rogers.com@there>

On Wednesday 28 November 2001 02:32 am, Titu Kim wrote:
> My html string is created via cgi. So i wish to create
> a pdf file that can be downloaded while displaying the
> the html page via browser. Calling Latex is a good
> approach for me too. Any idea? Thanks.

It would help to know which platform you're using.

Are you planning to batch process a bunch of files? If so, you're on your 
own. For a one-off, try printing to a ps file from your browser (install a ps 
printer if you're running winders or just use the "print to file" from any of 
the *nix browsers). You can then either use ps2pdf on the resulting output 
(*nix) or goto http://www.ps2pdf.com/convert/index.htm and do it online.

- Chirs


From danm@ActiveState.com  Thu Nov 29 01:42:48 2001
From: danm@ActiveState.com (Dan Milgram)
Date: Wed, 28 Nov 2001 17:42:48 -0800 (PST)
Subject: [Tutor] Re: KOMODO not working properly
In-Reply-To: <3C056B94.15574.247DE4@localhost>
Message-ID: <Pine.LNX.4.30.0111281741470.18212-100000@latte.ActiveState.com>

On Wed, 28 Nov 2001, A wrote:

> Does anyone use KOMODO by ActiveState to write programs
> together with Python and particularly with wxPython?
> What experience do you have? It does not work properly for me.
> Thanks for reply
> Ladislav
>
>

Ladislav, can you specify what isn't working?

Dan


-- 
Dan Milgram/ActiveState Developer
New! ASPN - ActiveState Programmer Network
Essential programming tools and information
http://www.ActiveState.com/ASPN



From deliberatus@my995internet.com  Thu Nov 29 06:52:40 2001
From: deliberatus@my995internet.com (Kirk Bailey)
Date: Thu, 29 Nov 2001 01:52:40 -0500
Subject: [Tutor] Bleching this snurklish bagonthe side into defenestration
Message-ID: <3C05DB38.588A8068@my995internet.com>

Yep. I am so blech'ed at this snurkling bag on the side I am either
going to defenistrate it, or definistrate MYSELF.

Ok, I want to read data into a dictionary. For the devlopment phase,
from a file, eventually, from the opsys <stdin> as it is being piped to
the program from an alias.

..............BACKGROUND SPEW- skip if not intrested in how a list
works......................

In email, a mail list is an alias feeding to a program, usually also
feeding a command to the program so it knows what list to talk to. (Why
no one reads the list name from the To: field leaves me bonked, but WTH,
there it is.)

Mail lists normally include a list manager program to make them
marginally smarter than a silicon doorknob, and provide assorter
services to the user base, such as refusing from non members, stripping
attachments, performing security functions, and helping the webmaster to
generate beer money with advertisements appended onto messages. Some
even thoughtfully add breif instructions on how to use the service in
the atteched footer.

Lists are built at lest partly in the alias file. A fairly intelligently
built list is commonly designed in this file as:

"listname:"|/www/cgi-bin/programname listname"

everything to the left of ":" is the identity we are talking about, and
everything to the right is where the message is to be fed to by that '|'
(pipe) sysbol, which tells the operatiing system to direct data to some
place or process, in this case the input of a program it must run. (Some
such as majordomo manage to find intresting ways to make this much more
complex with many aliases per list, huge configuration files, and large
clumbersome executables. I will spare you.)

The example feeds the incoming temporary file holding the data directly
to the <stdin> of the program, as if it was blasted at a wide open X =
foo.read("name","r") statement reading a file. Entire damn thing spewed
at the stdin, catch! the 'listname' after the 'programname' is provided
to the program as a command line arguement, as if I had typed

$programname listname

at the command prompt. Yep. Every incoming email lauches a run of a
program in the server. That program eats the message, decides what to do
withit, and does it, usually resulting in 1+ copies being sent, or a
reply going back to the sender telling them to bugger off as
non-members.

Want to store an incoming email to see how it is built? edit aliases in
/etc and add this alias:

mailtrap:">>/var/mailtrap.txt"

Then run the 'newaliases' command to compile the new alias into the
working dictionary your Mail Transmission Agent uses (such as sendmail).
Now you can send a letter there, and then read that file and see how it
is built.

.......................End of background
rant.................................


Opening and reading files I can do fine. Playing sorcery with the
incoming data and loading it correctly digested into the dictionary is
causing me to chew my fingernails to the second nuckle.

I have a letter sitting in the server as a file, all nice and high
church, with a modest attachment even. If anyone actually wants to see
it, I will post it, but it's really very ordinary.

I want it read into a dictionary, which I call 'letter{}'. The idea is
to have it split up into key and value, with the idea of having each
header portion by name, it's value, body, value, and attachment. Yes, as
there is an attachment, this is a multipart mime, although what mute
french street perfomers have to email leaves me totally snurkled,
possibly even pixelated.

When I set out on this project I had no idea of what I was letting
myself in for. Fortunately, these many days later, i can now with great
confidence say I have UTTERLY no Idea of what the hell I am doing. If
anyone sees me runnign past them screaming please email me and tell me
where I was.

Well, not quite. Progress at aquiring basic abilities iscoming along. My
first cgi script (a hello world page) works, and I can do simple things
now, such as input, print, play with simple variables and print
statements, do a few simple string manipulations, and math of course. In
the time it took  me to master the old basic integrated environment
programming editor, I have come from NADA to tyro python programmer. 

Python makes far more sense than anything else I ever saw, but I *WOULD*
hare off after a project that involves some fairly deep sorcery- the end
goal being a simple list server with web interface, and a few special
features.

Ah, thank ERIS for asprin...


(BTW, defenistration is the anchent and time honored method of diposing
a Check Prime minister by assisting him out of a 3rd or higher story
window. With considerable departure velocity.)

I even designed a list with an existing server for the discussion of the
creation of this list program, and it is called listtalk. This link
let's you subscribe to it.

mailto:listtalk@howlermonkey.net?subject=subscribe%20listtalk&body=we%20don'%20need%20no%20steenkin%20body!

Try it.



-- 
Respectfully,
             -Kirk D Bailey (C)2001
              Addme! icq #27840081
end


Within the sweep of his sword, Each man is an Ubar.

http://www.howlermonkey.net/
http://www.sacredelectron.org/


From karthikg@aztec.soft.net  Thu Nov 29 07:53:12 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Thu, 29 Nov 2001 13:23:12 +0530
Subject: [Tutor] Advantage of subclassing UserDict and UserList
In-Reply-To: <002e01c177f4$78294260$156710ac@pablo>
Message-ID: <NEBBJNMDEKBIBCMCNMBDIEEACKAA.karthikg@aztec.soft.net>

hi all,

What are the advantages of subclassing UserDict and UserList classes??

import UserList

class myclass(UserList.UserList):

    def __init__(self):
            UserList.UserList.__init__(self)
    def append(self,item):
            import types
            if type(item) == types.IntType:
                    UserList.UserList.append(self,item)
            else:
                    raise "Sorry only ints!"


ok here i have restricted the user from entering any other type other than
"ints"
by overriding append().

Is there any other advantsge of subclassing these classes other than
imposing such restrictions?.

thanks in advance,
karthik.



From Ecevit.Karakus@aprimus.de  Thu Nov 29 07:58:22 2001
From: Ecevit.Karakus@aprimus.de (Karakus, Ecevit)
Date: Thu, 29 Nov 2001 08:58:22 +0100
Subject: [Tutor] PSYCO ??
Message-ID: <A059E45D9E46D311831200C026FF058E488DBC@nt-exchange-srv>

Hello Python Fans!

Has anybody heard of  "Psyco, the Python Specializing Compiler"
I have read an article in  Daily Python-URL http://www.pythonware.com/daily/

http://homepages.ulb.ac.be/~arigo/psyco/

It sounds very interesting: This tool can (to some degree) compile Python
sourcee
and so achieve vast performance improvements.

Has some one of you experience with  PSYCO ??




From ak@silmarill.org  Thu Nov 29 08:21:38 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Thu, 29 Nov 2001 03:21:38 -0500
Subject: [Tutor] Advantage of subclassing UserDict and UserList
In-Reply-To: <NEBBJNMDEKBIBCMCNMBDIEEACKAA.karthikg@aztec.soft.net>
References: <002e01c177f4$78294260$156710ac@pablo>
 <NEBBJNMDEKBIBCMCNMBDIEEACKAA.karthikg@aztec.soft.net>
Message-ID: <20011129032138.A2275@sill.silmarill.org>

On Thu, Nov 29, 2001 at 01:23:12PM +0530, karthik Guru wrote:
> hi all,
> 
> What are the advantages of subclassing UserDict and UserList classes??
> 
> import UserList
> 
> class myclass(UserList.UserList):
> 
>     def __init__(self):
>             UserList.UserList.__init__(self)
>     def append(self,item):
>             import types
>             if type(item) == types.IntType:
>                     UserList.UserList.append(self,item)
>             else:
>                     raise "Sorry only ints!"
> 
> 
> ok here i have restricted the user from entering any other type other than
> "ints"
> by overriding append().
> 
> Is there any other advantsge of subclassing these classes other than
> imposing such restrictions?.
> 
> thanks in advance,
> karthik.

Yes, you can for example make ordered dict:

class SortedDict(UserDict.UserDict):
    """Sorted dictionary for dict of directories"""
    def keys(self):
        l = self.data.keys()
        l.sort()
        return l
    def items(self):
        l = self.data.items()
        l.sort()
        return l

> 
> 
> _______________________________________________
> 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  Thu Nov 29 10:43:32 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 29 Nov 2001 10:43:32 -0000
Subject: [Tutor] Re: how do I sleep?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C124@mbtlipnt02.btlabs.bt.co.uk>

> >NT, but a decent kernel will perform the time-slicing between
> >processes on its own.
> 
> I'm sure you know enough about NT to know it's an indecent kernel :)

True, although W2K and XP are much better IMHO.

But even NT has proper pre-emptive multi tasking. There is no need 
to yield control as there is on Win3 and to a lesser extent in 
Win9x.

Even in VB on NT there is no need to yield the CPU will get 
its time slice without any work from you.



> Anyway, there must be a way to give control to the NT 
> otherwise it would be unusable a serious Python program 
> in NT 

Not so the OS schedulling is perfectly adequate.

You can call the Windows APIU in NT to do this but its just a stub. 
It doesn't actually do anything, its simply there for 
compatibility with other Windows OS's. Of course if your program 
does want to run on Win3/9 then thats another problem. But even 
then, since most Python programs are batch orioemnted rather 
than GUI/Event driven they don't yield anyway - its only 
when processing Windows Events that VB programms yield control.

You could of course write it in Tkinter or wxPython which then 
allows the event handling scheduller to kick in. But on NT its 
all unnecessary.

Alan g.


From alan.gauld@bt.com  Thu Nov 29 10:52:04 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 29 Nov 2001 10:52:04 -0000
Subject: [Tutor] Remind me of ...
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C125@mbtlipnt02.btlabs.bt.co.uk>

 >Several weeks (months) ago somebody (maybe Danny Yoo? 
 >or Alan Gauld?) posted a reference to an interactive  
 >online-text-game concerning aspects of computer  
 >programming.Then I didn' know how to use it properly,  

It may have been me, I referred to Peter Coads 
Object-Think board game designed to get programmers thinking 
in OO terms. Its not an online game though its an old fashioned 
board game like Monopoly etc...

 >  Does anybody have it ready?  

I don't have a reference to it but I guess a search for Peter 
Coad or 'Object Think' may turn something up. This is quite 
old so dunno if its still available, I saw it in about 
1993-4 time. 

OTOH you might be thinking of something completely different!

Alan g.


From alan.gauld@bt.com  Thu Nov 29 10:55:52 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 29 Nov 2001 10:55:52 -0000
Subject: [Tutor] Re: how do I sleep?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C126@mbtlipnt02.btlabs.bt.co.uk>

> I'm not aware of anything like that (in Python or C) other than
> "sleep".  If you sleep, then your process isn't doing anything and the
> kernel will (should!) give the CPU to another process that is doing
> something.  That's what you're looking for, right?

Kind of. What he's looking for is a call that tells the OS to 
process any other active processes but if there aren't any come 
right back here. In other words only pause if you need to. 
Sleep pauses regardless.

This is only necessary on coopoerative multitasking environments 
like Win3x and Win 9x and early OS/2 and Mac. On Unix, NT etc this 
should not be needed as the kernewl will switch processes 
pre-emptively. (Win 9x will do so too provided the program is 
100% Win32 clean, unfortunately few are which is why so many 
programs still hang for long periods in Win9x...)

Alan g.


From scarblac@pino.selwerd.nl  Thu Nov 29 11:01:42 2001
From: scarblac@pino.selwerd.nl (Remco Gerlich)
Date: Thu, 29 Nov 2001 12:01:42 +0100
Subject: [Tutor] Remind me of ...
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66C125@mbtlipnt02.btlabs.bt.co.uk>; from alan.gauld@bt.com on Thu, Nov 29, 2001 at 10:52:04AM -0000
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C125@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <20011129120142.A18487@pino.selwerd.nl>

On  0, alan.gauld@bt.com wrote:
>  >Several weeks (months) ago somebody (maybe Danny Yoo? 
>  >or Alan Gauld?) posted a reference to an interactive  
>  >online-text-game concerning aspects of computer  
>  >programming.Then I didn' know how to use it properly,  
> 
> It may have been me, I referred to Peter Coads 
> Object-Think board game designed to get programmers thinking 
> in OO terms. Its not an online game though its an old fashioned 
> board game like Monopoly etc...

I recently mentioned a "text adventure" (it's two rooms) that teaches Lisp,
in a Java applet, at http://www.eblong.com/zarf/zplet/lists.html .

-- 
Remco Gerlich


From alan.gauld@bt.com  Thu Nov 29 11:04:12 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 29 Nov 2001 11:04:12 -0000
Subject: [Tutor] Getting Started; Syntax Error; Bad Command or File Na me
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C127@mbtlipnt02.btlabs.bt.co.uk>

> Yes, this means python isn't in the PATH. Please refer to what other
> people recommended 'cause I haven't used windows in quite 
> some time 

Edit AUTOEXEC.BAT.

Add a line:

PATH=%PATH%;C:\Python21   (or whatever the real path to python.exe is!)

> Although if I remember right, it's easier to simply associate python
> with .py extension (it's done somewhere in options in explorer), and

> Does anyone remember how to associate python with .py extension?

You should really set PATH too IMHO so that you can launch python from 
any command line anywhere.

To assoiciate files either:

Shift right-click on a .py file and choose openwith
Find python.exe and then check the box that says 
'always use this program' or something like it.

OR

Go to Windows Explorer and Open View||FolderOptions...

In the dialog select the FileTypes tab andif .py is a registered 
type ensure it points at python.exe (and check .pyw points at 
pythonw.exe while at it!)

If not create the two new types and then associate them with 
their appropriate programs.

The installer should have done all of this except setting 
the PATH. You can quickly tell by looking at the icon next 
to a .py file. If it shows a snake you are already set up 
correctly. In which case just double clkick the file to 
run it. Add the raw_input... line if necessary.

Alan G.



From alan.gauld@bt.com  Thu Nov 29 11:06:46 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 29 Nov 2001 11:06:46 -0000
Subject: [Tutor] Re: Thanks for your help  :-)
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C128@mbtlipnt02.btlabs.bt.co.uk>

> >2) Based on the solution the two of you provided, it appears 
> that PYTHON pys run in MSDOS mode.

No it runs under the Windows Script Host
That has a command line interpreter(csrcipt.exe) and a 
Windows one wscript.exe. Both work finev on XP - in fact XP 
enhanced WSH capability.

Alan G.


From virketis@fas.harvard.edu  Thu Nov 29 13:05:45 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Thu, 29 Nov 2001 08:05:45 -0500
Subject: Fwd: Re: [Tutor] KOMODO not working properly
Message-ID: <200111291304.fATD4wr26170@smtp1.fas.harvard.edu>

--=====================_111074614==_.ALT
Content-Type: text/plain; charset="us-ascii"


>
> Dear Ladislav, 


First, let me simply forward your problem message to the whole list. Then I'll
try to figure out what's wrong too ... :)

-P


>
> On 28 Nov 2001, at 17:24, Pijus Virketis wrote: 
>
> > I have Komodo installed. Works just fine here ... Can you describe 
> > what kinds of problems you're running into? 
> > 
> > Pijus 
> > 
> > At 10:56 PM 11/28/2001 +0100, you wrote: 
> > >Does anyone use KOMODO by ActiveState to write programs 
> > >together with Python and particularly with wxPython? 
> > >What experience do you have? It does not work properly for me. 
> > >Thanks for reply 
> > >Ladislav 
> > > 
>
> Dear Pijus Virketis, 
> Thank you for your email. 
> I have this, very simple example 
>
> from wxPython.wx import * 
>
> class MyApp(wxApp): 
>     def OnInit(self): 
>         frame = wxFrame(NULL, -1, "Hello from wxPython") 
>         frame.Show(true) 
>         self.SetTopWindow(frame) 
>         return true 
>
> app = MyApp(0) 
> app.MainLoop() 
>
> The sample code above should create a simple window. 
> It works fine when I run it under DOS or also under another IDE that is a
> part of Python distribution by ActiveState  
>
> But when I start Debugger in KOMODO to run it I can not see any results and 
> KOMODO says, Debugger is running. 
> Thank you for help. 
>
>
>
> I look forward to hearing from you soon. > > Best Regards, Ladislav
Blazek( Mr.) > > BMA TRADING Ltd. email:export@sendme.cz Fax:/Tel +420 506
447921 Tel:+420 506 447920, +420 602 849309 > > > > </blockquote> <br>>
<div>------------------------------------------------------------</div>>
<div>PGP PUBLIC KEY: <a href="http://www.fas.harvard.edu/~virketis/links"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis/links</a></div>> <div>My
weblog: <a href="http://www.fas.harvard.edu/~virketis"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis</a></div>> </html>


<br><div>------------------------------------------------------------</div><
div>PGP PUBLIC KEY: <a href="http://www.fas.harvard.edu/~virketis/links"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis/links</a></div><div>My weblog:
<a href="http://www.fas.harvard.edu/~virketis"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis</a></div></html>
<div>------------------------------------------------------------</div><div>
PGP PUBLIC KEY: <a href="http://www.fas.harvard.edu/~virketis/links"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis/links</a></div><div>My weblog:
<a href="http://www.fas.harvard.edu/~virketis"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis</a></div></html>
------------------------------------------------------------</div><div>PGP
PUBLIC KEY: <a href="http://www.fas.harvard.edu/~virketis/links"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis/links</a></div><div>My weblog:
<a href="http://www.fas.harvard.edu/~virketis"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis</a></div></html>
<div>PGP PUBLIC KEY: <a href="http://www.fas.harvard.edu/~virketis/links"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis/links</a></div><div>My weblog:
<a href="http://www.fas.harvard.edu/~virketis"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis</a></div></html>
PGP PUBLIC KEY: <a href="http://www.fas.harvard.edu/~virketis/links"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis/links</a></div><div>My weblog:
<a href="http://www.fas.harvard.edu/~virketis"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis</a></div></html>www.fas.harvard
.edu/~virketis/links</a></div><div>My weblog: <a
href="http://www.fas.harvard.edu/~virketis"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis</a></div></html></div><div>My
weblog: <a href="http://www.fas.harvard.edu/~virketis"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis</a></div></html>
<div>My weblog: <a href="http://www.fas.harvard.edu/~virketis"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis</a></div></html>
My weblog: <a href="http://www.fas.harvard.edu/~virketis"
EUDORA=AUTOURL>www.fas.harvard.edu/~virketis</a></div></html>www.fas.harvard
.edu/~virketis</a></div></html></div></html>
</html>
--=====================_111074614==_.ALT
Content-Type: text/html; charset="us-ascii"

<html>
<blockquote type=cite cite>Dear Ladislav, </blockquote><br>
First, let me simply forward your problem message to the whole list. Then
I'll try to figure out what's wrong too ... :)<br>
<br>
-P<br>
<br>
<br>
<font color="#010101"><blockquote type=cite cite>On 28 Nov 2001, at
17:24, Pijus Virketis wrote: <br>
<br>
</font><font color="#7F0000">&gt; I have Komodo installed. Works just
fine here ... Can you describe <br>
&gt; what kinds of problems you're running into? <br>
&gt; <br>
&gt; Pijus <br>
&gt; <br>
&gt; At 10:56 PM 11/28/2001 +0100, you wrote: <br>
&gt; &gt;Does anyone use KOMODO by ActiveState to write programs <br>
&gt; &gt;together with Python and particularly with wxPython? <br>
&gt; &gt;What experience do you have? It does not work properly for me.
<br>
&gt; &gt;Thanks for reply <br>
&gt; &gt;Ladislav <br>
&gt; &gt; <br>
<br>
</font><font color="#000000">Dear Pijus Virketis, <br>
Thank you for your email. <br>
I have this, very simple example <br>
<br>
</font><font face="Times New Roman, Times" color="#FF00FF">from</font><font color="#000000">
wxPython.wx
</font><font color="#FF00FF">import</font><font color="#000000"> * <br>
<br>
</font><font color="#008080">class</font><font color="#000000">
MyApp(wxApp): <br>
&nbsp;&nbsp;&nbsp;
</font><font color="#008080">def</font><font color="#000000">
OnInit(self): <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; frame = wxFrame(NULL, -1,
</font><font color="#FF00FF">&quot;Hello from
wxPython&quot;</font><font color="#000000">) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; frame.Show(true) <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.SetTopWindow(frame) 
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</font><font color="#808080"><b>return</font></b><font color="#000000">
true <br>
<br>
app = MyApp(0) <br>
app.MainLoop() <br>
<br>
The sample code above should create a simple window. <br>
It works fine when I run it under DOS or also under another IDE that is a
part of Python distribution by ActiveState&nbsp; <br>
<br>
But when I start Debugger in KOMODO to run it I can not see any results
and&nbsp; KOMODO says, Debugger is running. <br>
Thank you for help. <br>
<br>
<br>
<br>
</font><pre>I look forward to hearing from you soon. 

Best Regards, Ladislav Blazek( Mr.) 

BMA TRADING Ltd. email:export@sendme.cz Fax:/Tel +420 506 447921 Tel:+420
506 447920, +420 602 849309 



</blockquote> <br>
<div>------------------------------------------------------------</div>
<div>PGP PUBLIC KEY:
<a href="http://www.fas.harvard.edu/~virketis/links" EUDORA=AUTOURL>www.fas.harvard.edu/~virketis/links</a></div>
<div>My weblog:
<a href="http://www.fas.harvard.edu/~virketis" EUDORA=AUTOURL>www.fas.harvard.edu/~virketis</a></div>
</html>

--=====================_111074614==_.ALT--



From karthikg@aztec.soft.net  Thu Nov 29 13:28:55 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Thu, 29 Nov 2001 18:58:55 +0530
Subject: [Tutor] An example of ConfigParser module usage please....
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66C125@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <NEBBJNMDEKBIBCMCNMBDOEEICKAA.karthikg@aztec.soft.net>

hi all,

I read the documentation and found that ConfigParser can be used like
properties file in java. Am unable to put it to use.
A small code snippet would be of great help to me.


This can be a sample entry..

database="octago"
password="octago"
uid="sa"

How to get it back? or how to write it to a properties file 

thanks in advance
karthik.



From karthikg@aztec.soft.net  Thu Nov 29 13:36:31 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Thu, 29 Nov 2001 19:06:31 +0530
Subject: [Tutor] Is there a Python book which gives sample code / usage of all the modules which ship with python???
In-Reply-To: <NEBBJNMDEKBIBCMCNMBDOEEICKAA.karthikg@aztec.soft.net>
Message-ID: <NEBBJNMDEKBIBCMCNMBDGEEJCKAA.karthikg@aztec.soft.net>

or is there a website which lists the code samples??.
Oreilly, manning etc do not publish python related books in India :-(
The only one we have here is "Core Python programming" by Chun.











From Amresh@archeanit.com  Thu Nov 29 13:21:17 2001
From: Amresh@archeanit.com (Amresh kumar)
Date: Thu, 29 Nov 2001 18:51:17 +0530 (IST)
Subject: [Tutor] =?iso-8859-1?Q?Re:_[Tutor]_Is_there_a_Python_book_which_gives_sample_code_/_usage_of_all_the_modules_which_ship_with_python=3F=3F=3F?=
In-Reply-To: <NEBBJNMDEKBIBCMCNMBDGEEJCKAA.karthikg@aztec.soft.net>
References: <NEBBJNMDEKBIBCMCNMBDGEEJCKAA.karthikg@aztec.soft.net>
Message-ID: <1329.192.168.0.21.1007040077.squirrel@mail.archeanit.com>

Hi,
> or is there a website which lists the code samples??.
> Oreilly, manning etc do not publish python related books in India :-(
> The only one we have here is "Core Python programming" by Chun.
>
download dive into python book from www.diveintopythin.org

cheers
amresh

------------------------------------------------
Amresh kumar
lower level programmer
Archean infotech
------------------------------------------------

Computers are like air conditioners.
They stop working when you open Windows




-----------------------------------------
This email was sent using SquirrelMail.
   "Webmail for nuts!"
http://squirrelmail.org/




From pobrien@orbtech.com  Thu Nov 29 14:11:46 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Thu, 29 Nov 2001 08:11:46 -0600
Subject: [Tutor] Is there a Python book which gives sample code / usage of all the modules which ship with python???
In-Reply-To: <NEBBJNMDEKBIBCMCNMBDGEEJCKAA.karthikg@aztec.soft.net>
Message-ID: <NBBBIOJPGKJEKIECEMCBGENFLDAA.pobrien@orbtech.com>

Yes. Python Standard Library by Frederik Lundh does exactly that. You can
read sample pages on Amazon:

http://www.amazon.com/exec/obidos/ASIN/0596000960/qid=1007042737/br=1-12/ref
=br_lf_b_12/102-7173510-4372932

---
Patrick K. O'Brien
Orbtech.com - Your Source For Python Development Services


> -----Original Message-----
> From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
> karthik Guru
> Sent: Thursday, November 29, 2001 7:37 AM
> To: tutor@python.org
> Subject: [Tutor] Is there a Python book which gives sample code / usage
> of all the modules which ship with python???
> Importance: High
>
>
>
> or is there a website which lists the code samples??.
> Oreilly, manning etc do not publish python related books in India :-(
> The only one we have here is "Core Python programming" by Chun.
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor



From karthikg@aztec.soft.net  Thu Nov 29 14:25:47 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Thu, 29 Nov 2001 19:55:47 +0530
Subject: [Tutor] Is there a Python book which gives sample code / usage of all the modules which ship with python???
In-Reply-To: <NEBBJNMDEKBIBCMCNMBDGEEJCKAA.karthikg@aztec.soft.net>
Message-ID: <NEBBJNMDEKBIBCMCNMBDOEEKCKAA.karthikg@aztec.soft.net>

I got it!! thanks.

Let me just post it if it c'd be of some use to a fellow newbie!

This is what i had in the conf.txt file


[server]
database:octago
user:sa
password:blank
[personal]
name:karthik
age:21
company:Aztec

'personal' and 'server' are the sections.

config = ConfigParser.ConfigParser()
config.add_section("server")
config.add_section("personal")

//read the conf file

fname = open("conf.txt","r")
config.readfp(fname)

print config.get("server","database") // under the server section get the
value for the database key
>> octago
print config.get("personal","name")
>>karthik

python is fun :-)

-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
karthik Guru
Sent: Thursday, November 29, 2001 7:07 PM
To: tutor@python.org
Subject: [Tutor] Is there a Python book which gives sample code / usage
of all the modules which ship with python???
Importance: High



or is there a website which lists the code samples??.
Oreilly, manning etc do not publish python related books in India :-(
The only one we have here is "Core Python programming" by Chun.










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



From karthikg@aztec.soft.net  Thu Nov 29 14:31:49 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Thu, 29 Nov 2001 20:01:49 +0530
Subject: [Tutor] An example of ConfigParser module usage please....
In-Reply-To: <NEBBJNMDEKBIBCMCNMBDOEEICKAA.karthikg@aztec.soft.net>
Message-ID: <NEBBJNMDEKBIBCMCNMBDIEELCKAA.karthikg@aztec.soft.net>

I got it!! thanks.

Let me just post it if it c'd be of some use to a fellow newbie!

This is what i had in the conf.txt file
---------

[server]
database:octago
user:sa
password:blank
[personal]
name:karthik
age:21
company:Aztec

---------

'personal' and 'server' are the sections.

config = ConfigParser.ConfigParser()
config.add_section("server")
config.add_section("personal")

//read the conf file

fname = open("conf.txt","r")
config.readfp(fname)

print config.get("server","database") // under the server section get the
value for the database key
>> octago
print config.get("personal","name")
>>karthik

python is fun and simple :-)



From bwinton@tor.dhs.org  Thu Nov 29 14:44:36 2001
From: bwinton@tor.dhs.org (Blake Winton)
Date: Thu, 29 Nov 2001 09:44:36 -0500
Subject: [Tutor] Bleching this snurklish bagonthe side into defenestration
In-Reply-To: <3C05DB38.588A8068@my995internet.com>
Message-ID: <EHEPLGFHKAPDEDKIBONMGEKICBAA.bwinton@tor.dhs.org>

> Opening and reading files I can do fine. Playing sorcery with the
> incoming data and loading it correctly digested into the dictionary is
> causing me to chew my fingernails to the second nuckle.

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

Python: Batteries Are Included.  ;)

> I want it read into a dictionary, which I call 'letter{}'. The idea is
> to have it split up into key and value, with the idea of having each
> header portion by name, it's value, body, value, and attachment. Yes, as
> there is an attachment, this is a multipart mime,

In that case, you might want to check out:
http://www.python.org/doc/current/lib/module-mimetools.html
as well...

Or, for example code:
http://python.sourceforge.net/devel-docs/lib/multifile-example.html

Good luck,
Blake.



From dsh8290@rit.edu  Thu Nov 29 15:27:25 2001
From: dsh8290@rit.edu (dman)
Date: Thu, 29 Nov 2001 10:27:25 -0500
Subject: [Tutor] Re: how do I sleep?
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66C126@mbtlipnt02.btlabs.bt.co.uk>; from alan.gauld@bt.com on Thu, Nov 29, 2001 at 10:55:52AM +0000
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C126@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <20011129102725.A12664@harmony.cs.rit.edu>

On Thu, Nov 29, 2001 at 10:55:52AM +0000, alan.gauld@bt.com wrote:
| > I'm not aware of anything like that (in Python or C) other than
| > "sleep".  If you sleep, then your process isn't doing anything and the
| > kernel will (should!) give the CPU to another process that is doing
| > something.  That's what you're looking for, right?
| 
| Kind of. What he's looking for is a call that tells the OS to 
| process any other active processes but if there aren't any come 
| right back here. In other words only pause if you need to. 
| Sleep pauses regardless.
| 
| This is only necessary on coopoerative multitasking environments 

I see now.

| like Win3x and Win 9x and early OS/2 and Mac. On Unix, NT etc this 
| should not be needed as the kernewl will switch processes 
| pre-emptively. (Win 9x will do so too provided the program is 
| 100% Win32 clean, unfortunately few are which is why so many 
| programs still hang for long periods in Win9x...)

Yeah, I do remember reading that Win9x was a cooperative multitasking
system, and that is (part of) why a single user-land app can destroy
the whole system.

All of my development has either been on Unix or when it was in
Windows it was not windows-specific and yielding wasn't a concern
(either gui based or a simple batch-type script).

-D

-- 

Bugs come in through open windows. Keep Windows shut!



From urnerk@qwest.net  Thu Nov 29 16:22:23 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Thu, 29 Nov 2001 08:22:23 -0800
Subject: [Tutor] Advantage of subclassing UserDict and UserList
In-Reply-To: <20011129032138.A2275@sill.silmarill.org>
References: <NEBBJNMDEKBIBCMCNMBDIEEACKAA.karthikg@aztec.soft.net>
 <002e01c177f4$78294260$156710ac@pablo>
 <NEBBJNMDEKBIBCMCNMBDIEEACKAA.karthikg@aztec.soft.net>
Message-ID: <4.2.0.58.20011129081934.00bc9820@pop3.norton.antivirus>

Andrei Kulakov:


>Yes, you can for example make ordered dict:
>
>class SortedDict(UserDict.UserDict):
>     """Sorted dictionary for dict of directories"""
>     def keys(self):
>         l = self.data.keys()
>         l.sort()
>         return l
>     def items(self):
>         l = self.data.items()
>         l.sort()
>         return l

Note that in 2.2 you can subclass list and dictionary
directly (though I think in 2.2b2 it's dict).  E.g.

    class SortedDict(dictionary):
         _keys = dictionary.keys
         _items = dictionary.items

         def keys(self):
            L = self._keys()
            L.sort()
            return L
         def items(self):
            L = self._items()
            L.sort()
            return L

  >>> b = SortedDict({'D':9,'C':2,'A':1, 'E':5,})
  >>> b._items()
  [('A', 1), ('C', 2), ('E', 5), ('D', 9)]
  >>> b.items()
  [('A', 1), ('C', 2), ('D', 9), ('E', 5)]
  >>> b._keys()
  ['A', 'C', 'E', 'D']
  >>> b.keys()
  ['A', 'C', 'D', 'E']

Kirby



From wilson@visi.com  Thu Nov 29 16:39:11 2001
From: wilson@visi.com (Timothy Wilson)
Date: Thu, 29 Nov 2001 10:39:11 -0600 (CST)
Subject: [Tutor] Catching cheaters with Python
Message-ID: <Pine.GSO.4.21.0111291025310.7869-100000@isis.visi.com>

Greetings all:

As a high school teacher I'm confronted regularly with the problem of
student plagiarism. Students are tempted to submit the same paper to
different instructors, copy large chunks of text from Web sites, and, much
less frequently, purchase research papers online. Google is an amazing tool
for catching the second type. Simply identify a particularly interesting
sentence from the suspected paper, enter the sentence into Google
surroundied by quotes, and bingo, you've got it. It typically takes less
than 10 seconds.

A year or so ago a professor at some university made the news when he wrote
a program that would automatically scan submitted papers and identify
passages that were likely plagiarized from other students. I would like to
extend that to do the following:

1. Check for similarities between submitted papers and
2. Submit suspicious sentences to google for searching.

I've thought that it would be possible to bring all of our students to the
computer lab on the day the paper is due and have them upload their paper
via a Web form. I use Zope here so I could write some code to convert
MSWord-formatted papers to plain text. Students who didn't use Word could
cut and paste their text directly into a textarea on the form.

Does anyone have an hints on something like this? Any modules that would be
particularly useful? Obviously, this could be a huge AI project, but I'm not
interested in that particularly. A brute force approach is all I'm smart 
enough to try. :-) Once I've got the text from their papers I can set it up
to run in the background to run for days if I have to. That said, the more
efficiently the program could identify matching patterns the better.

I'd love to hear others' thoughts on this.

-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 alan.gauld@bt.com  Thu Nov 29 17:12:28 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Thu, 29 Nov 2001 17:12:28 -0000
Subject: [Tutor] Is there a Python book which gives sample code / usag e of
 all the modules which ship with python???
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C12D@mbtlipnt02.btlabs.bt.co.uk>

> Oreilly, manning etc do not publish python related books in India :-(

I'm sure Amazon will be delighted to quote you for shipping.
Until recently ordering from Amazon was the only way to get 
most Manning books in the UK too. More recently they've 
started to appear in bookshops.

> The only one we have here is "Core Python programming" by Chun.

What about New Riders? 
They do the best reference book for what you asked:

Python Essential Reference by Dave Beasley.

However there are no books that provide code samples 
for ALL of the modules, also many modules contain code samples 
in the standard library documents.

Finally try searching the google newsgroup archives, and
the ActiveState archives of the Python mailing lists, there 
are often examples in there.

Alan g.


From thejoness3@home.com  Thu Nov 29 18:29:26 2001
From: thejoness3@home.com (Jeff Jones)
Date: Thu, 29 Nov 2001 13:29:26 -0500
Subject: [Tutor] linux
Message-ID: <000e01c17903$c6f82ae0$fe2c0d18@grapid1.mi.home.com>

This is a multi-part message in MIME format.

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

Sorry about getting off topic here, but beginning to learn programming =
through Python has peaked my interest in Linux. The only operating =
system I have ever used has been windows, and I've been using it since =
the DOS days (except for computer class in the 7th grade when we used =
apple IIc). Not by choice but because that's what has always been there =
when I turned the computer on. Getting to the point... Does anyone know =
of any decent FAQ's etc. for windows users not yet switched to Linux. =
Specifically, which version to use? Thanks in advance for any help.

------=_NextPart_000_000B_01C178D9.DDCE3680
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>Sorry about getting off topic here, but =
beginning=20
to learn programming through Python has peaked my interest in Linux. The =
only=20
operating system I have ever used has been windows, and I've been using =
it since=20
the DOS days (except for computer class in the 7th grade when we used =
apple=20
IIc). Not by choice but because that's what has always been there when I =
turned=20
the computer on. Getting to the point... Does anyone know of any decent =
FAQ's=20
etc. for windows users not yet switched to Linux. Specifically, which =
version to=20
use? Thanks in advance for any help.</FONT></DIV></BODY></HTML>

------=_NextPart_000_000B_01C178D9.DDCE3680--



From wilson@visi.com  Thu Nov 29 18:41:09 2001
From: wilson@visi.com (Timothy Wilson)
Date: Thu, 29 Nov 2001 12:41:09 -0600 (CST)
Subject: [Tutor] linux
In-Reply-To: <000e01c17903$c6f82ae0$fe2c0d18@grapid1.mi.home.com>
Message-ID: <Pine.GSO.4.21.0111291240120.20160-100000@isis.visi.com>

On Thu, 29 Nov 2001, Jeff Jones wrote:

> Sorry about getting off topic here, but beginning to learn programming through Python has peaked my interest in Linux. The only operating system I have ever used has been windows, and I've been using it since the DOS days (except for computer class in the 7th grade when we used apple IIc). Not by choice but because that's what has always been there when I turned the computer on. Getting to the point... Does anyone know of any decent FAQ's etc. for windows users not yet switched to Linux. Specifically, which version to use? Thanks in advance for any help.

Hi Jeff,

I would try poking around at http://www.linux.com/. I seem to remember
seeing some info like that there. Good luck and have fun!

-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 John.Gouveia2@CIGNA.COM  Thu Nov 29 19:22:35 2001
From: John.Gouveia2@CIGNA.COM (Gouveia, John M   W44)
Date: Thu, 29 Nov 2001 14:22:35 -0500
Subject: [Tutor] linux
Message-ID: <1D7FF56FBD1FD511982D001083FD3172C3631D@WLDEXU15>

Jeff,
If you're just starting with Linux, I'd recommend Mandrake-Linux.com.  =
You
can download it for free or and burn the iso's to cd or drop the $40 or =
so
at a retailer(even WalMart).  It has a nice GUI install and will =
probably
detect most if not all of your hardware.  A dedicated machine would be =
ideal
but you can check out the how-to's on linuxdoc.org for dual booting =
with the
version of Windows you already have.  Have Fun.

  John Gouveia
  CIGNA HealthCare IM&T
   IM Release 2 Decision Support Services
   Phone:  xxx.xxx-xxxx
<mailto:John.Gouveia2@Cigna.com>

Confidential, unpublished property of CIGNA.=20
Do not duplicate or distribute.=20
Use and distribution limited solely to authorized personnel.=20
=A9 Copyright 2001 by CIGNA


> -----Original Message-----
> From:	Jeff Jones [SMTP:thejoness3@home.com]
> Sent:	Thursday, November 29, 2001 1:29 PM
> To:	tutor@python.org
> Subject:	[Tutor] linux
>=20
> Sorry about getting off topic here, but beginning to learn =
programming
> through Python has peaked my interest in Linux. The only operating =
system
> I have ever used has been windows, and I've been using it since the =
DOS
> days (except for computer class in the 7th grade when we used apple =
IIc).
> Not by choice but because that's what has always been there when I =
turned
> the computer on. Getting to the point... Does anyone know of any =
decent
> FAQ's etc. for windows users not yet switched to Linux. Specifically,
> which version to use? Thanks in advance for any help.

------------------------------------------------------------------------------
CONFIDENTIALITY NOTICE: If you have received this e-mail in error, please immediately notify the sender by e-mail at the address shown.  This e-mail transmission may contain confidential information.  This information is intended only for the use of the individual(s) or entity to whom it is intended even if addressed incorrectly.  Please delete it from your files if you are not the intended recipient.  Thank you for your compliance.© Copyright 2001 CIGNA

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



From urnerk@qwest.net  Thu Nov 29 19:24:03 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Thu, 29 Nov 2001 11:24:03 -0800
Subject: [Tutor] Catching cheaters with Python
In-Reply-To: <Pine.GSO.4.21.0111291025310.7869-100000@isis.visi.com>
Message-ID: <4.2.0.58.20011129111704.019d6e40@pop3.norton.antivirus>

>
>to run in the background to run for days if I have to. That said,
>the more efficiently the program could identify matching patterns
>the better.

I took a phrase from your post and entered it into google,
getting: http://www.wesleyan.edu/libr/turnitin/ , which
appears relevant.

It's too bad some kids don't learn the algorithms to
*generate* BS, and therefore have to copy the BS of others.

Various BS generators on the web too, also suggestive of
fun projects (PyBS?):

Example:  http://www.elsewhere.org/cgi-bin/postmodern
(Hit reload to get a new paper).

I don't think the plagiarism police are able to trace
these, so students in a hurry should feel free to use
'em freely (until they learn to auto-spawn the stuff
from whole cloth)).

Kirby

>I'd love to hear others' thoughts on this.
>
>-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 vcardon@siue.edu  Thu Nov 29 19:29:14 2001
From: vcardon@siue.edu (Victor R. Cardona)
Date: Thu, 29 Nov 2001 13:29:14 -0600
Subject: [Tutor] linux
In-Reply-To: <000e01c17903$c6f82ae0$fe2c0d18@grapid1.mi.home.com>; from thejoness3@home.com on Thu, Nov 29, 2001 at 01:29:26PM -0500
References: <000e01c17903$c6f82ae0$fe2c0d18@grapid1.mi.home.com>
Message-ID: <20011129132914.C3180@client156-52.ll.siue.edu>

--lMM8JwqTlfDpEaS6
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Nov 29, 2001 at 01:29:26PM -0500, Jeff Jones wrote:
> Sorry about getting off topic here, but beginning to learn programming th=
rough Python has peaked my interest in Linux. The only operating system I h=
ave ever used has been windows, and I've been using it since the DOS days (=
except for computer class in the 7th grade when we used apple IIc). Not by =
choice but because that's what has always been there when I turned the comp=
uter on. Getting to the point... Does anyone know of any decent FAQ's etc. =
for windows users not yet switched to Linux. Specifically, which version to=
 use? Thanks in advance for any help.

I would start by looking at http://www.linuxdocs.org and
http://www.linux.com. This two sites have a lot of documentation. Other
then that, my only suggestion would be to start with a popular
distribution. SuSE, Red Hat, or Mandrake would all be good choices.

-v
--=20
Victor R. Cardona
Powered by SuSE Linux 7.1 (i386) Professional
GPG key ID E81B3A1C
Key fingerprint =3D 0147 A234 99C3 F4C5 BC64  F501 654F DB49 E81B 3A1C

--lMM8JwqTlfDpEaS6
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8BoyKZU/bSegbOhwRAr29AJ44JV3rukTc+IyX2yu8FxgI0i4IswCaAoIB
jFWtfXadznEqm++OBbor9Vk=
=RJIY
-----END PGP SIGNATURE-----

--lMM8JwqTlfDpEaS6--


From virketis@fas.harvard.edu  Thu Nov 29 19:38:16 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Thu, 29 Nov 2001 14:38:16 -0500
Subject: [Tutor] linux
In-Reply-To: <000e01c17903$c6f82ae0$fe2c0d18@grapid1.mi.home.com>
Message-ID: <200111291937.fATJbTr07881@smtp1.fas.harvard.edu>

Hi Jeff, 

I would second the recommendation of Mandrake Linux. It was my first distro
(distribution :)) and it is still my favourite in terms of the completeness
of experience. As for FAQ/newbie help, do check out www.linuxnewbie.org.
They have great simple walkthroughs of many important (and initially
intimidating) tasks in Linux, reviews of different distros with a beginner
in mind and a helpfull forum for questions. Another site that surveys and
reviews different distros very thoroughly is www.thedukeofurl.org.

-P


------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis



From wilson@visi.com  Thu Nov 29 19:38:29 2001
From: wilson@visi.com (Timothy Wilson)
Date: Thu, 29 Nov 2001 13:38:29 -0600 (CST)
Subject: [Tutor] Catching cheaters with Python
In-Reply-To: <4.2.0.58.20011129111704.019d6e40@pop3.norton.antivirus>
Message-ID: <Pine.GSO.4.21.0111291332350.20160-100000@isis.visi.com>

On Thu, 29 Nov 2001, Kirby Urner wrote:

> I took a phrase from your post and entered it into google,
> getting: http://www.wesleyan.edu/libr/turnitin/ , which
> appears relevant.

According to this site the Turnitin software works by "a series of
algorithms to turn textual information into a 'digital fingerprint' that can
identify matching patterns, including those from texts substantially altered
by paraphrasing or word substitution."

I wonder how such an algorithm is implemented?

-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 urnerk@qwest.net  Thu Nov 29 19:44:02 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Thu, 29 Nov 2001 11:44:02 -0800
Subject: [Tutor] linux
In-Reply-To: <000e01c17903$c6f82ae0$fe2c0d18@grapid1.mi.home.com>
Message-ID: <4.2.0.58.20011129112530.019d3b00@pop3.norton.antivirus>

At 01:29 PM 11/29/2001 -0500, Jeff Jones wrote:
>Sorry about getting off topic here, but beginning to learn programming 
>through Python has peaked my interest in Linux. The only operating system 
>I have ever used has been windows, and I've been using it since the DOS 
>days (except for computer class in the 7th grade when we used apple IIc). 
>Not by choice but because that's what has always been there when I turned 
>the computer on. Getting to the point... Does anyone know of any decent 
>FAQ's etc. for windows users not yet switched to Linux. Specifically, 
>which version to use? Thanks in advance for any help.


It's a huge topic, and I'll confine my remarks to this post
as I agree it's not about Python per se.

Makes a difference if you plan to devote a box to Linux or
dual boot it with Windows.

Makes a difference how much horse power your Linux box
will have, and whether you want to tackle it as a
"Windows-like GUI" gradually drilling down into the guts,
or as a DOS-on-steroids command line environment (easy to
do the latter on a low horse power machine, but an
only-knows-Windows person would find KDE or Gnome (GUIs)
an easier starting point).

There are also much-less-resource-intensive GUIs like
WindowMaker and BlackBox which many people like a lot.

A lot of people are liking the Mandrake 8.1 distro these
days, which is what I use (dual boot with WinME).  It has
an easy graphical install and comes with a fairly well
integrated set of tools (for a Linux distro -- they tend
to be hodge-podgey, because in open source, lots of
people get to play and the stuff is free, so there's a
tendency to get lots of GUIs, lots of browsers, lots of
email clients (which is good -- find which you like best
and uninstall the rest (or just let em sit there))).

You can download Mandrake and burn the CDs free, if you
want to go that route (some of the apps are not in the
free version, but all of Linux is, and of course Python
is, which you can download and build from the website
anyway).  In Mandrake, if you install it with the developer
tools, you'll get IDLE in a KDE menu without any configuring
on your part, ready to go.

Linux is a fairly steep learning curve if your goal is
to learn all about it, because "learning all about it"
really means tackling an arbitrarily large body of
knowledge and skills.  I recommend 'Linux Cookbook' by
Michael Stutz (Linux Journal Press), but there are tons
of useful books.

(There's also FreeBSD to consider -- in some ways a cleaner
environment than Linux (Torvalds agrees), but nevermind).

Kirby



From james2dope@yahoo.com  Thu Nov 29 19:45:26 2001
From: james2dope@yahoo.com (james middendorff)
Date: Thu, 29 Nov 2001 11:45:26 -0800 (PST)
Subject: [Tutor] question
Message-ID: <20011129194526.97922.qmail@web13907.mail.yahoo.com>

--0-2033992585-1007063126=:97882
Content-Type: text/plain; charset=us-ascii


I just wanted to ask you guys a question, I recently tried out Visual Basic 6.0 at a friends house, and I was amazed at how easy things are to do with the making of the GUI interface to programs, but I wonder if that language is even worth it to learn or what, I am still what I would like to think a beginer at programming and I thought I couldnt really do anything until I started visual basic, would I be better off learning visual basic good and then coming back to python when I understand the programming concepts better, or should I stick it out with python? Also this may a dumb question but I have tried to read the docs on how to compile with python but I think I am retarded or something because I cant figure it out, could someone help me I would appreciate it

thanks jimmy


"I would kill everyone in this room
    for a drop of sweet beer."
     ----Homer Simpson----


---------------------------------
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
--0-2033992585-1007063126=:97882
Content-Type: text/html; charset=us-ascii

<P>I just wanted to ask you guys a question, I recently tried out Visual Basic 6.0 at a friends house, and I was amazed at how easy things are to do with the making of the GUI interface to programs, but I wonder if that language is even worth it to learn or what, I am still what I would like to think a beginer at programming and I thought I couldnt really do anything until I started visual basic, would I be better off learning visual basic good and then coming back to python when I understand the programming concepts better, or should I stick it out with python? Also this may a dumb question but I have tried to read the docs on how to compile with python but I think I am retarded or something because I cant figure it out, could someone help me I would appreciate it</P>
<P>thanks jimmy</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>
<a href="http://geocities.yahoo.com/ps/info1">Yahoo! GeoCities</a> - quick and easy web site hosting, just $8.95/month.
--0-2033992585-1007063126=:97882--


From dyoo@hkn.eecs.berkeley.edu  Thu Nov 29 20:22:29 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 29 Nov 2001 12:22:29 -0800 (PST)
Subject: [Tutor] Re: how do I sleep?
In-Reply-To: <20011127152410.B7792@harmony.cs.rit.edu>
Message-ID: <Pine.LNX.4.21.0111271532470.14331-100000@hkn.eecs.berkeley.edu>

On Tue, 27 Nov 2001, dman wrote:

> 
> On Tue, Nov 27, 2001 at 08:34:35PM +0000, Pablo Prieto wrote:
> | Hello!
> | 
> | I'm Pablo, from Spain.
> 
> Hi Pablo.  Just a tip : when posting a question start by composing a
> new message with a relevant Subject: line, rather than replying to an
> unrelated message.
> 
> | How can I give time-slices of processing to the OS when I'm stuck in a very
> | cost-time loop?. I mean, not to freeze the system (NT, you know) while the
> | loop is on.

This timesharing is the responsibility of an operating system --- you
shouldn't have to worry about this at all.  NT should automagically
coordinate things so that no process should freeze the system.  At least,
that's the ideal that the OS should strive towards...  *grin*


Do you mean, instead, that you want to do several things at the same time?  
If so, you might be looking for the "threading" module:

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



From dyoo@hkn.eecs.berkeley.edu  Thu Nov 29 20:23:54 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 29 Nov 2001 12:23:54 -0800 (PST)
Subject: [Tutor] Remind me of ...
In-Reply-To: <002701c1782e$7f663d00$1664a8c0@mega>
Message-ID: <Pine.LNX.4.21.0111281235470.5652-100000@hkn.eecs.berkeley.edu>

On Wed, 28 Nov 2001, Gregor Lingl wrote:

> Several weeks (months) ago somebody (maybe Danny Yoo?
> or Alan Gauld?) posted a reference to an interactive 

Remco Gerlich sent a message about the Lists and Lists game:

    http://www.wurb.com/if/game/128

Hope this helps!



From virketis@fas.harvard.edu  Thu Nov 29 21:11:37 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Thu, 29 Nov 2001 16:11:37 -0500
Subject: [Tutor] question
In-Reply-To: <20011129194526.97922.qmail@web13907.mail.yahoo.com>
Message-ID: <200111292110.fATLAor16565@smtp1.fas.harvard.edu>

--=====================_140231461==_.ALT
Content-Type: text/plain; charset="us-ascii"

Jimmy, 

My first language was Python (well, Pascal really, but that got me nowhere: )
and since then I picked up Perl, PHP and VB. I used the latter alot at work
this summer. My personal opinion (and this is a crucial caveat, because
some of
the most spectacular flame wars I've seen on the web have been on language
choice) is that Python is vastly superior to VB as a learning paradigm. Python
is at the same time more general in terms of what it can do and what platforms
it runs on, and syntactically much more regular. Now, far be it from me to
suggest that VB is not useful sometimes. As you noted, if you want to put
something small together fast in Windows, VB drop-in "wizards" will do it.
It's
tightly integrated with the Windows Office package as well, so it makes sense
to write programs that interface between, say Word and Outlook, in VB.
However,
once you try writing something more significant on VB, you'll find that you
either have to be extremely meticulous about your code, or it will just be a
nightmare in terms of maintaining and debugging, because it relies on very
suspect innards of Windows. It's low initial learning curve, which you are now
enjoying, becomes a handicap in terms of power later on. So, as a non-CS
person
who also started with scripted languages, I would suggest you stick with
Python. Did you expect something else on this list? :)

-P

At 11:45 AM 11/29/2001 -0800, you wrote: 

>
> I just wanted to ask you guys a question, I recently tried out Visual Basic
> 6.0 at a friends house, and I was amazed at how easy things are to do with
> the making of the GUI interface to programs, but I wonder if that
language is
> even worth it to learn or what, I am still what I would like to think a
> beginer at programming and I thought I couldnt really do anything until I
> started visual basic, would I be better off learning visual basic good and
> then coming back to python when I understand the programming concepts
better,
> or should I stick it out with python? Also this may a dumb question but I
> have tried to read the docs on how to compile with python but I think I am
> retarded or something because I cant figure it out, could someone help me I
> would appreciate it
>
> thanks jimmy
>
>
> "I would kill everyone in this room
> for a drop of sweet beer."
> ----Homer Simpson----
>
>
>
> Do You Yahoo!?
> <http://geocities.yahoo.com/ps/info1>Yahoo! GeoCities - quick and easy web
> site hosting, just $8.95/month. 



------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis

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

<html>
Jimmy, <br>
<br>
My first language was Python (well, Pascal really, but that got me
nowhere: ) and since then I picked up Perl, PHP and VB. I used the latter
alot at work this summer. My personal opinion (and this is a crucial
caveat, because some of the most spectacular flame wars I've seen on the
web have been on language choice) is that Python is vastly superior to VB
as a learning paradigm. Python is at the same time more general in terms
of what it can do and what platforms it runs on, and syntactically much
more regular. Now, far be it from me to suggest that VB is not useful
sometimes. As you noted, if you want to put something small together fast
in Windows, VB drop-in &quot;wizards&quot; will do it. It's tightly
integrated with the Windows Office package as well, so it makes sense to
write programs that interface between, say Word and Outlook, in VB.
However, once you try writing something more significant on VB, you'll
find that you either have to be extremely meticulous about your code, or
it will just be a nightmare in terms of maintaining and debugging,
because it relies on very suspect innards of Windows. It's low initial
learning curve, which you are now enjoying, becomes a handicap in terms
of power later on. So, as a non-CS person who also started with scripted
languages, I would suggest you stick with Python. Did you expect
something else on this list? :)<br>
<br>
-P<br>
<br>
At 11:45 AM 11/29/2001 -0800, you wrote: <br>
<br>
<blockquote type=3Dcite cite>I just wanted to ask you guys a question, I
recently tried out Visual Basic 6.0 at a friends house, and I was amazed
at how easy things are to do with the making of the GUI interface to
programs, but I wonder if that language is even worth it to learn or
what, I am still what I would like to think a beginer at programming and
I thought I couldnt really do anything until I started visual basic,
would I be better off learning visual basic good and then coming back to
python when I understand the programming concepts better, or should I
stick it out with python? Also this may a dumb question but I have tried
to read the docs on how to compile with python but I think I am retarded
or something because I cant figure it out, could someone help me I would
appreciate it<br>
<br>
thanks jimmy<br>
<br>
<br>
&quot;I would kill everyone in this room<br>
for a drop of sweet beer.&quot;<br>
----Homer Simpson----<br>
<br>
<br>
<br>
<b>Do You Yahoo!?</b><br>
</b><a href=3D"http://geocities.yahoo.com/ps/info1">Yahoo! GeoCities</a> -
quick and easy web site hosting, just $8.95/month. </blockquote><br>
<br>
<div>------------------------------------------------------------</div>
<div>PGP PUBLIC KEY:
<a href=3D"http://www.fas.harvard.edu/~virketis/links"=
 EUDORA=3DAUTOURL>www.fas.harvard.edu/~virketis/links</a></div>
<div>My weblog:
<a href=3D"http://www.fas.harvard.edu/~virketis"=
 EUDORA=3DAUTOURL>www.fas.harvard.edu/~virketis</a></div>
</html>

--=====================_140231461==_.ALT--



From urnerk@qwest.net  Thu Nov 29 21:40:40 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Thu, 29 Nov 2001 13:40:40 -0800
Subject: [Tutor] question
In-Reply-To: <20011129194526.97922.qmail@web13907.mail.yahoo.com>
Message-ID: <4.2.0.58.20011129133338.019f4a30@pop3.norton.antivirus>

Jimmy --

In the preferred future according to Microsoft, you can use
the VB IDE or some other GUI-aware IDE to throw together a
front end, and then maybe use Python to write some service
provider which the VB grabs and uses.

When it comes to Microsoft products, I like Visual FoxPro
for GUI development.  I think the language, OO implementation,
and IDE are well designed, better than VB's even.  Even
you're looking to toss together GUIs with lots of widgets
on Windows, and want to spend the bucks, consider VFP 7.0
as a strong candidate (especially if you're doing database
work -- VFP is *really* good at that).

Python piggy backs on other products for its GUI.  That's
OK.  That's what many besides Microsoft are shooting for:
interoperability.  You don't have to use just one language
for any given project or product.  Use each for what its
best at.

Note:  a lot of purist programmers consider the GUI stuff
to be the icing on the cake, the cosmetic outer layer,
the superficial gloss.  It's fun to wrap it up and tie it
in a bow at the end of the day, but the guts and wonder of
programming is all in the guts, which are below the surface.

But this metaphor is only somewhat correct.  If the whole
point of the app is to do graphical stuff, and the interface
is core to its functionality, then it's too dismissive to
call it "cosmetic".  That being said, all the interface
widgets in the world don't an interesting app make -- it's
gotta actually DO something (right?).

Kirby

At 11:45 AM 11/29/2001 -0800, james middendorff wrote:

>I just wanted to ask you guys a question, I recently tried out Visual 
>Basic 6.0 at a friends house, and I was amazed at how easy things are to 
>do with the making of the GUI interface to programs, but I wonder if that 
>language is even worth it to learn or what, I am still what I would like 
>to think a beginer at programming and I thought I couldnt really do 
>anything until I started visual basic, would I be better off learning 
>visual basic good and then coming back to python when I understand the 
>programming concepts better, or should I stick it out with python? Also 
>this may a dumb question but I have tried to read the docs on how to 
>compile with python but I think I am retarded or something because I cant 
>figure it out, could someone help me I would appreciate it
>
>thanks jimmy




From lkvam@venix.com  Thu Nov 29 14:28:38 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Thu, 29 Nov 2001 09:28:38 -0500
Subject: [Tutor] Re: how do I sleep?
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C126@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <3C064616.6010608@venix.com>

Since I have also found that VB programs (even on NT) require an occassional
call to DoEvents, it is probably a defect in the VB runtime.  So far, I have
not experienced a need for this kind of function in my Python code.

alan.gauld@bt.com wrote:

>>I'm not aware of anything like that (in Python or C) other than
>>"sleep".  If you sleep, then your process isn't doing anything and the
>>kernel will (should!) give the CPU to another process that is doing
>>something.  That's what you're looking for, right?
>>
> 
> Kind of. What he's looking for is a call that tells the OS to 
> process any other active processes but if there aren't any come 
> right back here. In other words only pause if you need to. 
> Sleep pauses regardless.
> 
> This is only necessary on coopoerative multitasking environments 
> like Win3x and Win 9x and early OS/2 and Mac. On Unix, NT etc this 
> should not be needed as the kernewl will switch processes 
> pre-emptively. (Win 9x will do so too provided the program is 
> 100% Win32 clean, unfortunately few are which is why so many 
> programs still hang for long periods in Win9x...)
> 
> Alan g.
> 
> _______________________________________________
> 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 willd@p-wave.com  Thu Nov 29 15:34:59 2001
From: willd@p-wave.com (Will Dennis)
Date: Thu, 29 Nov 2001 10:34:59 -0500
Subject: [Tutor] Appropriate questions
Message-ID: <5.1.0.14.0.20011129083939.00a60c80@websvr01.p-wave.com>

Hello,

I am a beginning Python programmer (beginning *any* kind of programmer, 
really!) and I would like to know if this forum is appropriate for asking 
"How do I do xxxxx in Python" type of questions, which would be kind of 
specific to a Python program I'm working on. Or is there another forum that 
a Python newbie should ask such questions in (without the risk of being 
flamed to Mars and back? :)

Thanks for letting me know...

Will Dennis



From dyoo@hkn.eecs.berkeley.edu  Thu Nov 29 21:42:30 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 29 Nov 2001 13:42:30 -0800 (PST)
Subject: [Tutor] Is there a Python book which gives sample code / usag
 e of         all the modules which ship with python???
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66C12D@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <Pine.LNX.4.21.0111291340120.8976-100000@hkn.eecs.berkeley.edu>

On Thu, 29 Nov 2001 alan.gauld@bt.com wrote:

> What about New Riders? 
> They do the best reference book for what you asked:
>
> Python Essential Reference by Dave Beasley.

Agreed!  Python Essential Reference is one of the best Python reference
books I've seen.  It's nice and easy to carry.  *grin*


> However there are no books that provide code samples for ALL of the
> modules, also many modules contain code samples in the standard
> library documents.
> 
> Finally try searching the google newsgroup archives, and
> the ActiveState archives of the Python mailing lists, there 
> are often examples in there.

Another great place for sample snippets is the ongoing Python Cookbook
project that Activestate is hosting:

    http://aspn.activestate.com/ASPN/Cookbook/Python


Another good place to see example code is at Useless Python:

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



From pobrien@orbtech.com  Thu Nov 29 21:59:25 2001
From: pobrien@orbtech.com (Patrick K. O'Brien)
Date: Thu, 29 Nov 2001 15:59:25 -0600
Subject: [Tutor] Appropriate questions
In-Reply-To: <5.1.0.14.0.20011129083939.00a60c80@websvr01.p-wave.com>
Message-ID: <NBBBIOJPGKJEKIECEMCBKEOMLDAA.pobrien@orbtech.com>

This list is definitely one of the friendliest lists I've ever experienced.
I've never seen a question that was considered too simple or too obscure for
this list. Ask away.

---
Patrick K. O'Brien
Orbtech.com - Your Source For Python Development Services


> -----Original Message-----
> From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
> Will Dennis
> Sent: Thursday, November 29, 2001 9:35 AM
> To: tutor@python.org
> Subject: [Tutor] Appropriate questions
>
>
> Hello,
>
> I am a beginning Python programmer (beginning *any* kind of programmer,
> really!) and I would like to know if this forum is appropriate for asking
> "How do I do xxxxx in Python" type of questions, which would be kind of
> specific to a Python program I'm working on. Or is there another
> forum that
> a Python newbie should ask such questions in (without the risk of being
> flamed to Mars and back? :)
>
> Thanks for letting me know...
>
> Will Dennis
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor



From dyoo@hkn.eecs.berkeley.edu  Thu Nov 29 21:55:18 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 29 Nov 2001 13:55:18 -0800 (PST)
Subject: [Tutor] linux
In-Reply-To: <200111291937.fATJbTr07881@smtp1.fas.harvard.edu>
Message-ID: <Pine.LNX.4.21.0111291349190.8976-100000@hkn.eecs.berkeley.edu>

On Thu, 29 Nov 2001, Pijus Virketis wrote:

> I would second the recommendation of Mandrake Linux. It was my first
> distro (distribution :)) and it is still my favourite in terms of the
> completeness of experience. As for FAQ/newbie help, do check out

Thirded.  *grin* Mandrake Linux is a very good distribution of Linux.  
The Mandrake distribution even has an option so that you can install it
alongside Windows without doing repartitioning: it allows you to
experiment casually with a Linux system.


> www.linuxnewbie.org. They have great simple walkthroughs of many
> important (and initially intimidating) tasks in Linux, reviews of
> different distros with a beginner in mind and a helpfull forum for
> questions. Another site that surveys and reviews different distros
> very thoroughly is www.thedukeofurl.org.

It's also very important, I think, to try to get in contact with other
Linux users; a user community can be very helpful at times.  Try:

    http://www.linux.org/groups/

for a list of Linux User Groups (LUGs).

Good luck to you!



From tjenkins@devis.com  Thu Nov 29 22:01:50 2001
From: tjenkins@devis.com (Tom Jenkins)
Date: 29 Nov 2001 17:01:50 -0500
Subject: [Tutor] Appropriate questions
In-Reply-To: <5.1.0.14.0.20011129083939.00a60c80@websvr01.p-wave.com>
References: <5.1.0.14.0.20011129083939.00a60c80@websvr01.p-wave.com>
Message-ID: <1007071310.976.69.camel@asimov>

On Thu, 2001-11-29 at 10:34, Will Dennis wrote:
> Hello,
> 
> I am a beginning Python programmer (beginning *any* kind of programmer, 
> really!) and I would like to know if this forum is appropriate for asking 
> "How do I do xxxxx in Python" type of questions, which would be kind of 
> specific to a Python program I'm working on. Or is there another forum that 
> a Python newbie should ask such questions in (without the risk of being 
> flamed to Mars and back? :)
> 

Will,
This is exactly the forum for your questions.  you will not get
flamed... unless you're trying to get us to do your homework <wink>

-- 

Tom Jenkins
Development InfoStructure
http://www.devis.com




From kimtitu@yahoo.com  Thu Nov 29 22:01:06 2001
From: kimtitu@yahoo.com (Titu Kim)
Date: Thu, 29 Nov 2001 14:01:06 -0800 (PST)
Subject: [Tutor] transform html to pdf
In-Reply-To: <20011129041506.YKUM1625.fep03-mail.bloor.is.net.cable.rogers.com@there>
Message-ID: <20011129220106.57776.qmail@web14704.mail.yahoo.com>

I am using RH Linux 7.1.
--- Chris Keelan <rufmetal@rogers.com> wrote:
> On Wednesday 28 November 2001 02:32 am, Titu Kim
> wrote:
> > My html string is created via cgi. So i wish to
> create
> > a pdf file that can be downloaded while displaying
> the
> > the html page via browser. Calling Latex is a good
> > approach for me too. Any idea? Thanks.
> 
> It would help to know which platform you're using.
> 
> Are you planning to batch process a bunch of files?
> If so, you're on your 
> own. For a one-off, try printing to a ps file from
> your browser (install a ps 
> printer if you're running winders or just use the
> "print to file" from any of 
> the *nix browsers). You can then either use ps2pdf
> on the resulting output 
> (*nix) or goto
> http://www.ps2pdf.com/convert/index.htm and do it
> online.
> 
> - Chirs
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor


__________________________________________________
Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.
http://geocities.yahoo.com/ps/info1


From dyoo@hkn.eecs.berkeley.edu  Thu Nov 29 22:13:30 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 29 Nov 2001 14:13:30 -0800 (PST)
Subject: [Tutor] Appropriate questions
In-Reply-To: <5.1.0.14.0.20011129083939.00a60c80@websvr01.p-wave.com>
Message-ID: <Pine.LNX.4.21.0111291357430.8976-100000@hkn.eecs.berkeley.edu>

On Thu, 29 Nov 2001, Will Dennis wrote:

> I am a beginning Python programmer (beginning *any* kind of
> programmer, really!) and I would like to know if this forum is
> appropriate for asking "How do I do xxxxx in Python" type of
> questions, which would be kind of specific to a Python program I'm
> working on. Or is there another forum that a Python newbie should ask
> such questions in (without the risk of being flamed to Mars and back?
> :)

Yes, we welcome "How do I do xxxxx in Python" questions all the time!  
We're happy to have you here.


By the way, you might have gotten a message from the mailing list software
about not being subscribed --- you can fix this by visiting:

    http://mail.python.org/mailman/listinfo/tutor

There's a form there that you can use to subscribe to the list.  Once you
do this, your posts will automatically go to everyone here without any
delays.  If you find that there are too many posts coming your way, you
can also change your options to "digest mode", which will bundle up
messages for you.

Good luck!



From i812@iname.com  Thu Nov 29 22:28:06 2001
From: i812@iname.com (Rob McGee)
Date: Thu, 29 Nov 2001 16:28:06 -0600
Subject: [Tutor] linux
In-Reply-To: <1D7FF56FBD1FD511982D001083FD3172C3631D@WLDEXU15>; from John.Gouveia2@CIGNA.COM on Thu, Nov 29, 2001 at 02:22:35PM -0500
References: <1D7FF56FBD1FD511982D001083FD3172C3631D@WLDEXU15>
Message-ID: <20011129162806.A27400@hal>

Jeff Jones wrote:
> > Sorry about getting off topic here, but beginning to learn programming
> > through Python has peaked my interest in Linux. The only operating system
> > I have ever used has been windows, and I've been using it since the DOS
> > days (except for computer class in the 7th grade when we used apple IIc).
> > Not by choice but because that's what has always been there when I turned
> > the computer on. Getting to the point... Does anyone know of any decent
> > FAQ's etc. for windows users not yet switched to Linux. Specifically,
> > which version to use? Thanks in advance for any help.

Different beginning users have different needs. Yes, Mandrake does a
pretty good job of setting things up for you. It's very much like MS
Windows in that regard! And also like MS Windows, you're not likely to
learn as much about how things work behind the scenes.

I started with Slackware, not quite 3 years ago. In that time I have
attained some real competence as a GNU/Linux and UNIX sysadmin. I don't
think I would have made it as far if I had started with something like
Mandrake. (I know some who did, and they're not.)

One thing for sure is that my skills are portable to any distro. I've
seen the RedHat and Mandrake people talking about how to fix something,
and their answers are all related to their GUI configuration tools. OTOH
I would go to a configuration file and edit it. That works anywhere, not
just Slackware.

If you have a strong DOS background, you might appreciate Slackware. But
if you just want to get up and running in a GUI ASAP, Mandrake and the
other big commercial distros are good choices. I'd stay away from Corel
(if it still exists) because it wasn't maintained, and steer clear of
Caldera because of their per-seat licencing fees.

Write me off-list if you're interested in Slackware.

    Rob - /dev/rob0


From dsh8290@rit.edu  Thu Nov 29 23:01:03 2001
From: dsh8290@rit.edu (dman)
Date: Thu, 29 Nov 2001 18:01:03 -0500
Subject: [Tutor] linux
In-Reply-To: <20011129162806.A27400@hal>; from i812@iname.com on Thu, Nov 29, 2001 at 04:28:06PM -0600
References: <1D7FF56FBD1FD511982D001083FD3172C3631D@WLDEXU15> <20011129162806.A27400@hal>
Message-ID: <20011129180103.C12973@harmony.cs.rit.edu>

On Thu, Nov 29, 2001 at 04:28:06PM -0600, Rob McGee wrote:
| Jeff Jones wrote:
| > > Sorry about getting off topic here, but beginning to learn programming
| > > through Python has peaked my interest in Linux. The only operating system
| > > I have ever used has been windows, and I've been using it since the DOS
| > > days (except for computer class in the 7th grade when we used apple IIc).
| > > Not by choice but because that's what has always been there when I turned
| > > the computer on. Getting to the point... Does anyone know of any decent
| > > FAQ's etc. for windows users not yet switched to Linux. Specifically,
| > > which version to use? Thanks in advance for any help.
| 
| Different beginning users have different needs. Yes, Mandrake does a
| pretty good job of setting things up for you. It's very much like MS
| Windows in that regard! And also like MS Windows, you're not likely to
| learn as much about how things work behind the scenes.

I agree.  I started with RH a couple years ago, but switched to Debian
for a number of reasons.  I first took a look at Debian because the RH
people really messed up with verison 7 (buggy binary incompatible
compiler, buggy libc) and I had heard good things about Debian in some
newsgroups.  I had the two systems dual-booting and I found that
Debian's package management (and the packages that are available) are
far superior.

| I started with Slackware, not quite 3 years ago. In that time I have
| attained some real competence as a GNU/Linux and UNIX sysadmin. I don't
| think I would have made it as far if I had started with something like
| Mandrake. (I know some who did, and they're not.)

Debian is closer to Slackware than RH or Mandrake in that the usual
config tool is $EDITOR.  It is different in that it provides a
higher-level package management system.

-D

-- 

For society, it's probably a good thing that engineers value function
over appearance.  For example, you wouldn't want engineers to build
nuclear power plants that only _look_ like they would keep all the
radiation inside.
    (Scott Adams - The Dilbert principle)



From i812@iname.com  Thu Nov 29 23:09:01 2001
From: i812@iname.com (Rob McGee)
Date: Thu, 29 Nov 2001 17:09:01 -0600
Subject: [Tutor] the class struggle
Message-ID: <20011129170901.B27400@hal>

Hi all, I am a python 2.0 beginner. I'm trying to write a silly little
program. Actually I *did* write it using a function definition, but I
wanted to be object-oriented, so I'm trying to use a class instead. This
isn't working out.

{code}
import random

def myObject(name):
  variable = name
  anotherOne = anotherValue
  if name in someList:
    nextVar = this
    lastOne = that
  else:
    nextVar = random.randrange(10, 70)
    lastOne = random.randrange(5, 15)
{/code}

That works. I got a complete and working (although not very polished)
program using a function like that. It's worthy of the Useless Python
site, for sure. :)

{code}
import random

class myObject(name):
  def __init__(self, name):
    variable = name
    anotherOne = anotherValue
    if name in someList:
      nextVar = this
      lastOne = that
    else:
      nextVar = random.randrange(10, 70)
      lastOne = random.randrange(5, 15)
{/code}

That doesn't work. "SyntaxError: invalid syntax" on the "if" (caret goes
under the "f".) I tried adding "self." in front of the class instance
variables just for fun. Same thing.

I have read the tutorial and what I could find in the other docs about
classes. I rented Ivan Van Laningham's "24 Hours" book at the local
bookstore / coffee shop (I always buy a cup of coffee :) and thought I
I was beginning to understand.

I guess not.

I tried commenting out the if/else lines and making a little function to
test it out, and now everything after this accursed class definition is
a SyntaxError.

Is there something online with another description of using class
definitions? Or perhaps can you fine folks point me in the right
direction?

BTW, except for classes I think I'm understanding things pretty well. I
am able to make python do what I set out to do.

Thank you,
    Rob - /dev/rob0


From kojo@hal-pc.org  Thu Nov 29 23:21:11 2001
From: kojo@hal-pc.org (Kojo Idrissa)
Date: Thu, 29 Nov 2001 17:21:11 -0600
Subject: [Tutor] Re: [Tutor] Is there a Python book which gives
 sample code / usage of all the modules which ship with python???
In-Reply-To: <1329.192.168.0.21.1007040077.squirrel@mail.archeanit.com>
References: <NEBBJNMDEKBIBCMCNMBDGEEJCKAA.karthikg@aztec.soft.net>
 <NEBBJNMDEKBIBCMCNMBDGEEJCKAA.karthikg@aztec.soft.net>
Message-ID: <5.1.0.14.0.20011129171942.0282a158@Pop3.norton.antivirus>

Just in case no one noticed, the link below to www.diveintopython.org is 
spelled wrong.  There's no "in" in "Python".

No wonder I couldn't get the page to open...
:-)

At 06:51 PM 11/29/2001 +0530, Amresh kumar wrote:
>Hi,
> > or is there a website which lists the code samples??.
> > Oreilly, manning etc do not publish python related books in India :-(
> > The only one we have here is "Core Python programming" by Chun.
> >
>download dive into python book from www.diveintopythin.org
>
>cheers
>amresh
>
>------------------------------------------------
>Amresh kumar
>lower level programmer
>Archean infotech
>------------------------------------------------
>
>Computers are like air conditioners.
>They stop working when you open Windows
>
>
>
>
>-----------------------------------------
>This email was sent using SquirrelMail.
>    "Webmail for nuts!"
>http://squirrelmail.org/
>
>
>
>_______________________________________________
>Tutor maillist  -  Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor

****************************
Kojo Idrissa

kojo@hal-pc.org
http://www.hal-pc.org/~kojo/
****************************



From kojo@hal-pc.org  Thu Nov 29 23:46:16 2001
From: kojo@hal-pc.org (Kojo Idrissa)
Date: Thu, 29 Nov 2001 17:46:16 -0600
Subject: [Tutor] linux
In-Reply-To: <20011129162806.A27400@hal>
References: <1D7FF56FBD1FD511982D001083FD3172C3631D@WLDEXU15>
 <1D7FF56FBD1FD511982D001083FD3172C3631D@WLDEXU15>
Message-ID: <5.1.0.14.0.20011129173422.0282a7e8@Pop3.norton.antivirus>

I'm going to second (or third) the recommendation for Slackware.  I came 
from a DOS background before I moved to Win 3.1/9X/2K.  In Linux, I started 
with Slack 3.3 and it made sense.  Now I'm dual-booting Win2K and Slack 
8.  If you feel you NEED a gui first, you might want to go with Mandrake, 
but you can do most programming from the command line.  The Slackware disk 
sets make things easy to set up.  All you'd need would be the A/AP/D disk 
sets (Base System/Extras for Base/Development <all programming stuff>) and 
you're ready.  Add more as you like.  Want to do Networking stuff?  Add the 
N disk set.  The skills you get from "fighting' Slackware will definitely 
carry over to other distros.

I'll also second the "Find a LUG" sentiment.  It can keep you from 
re-inventing the wheel.

Debian is also a good distro, but probably better as a 'second' distro.  It 
might not be the best thing for someone wanting to get started doing things 
quickly, unless you've got an experienced friend around to point things out 
for you.  The install is a little more complicated.  Not so much so that 
you won't be able to deal with it, but it's a little less obvious than some 
others.  The package management system is superior to all others though.

Good luck,

At 04:28 PM 11/29/2001 -0600, Rob McGee wrote:
>I started with Slackware, not quite 3 years ago. In that time I have
>attained some real competence as a GNU/Linux and UNIX sysadmin. I don't
>think I would have made it as far if I had started with something like
>Mandrake. (I know some who did, and they're not.)
>
>One thing for sure is that my skills are portable to any distro. I've
>seen the RedHat and Mandrake people talking about how to fix something,
>and their answers are all related to their GUI configuration tools. OTOH
>I would go to a configuration file and edit it. That works anywhere, not
>just Slackware.
>
>If you have a strong DOS background, you might appreciate Slackware. But
>if you just want to get up and running in a GUI ASAP, Mandrake and the
>other big commercial distros are good choices. I'd stay away from Corel
>(if it still exists) because it wasn't maintained, and steer clear of
>Caldera because of their per-seat licencing fees.

****************************
Kojo Idrissa

kojo@hal-pc.org
http://www.hal-pc.org/~kojo/
****************************



From lkvam@venix.com  Thu Nov 29 23:38:09 2001
From: lkvam@venix.com (Lloyd Kvam)
Date: Thu, 29 Nov 2001 18:38:09 -0500
Subject: [Tutor] the class struggle
References: <20011129170901.B27400@hal>
Message-ID: <3C06C6E1.3050806@venix.com>

The syntax error probably relates to name.  You show myobject inheriting
from name and then list name as an argument for the __init__ method.

name would have to be a class for the inheritance.  It would probably be
an instance or variable for the argument to init.

I suspect that you really want:
class myObject:

Note that people usually capitalize their classes to help prevent this kind
of confusion.

customer = Customer()	# create a customer instance from Customer class.



Rob McGee wrote:

> Hi all, I am a python 2.0 beginner. I'm trying to write a silly little
> program. Actually I *did* write it using a function definition, but I
> wanted to be object-oriented, so I'm trying to use a class instead. This
> isn't working out.
> 
> {code}
> import random
> 
> def myObject(name):
>   variable = name
>   anotherOne = anotherValue
>   if name in someList:
>     nextVar = this
>     lastOne = that
>   else:
>     nextVar = random.randrange(10, 70)
>     lastOne = random.randrange(5, 15)
> {/code}
> 
> That works. I got a complete and working (although not very polished)
> program using a function like that. It's worthy of the Useless Python
> site, for sure. :)
> 
> {code}
> import random
> 
> class myObject(name):
>   def __init__(self, name):
>     variable = name
>     anotherOne = anotherValue
>     if name in someList:
>       nextVar = this
>       lastOne = that
>     else:
>       nextVar = random.randrange(10, 70)
>       lastOne = random.randrange(5, 15)
> {/code}
> 
> That doesn't work. "SyntaxError: invalid syntax" on the "if" (caret goes
> under the "f".) I tried adding "self." in front of the class instance
> variables just for fun. Same thing.
> 
> I have read the tutorial and what I could find in the other docs about
> classes. I rented Ivan Van Laningham's "24 Hours" book at the local
> bookstore / coffee shop (I always buy a cup of coffee :) and thought I
> I was beginning to understand.
> 
> I guess not.
> 
> I tried commenting out the if/else lines and making a little function to
> test it out, and now everything after this accursed class definition is
> a SyntaxError.
> 
> Is there something online with another description of using class
> definitions? Or perhaps can you fine folks point me in the right
> direction?
> 
> BTW, except for classes I think I'm understanding things pretty well. I
> am able to make python do what I set out to do.
> 
> Thank you,
>     Rob - /dev/rob0
> 
> _______________________________________________
> 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  Fri Nov 30 00:21:22 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 29 Nov 2001 16:21:22 -0800 (PST)
Subject: [Tutor] Catching cheaters with Python
In-Reply-To: <Pine.GSO.4.21.0111291025310.7869-100000@isis.visi.com>
Message-ID: <Pine.LNX.4.21.0111291344010.8976-100000@hkn.eecs.berkeley.edu>

On Thu, 29 Nov 2001, Timothy Wilson wrote:

> A year or so ago a professor at some university made the news when he
> wrote a program that would automatically scan submitted papers and
> identify

Here's one example, from Yes, Professor Aiken from UC Berkeley:

    http://www.cs.berkeley.edu/~aiken/

had researched a program that would attempt to detect plagiarism:

   http://www.cs.berkeley.edu/~aiken/moss.html

This particular program appears to be limited to detecting source code
plagiarism.  You can contact him to see if his algorithm can be
generalized to other environments.



From dyoo@hkn.eecs.berkeley.edu  Fri Nov 30 00:33:47 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 29 Nov 2001 16:33:47 -0800 (PST)
Subject: [Tutor] Catching cheaters with Python
In-Reply-To: <Pine.LNX.4.21.0111291344010.8976-100000@hkn.eecs.berkeley.edu>
Message-ID: <Pine.LNX.4.21.0111291630080.12490-100000@hkn.eecs.berkeley.edu>

On Thu, 29 Nov 2001, Danny Yoo wrote:

> On Thu, 29 Nov 2001, Timothy Wilson wrote:
> 
> > A year or so ago a professor at some university made the news when he
> > wrote a program that would automatically scan submitted papers and
> > identify
> 
> Here's one example, from Yes, Professor Aiken from UC Berkeley:
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

??!  What in the world?

I must have pressed Submit too quickly in my email program.  I'm sorry if
that sentence came out sounding arrogant or weird.  It should have just
said "Professor Aiken from UC Berkeley..."



From urnerk@qwest.net  Fri Nov 30 00:36:59 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Thu, 29 Nov 2001 16:36:59 -0800
Subject: [Tutor] the class struggle
In-Reply-To: <20011129170901.B27400@hal>
Message-ID: <4.2.0.58.20011129160411.019fcce0@pop3.norton.antivirus>

At 05:09 PM 11/29/2001 -0600, Rob McGee wrote:
>Hi all, I am a python 2.0 beginner. I'm trying to write a silly little
>program. Actually I *did* write it using a function definition, but I
>wanted to be object-oriented, so I'm trying to use a class instead. This
>isn't working out.
>
>{code}
>import random
>
>def myObject(name):
>   variable = name
>   anotherOne = anotherValue
>   if name in someList:
>     nextVar = this
>     lastOne = that
>   else:
>     nextVar = random.randrange(10, 70)
>     lastOne = random.randrange(5, 15)
>{/code}


Rob, this function is not self contained as written.
You've defined a lot of the variables in the shell,
off camera (so to speak) and these are available as
global variables.  You also appear to be assigning
to globals, versus returning values.  That's called
relying on side-effects and its a major ingredient
in messy, hard-to-debug code.  Not to worry.

If I simply cut and paste your code to my shell,
including the import statement, it dies (not
surprisingly):

   >>> myObject("jim")
   Traceback (most recent call last):
     File "<pyshell#5>", line 1, in ?
       myObject("jim")
     File "<pyshell#4>", line 3, in myObject
       anotherOne = anotherValue
   NameError: global name 'anotherValue' is not defined

I have to make up values for a lot of the variables
in your code before it'll work.  Generally, functions
shouldn't be so dependent on their environment -- critical
external stuff should mostly come through the "front door",
as passed arguments.  And whatever the function does, its
final results should go out the "back door" using a
return statement.

>That works. I got a complete and working (although not very polished)
>program using a function like that. It's worthy of the Useless Python
>site, for sure. :)

I think as a standalone, it's not ready for Useless, because
of it's heavy reliance on stuff you've defined out-of-scope.
Also, it's not documented (gotta have comments explaining
the purpose of the function, before it goes to the internet).

>{code}
>import random
>
>class myObject(name):
>   def __init__(self, name):
>     variable = name
>     anotherOne = anotherValue
>     if name in someList:
>       nextVar = this
>       lastOne = that
>     else:
>       nextVar = random.randrange(10, 70)
>       lastOne = random.randrange(5, 15)
>{/code}

The first problem here is you're saying your class inherits from
some other parent class named 'name'.  Unless you've actually
written such a class, you should not have any parents in the
class declaration, i.e. just go:

   class myObject:

to start.

Beyond that, it should compile as is.  I cut and pasted your
code to my shell and it took.

I was even able to instantiate an object

   omy = MyObject("Duh")

but that's because I've already made anotherValue and
SomeList global, i.e. I defined them higher up in the
session (or module).  If I go:

   >>> del anotherValue

and try to instantiate another object of class myObject:

   >>> omy = myObject("Duh")
   Traceback (most recent call last):
     File "<pyshell#20>", line 1, in ?
       omy = myObject("Duh")
     File "<pyshell#19>", line 4, in __init__
       anotherOne = anotherValue
   NameError: global name 'anotherValue' is not defined

>That doesn't work. "SyntaxError: invalid syntax" on the "if"
>(caret goes under the "f".) I tried adding "self." in front
>of the class instance variables just for fun. Same thing.

I don't understand this error exactly.  I can't reproduce it.
Are you in IDLE, and do your key words colorize?  Is your
'if' orange?

It could be a consequence of trying to inherit from
'name' as a parent class.  You may have 'name' defined
as a global elsewhere...

Back to my original comment, your function 'works' in the
sense that it assigns to global variables.  But this
isn't the way you'll want to assign to globals using
functions.  You should make your function return a value,
or a tuple of values, and let the internal variables
vanish when the function is complete.  Like this:

def mynumber(number, SomeList):
    if number in SomeList:
        return name
    else:
        return random.randrange(10,70)

Then, when using this function, go:

  >>> variable = mynumber(71,[70,71,72])
  >>> variable
  71
  >>> anotherValue = mynumber(73,[70,71,72])
  >>> anotherValue
  46


>I have read the tutorial and what I could find in the other docs about
>classes. I rented Ivan Van Laningham's "24 Hours" book at the local
>bookstore / coffee shop (I always buy a cup of coffee :) and thought I
>I was beginning to understand.

I think you are.  But I'd recommend mastering functions first,
moving to objects next.


>I guess not.
>
>I tried commenting out the if/else lines and making a little function to
>test it out, and now everything after this accursed class definition is
>a SyntaxError.
>
>Is there something online with another description of using class
>definitions? Or perhaps can you fine folks point me in the right
>direction?
>
>BTW, except for classes I think I'm understanding things pretty well. I
>am able to make python do what I set out to do.

But given you're doing a lot of global variable manipulation,
as side-effects of functions, functions which don't explictly
return values, plus heavily depend on environmental values
not passed in as arguments, I'd recommend you slow down and
get a better grip.  Getting the basics down before moving on
can save you a lot of 'unlearning' in the future.

There's no hurry (is there?).

Kirby




From m_konermann@gmx.de  Fri Nov 30 00:40:56 2001
From: m_konermann@gmx.de (Marcus Konermann)
Date: Fri, 30 Nov 2001 01:40:56 +0100
Subject: [Tutor] python21_d.lib ?
Message-ID: <3C06D598.19AD6057@gmx.de>

--------------59D22F0ED047BCDC45DD43E7
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Hi @ all !

I am working with SWIG and generated a C++ file to use it under python.
I work with windows2000 and the VC++ 6.0 Compiler, but now there´s a
linking problem, VC++ says:

Temporäre Dateien und Ausgabedateien für "AG TEM - Win32 Debug" werden
gelöscht.
--------------------Konfiguration: AG TEM - Win32
Debug--------------------
SWIG !!!
Kompilierung läuft...
simanneal.cpp
simanneal_wrap.cpp
Linker-Vorgang läuft...
LINK : fatal error LNK1104: Datei "python21_d.lib" kann nicht geoeffnet
werden
Fehler beim Ausführen von link.exe.

AG TEM.dll - 1 Fehler, 0 Warnung(en)

I searched for the python21_d.lib on my local drive, but i did´nt find
it. Have you got an advice for me ?

Greetings
Marcus

--------------59D22F0ED047BCDC45DD43E7
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi @ all !
<p>I am working with SWIG and generated a C++ file to use it under python.
I work with windows2000 and the VC++ 6.0 Compiler, but now there&acute;s
a linking problem, VC++ says:
<p><i>Tempor&auml;re Dateien und Ausgabedateien f&uuml;r "AG TEM - Win32
Debug" werden gel&ouml;scht.</i>
<br><i>--------------------Konfiguration: AG TEM - Win32 Debug--------------------</i>
<br><i>SWIG !!!</i>
<br><i>Kompilierung l&auml;uft...</i>
<br><i>simanneal.cpp</i>
<br><i>simanneal_wrap.cpp</i>
<br><i>Linker-Vorgang l&auml;uft...</i>
<br><i>LINK : fatal error LNK1104: Datei "python21_d.lib" kann nicht geoeffnet
werden</i>
<br><i>Fehler beim Ausf&uuml;hren von link.exe.</i><i></i>
<p><i>AG TEM.dll - 1 Fehler, 0 Warnung(en)</i>
<p>I searched for the python21_d.lib on my local drive, but i did&acute;nt
find it. Have you got an advice for me ?
<p>Greetings
<br>Marcus</html>

--------------59D22F0ED047BCDC45DD43E7--



From rufmetal@rogers.com  Fri Nov 30 01:05:36 2001
From: rufmetal@rogers.com (Chris Keelan)
Date: Thu, 29 Nov 2001 20:05:36 -0500
Subject: [Tutor] transform html to pdf
In-Reply-To: <20011129220106.57776.qmail@web14704.mail.yahoo.com>
References: <20011129220106.57776.qmail@web14704.mail.yahoo.com>
Message-ID: <20011130011745.GBVN1541.fep04-mail.bloor.is.net.cable.rogers.com@there>

On Thursday 29 November 2001 05:01 pm, Titu Kim wrote:
> I am using RH Linux 7.1.

Cool. Then you should have just about everything you need either on your box 
or on your install CDs.

I tried printing to file from Galeon then running ps2pdf. Note that while the 
output looks good, it doesn't handle frames at all. You may want to 
investigate html2latex or html2tex. I constantly use ps2pdf to produce pdf 
files and it works very well. I have'nt tried html2*tex so please let me know 
how things go.

- Chris


From dyoo@hkn.eecs.berkeley.edu  Fri Nov 30 01:18:23 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Thu, 29 Nov 2001 17:18:23 -0800 (PST)
Subject: [Tutor] python21_d.lib ?
In-Reply-To: <3C06D598.19AD6057@gmx.de>
Message-ID: <Pine.LNX.4.21.0111291638570.12818-100000@hkn.eecs.berkeley.edu>

On Fri, 30 Nov 2001, Marcus Konermann wrote:

> I work with windows2000 and the VC++ 6.0 Compiler, but now there=B4s a
> linking problem, VC++ says:
>=20
> Tempor=E4re Dateien und Ausgabedateien f=FCr "AG TEM - Win32 Debug" werde=
n
> gel=F6scht.
> --------------------Konfiguration: AG TEM - Win32
> Debug--------------------
> SWIG !!!
> Kompilierung l=E4uft...
> simanneal.cpp
> simanneal_wrap.cpp
> Linker-Vorgang l=E4uft...
> LINK : fatal error LNK1104: Datei "python21_d.lib" kann nicht geoeffnet
> werden
> Fehler beim Ausf=FChren von link.exe.
>=20
> AG TEM.dll - 1 Fehler, 0 Warnung(en)
>=20
> I searched for the python21_d.lib on my local drive, but i did=B4nt find
> it. Have you got an advice for me ?


There should be a switch under VC++'s project compile options that says
something about compiling "debug" versions of your program.  You'll
probably want to turn this off when working with Python extensions.


Alternatively, you can download the debug libraries in the
"Python-2.1-Debug.zip" file here:

    http://www.python.org/ftp/python/2.1/

They're not included with the standard Python distribution because they're
rarely used by Python developers.


Hope this helps!



From rufmetal@rogers.com  Fri Nov 30 01:12:16 2001
From: rufmetal@rogers.com (Chris Keelan)
Date: Thu, 29 Nov 2001 20:12:16 -0500
Subject: [Tutor] linux
In-Reply-To: <20011129180103.C12973@harmony.cs.rit.edu>
References: <1D7FF56FBD1FD511982D001083FD3172C3631D@WLDEXU15> <20011129162806.A27400@hal> <20011129180103.C12973@harmony.cs.rit.edu>
Message-ID: <20011130012426.GGKI1541.fep04-mail.bloor.is.net.cable.rogers.com@there>

On Thursday 29 November 2001 06:01 pm, dman wrote:

> I agree.  I started with RH a couple years ago, but switched to Debian
> for a number of reasons.  I first took a look at Debian because the RH
> people really messed up with verison 7 (buggy binary incompatible
> compiler, buggy libc) and I had heard good things about Debian in some
> newsgroups.  I had the two systems dual-booting and I found that
> Debian's package management (and the packages that are available) are
> far superior.

apt-get is one of the coolest things I've ever seen and reason enough to run 
Debian. I'm sticking with Mandrake 8.1 right now because I just couldn't get 
my sound card working with Woody and I have to do some mixing and editing for 
a little project right now. As soon as I buy a bigger harddrive, I'm going to 
dual-boot.

- Chris


From urnerk@qwest.net  Fri Nov 30 01:33:51 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Thu, 29 Nov 2001 17:33:51 -0800
Subject: [Tutor] the class struggle
In-Reply-To: <4.2.0.58.20011129160411.019fcce0@pop3.norton.antivirus>
References: <20011129170901.B27400@hal>
Message-ID: <4.2.0.58.20011129173233.019ced00@pop3.norton.antivirus>

>
>def mynumber(number, SomeList):
>    if number in SomeList:
>        return name
                ^^^^
oops.

typo here -- should be number (decided to change the
variable name midstream, given its content was numeric,
not alpha).

Kirby



From ak@silmarill.org  Fri Nov 30 01:52:18 2001
From: ak@silmarill.org (Andrei Kulakov)
Date: Thu, 29 Nov 2001 20:52:18 -0500
Subject: [Tutor] linux
In-Reply-To: <000e01c17903$c6f82ae0$fe2c0d18@grapid1.mi.home.com>
References: <000e01c17903$c6f82ae0$fe2c0d18@grapid1.mi.home.com>
Message-ID: <20011129205218.A5547@sill.silmarill.org>

On Thu, Nov 29, 2001 at 01:29:26PM -0500, Jeff Jones wrote:
> Sorry about getting off topic here, but beginning to learn programming through Python has peaked my interest in Linux. The only operating system I have ever used has been windows, and I've been using it since the DOS days (except for computer class in the 7th grade when we used apple IIc). Not by choice but because that's what has always been there when I turned the computer on. Getting to the point... Does anyone know of any decent FAQ's etc. for windows users not yet switched to Linux. Specifically, which version to use? Thanks in advance for any help.

I recommend Debian. I first started out with Slackware and spend
countless hours compiling and recompiling things, then I switched to
Debian and it just worked marvellously. The key advantage, I think, is
that Debian seems to have a package for everything and it downloads,
installs and sets it up for you after one command.

The one thing that I liked better in Slack was the init system, but you
don't often need that, and Deb's isn't all that horrible either.

 - Andrei

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


From karthikg@aztec.soft.net  Fri Nov 30 04:32:55 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Fri, 30 Nov 2001 10:02:55 +0530
Subject: [Tutor] generators?
In-Reply-To: <Pine.LNX.4.21.0111291340120.8976-100000@hkn.eecs.berkeley.edu>
Message-ID: <NEBBJNMDEKBIBCMCNMBDOEGGCKAA.karthikg@aztec.soft.net>

hi all,

I remember having seen a link to "new features in python2.2" by Andrew
Kuchling in the python web site.
unable to find that now. Anyway there was a concept of generators?.
if i remember that correctly , it's a function that remembers it's state?
am unable to appreciate it's use.

from __future__ import generators

def func():
	x=1
	y = 100
	yield y
	x+=2
	yield x

f = func()
f.next()
>>100
f.next()
>>3

i get the function object which i guess basically returns an iterator and a
next() gets me the next yield. Where w'd i probably need it? i mean can
someone suggest an ideal scenario OR
can i live w/o it.

thanks in advance,
karthik





















From dsh8290@rit.edu  Fri Nov 30 04:43:14 2001
From: dsh8290@rit.edu (dman)
Date: Thu, 29 Nov 2001 23:43:14 -0500
Subject: [Tutor] generators?
In-Reply-To: <NEBBJNMDEKBIBCMCNMBDOEGGCKAA.karthikg@aztec.soft.net>; from karthikg@aztec.soft.net on Fri, Nov 30, 2001 at 10:02:55AM +0530
References: <Pine.LNX.4.21.0111291340120.8976-100000@hkn.eecs.berkeley.edu> <NEBBJNMDEKBIBCMCNMBDOEGGCKAA.karthikg@aztec.soft.net>
Message-ID: <20011129234314.H13286@harmony.cs.rit.edu>

On Fri, Nov 30, 2001 at 10:02:55AM +0530, karthik Guru wrote:
| hi all,
| 
| I remember having seen a link to "new features in python2.2" by Andrew
| Kuchling in the python web site.
| unable to find that now. Anyway there was a concept of generators?.
| if i remember that correctly , it's a function that remembers it's state?
| am unable to appreciate it's use.
 
| i get the function object which i guess basically returns an iterator and a
| next() gets me the next yield. Where w'd i probably need it? i mean can
| someone suggest an ideal scenario OR
| can i live w/o it.

If you don't understand it, you can live without it.

Now suppose you wanted to make a function that would compute and
return a lot of data.  This can be time-consuming and also
space-consuming.  The data may even be infinite in size.  A client of
your function may only be interested in part of it.  A traditional
solution is to accept a callback from the client, then it is called
periodically with the next bit of data.  The client must then do a lot
of work to break the processing into asynchronous pieces and maintain
state.  Here's an example of how generators make both the producer and
consumer code natural :


from __future__ import generators

def fib() :
    """
    Generate the fibonacci series
    """

    prev2 = 1
    prev1 = 1
    while 1 :
        next = prev1 * prev2
        prev2 = prev1
        prev1 = next

        yield next


# now for the consumer

# this should be an integer
n = input( "How much of the series to you want?" )
count = 0
for item in fib() :
    print item ,
    count += 1
    if count >= n : break


HTH,
-D
 
-- 

It took the computational power of three Commodore 64s to fly to the moon.
It takes at least a 486 to run Windows 95.
Something is wrong here.



From urnerk@qwest.net  Fri Nov 30 05:51:34 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Thu, 29 Nov 2001 21:51:34 -0800
Subject: [Tutor] generators?
In-Reply-To: <NEBBJNMDEKBIBCMCNMBDOEGGCKAA.karthikg@aztec.soft.net>
References: <Pine.LNX.4.21.0111291340120.8976-100000@hkn.eecs.berkeley.edu>
Message-ID: <4.2.0.58.20011129213915.00c37290@pop3.norton.antivirus>

If you don't like the idea of preallocating
memory to hold a list of a million consecutive
integers, as in range(int(1E6)), you could
write lazyrange(a,b,c), which gives the next
integer as needed, but doesn't preallocate.

  >>> def lazyrange(start,stop,inc):
	if (start<stop and inc<0) or \
	   (start>stop and inc>0):
	   raise ValueError,"Illegal parameters"
	while start<stop:
	   yield start
	   start += inc
	return

Because it's a generator, a kind of iterator,
you can iterate over lazyrange() just as you
would range(), meaning you have the benefit
of already familiar syntax:

  >>> for i in lazyrange(0,10,1):
        print i,

  0 1 2 3 4 5 6 7 8 9

You could even get fancy and call yours 'range'
for the duration of your program.  Just store the
builtin range to a variable and restore it when
done:

  >> sr = __builtins__.range

  [define range as above, lazyrange...]

  >>> for i in range(0,1,.1): print i,

  0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0

Works for non-integer increment! -- except I don't
get why it doesn't stop with 0.9, as the previous
example stopped at 9.  Anyone?

OK, we want our regular range() builtin back:

  >>> range = sr  # -- setting range back to default
  >>> range(0,1,.1)
  Traceback (most recent call last):
    File "<pyshell#37>", line 1, in ?
      range(0,1,.1)
  ValueError: range() arg 3 must not be zero

OK, now we get an error message, cuz builtin range
doesn't like .1 as the increment.

Kirby



From urnerk@qwest.net  Fri Nov 30 06:10:50 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Thu, 29 Nov 2001 22:10:50 -0800
Subject: [Tutor] generators?
In-Reply-To: <4.2.0.58.20011129213915.00c37290@pop3.norton.antivirus>
References: <NEBBJNMDEKBIBCMCNMBDOEGGCKAA.karthikg@aztec.soft.net>
 <Pine.LNX.4.21.0111291340120.8976-100000@hkn.eecs.berkeley.edu>
Message-ID: <4.2.0.58.20011129220557.00c3a260@pop3.norton.antivirus>

>
>  >>> for i in range(0,1,.1): print i,
>
>  0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0

OK, I get it now.

yield, like print, is not returning the full floating
point representation as stored internally, and adding .1
successively is introducing slight variances from the
decimal answer, because of the binary thing.

If I force yield to dump a more explicit floating point,
I can see what's happening:

 >>> def lazyrange(start,stop,inc):
         if (start<stop and inc<0) or \
            (start>stop and inc>0):
            raise ValueError,"Illegal"
         while start<stop:
            yield "%r" % start  # <------- note change
            start += inc
         return

 >>> for i in lazyrange(0,1,0.1): print i

0
0.10000000000000001
0.20000000000000001
0.30000000000000004
0.40000000000000002
0.5
0.59999999999999998
0.69999999999999996
0.79999999999999993
0.89999999999999991
0.99999999999999989

start didn't quite reach 1, and so actually yields 1.0
(in the original version) before quitting.

Moral:  floating point can be tricky!  Take care.

Kirby



From deliberatus@my995internet.com  Fri Nov 30 06:32:25 2001
From: deliberatus@my995internet.com (Kirk Bailey)
Date: Fri, 30 Nov 2001 01:32:25 -0500
Subject: [Tutor] Barking mad, simply barking mad, but here it is thus far...
Message-ID: <3C0727F9.E20AD87F@my995internet.com>


Ok, call me a fool, but I am working on a psuedo code outline for the
receive/resend
module of the tinylist list manager. This is very rough at this point,
but if ya want
a look, squint on. Laughter is understood.

All it does is check to see if the sender is a subscriber (and reply
with a refusal message if they are not) and send the letter indivigually
(seperate envlopes) if sender is in the subscriber list.

Ought to look into setting a X header in the thing to prevent mail
loops, and checking for them.
Ought to go to bed.
Ought to go to college for computersci...
ZZZzzz...




------------------shallow mockery of programming
follows--------------------------
#!/usr/local/bin/python
#
# This rough work is a jumble of psuedo code, Python, and wierdshit from
the back
# of my mind back in the days of compiler basic!!!
#
incomingletter = raw_input()
#<stdin> provides the input from the alias,
# which is structured as
#
# listname:"|/path/programname"
#
# Note there is no command line arguement, nor is one needed.
# We KNOW it's a valid list, it came here from an alias!
# Were there no valid identity for that list, we would never see it
here!
#
# therefore, we just read the first part of the TO: field to know it's
name!
# and store that as LISTNAME.
#
letter{}=Parse(incomingletter)
#gotta read more on how to parse a incoming letter. Dummy code for now.
#
listname=leftstr$(len(letter{'To:'}),pos(letter{'To:'},"@")letter{'To:'})
# in other words, set variable listname to everything to the LEFT of '@'
in the
# 'To:' field of the incoming letter.
#
sender = rstrong$(letter{'From'},len(letter{'From:'}-5))
# In other words, trim off the left 5 chars of that field, which 
# would be 'From:' of course. Whatever is left is what we want.
#
# now check to see if the sender string is to be found in the 
# contents of a file with the name of the list in the path specfied.
#
if included('/etc/lists/'+listname, sender)
        # It is in there, so he is a subscriber, and may therefore post
to the list.
        open mail('message','s')
        letter{'Subject:'}
        subject="["+ listname + "]" + letter{'subject'}
        letter{'Subject:'}=subject
        for i in a1:
                mail.send(a1,listname+@+domain, letter{'subject'},
letter{body})
        exit(0)
else
        #This block executes if they are not subscribers to the list!
        open mail('message','s')
        message = "To:"+letter{'From'}
        message = "Subject: RE:"+letter{subject:}
        message = """Body:

Sorry, you are not a subscriber to this list, so you may not post.
Goodby.

This list is mangled by tinylist, so there.
"""
# this line could have read a file for the reply to use, but I got
bigger
# conceptual fish to fry right now.
        close a1

exit(0)
-----------------end of drooling madness------------------------------

Part of me feels the fool for displaying such crude code, but this is a
tutor list for newbies and such, so if not here, where?

Oh- I have got a book about python cgi for the web coming from the
library from out of town, my posts should leap upeards to the merely
confusing soon.

-- 
Respectfully,
             -Kirk D Bailey (C)2001
              Addme! icq #27840081
end


Within the sweep of his sword, Each man is an Ubar.

http://www.howlermonkey.net/
http://www.sacredelectron.org/


-- 
Respectfully,
             -Kirk D Bailey (C)2001
              Addme! icq #27840081
end


Within the sweep of his sword, Each man is an Ubar.

http://www.howlermonkey.net/
http://www.sacredelectron.org/


From cow@esweeet.com  Fri Nov 30 08:03:54 2001
From: cow@esweeet.com (Cow)
Date: Fri, 30 Nov 2001 00:03:54 -0800 (PST)
Subject: [Tutor] Saving files in Python, etc.
Message-ID: <20011130080354.3BACA2755@sitemail.everyone.net>

Hey, my name is Ryan.

I have been programming Visual Basic for about 2 years (on and off) and i decided i wanted to learn another programming language to go along with it.  I looked around and found Python to be very appealing.  I decided to give it a go and i love it.  I am slowly learning the basics and newer things ever day.  I plan to make a Text editor 9or program similiar to one) in Python, but i do not know how to save a file in Python.  lets say i have:

name=raw_input("What is your name?")
age =input("How old are you?")
favcolor=raw_input("What is your favorite color?")

and after the user enters in that information, i want it to save the values of the variables into a new text file.  how could you do that with Python code?

Also, how can you change the color of the console window (in which your program runs in) using code in Python?

Thanks a bunch
-Ryan

_____________________________________________________________
Free eSweeet Mail - http://www.esweeet.com


From karthikg@aztec.soft.net  Fri Nov 30 09:35:25 2001
From: karthikg@aztec.soft.net (karthik Guru)
Date: Fri, 30 Nov 2001 15:05:25 +0530
Subject: [Tutor] Saving files in Python, etc.
In-Reply-To: <20011130080354.3BACA2755@sitemail.everyone.net>
Message-ID: <NEBBJNMDEKBIBCMCNMBDEEGPCKAA.karthikg@aztec.soft.net>

name=raw_input("What is your name?")
age =input("How old are you?")
favcolor=raw_input("What is your favorite color?")

fileObj = open("test.txt","w") // open for for write
fileObj.write(name)
fileObj.write(age)
fileObj.write(favcolor)
fileObj.close()



-----Original Message-----
From: tutor-admin@python.org [mailto:tutor-admin@python.org]On Behalf Of
Cow
Sent: Friday, November 30, 2001 1:34 PM
To: tutor@python.org
Subject: [Tutor] Saving files in Python, etc.


Hey, my name is Ryan.

I have been programming Visual Basic for about 2 years (on and off) and i
decided i wanted to learn another programming language to go along with it.
I looked around and found Python to be very appealing.  I decided to give it
a go and i love it.  I am slowly learning the basics and newer things ever
day.  I plan to make a Text editor 9or program similiar to one) in Python,
but i do not know how to save a file in Python.  lets say i have:

name=raw_input("What is your name?")
age =input("How old are you?")
favcolor=raw_input("What is your favorite color?")

and after the user enters in that information, i want it to save the values
of the variables into a new text file.  how could you do that with Python
code?

Also, how can you change the color of the console window (in which your
program runs in) using code in Python?

Thanks a bunch
-Ryan

_____________________________________________________________
Free eSweeet Mail - http://www.esweeet.com

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



From i812@iname.com  Fri Nov 30 13:17:49 2001
From: i812@iname.com (Rob McGee)
Date: Fri, 30 Nov 2001 07:17:49 -0600
Subject: [Tutor] Re: Thanks for your help  :-)
In-Reply-To: <4.2.0.58.20011128164740.0159de60@pop3.norton.antivirus>; from urnerk@qwest.net on Wed, Nov 28, 2001 at 04:58:51PM -0800
References: <4.2.0.58.20011128100016.00c3cc50@pop3.norton.antivirus> <5.1.0.14.0.20011128092717.00ab17a0@mail45566.popserver.pop <E169851-00014Q-00@mail.python.org> <5.1.0.14.0.20011128103022.00a602e0@mail45566.popserver.pop .net> <4.2.0.58.20011128164740.0159de60@pop3.norton.antivirus>
Message-ID: <20011130071749.C27400@hal>

On Wed, Nov 28, 2001 at 04:58:51PM -0800, Kirby Urner wrote:
> >batch file solution that you provided, seems to be a Windows thing, not a 
> >Linux/Unix thing. Will this hinder my ability to produce cross platform 
> >applications?
> >I know this question is very advanced but I would like to get it right, up 
> >front.
> 
> Linux is similar, except you can use ! "bang" notation at the top
> of a program to tell the OS what interpreter to use.  Then you
> can make the programs executables directly, so a single command
> (the name of the program), with optional arguments, will work.

Actually there is Windows trickery to do this as well, involving some
registry editing. You tell the registry that a .py extension is to be
executed with the Drive:\path-to\python.exe interpreter.

I can't help with details because I don't even have a Windows system
available to me. But I think you can do the registry editing in that
"file types" tab -- I can't remember what main dialog it's attached to
but perhaps you or someone else has seen it before.

> >4) Also, I would like to distribute my apps standalone.
> 
> You'll have to bundle your app with the Python interpreter if
> you can't assume the target machines have Python installed.

Note that you can't distribute the same package for Windows and Linux.
You should also be aware that there are issues with using pre-compiled
binary packages on different GNU/Linux distributions. The UNIX standard,
which works with almost every UNIX-like flavor, is to distribute source
code packages. A binary package might not even work on other systems of
the same distro and version!

My advice is to make your standalone package for Windows only. For your
GNU/Linux users, just give them the script and information about python.
Every major distribution includes a package for python, so most users
probably already have it.

> >5) I also have some question related to how to approach a PYTHON 
> >project(taking into consideration OO). I would like to produce re-usable 
> >code, instead of one time only code.
> 
> As a learner, you should accept the idea of writing lots of
> throwaway code, useful for the learning process, but not
> necessarily worth keeping as is.

I do accept that, Kirby. :) But it's still a good question. I think what
he meant was not that his code was of such high quality, but that he
wants to minimize work over the long term.

For the answer I would have to defer to someone more knowledgeable in
python, but the idea is to save your reusable routines in one or more
.py files separate from your project at hand. Then you import them:
    import [path-to]myRoutines
and you call them with the filename as a prefix:
    duh = myRoutines.helloWorld
    print duh
    approval = myRoutines.getInput('Did you like that?', '(y/n)')
    if approval == 'y':
      print "Great, there's more where that came from."
    elif approval = 'n':
      print "You're no fun."
    else:
      print 'Can\'t you follow simple directions? Type "Y" or "N"!!'

As time goes on and you learn more you can go in and edit myRoutines.py.
If parameters and input formats remain compatible you won't have to edit
the programs which depend on myRoutines. But as you get better ideas,
such as for a new parameter for your getInput() function, you'll break
your old code which is missing the parameter. So perhaps Kirby's right
and at this point it's not worth the trouble to modularize your work.
Again, the judgement of more experienced Python people should be given
more consideration than mine.

    Rob - /dev/rob0


From alan.gauld@bt.com  Fri Nov 30 13:10:10 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 30 Nov 2001 13:10:10 -0000
Subject: [Tutor] question
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C137@mbtlipnt02.btlabs.bt.co.uk>

> I just wanted to ask you guys a question, I recently tried 
> out Visual Basic 6.0 at a friends house, and I was amazed at 
> how easy things are to do with the making of the GUI 
> interface to programs, 

Yep, VB is king at quick GUI building. (Actually Delphi is pretty 
good too). VB is less good when you get to writing the code that 
does the work - you can do it but it tends to be quite verbose.

There are some GUI builders for doing GUIs in Python too.
BlackAdder, Glade, SpecTCL and KOMODO all do visual GUI 
building. But the VB environment is one of the fastest 
and easiest to use without doubt.

> off learning visual basic good and then coming back to python 

The opposite is better. Python forces you down good programming 
habits. Those habits can be used in VB but the language does 
nothing to stop you using bad habits. Bad habits once learnt 
are hard to break!

VB is definitely worth knowing tho' if only because it's the 
natural scripting language for Microsoft products. There are 
also lots of VB jobs around!

> I have tried to read the docs on how to compile with python 

Why do you believe you need to compile with Python?
VB up until V5 couldn't "compile" either. It didn't harm its 
acceptance, people just got used to having ~1Mb DLL and ocx files
on the PC to run their VB programs. (try searching your PC for 
VBRUN*.DLL  and *.ocx to see how many you have and how much 
space they take up! You'll almost certainly find at least one 
VBRUN and loads of ocxs - about 20Mb worth on my machine)) 
Once you get Python installed the programs run fast enough for 
most things just as they are.

Alan G.


From alan.gauld@bt.com  Fri Nov 30 13:17:43 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 30 Nov 2001 13:17:43 -0000
Subject: [Tutor] question
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C138@mbtlipnt02.btlabs.bt.co.uk>

> But this metaphor is only somewhat correct.  If the whole
> point of the app is to do graphical stuff, and the interface
> is core to its functionality, then it's too dismissive to
> call it "cosmetic".  That being said, all the interface
> widgets in the world don't an interesting app make -- it's
> gotta actually DO something (right?).

I recall the look I got from a client once when trying to explain 
why his heavily batch oriented server based project was costing 
so much with so little to show for it - basically there were 
just some primitive admin screens as a GUI.

I pointed out he was getting as much code as was in Excel 
its just that Excel was all glitter and gloss on top of what 
was basically a pocket caclulator replicated many times, 
whereas he was getting a wild west style facade onto a 
full blown factory.

His expression as he tried to think of Excel as being 
"just a pocket calculator" was a picture (It was a 
rather tongue in cheek explanation I must confess! :-)

Alan g.


From alan.gauld@bt.com  Fri Nov 30 13:22:30 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 30 Nov 2001 13:22:30 -0000
Subject: [Tutor] Re: how do I sleep?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C139@mbtlipnt02.btlabs.bt.co.uk>

> Since I have also found that VB programs (even on NT) require 
> an occassional call to DoEvents, it is probably a defect 
> in the VB runtime.  

Nope its a defect in the NT kernel if you can do that. There is 
catagorically no way that a VB app should be able to block 
other processes on NT. I'd be interested to know under what 
circumstances that happens. It *might* be feasible if operating 
at ring 0 but that's not usually VB country!

I must confess I've seen the PCV slowed down by heavy CPU munching 
but I've never seen NT lose scheduling completely. In the former 
case the usual answer is to launch a seaparate thread for the CPU intensive
bit or simply lower the process priority.

Alan g.


From alan.gauld@bt.com  Fri Nov 30 13:32:41 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 30 Nov 2001 13:32:41 -0000
Subject: [Tutor] the class struggle
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C13A@mbtlipnt02.btlabs.bt.co.uk>

> import random
> 
> class myObject(name):

This says you are defining a class that inherits from 
something called name, you probably don't mean that.

>   def __init__(self, name):

This says you have a constructor taking a parameter called 
name, this is starting to get confusing - to me if not to 
Python!

>     variable = name
>     anotherOne = anotherValue

anotherValue is presumably a global variable defined elsewhere?

>     if name in someList:

As is someList?
It might be better to pass these in as parameters to init() too.
Now which name are we referring to here? Is it the parent 
class or the parameter to the method?

I'm not sure how Python sees that but it might contribute. 
Its certainly confusing me!

BTW Without using self all of these values get thrown 
away when you finish __init__()... unless they are all 
globals!?

Alan g.

PS If someone else has already answered my apologies I'm 
catching up on the digested list during a very boring 
teleconference!!!


From arcege@speakeasy.net  Fri Nov 30 14:05:14 2001
From: arcege@speakeasy.net (Michael P. Reilly)
Date: Fri, 30 Nov 2001 09:05:14 -0500
Subject: [Tutor] question
In-Reply-To: <5104D4DBC598D211B5FE0000F8FE7EB20E66C138@mbtlipnt02.btlabs.bt.co.uk>; from alan.gauld@bt.com on Fri, Nov 30, 2001 at 01:17:43PM -0000
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C138@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <20011130090514.C1033@speakeasy.net>

On Fri, Nov 30, 2001 at 01:17:43PM -0000, alan.gauld@bt.com wrote:
> His expression as he tried to think of Excel as being 
> "just a pocket calculator" was a picture (It was a 
> rather tongue in cheek explanation I must confess! :-)

Is it? Remember the old Hewlett Packard programmable calculators?
_That_ was just a pocket calculator ;)  Personally, I'd rather have one
of those HP calculators than someting like Excel.

  -Arcege

-- 
+----------------------------------+-----------------------------------+
| Michael P. Reilly                | arcege@speakeasy.net              |


From m_konermann@gmx.de  Fri Nov 30 14:35:52 2001
From: m_konermann@gmx.de (Marcus Konermann)
Date: Fri, 30 Nov 2001 15:35:52 +0100
Subject: [Tutor] Linking Problems using VC++ 6.0
Message-ID: <3C079948.F2CC54DC@gmx.de>

--------------06D8857BC038DDB47BC7FFFF
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

Hi @ All !

I am working with SWIG and generated a C++ file to use it under python.
I work with windows2000 and the VC++ 6.0 Compiler, but now there are
linking problems, VC++ says:

Temporäre Dateien und Ausgabedateien für "AG TEM - Win32 Debug" werden
gelöscht.
--------------------Konfiguration: AG TEM - Win32
Debug--------------------
SWIG !!!
Kompilierung läuft...
simanneal.cpp
simanneal_wrap.cpp
Linker-Vorgang läuft...
   Bibliothek Debug/AG TEM.lib und Objekt Debug/AG TEM.exp wird erstellt

simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: void __thiscall variablelist::clean(void)"
(?clean@variablelist@@QAEXXZ)
simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall variablelist::pt2xn(int)"
(?pt2xn@variablelist@@QAEHH@Z)
simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::copy(struct variable *)"
(?copy@string@@QAEHPAUvariable@@@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::copy(struct variable *)"
(?copy@string@@QAEHPAUvariable@@@Z)
simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct variable & __thiscall variable::operator=(struct
variable &)"
(??4variable@@QAEAAU0@AAU0@@Z)
simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol "int
__cdecl calculate(struct variable &,struct variablelist *,struct
basisfile *,struct string *)"
(?calculate@@YAHAAUvariable@@PAUvariablelist@@PAUbasisfile@@PAUstring@@@Z)

simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"int __cdecl calculate(struct variable &,struct variablelist *,struct
basisfile *,struct string *)"
(?calculate@@YAHAAUvariable@@PAUvariablelist@@PAUbasisfile@@PAUstring@@@Z)

simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall evaluate::abort(struct variable &)"
(?abort@evaluate@@QAEHAAUvariable@@@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall evaluate::abort(struct variable &)"
(?abort@evaluate@@QAEHAAUvariable@@@Z)
simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall variable::~variable(void)" (??1variable@@QAE@XZ)
simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol "void
__cdecl strprint(struct string &,char *,char *)"
(?strprint@@YAXAAUstring@@PAD1@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"void __cdecl strprint(struct string &,char *,char *)"
(?strprint@@YAXAAUstring@@PAD1@Z)

simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol "int
__cdecl calculate(struct variable &,struct basisfile *,struct string *)"

(?calculate@@YAHAAUvariable@@PAUbasisfile@@PAUstring@@@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"int __cdecl calculate(struct variable &,struct basisfile *,struct
string *)"
(?calculate@@YAHAAUvariable@@PAUbasisfile@@PAUstring@@@Z)
simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: void __thiscall variable::init(double,int)"
(?init@variable@@QAEXNH@Z)
simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall variable::variable(void)" (??0variable@@QAE@XZ)
simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol "int
__cdecl read_double(double &,struct variable *)"
(?read_double@@YAHAANPAUvariable@@@Z)
simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol "int
__cdecl random_step(struct variable *,struct variable *)"
(?random_step@@YAHPAUvariable@@0@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall evaluate::evaluate(void)" (??0evaluate@@QAE@XZ)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall evaluate::~evaluate(void)" (??1evaluate@@QAE@XZ)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall string::string(void)" (??0string@@QAE@XZ)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall string::string(int,char *)" (??0string@@QAE@HPAD@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall string::string(char *,char *)"
(??0string@@QAE@PAD0@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall string::string(struct string &,char *)"
(??0string@@QAE@AAU0@PAD@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall string::~string(void)" (??1string@@QAE@XZ)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: void __thiscall string::clean(void)" (?clean@string@@QAEXXZ)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string & __thiscall string::cat(struct string &)"
(?cat@string@@QAEAAU1@AAU1@@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string & __thiscall string::cat(char *)"
(?cat@string@@QAEAAU1@PAD@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string & __thiscall string::copy(struct string &)"
(?copy@string@@QAEAAU1@AAU1@@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string & __thiscall string::copy(char *)"
(?copy@string@@QAEAAU1@PAD@Z)

simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::copy(double,long)"
(?copy@string@@QAEHNJ@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::copy(int)" (?copy@string@@QAEHH@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: void __thiscall string::out(char * *)"
(?out@string@@QAEXPAPAD@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string & __thiscall string::ncopy(struct string &,int)"
(?ncopy@string@@QAEAAU1@AAU1@H@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string & __thiscall string::ncopy(struct string
&,int,int)"
(?ncopy@string@@QAEAAU1@AAU1@HH@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string & __thiscall string::compose(struct string
&,struct string &,char *)"
(?compose@string@@QAEAAU1@AAU1@0PAD@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string & __thiscall string::compose(struct string &,char
*,char *)"
(?compose@string@@QAEAAU1@AAU1@PAD1@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string & __thiscall string::compose(struct string
&,double,char *)"
(?compose@string@@QAEAAU1@AAU1@NPAD@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string & __thiscall string::compose(struct string
&,int,char *)"
(?compose@string@@QAEAAU1@AAU1@HPAD@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::element(int)" (?element@string@@QAEHH@Z)

simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::compare(struct string &)"
(?compare@string@@QAEHAAU1@@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::compare(char *)"
(?compare@string@@QAEHPAD@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_complement_span(char *,int)"
(?string_complement_span@string@@QAEHPADH@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_complement_span(struct string
&,int)"
(?string_complement_span@string@@QAEHAAU1@H@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_complement_span(char *)"
(?string_complement_span@string@@QAEHPAD@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_span(struct string &,int)"
(?string_span@string@@QAEHAAU1@H@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_span(char *,int)"
(?string_span@string@@QAEHPADH@Z)

simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_string(struct string &,char *)"
(?string_string@string@@QAEHAAU1@PAD@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_string(struct string &,struct
string &)"
(?string_string@string@@QAEHAAU1@0@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_string(struct string &,struct
string &,int)"
(?string_string@string@@QAEHAAU1@0H@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_character(char)"
(?string_character@string@@QAEHD@Z)

simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: void __thiscall string::string_pointer_break(struct string
&,char *)"
(?string_pointer_break@string@@QAEXAAU1@PAD@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct _iobuf * __thiscall string::fileopen(char *)"
(?fileopen@string@@QAEPAU_iobuf@@PAD@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::fileread(struct string &)"
(?fileread@string@@QAEHAAU1@@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::filereadc(struct string &,char)"
(?filereadc@string@@QAEHAAU1@D@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::filewrite(struct string &,char *)"
(?filewrite@string@@QAEHAAU1@PAD@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::filewrite(struct _iobuf *)"
(?filewrite@string@@QAEHPAU_iobuf@@@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::system_call(void)"
(?system_call@string@@QAEHXZ)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: void __thiscall string::init(int,char *)"
(?init@string@@QAEXHPAD@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"void __cdecl print(struct string &)" (?print@@YAXAAUstring@@@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"void __cdecl strprint(struct string &,int,char *,char *)"
(?strprint@@YAXAAUstring@@HPAD1@Z)
simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"void __cdecl strprint(struct string &,int,char,char *,char *)"
(?strprint@@YAXAAUstring@@HDPAD1@Z)
Debug/AG TEM.dll : fatal error LNK1120: 57 unaufgeloeste externe
Verweise
Fehler beim Ausführen von link.exe.

AG TEM.dll - 63 Fehler, 0 Warnung(en)

Have you got an idea ?

Greetings
Marcus

--------------06D8857BC038DDB47BC7FFFF
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi @ All !
<p>I am working with SWIG and generated a C++ file to use it under python.
I work with windows2000 and the VC++ 6.0 Compiler, but now there are linking
problems, VC++ says:
<p><i>Tempor&auml;re Dateien und Ausgabedateien f&uuml;r "AG TEM - Win32
Debug" werden gel&ouml;scht.</i>
<br><i>--------------------Konfiguration: AG TEM - Win32 Debug--------------------</i>
<br><i>SWIG !!!</i>
<br><i>Kompilierung l&auml;uft...</i>
<br><i>simanneal.cpp</i>
<br><i>simanneal_wrap.cpp</i>
<br><i>Linker-Vorgang l&auml;uft...</i>
<br><i>&nbsp;&nbsp; Bibliothek Debug/AG TEM.lib und Objekt Debug/AG TEM.exp
wird erstellt</i>
<br><i>simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: void __thiscall variablelist::clean(void)" (?clean@variablelist@@QAEXXZ)</i>
<br><i>simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall variablelist::pt2xn(int)" (?pt2xn@variablelist@@QAEHH@Z)</i>
<br><i>simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::copy(struct variable *)" (?copy@string@@QAEHPAUvariable@@@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::copy(struct variable *)"</i>
<br><i>(?copy@string@@QAEHPAUvariable@@@Z)</i>
<br><i>simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct variable &amp; __thiscall variable::operator=(struct variable
&amp;)"</i>
<br><i>(??4variable@@QAEAAU0@AAU0@@Z)</i>
<br><i>simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"int __cdecl calculate(struct variable &amp;,struct variablelist *,struct
basisfile *,struct string *)"</i>
<br><i>(?calculate@@YAHAAUvariable@@PAUvariablelist@@PAUbasisfile@@PAUstring@@@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"int __cdecl calculate(struct variable &amp;,struct variablelist *,struct
basisfile *,struct string *)"</i>
<br><i>(?calculate@@YAHAAUvariable@@PAUvariablelist@@PAUbasisfile@@PAUstring@@@Z)</i>
<br><i>simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall evaluate::abort(struct variable &amp;)"</i>
<br><i>(?abort@evaluate@@QAEHAAUvariable@@@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall evaluate::abort(struct variable &amp;)"</i>
<br><i>(?abort@evaluate@@QAEHAAUvariable@@@Z)</i>
<br><i>simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall variable::~variable(void)" (??1variable@@QAE@XZ)</i>
<br><i>simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"void __cdecl strprint(struct string &amp;,char *,char *)" (?strprint@@YAXAAUstring@@PAD1@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"void __cdecl strprint(struct string &amp;,char *,char *)" (?strprint@@YAXAAUstring@@PAD1@Z)</i><i></i>
<p><i>simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"int __cdecl calculate(struct variable &amp;,struct basisfile *,struct
string *)"</i>
<br><i>(?calculate@@YAHAAUvariable@@PAUbasisfile@@PAUstring@@@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"int __cdecl calculate(struct variable &amp;,struct basisfile *,struct
string *)"</i>
<br><i>(?calculate@@YAHAAUvariable@@PAUbasisfile@@PAUstring@@@Z)</i>
<br><i>simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: void __thiscall variable::init(double,int)" (?init@variable@@QAEXNH@Z)</i>
<br><i>simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall variable::variable(void)" (??0variable@@QAE@XZ)</i>
<br><i>simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"int __cdecl read_double(double &amp;,struct variable *)"</i>
<br><i>(?read_double@@YAHAANPAUvariable@@@Z)</i>
<br><i>simanneal.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"int __cdecl random_step(struct variable *,struct variable *)"</i>
<br><i>(?random_step@@YAHPAUvariable@@0@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall evaluate::evaluate(void)" (??0evaluate@@QAE@XZ)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall evaluate::~evaluate(void)" (??1evaluate@@QAE@XZ)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall string::string(void)" (??0string@@QAE@XZ)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall string::string(int,char *)" (??0string@@QAE@HPAD@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall string::string(char *,char *)" (??0string@@QAE@PAD0@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall string::string(struct string &amp;,char *)" (??0string@@QAE@AAU0@PAD@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: __thiscall string::~string(void)" (??1string@@QAE@XZ)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: void __thiscall string::clean(void)" (?clean@string@@QAEXXZ)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string &amp; __thiscall string::cat(struct string &amp;)"</i>
<br><i>(?cat@string@@QAEAAU1@AAU1@@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string &amp; __thiscall string::cat(char *)" (?cat@string@@QAEAAU1@PAD@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string &amp; __thiscall string::copy(struct string &amp;)"</i>
<br><i>(?copy@string@@QAEAAU1@AAU1@@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string &amp; __thiscall string::copy(char *)" (?copy@string@@QAEAAU1@PAD@Z)</i><i></i>
<p><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::copy(double,long)" (?copy@string@@QAEHNJ@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::copy(int)" (?copy@string@@QAEHH@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: void __thiscall string::out(char * *)" (?out@string@@QAEXPAPAD@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string &amp; __thiscall string::ncopy(struct string &amp;,int)"</i>
<br><i>(?ncopy@string@@QAEAAU1@AAU1@H@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string &amp; __thiscall string::ncopy(struct string &amp;,int,int)"</i>
<br><i>(?ncopy@string@@QAEAAU1@AAU1@HH@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string &amp; __thiscall string::compose(struct string &amp;,struct
string &amp;,char *)"</i>
<br><i>(?compose@string@@QAEAAU1@AAU1@0PAD@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string &amp; __thiscall string::compose(struct string &amp;,char
*,char *)"</i>
<br><i>(?compose@string@@QAEAAU1@AAU1@PAD1@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string &amp; __thiscall string::compose(struct string &amp;,double,char
*)"</i>
<br><i>(?compose@string@@QAEAAU1@AAU1@NPAD@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct string &amp; __thiscall string::compose(struct string &amp;,int,char
*)"</i>
<br><i>(?compose@string@@QAEAAU1@AAU1@HPAD@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::element(int)" (?element@string@@QAEHH@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::compare(struct string &amp;)"</i>
<br><i>(?compare@string@@QAEHAAU1@@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::compare(char *)" (?compare@string@@QAEHPAD@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_complement_span(char *,int)"</i>
<br><i>(?string_complement_span@string@@QAEHPADH@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_complement_span(struct string &amp;,int)"</i>
<br><i>(?string_complement_span@string@@QAEHAAU1@H@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_complement_span(char *)"</i>
<br><i>(?string_complement_span@string@@QAEHPAD@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_span(struct string &amp;,int)"</i>
<br><i>(?string_span@string@@QAEHAAU1@H@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_span(char *,int)" (?string_span@string@@QAEHPADH@Z)</i><i></i>
<p><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_string(struct string &amp;,char
*)"</i>
<br><i>(?string_string@string@@QAEHAAU1@PAD@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_string(struct string &amp;,struct
string &amp;)"</i>
<br><i>(?string_string@string@@QAEHAAU1@0@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_string(struct string &amp;,struct
string &amp;,int)"</i>
<br><i>(?string_string@string@@QAEHAAU1@0H@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::string_character(char)" (?string_character@string@@QAEHD@Z)</i><i></i>
<p><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: void __thiscall string::string_pointer_break(struct string &amp;,char
*)"</i>
<br><i>(?string_pointer_break@string@@QAEXAAU1@PAD@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: struct _iobuf * __thiscall string::fileopen(char *)"</i>
<br><i>(?fileopen@string@@QAEPAU_iobuf@@PAD@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::fileread(struct string &amp;)" (?fileread@string@@QAEHAAU1@@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::filereadc(struct string &amp;,char)"</i>
<br><i>(?filereadc@string@@QAEHAAU1@D@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::filewrite(struct string &amp;,char *)"</i>
<br><i>(?filewrite@string@@QAEHAAU1@PAD@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::filewrite(struct _iobuf *)"</i>
<br><i>(?filewrite@string@@QAEHPAU_iobuf@@@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: int __thiscall string::system_call(void)" (?system_call@string@@QAEHXZ)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"public: void __thiscall string::init(int,char *)" (?init@string@@QAEXHPAD@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"void __cdecl print(struct string &amp;)" (?print@@YAXAAUstring@@@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"void __cdecl strprint(struct string &amp;,int,char *,char *)"</i>
<br><i>(?strprint@@YAXAAUstring@@HPAD1@Z)</i>
<br><i>simanneal_wrap.obj : error LNK2001: Nichtaufgeloestes externes Symbol
"void __cdecl strprint(struct string &amp;,int,char,char *,char *)"</i>
<br><i>(?strprint@@YAXAAUstring@@HDPAD1@Z)</i>
<br><i>Debug/AG TEM.dll : fatal error LNK1120: 57 unaufgeloeste externe
Verweise</i>
<br><i>Fehler beim Ausf&uuml;hren von link.exe.</i><i></i>
<p><i>AG TEM.dll - 63 Fehler, 0 Warnung(en)</i>
<p>Have you got an idea ?
<p>Greetings
<br>Marcus</html>

--------------06D8857BC038DDB47BC7FFFF--



From pythontutor@venix.com  Fri Nov 30 14:35:45 2001
From: pythontutor@venix.com (Lloyd Kvam)
Date: Fri, 30 Nov 2001 09:35:45 -0500
Subject: [Tutor] Re: how do I sleep?
References: <5104D4DBC598D211B5FE0000F8FE7EB20E66C139@mbtlipnt02.btlabs.bt.co.uk>
Message-ID: <3C079941.8080600@venix.com>

Private Sub txtValue_GotFocus(Index As Integer)
' This looks very peculiar.  It solves a problem where VB
' would sometimes position the cursor so that no text was visible.
DoEvents                    'external events
txtValue(Index).SelStart = 0
DoEvents
txtValue(Index).SelLength = Len(txtValue(Index).Text)
End Sub

This is my VB handler for text boxes when they get focus.
The purpose is to select the current text value so that you can copy/cut
OR simply start typing and replace the whole string.

Without the calls to DoEvents, the text box would sometimes be displayed as an
empty.  The text was positioned out of the text box window.  I had to prove this
to my users by hitting <left arrow> keys to get back to the text.

This is speculation on my part:
DoEvents doesn't yield to other NT processes.  It yields to other threads in the VB
runtime.  VB has trouble doing all of its screen handling in the right order.  The
GotFocus event can be triggered before VB is really ready to accept any
instructions.

I am very glad to say that I have never encountered this kind of weird behavior in
Python.

alan.gauld@bt.com wrote:

>>Since I have also found that VB programs (even on NT) require 
>>an occassional call to DoEvents, it is probably a defect 
>>in the VB runtime.  
>>
> 
> Nope its a defect in the NT kernel if you can do that. There is 
> catagorically no way that a VB app should be able to block 
> other processes on NT. I'd be interested to know under what 
> circumstances that happens. It *might* be feasible if operating 
> at ring 0 but that's not usually VB country!
> 
> I must confess I've seen the PCV slowed down by heavy CPU munching 
> but I've never seen NT lose scheduling completely. In the former 
> case the usual answer is to launch a seaparate thread for the CPU intensive
> bit or simply lower the process priority.
> 
> Alan g.
> 
> 


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

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



From rickp@telocity.com  Fri Nov 30 14:40:07 2001
From: rickp@telocity.com (rickp@telocity.com)
Date: Fri, 30 Nov 2001 09:40:07 -0500
Subject: [Tutor] Tkinter and threads
Message-ID: <20011130094007.A14730@tc.niof.net>

Following is some pseudo code to illustrate my problem. The text that is
written from the main program displays immediately, as it should.
However, the text that is written from the thread doesn't display until
I fiddle with the scrollbar. What I'm trying to do is let the user know
as each background process completes. Do I need to add some kind of
locking?

def bkgrd(l,w):
	w.write('starting background process\n')
	for i in l:
		# do something
	w.write('done with background\n')

class WinLog:
	def __init__(self,master):
		self.win = Toplevel(master)
		self.txt = ScrolledText(self.win)
		self.txt.pack()
	def write(self,txt):
		self.txt.insert(END,txt)
		self.win.update()

win = Tk()
wl = WinLog(win)
for x in 'file1','file2','file3','file4':
	f = open(x)
	lns = f.readlines()
	wl.write('read %d lines\n' % len(lns))
	f.close()
	thread.start_new(bkgrd,(lns,wl))
win.wait_window(wl)

-- 
If each man has the right to defend, even by force, his person,
his liberty, and his property, several men have the right to get
together, come to an understanding, and organize a collective
force to provide regularly for this defense.
	-- Frédéric Bastiat (1801-1850)
    Rick Pasotto    rickp@telocity.com    http://www.niof.net


From alan.gauld@bt.com  Fri Nov 30 15:00:17 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 30 Nov 2001 15:00:17 -0000
Subject: [Tutor] Re: how do I sleep?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C13B@mbtlipnt02.btlabs.bt.co.uk>

> Private Sub txtValue_GotFocus(Index As Integer)
> DoEvents                    'external events
> txtValue(Index).SelStart = 0
> ...
> End Sub
> 
> This is my VB handler for text boxes when they get focus.
> The purpose is to select the current text value so that you 
> can copy/cut OR simply start typing and replace the whole string.

> DoEvents doesn't yield to other NT processes.  It yields to 
> other threads in the VB runtime.  VB has trouble doing all 
> of its screen handling in the right order.  

Ah I see. Yes you could use DoEvents for that. Its freeing 
the local process to read events from its own queue not 
doing anything with the NT kernel at all.

In that case it is a bit of VB cruft rather than an NT problem.

> I am very glad to say that I have never encountered this kind 
> of weird behavior in Python.

I've never encountered it even in other MS development tools
J++, VC++ etc. Certainly not in Delphi (my personal favourite 
NT tool)


Thanks for clarifying that,

Alan g


From alan.gauld@bt.com  Fri Nov 30 15:07:13 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 30 Nov 2001 15:07:13 -0000
Subject: [Tutor] Saving files in Python, etc.
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C13C@mbtlipnt02.btlabs.bt.co.uk>

> I have been programming Visual Basic for about 2 years (on 
> to one) in Python, but i do not know how to save a file in 
> Python.  lets say i have:

Try my tutor. It illustrates concepts using QBASIC and Python 
so you can compare what you know with Python(QBASIC being 
similar to VB in syntax)

It has a topivc on file handling

http://www.freenetpages.co.uk/hp/alan.gauld/

> Also, how can you change the color of the console window (in 
> which your program runs in) using code in Python?

Assuming you are in a DOS window you can write ANSI.SYS 
control strings - read the ANSI.SYS info in the help pages 
- might be part of the Res Kit help in recent Win9x....

If you mean IDLE I think you have to do it the hard way 
and edit the .py file code - probably safer to leave it 
alone for now!

HTH

Alan g


From dsh8290@rit.edu  Fri Nov 30 15:17:38 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 30 Nov 2001 10:17:38 -0500
Subject: [Tutor] generators?
In-Reply-To: <4.2.0.58.20011129220557.00c3a260@pop3.norton.antivirus>; from urnerk@qwest.net on Thu, Nov 29, 2001 at 10:10:50PM -0800
References: <NEBBJNMDEKBIBCMCNMBDOEGGCKAA.karthikg@aztec.soft.net> <Pine.LNX.4.21.0111291340120.8976-100000@hkn.eecs.berkeley.edu> <4.2.0.58.20011129213915.00c37290@pop3.norton.antivirus> <4.2.0.58.20011129220557.00c3a260@pop3.norton.antivirus>
Message-ID: <20011130101737.A13560@harmony.cs.rit.edu>

On Thu, Nov 29, 2001 at 10:10:50PM -0800, Kirby Urner wrote:
| 
| >
| >  >>> for i in range(0,1,.1): print i,
| >
| >  0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0
| 
| OK, I get it now.
| 
| yield, like print, is not returning the full floating

Actually, yield returns the object you have it yielding, whatever that
is.  It is your "print" (that prints the yielded object) that is
causing the rounding to occur.

| start didn't quite reach 1, and so actually yields 1.0
| (in the original version) before quitting.
| 
| Moral:  floating point can be tricky!  Take care.

Right.

-D

-- 

the nice thing about windoze is - it does not just crash,
it displays a dialog box and lets you press 'ok' first.



From alan.gauld@bt.com  Fri Nov 30 15:14:47 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 30 Nov 2001 15:14:47 -0000
Subject: [Tutor] Re: Thanks for your help  :-)
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C13D@mbtlipnt02.btlabs.bt.co.uk>

> > >project(taking into consideration OO). I would like to 
> > >produce re-usable code, instead of one time only code.

> For the answer I would have to defer to someone more knowledgeable in
> python, but the idea is to save your reusable routines in one or more
> .py files separate from your project at hand. Then you import them:

One of the things I attempt to illustrate in my Case Study on 
my web tutor is how a bit of simple one-shot code can be 
evolved into:

1) a reusable module then
2) an OO module allowing extension and specialisation and
3) a GUI wrapper placed around it

One of the great myths of software engineering is that code 
reuse is cheaper than writing it twice. Its not, its nearly 
always cheaper to write it twice. Reuse is only valuable 
when you don't want to write it 5 or more times(*).

Having said that Python makes economical reuse easier than 
nearly any other languahe I've seen. But even so reuse is 
best evolved not designed - its nearly impossible to design 
a resusable bit of code correctly from scratch!

Alan g.

(*) Studies on reuse show figures varying from 3 to 10 times 
the cost of one-shot code. 5 seems like a reasonable average...


From dsh8290@rit.edu  Fri Nov 30 15:23:07 2001
From: dsh8290@rit.edu (dman)
Date: Fri, 30 Nov 2001 10:23:07 -0500
Subject: [Tutor] generators?
In-Reply-To: <20011129234314.H13286@harmony.cs.rit.edu>; from dsh8290@ritvax.rit.edu on Thu, Nov 29, 2001 at 11:43:14PM -0500
References: <Pine.LNX.4.21.0111291340120.8976-100000@hkn.eecs.berkeley.edu> <NEBBJNMDEKBIBCMCNMBDOEGGCKAA.karthikg@aztec.soft.net> <20011129234314.H13286@harmony.cs.rit.edu>
Message-ID: <20011130102306.B13560@harmony.cs.rit.edu>

On Thu, Nov 29, 2001 at 11:43:14PM -0500, dman wrote:
...

| def fib() :
|     """
|     Generate the fibonacci series
|     """
| 
|     prev2 = 1
|     prev1 = 1
|     while 1 :
|         next = prev1 * prev2
|         prev2 = prev1
|         prev1 = next
| 
|         yield next

As you can see here I messed up the math.  This would return '1'
forever.


def fib() :
    # the first two values in the sequence
    prev2 = 0
    yield prev2 
    prev1 = 1
    yield prev1

    while 1 :
        next = prev1 + prev2
        prev2 = prev1
        prev1 = next

        yield next


If I test it this time :

>>> for i in fib() :
...   print i ,
...   time.sleep( 1 )
... 
0 1 1 2 3 5 8 13
Traceback (most recent call last):
  File "<stdin>", line 3, in ?
  KeyboardInterrupt
>>> 

That looks better :-).  (BTW, without the sleep the numbers get real
big real fast!)

-D

-- 

the nice thing about windoze is - it does not just crash,
it displays a dialog box and lets you press 'ok' first.



From Bruce.Lee-Shanok@cognos.com  Fri Nov 30 15:27:15 2001
From: Bruce.Lee-Shanok@cognos.com (Lee-Shanok, Bruce)
Date: Fri, 30 Nov 2001 10:27:15 -0500
Subject: [Tutor] Variables by reference?
Message-ID: <FB15E670DA55D51185350008C786514A0140EA99@sottexch1.cognos.com>

Is there any way to get python to return values by reference, like a C
pointer?

This message may contain privileged and/or confidential information.  If you
have received this e-mail in error or are not the intended recipient, you
may not use, copy, disseminate, or distribute it; do not open any
attachments, delete it immediately from your system and notify the sender by
e-mail promptly that you have done so.  Thank You.


From urnerk@qwest.net  Fri Nov 30 16:01:42 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Fri, 30 Nov 2001 08:01:42 -0800
Subject: [Tutor] generators?
In-Reply-To: <20011130101737.A13560@harmony.cs.rit.edu>
References: <4.2.0.58.20011129220557.00c3a260@pop3.norton.antivirus>
 <NEBBJNMDEKBIBCMCNMBDOEGGCKAA.karthikg@aztec.soft.net>
 <Pine.LNX.4.21.0111291340120.8976-100000@hkn.eecs.berkeley.edu>
 <4.2.0.58.20011129213915.00c37290@pop3.norton.antivirus>
 <4.2.0.58.20011129220557.00c3a260@pop3.norton.antivirus>
Message-ID: <4.2.0.58.20011130080125.00c1aea0@pop3.norton.antivirus>

>
>Actually, yield returns the object you have it yielding, whatever that
>is.  It is your "print" (that prints the yielded object) that is
>causing the rounding to occur.

Ah yes, thanks, good point.

Kirby



From wilson@visi.com  Fri Nov 30 16:18:22 2001
From: wilson@visi.com (Timothy Wilson)
Date: Fri, 30 Nov 2001 10:18:22 -0600 (CST)
Subject: [Tutor] catching cheaters (cont.)
Message-ID: <Pine.GSO.4.21.0111301008290.20742-100000@isis.visi.com>

Hi everyone,

I located the Web page of the professor I mentioned in my initial
message. He has a GPL'ed version of his 'Copyfind' software on his Web site
at http://plagiarism.physics.virginia.edu/. The source is available
(obviously for a GPD'ed program), but it's in C++. I think I can read it
well enough to come up with some ideas of my own. Interestingly, he posts a
list of improvements that could be made to the software and invites people
to try to improve it.

This could be a fun project to work on. And as they say in the free software
world, most projects of this type get started because someone writes
something to "scratch their own itch."

-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 SWidney@ci.las-vegas.nv.us  Fri Nov 30 17:10:22 2001
From: SWidney@ci.las-vegas.nv.us (Scott Widney)
Date: Fri, 30 Nov 2001 09:10:22 -0800
Subject: [Tutor] Re: Thanks for your help  :-)
Message-ID: <D4EB5574F4A7D2119C9E00A0C9EA408D059F584E@SOVEREIGN>

> > Linux is similar, except you can use ! "bang" notation at the top
> > of a program to tell the OS what interpreter to use.  Then you
> > can make the programs executables directly, so a single command
> > (the name of the program), with optional arguments, will work.
> 
> Actually there is Windows trickery to do this as well, involving some
> registry editing. You tell the registry that a .py extension is to be
> executed with the Drive:\path-to\python.exe interpreter.
> 
> I can't help with details because I don't even have a Windows system
> available to me. But I think you can do the registry editing in that
> "file types" tab -- I can't remember what main dialog it's attached to
> but perhaps you or someone else has seen it before.

Even better, the trickery can be accomplished from a DOS command prompt,
avoiding both the Registry Editor and the dialog boxes. The two commands
that need to be used are ASSOC and FTYPE. You can get the full scoop by
entering 'help ftype' at the prompt, but here's the quick overview.

First, ASSOC associates a file extension (.py) with a file type
(Python.File).

Second, FTYPE specifies the command to run ("C:\python\python.exe" "%1" %*)
when opening that file type (Python.File).

Finally, the PATHEXT environment variable maintains file extensions for
"executable" file types (.COM;.EXE;.PY).

Using all three reduces your typing to the script name (without its
extension) and any arguments. It also makes the file
"double-click-launchable"(tm) from an explorer window.

Scott
=^)


From wilson@visi.com  Fri Nov 30 17:11:20 2001
From: wilson@visi.com (Timothy Wilson)
Date: Fri, 30 Nov 2001 11:11:20 -0600 (CST)
Subject: [Tutor] destructor methods
Message-ID: <Pine.GSO.4.21.0111301108230.25313-100000@isis.visi.com>

Hi everyone,

I've started looking through the C++ code for that plagiarism program
'Copyfind'. I notice that the author has a destructor method to get rid of
instances of his 'document' class. I don't recall any Python programs that
use destructors (I'm not an accomplished object-oriented programmer). Does
Python every use them? I understand that Python's garbage collection
automatically takes care of that sort of thing. Is it possible that
explicitly removing instances of a class improves performance in an
application that uses a lot of RAM (like a plagiarism scanner, for instance
:-)?

-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 alan.gauld@bt.com  Fri Nov 30 17:22:18 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 30 Nov 2001 17:22:18 -0000
Subject: [Tutor] Tkinter and threads
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C142@mbtlipnt02.btlabs.bt.co.uk>

> written from the main program displays immediately, as it should.
> However, the text that is written from the thread doesn't 
> display until I fiddle with the scrollbar. 

I'll take a guess that you need to invalidate the app so that 
it will redraw but I can't recall how to do that in Tkinter 
- I'm pretty sure there is a function in there somewhere to 
do it.

> as each background process completes. Do I need to add some kind of
> locking?

I don't think so, I think you need to call invalidate after(or as) 
each thread terminates.

Alan G


From toodles@yifan.net  Fri Nov 30 17:29:38 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Sat, 1 Dec 2001 01:29:38 +0800
Subject: [Tutor] destructor methods
References: <Pine.GSO.4.21.0111301108230.25313-100000@isis.visi.com>
Message-ID: <002b01c179c4$97e08830$0300a8c0@sun>

> Hi everyone,

Hiya

>
> I've started looking through the C++ code for that plagiarism program
> 'Copyfind'. I notice that the author has a destructor method to get rid of
> instances of his 'document' class. I don't recall any Python programs that
> use destructors (I'm not an accomplished object-oriented programmer). Does
> Python every use them? I understand that Python's garbage collection
> automatically takes care of that sort of thing.

When defining a class, you can define a method called __del__ to handle what
happens in the deletion, so it has the desired effect. Look for more in
"3.3.1 Basic Customisation" in the Python Reference Manual.

> -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 alan.gauld@bt.com  Fri Nov 30 17:36:43 2001
From: alan.gauld@bt.com (alan.gauld@bt.com)
Date: Fri, 30 Nov 2001 17:36:43 -0000
Subject: [Tutor] Variables by reference?
Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20E66C143@mbtlipnt02.btlabs.bt.co.uk>

> Is there any way to get python to return values by reference, like a C
> pointer?

Depends what you mean exactly.
Python object variables are references.
Python values - as in literals are normally 
references to a single instance too.

What do you want to do with these references, 
that might help give the pythonic answer you need?

FWIW I try not to think in C++ terms when working in
Python, it tends to create more confusion than it 
does clarity!

Alan G.


From wilson@visi.com  Fri Nov 30 17:53:12 2001
From: wilson@visi.com (Timothy Wilson)
Date: Fri, 30 Nov 2001 11:53:12 -0600 (CST)
Subject: [Tutor] destructor methods
In-Reply-To: <002b01c179c4$97e08830$0300a8c0@sun>
Message-ID: <Pine.GSO.4.21.0111301142560.25313-100000@isis.visi.com>

On Sat, 1 Dec 2001, Andrew Wilkins wrote:

> When defining a class, you can define a method called __del__ to handle what
> happens in the deletion, so it has the desired effect. Look for more in
> "3.3.1 Basic Customisation" in the Python Reference Manual.

So is there a performance benefit to explicitly calling __del__?

-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 toodles@yifan.net  Fri Nov 30 18:03:08 2001
From: toodles@yifan.net (Andrew Wilkins)
Date: Sat, 1 Dec 2001 02:03:08 +0800
Subject: [Tutor] destructor methods
References: <Pine.GSO.4.21.0111301142560.25313-100000@isis.visi.com>
Message-ID: <005001c179c9$461456d0$0300a8c0@sun>

> On Sat, 1 Dec 2001, Andrew Wilkins wrote:
>
> > When defining a class, you can define a method called __del__ to handle
what
> > happens in the deletion, so it has the desired effect. Look for more in
> > "3.3.1 Basic Customisation" in the Python Reference Manual.
>
> So is there a performance benefit to explicitly calling __del__?

Sorry I should have explained a little better (it's 2 in the morning, heh).
__del__ is called just before the object is to be deleted - it doesn't
delete the object, but rather it performs some actions before the object is
deleted. And also, the reference counting needs to be taken into account.
__del__ isn't called until the object is deleted, ie. when the reference
count is 0. I'll show a quick demo:

>>> class x:
...  def __del__(self):
...   print "Destruction!"
...
>>> y=x()
>>> z=y
>>> del y
>>> del z
Destruction!


Now I'm not sure if I answered your initial questions at all...
Maybe I'll look at that C code after some sleep, and see if I can see
anything that destructors are useful/beneficial for.
HTH
Andrew

>
> -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
>



From jeff@ccvcorp.com  Fri Nov 30 18:18:29 2001
From: jeff@ccvcorp.com (Jeff Shannon)
Date: Fri, 30 Nov 2001 10:18:29 -0800
Subject: [Tutor] Variables by reference?
References: <E169r2M-0004gX-00@mail.python.org>
Message-ID: <3C07CD75.5321E25@ccvcorp.com>

> On Fri, 30 Nov 2001 10:27:15 -0500,
> "Lee-Shanok, Bruce" <Bruce.Lee-Shanok@cognos.com> wrote:
>
> Is there any way to get python to return values by reference, like a C
> pointer?

Yes, there are ways to emulate this sort of behavior, but in Python, they're usually
not the best way to approach the problem.  What is it that you're trying to accomplish
by returning a reference?

Note that, in some ways, Python variables already act a lot like C pointers--every name
is bound to (a reference to) some object.  But the specific semantics are a bit
different from C pointers (and usually much more sane).

Jeff Shannon
Technician/Programmer
Credit International





From fpeavy@pop.net  Fri Nov 30 18:56:38 2001
From: fpeavy@pop.net (Frank Peavy)
Date: Fri, 30 Nov 2001 10:56:38 -0800
Subject: [Tutor] Python Development Standards..?
In-Reply-To: <E169gbd-0005KB-00@mail.python.org>
Message-ID: <5.1.0.14.0.20011130105425.00aca980@mail45566.popserver.pop.net>

Lloyd wrote:

>I suspect that you really want:
>class myObject:
>
>Note that people usually capitalize their classes to help prevent this kind
>of confusion.
Lloyd mentions that "people usually..";  is there a resource that defines 
Python development standards?



From thejoness3@home.com  Fri Nov 30 19:21:02 2001
From: thejoness3@home.com (Jeff Jones)
Date: Fri, 30 Nov 2001 14:21:02 -0500
Subject: [Tutor] linux
References: <1D7FF56FBD1FD511982D001083FD3172C3631D@WLDEXU15> <20011129162806.A27400@hal>
Message-ID: <003501c179d4$26470220$fe2c0d18@grapid1.mi.home.com>

Thanks everyone for your help. I have found a LUG in my area and with their
help hope to be on the 12 step program to windows freedom.

"Hi, My name is Jeff, and I am a windows user...."


----- Original Message -----
From: "Rob McGee" <i812@iname.com>
To: <tutor@python.org>
Sent: Thursday, November 29, 2001 5:28 PM
Subject: Re: [Tutor] linux


> Jeff Jones wrote:
> > > Sorry about getting off topic here, but beginning to learn programming
> > > through Python has peaked my interest in Linux. The only operating
system
> > > I have ever used has been windows, and I've been using it since the
DOS
> > > days (except for computer class in the 7th grade when we used apple
IIc).
> > > Not by choice but because that's what has always been there when I
turned
> > > the computer on. Getting to the point... Does anyone know of any
decent
> > > FAQ's etc. for windows users not yet switched to Linux. Specifically,
> > > which version to use? Thanks in advance for any help.
>
> Different beginning users have different needs. Yes, Mandrake does a
> pretty good job of setting things up for you. It's very much like MS
> Windows in that regard! And also like MS Windows, you're not likely to
> learn as much about how things work behind the scenes.
>
> I started with Slackware, not quite 3 years ago. In that time I have
> attained some real competence as a GNU/Linux and UNIX sysadmin. I don't
> think I would have made it as far if I had started with something like
> Mandrake. (I know some who did, and they're not.)
>
> One thing for sure is that my skills are portable to any distro. I've
> seen the RedHat and Mandrake people talking about how to fix something,
> and their answers are all related to their GUI configuration tools. OTOH
> I would go to a configuration file and edit it. That works anywhere, not
> just Slackware.
>
> If you have a strong DOS background, you might appreciate Slackware. But
> if you just want to get up and running in a GUI ASAP, Mandrake and the
> other big commercial distros are good choices. I'd stay away from Corel
> (if it still exists) because it wasn't maintained, and steer clear of
> Caldera because of their per-seat licencing fees.
>
> Write me off-list if you're interested in Slackware.
>
>     Rob - /dev/rob0
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor



From John.Gouveia2@CIGNA.COM  Fri Nov 30 19:42:25 2001
From: John.Gouveia2@CIGNA.COM (Gouveia, John M   W44)
Date: Fri, 30 Nov 2001 14:42:25 -0500
Subject: [Tutor] linux
Message-ID: <1D7FF56FBD1FD511982D001083FD3172C3637E@WLDEXU15>

One other thing - years ago pre cd burner and cable connection there =
used to
be a site called cheapbytes.com that would sell distro's for $1-$5.  =
They
basically just burned the free versions and mailed them to you.  Don't =
know
if they or anyone like them is still around but it came in handy when =
I'd
want to try different distro's.  Also, if you've got a burner and good
connection linuxiso.org is a good iso 'portal'.

  John Gouveia
  CIGNA HealthCare IM&T
   IM Release 2 Decision Support Services
<mailto:John.Gouveia2@Cigna.com>

Confidential, unpublished property of CIGNA.=20
Do not duplicate or distribute.=20
Use and distribution limited solely to authorized personnel.=20
=A9 Copyright 2001 by CIGNA


> -----Original Message-----
> From:	Jeff Jones [SMTP:thejoness3@home.com]
> Sent:	Friday, November 30, 2001 2:21 PM
> To:	tutor@python.org
> Subject:	Re: [Tutor] linux
>=20
> Thanks everyone for your help. I have found a LUG in my area and with
> their
> help hope to be on the 12 step program to windows freedom.
>=20
> "Hi, My name is Jeff, and I am a windows user...."
>=20
>=20
> ----- Original Message -----
> From: "Rob McGee" <i812@iname.com>
> To: <tutor@python.org>
> Sent: Thursday, November 29, 2001 5:28 PM
> Subject: Re: [Tutor] linux
>=20
>=20
> > Jeff Jones wrote:
> > > > Sorry about getting off topic here, but beginning to learn
> programming
> > > > through Python has peaked my interest in Linux. The only =
operating
> system
> > > > I have ever used has been windows, and I've been using it since =
the
> DOS
> > > > days (except for computer class in the 7th grade when we used =
apple
> IIc).
> > > > Not by choice but because that's what has always been there =
when I
> turned
> > > > the computer on. Getting to the point... Does anyone know of =
any
> decent
> > > > FAQ's etc. for windows users not yet switched to Linux.
> Specifically,
> > > > which version to use? Thanks in advance for any help.
> >
> > Different beginning users have different needs. Yes, Mandrake does =
a
> > pretty good job of setting things up for you. It's very much like =
MS
> > Windows in that regard! And also like MS Windows, you're not likely =
to
> > learn as much about how things work behind the scenes.
> >
> > I started with Slackware, not quite 3 years ago. In that time I =
have
> > attained some real competence as a GNU/Linux and UNIX sysadmin. I =
don't
> > think I would have made it as far if I had started with something =
like
> > Mandrake. (I know some who did, and they're not.)
> >
> > One thing for sure is that my skills are portable to any distro. =
I've
> > seen the RedHat and Mandrake people talking about how to fix =
something,
> > and their answers are all related to their GUI configuration tools. =
OTOH
> > I would go to a configuration file and edit it. That works =
anywhere, not
> > just Slackware.
> >
> > If you have a strong DOS background, you might appreciate =
Slackware. But
> > if you just want to get up and running in a GUI ASAP, Mandrake and =
the
> > other big commercial distros are good choices. I'd stay away from =
Corel
> > (if it still exists) because it wasn't maintained, and steer clear =
of
> > Caldera because of their per-seat licencing fees.
> >
> > Write me off-list if you're interested in Slackware.
> >
> >     Rob - /dev/rob0
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor@python.org
> > http://mail.python.org/mailman/listinfo/tutor
>=20
>=20
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

------------------------------------------------------------------------------
CONFIDENTIALITY NOTICE: If you have received this e-mail in error, please immediately notify the sender by e-mail at the address shown.  This e-mail transmission may contain confidential information.  This information is intended only for the use of the individual(s) or entity to whom it is intended even if addressed incorrectly.  Please delete it from your files if you are not the intended recipient.  Thank you for your compliance.© Copyright 2001 CIGNA

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



From shalehperry@home.com  Fri Nov 30 17:39:41 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Fri, 30 Nov 2001 09:39:41 -0800 (PST)
Subject: [Tutor] catching cheaters (cont.)
In-Reply-To: <Pine.GSO.4.21.0111301008290.20742-100000@isis.visi.com>
Message-ID: <XFMail.20011130093941.shalehperry@home.com>

On 30-Nov-2001 Timothy Wilson wrote:
> Hi everyone,
> 
> I located the Web page of the professor I mentioned in my initial
> message. He has a GPL'ed version of his 'Copyfind' software on his Web site
> at http://plagiarism.physics.virginia.edu/. The source is available
> (obviously for a GPD'ed program), but it's in C++. I think I can read it
> well enough to come up with some ideas of my own. Interestingly, he posts a
> list of improvements that could be made to the software and invites people
> to try to improve it.
> 

actually its:

http://plagiarism.phys.virginia.edu/software.html


From shalehperry@home.com  Fri Nov 30 18:19:25 2001
From: shalehperry@home.com (Sean 'Shaleh' Perry)
Date: Fri, 30 Nov 2001 10:19:25 -0800 (PST)
Subject: [Tutor] destructor methods
In-Reply-To: <Pine.GSO.4.21.0111301142560.25313-100000@isis.visi.com>
Message-ID: <XFMail.20011130101925.shalehperry@home.com>

On 30-Nov-2001 Timothy Wilson wrote:
> On Sat, 1 Dec 2001, Andrew Wilkins wrote:
> 
>> When defining a class, you can define a method called __del__ to handle what
>> happens in the deletion, so it has the desired effect. Look for more in
>> "3.3.1 Basic Customisation" in the Python Reference Manual.
> 
> So is there a performance benefit to explicitly calling __del__?
> 

you actually say:

del var

this forces the variable to be garbage collected.  Whether it needs a
destructor depends on how it was created.

It is safe to write the program without explicit del's the first time then go
through and see if optimization is needed.


From virketis@fas.harvard.edu  Fri Nov 30 20:45:34 2001
From: virketis@fas.harvard.edu (Pijus Virketis)
Date: Fri, 30 Nov 2001 15:45:34 -0500
Subject: [Tutor] linux
In-Reply-To: <1D7FF56FBD1FD511982D001083FD3172C3637E@WLDEXU15>
Message-ID: <200111302044.fAUKiml14574@smtp2.fas.harvard.edu>

>One other thing - years ago pre cd burner and cable connection there used to
>be a site called cheapbytes.com that would sell distro's for $1-$5.  They
>basically just burned the free versions and mailed them to you.  Don't know
>if they or anyone like them is still around but it came in handy when I'd
>want to try different distro's.  Also, if you've got a burner and good
>connection linuxiso.org is a good iso 'portal'.

www.linuxcentral.com does exactly that. If you want disks of any distro for
$2.99, go there.

-P
------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis



From i812@iname.com  Fri Nov 30 21:04:31 2001
From: i812@iname.com (Rob McGee)
Date: Fri, 30 Nov 2001 15:04:31 -0600
Subject: [Tutor] the class struggle
In-Reply-To: <4.2.0.58.20011129160411.019fcce0@pop3.norton.antivirus>; from urnerk@qwest.net on Thu, Nov 29, 2001 at 04:36:59PM -0800
References: <20011129170901.B27400@hal> <4.2.0.58.20011129160411.019fcce0@pop3.norton.antivirus>
Message-ID: <20011130150431.D27400@hal>

First off, thanks to all who replied. I'll try to cover everything in a
single reply here. Sorry if it's a bit disjointed. I've made a lot of
progress, but there's still one remaining item of confusion -- see down
at the end of this message.

Whoa, that's bad Internet manners. Here's the question:
    How, in a class __init__ function, can you get the name of the
    instance?
A code sample (tested this time :) and further explanation of what I'm
trying to do is down at the end. But if you have a quick answer to this
question you probably don't have to read (nor quote) all the way.

On Thu, Nov 29, 2001 at 04:36:59PM -0800, Kirby Urner wrote:
> >{code}
> >import random
> >
> >def myObject(name):
> >   variable = name
> >   anotherOne = anotherValue
> >   if name in someList:
> >     nextVar = this
> >     lastOne = that
> >   else:
> >     nextVar = random.randrange(10, 70)
> >     lastOne = random.randrange(5, 15)
> >{/code}
> 
> 
> Rob, this function is not self contained as written.

Eek! You're right. I'm sorry. I tried to simplify my code and ended up
oversimplifying. This time around I'm going to simplify the *questions*
I'm asking. :)

> You've defined a lot of the variables in the shell,
> off camera (so to speak) and these are available as
> global variables.  You also appear to be assigning
> to globals, versus returning values.  That's called

Actually they were hard-coded values. I used variables in my example,
but the real code had values. And yes, the function was assigning global
variables. I think it would be much better to have a class instance's
namespace.

> relying on side-effects and its a major ingredient
> in messy, hard-to-debug code.  Not to worry.

Yes, I know I've got a long way to go. {aside} This isn't the first time
I've tried to take up programming. When I was running DOS 5 on a 8086, I
had a terrible time trying to write a little game in QBasic (ever hear
of "MasterMind", a code-breaking game? This was a solitaire, text-mode
version of it.) I finally got it but was really burned out. Toward the
end of my Windows days I played with MSVB4, but I got bored with it. Now
in python the light is really starting to come on. :) {/aside}

> >That works. I got a complete and working (although not very polished)
> >program using a function like that. It's worthy of the Useless Python
> >site, for sure. :)
> 
> I think as a standalone, it's not ready for Useless, because

I guess I had a different understanding of the mission of Useless. :)

> of it's heavy reliance on stuff you've defined out-of-scope.

This was actually a subordinate function nested inside another one. Not
that it really matters as to what I'll be asking below, but I'm just
trying to explain what was going on. There was an index number and a
list coming from the parent function. The index is incremented, and the
value from the list is remove()'ed so that it won't be available for the
next pass (values must be unique.)

I realize that nesting functions probably isn't the best way to do it.
The index is incremented in a for loop. But I'm not sure of how else I
might maintain my list? ISTM it has to remain out-of-scope.

> Also, it's not documented (gotta have comments explaining
> the purpose of the function, before it goes to the internet).

Again, this was an oversimplification. It's liberally commented in "real
life". :)

> >{code}
> >import random
> >
> >class myObject(name):
> >   def __init__(self, name):
> >     variable = name
> >     anotherOne = anotherValue
> >     if name in someList:
> >       nextVar = this
> >       lastOne = that
> >     else:
> >       nextVar = random.randrange(10, 70)
> >       lastOne = random.randrange(5, 15)
> >{/code}
> 
> The first problem here is you're saying your class inherits from
> some other parent class named 'name'.  Unless you've actually

Yes, all of you caught that. I was indeed getting confused between
    def function(values, passedToIt):
and
    class Class(ParentClass):
I thought I was passing values to the class that way. That's one part of
my class struggle completed successfully. :)

> >That doesn't work. "SyntaxError: invalid syntax" on the "if"
> >(caret goes under the "f".) I tried adding "self." in front
> >of the class instance variables just for fun. Same thing.
> 
> I don't understand this error exactly.  I can't reproduce it.
> Are you in IDLE, and do your key words colorize?  Is your
> 'if' orange?

I finally found it. Yes, I was using IDLE. But IDLE didn't make me use
")" to close off a function call. :) Basically it was like this:
    random.randrange(start, stop
without the closing parenthesis. It didn't jump out at me because the
stop value was itself a product of two functions: I had two ("))") but
needed three.

IOW PEBKAC, never mind, sorry. :)

> It could be a consequence of trying to inherit from
> 'name' as a parent class.  You may have 'name' defined
> as a global elsewhere...

Is there an easy way to clear out the IDLE session between runs of a
script?

And now for something completely different ...

... not really different, but I've been awaiting an opportunity to say
that here. :) For those of you who read above, here's a repeat:
    There's one little question which I think may be the only thing left
    I'm not understanding. How, in a class __init__ function, can you
    get the name of the instance?

{code}
surnames = ('Marx', 'Engels', 'Lenin')

class Struggle:		# no parent class! :)
  def __init__(self, firstnames):
    self.firstname = firstnames.pop()
    if self.firstname == 'Vladimir':
      self.nationality = 'Russian'
    else:
      self.nationality = 'German'
#   self.surname = self

firstnames = ['Vladimir', 'Friedrich', 'Karl']

for x in surnames:
  exec(x + ' = Struggle(firstnames)')
{/code}

The "self.surname" thing doesn't do it. I get this:
    <__main__.Struggle instance at 0x80db334>
What I want to do is a different test inside the class definition. Like
    if len(surname) == 5:	# 'Lenin'
      self.nationality = 'Russian'
What would work in the place of "surname"? Or can this be done?

See, what I'm wanting is to use fixed values for class instances where
the name is in a list, and random values for all other instances. I can
see workarounds now, such as passing more arguments to the class
instantiation, but it seems simpler to me to do it the way I had wanted
originally (which was how I did it in my function.)

Thanks again, all, and I'm sorry about confusing you all with my code
example. :)

    Rob - /dev/rob0


From pythontutor@venix.com  Fri Nov 30 21:02:20 2001
From: pythontutor@venix.com (Lloyd Kvam)
Date: Fri, 30 Nov 2001 16:02:20 -0500
Subject: [Tutor] Python Development Standards..?
References: <5.1.0.14.0.20011130105425.00aca980@mail45566.popserver.pop.net>
Message-ID: <3C07F3DC.30707@venix.com>

http://www.python.org/doc/essays/
Python Essays

This is the URL for Guido van Rossum's Python essays.

Look at the Python Style Guide.
http://www.python.org/doc/essays/styleguide.html
Python Style Guide

And I see now that some of the style guide's recommendations have been put
into PEP's.

Frank Peavy wrote:

> Lloyd wrote:
> 
>> I suspect that you really want:
>> class myObject:
>>
>> Note that people usually capitalize their classes to help prevent this 
>> kind
>> of confusion.
> 
> Lloyd mentions that "people usually..";  is there a resource that 
> defines Python development standards?
> 
> 
> _______________________________________________
> 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 pythontutor@venix.com  Fri Nov 30 21:23:19 2001
From: pythontutor@venix.com (Lloyd Kvam)
Date: Fri, 30 Nov 2001 16:23:19 -0500
Subject: [Tutor] destructor methods
References: <Pine.GSO.4.21.0111301142560.25313-100000@isis.visi.com>
Message-ID: <3C07F8C7.3030305@venix.com>

C++ puts responsibility for heap memory management on the programmer.  new
will grab some memory and del will release.

In converting to Python:
	x = new Class;	==>	x = Class()
	(that c++ code is from memory.  It may be slightly off)
The del statements can be discarded.

__del__ exists for odd situations.  One example, if your class creates
doubly linked lists, you could have:
	a.next = b
	b.prior = a
	del a; del b
Python's old garbager collect will NOT collect this memory because those
two deleted each reference each other.  I beleive there are PEP's to improve
this, but don't know where they stand.  These deletions also break the list!
You would use __del__ to come up with logic to handle these kinds of cases
AND also protect the linked list so that deletions didn't break the list.

Timothy Wilson wrote:

> On Sat, 1 Dec 2001, Andrew Wilkins wrote:
> 
> 
>>When defining a class, you can define a method called __del__ to handle what
>>happens in the deletion, so it has the desired effect. Look for more in
>>"3.3.1 Basic Customisation" in the Python Reference Manual.
>>
> 
> So is there a performance benefit to explicitly calling __del__?
> 
> -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 urnerk@qwest.net  Fri Nov 30 21:39:39 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Fri, 30 Nov 2001 13:39:39 -0800
Subject: [Tutor] the class struggle
In-Reply-To: <20011130150431.D27400@hal>
References: <4.2.0.58.20011129160411.019fcce0@pop3.norton.antivirus>
 <20011129170901.B27400@hal>
 <4.2.0.58.20011129160411.019fcce0@pop3.norton.antivirus>
Message-ID: <4.2.0.58.20011130133646.00c54930@pop3.norton.antivirus>

>
>Thanks again, all, and I'm sorry about confusing you all with my code
>example. :)
>
>     Rob - /dev/rob0

I only dimly grasp what you want as yet, but I'm repeating
your code as I've run it just now, in IDLE:

  >>> firstnames = ['Vladimir', 'Friedrich', 'Karl']
  >>> surnames = ('Marx', 'Engels', 'Lenin')

  >>> class Struggle:            # no parent class! :)

       def __init__(self, firstnames):
          self.firstname = firstnames.pop()
          if self.firstname == 'Vladimir':
             self.nationality = 'Russian'
          else:
             self.nationality = 'German'

  >>> for x in surnames:
          exec(x + ' = Struggle(firstnames)')


  >>> Lenin
  <__main__.Struggle instance at 0x00ABF870>
  >>> Lenin.nationality
  'Russian'
  >>> Engels.nationality
  'German'

And my first reaction is:  OK, he's got instances named
using surnames, and the nationality property of each
is set properly.  So what's the problem?  What did you
want to be different again?

Kirby



From dyoo@hkn.eecs.berkeley.edu  Fri Nov 30 21:42:31 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 30 Nov 2001 13:42:31 -0800 (PST)
Subject: [Tutor] Linking Problems using VC++ 6.0
In-Reply-To: <3C079948.F2CC54DC@gmx.de>
Message-ID: <Pine.LNX.4.21.0111301340280.4193-100000@hkn.eecs.berkeley.edu>

On Fri, 30 Nov 2001, Marcus Konermann wrote:

> I am working with SWIG and generated a C++ file to use it under python.
> I work with windows2000 and the VC++ 6.0 Compiler, but now there are
> linking problems, VC++ says:

Hi Marcus,

You might want to ask your question on the win32 Python list as well, if
you don't get a good answer on Tutor.  The people in the win32 list should
have more experience with Visual C++ extension issues.

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



From fpeavy@pop.net  Fri Nov 30 22:10:22 2001
From: fpeavy@pop.net (Frank Peavy)
Date: Fri, 30 Nov 2001 14:10:22 -0800
Subject: [Tutor] Newbie Question:  IDLE, is there a HOWTO use...
Message-ID: <5.1.0.14.0.20011130140831.02dda470@mail45566.popserver.pop.net>

So far, I have used the IDLE to edit py's but it seems that there is more 
to it than that.
Is there a HOWTO for the use of IDLE?



From dyoo@hkn.eecs.berkeley.edu  Fri Nov 30 22:22:32 2001
From: dyoo@hkn.eecs.berkeley.edu (Danny Yoo)
Date: Fri, 30 Nov 2001 14:22:32 -0800 (PST)
Subject: [Tutor] the class struggle
In-Reply-To: <20011130150431.D27400@hal>
Message-ID: <Pine.LNX.4.21.0111301356400.4193-100000@hkn.eecs.berkeley.edu>

On Fri, 30 Nov 2001, Rob McGee wrote:

> First off, thanks to all who replied. I'll try to cover everything in a
> single reply here. Sorry if it's a bit disjointed. I've made a lot of
> progress, but there's still one remaining item of confusion -- see down
> at the end of this message.
> 
> Whoa, that's bad Internet manners. Here's the question:
>     How, in a class __init__ function, can you get the name of the
>     instance?


This depends on what you mean by "name".  An example might clarify:

###
>>> class Person:
...     def __init__(self, name):
...         self.name = name
...     def sayHello(self):
...         print "Hello, my name is", self.name
... 
>>> strider = Person("Aragorn")
>>> dunedain = leader
>>> strider.sayHello()
Hello, my name is Aragorn
>>> dunedain.sayHello()
Hello, my name is Aragorn
>>> Person("boromir").sayHello()
Hello, my name is boromir
###

Here, we're making a person whose name is "Aragorn".  It's part of his
identity, and that's why we're passing the name to the initializer.  When
we construct a Person, we create an "instance" of that person.

What's interesting is that we can refer to Aragorn with different variable
"names" --- in the example, he's both 'strider' and 'dunedain'.  Same
person, but different "names".  The constructor won't make it easy to
monitor what sort of variable name we are using to refer to Aragorn,
since, as far as it's concerned, we could call Aragorn anything we wish.


The last line in the example shows that we don't even need to use a
variable name --- we can bring Boromir to life, just long enough for him
to sayHello().  Boromir will disappear after the expression evaluates,
since we can't refer to him again by name anymore.


Is this what you mean?  What's tricky about your question is the ambiguity
of the word "name", so if you can give an example, that will help a lot.  
Hope this helps!



From urnerk@qwest.net  Fri Nov 30 23:03:45 2001
From: urnerk@qwest.net (Kirby Urner)
Date: Fri, 30 Nov 2001 15:03:45 -0800
Subject: [Tutor] Newbie Question:  IDLE, is there a HOWTO use...
In-Reply-To: <5.1.0.14.0.20011130140831.02dda470@mail45566.popserver.pop
 .net>
Message-ID: <4.2.0.58.20011130145851.00c5a270@pop3.norton.antivirus>

At 02:10 PM 11/30/2001 -0800, Frank Peavy wrote:
>So far, I have used the IDLE to edit py's but it seems that
>there is more to it than that.
>Is there a HOWTO for the use of IDLE?

Have you used IDLE as a calculator?  This is how the Python
tutorial starts as I recall (the one that comes with it).

  >>> 1 + 1
  2

  >>> import.math
  >>> math.log10(100)
  2.0

stuff like that.

The next step is to keep some of your results stored in
variables:

  >>> a = 1 + 1
  >>> b = math.log10(100)
  >>> a + b
  4.0

The next step is to write a function and run it:

  >>> def adder(a,b):
          return a + b

  >>> adder(3,4)
  7

Now you're off and running.  Explore string functions,
goof off, and then, if you start getting functions you
want to keep for next time, cut and paste 'em to an
open text Window (IDLE's editor) and save 'em as a
.py file.  Group together functions that do similar
things, so it makes sense to have 'em in the same file.
Voila, you've written a Python module.

Class dismissed.

Kirby