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 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") 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: 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: 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: ; from vulpine@pobox.com on Thu, Nov 01, 2001 at 02:08:51AM -0600 References: Message-ID: <20011101094010.A1978@pino.selwerd.nl> On 0, 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. 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") > > 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/ 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"

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/

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-- 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: References: 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") | > | > 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: References: 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 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: 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
Hi ,
How can i create a dll file ( C = dynamic=20 library) from windows to be imported by python .
 
------=_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: Message-ID: 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 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 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: > 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: 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
Hi, I am new to python AND to = proggramming=20 languages as the forgoing will show. I need to create a path = to the=20 system files (?) to create 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 just can't wait to write that killer script: = 'Hello,=20 World!' :-)
below is my system info ( in case it is = usefully=20 required?)
Microsoft Windows 98 4.10.1998  =
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 =20 /U:xxxxxxxxxxxxxxxxx
IE 5 5.50.4807.2300
Uptime: = 0:00:08:50
Normal=20 mode
On "OEMCOMPUTER" as "Gary"
Time Computers
AuthenticAMD = AMD-K6(tm)=20 3D processor Intel MMX(TM) Technology
64MB RAM
59% system = resources=20 free
Windows-managed swap file on drive C (10139MB free)
Available = space=20 on drive C: 10139MB of 12405MB=20 (FAT32)
------=_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
Hi, I'm trying to learn Python = programming and I=20 ran into an odd problem.
I was reading the sample chapter of = "Python and=20 Tkinter programming" to learn how to use Tkinter in Python.
I downloaded the sample code and tried = to run them=20 in IDLE.
For some reason, I couldn't run them in = IDLE with=20 the following error.
 
Traceback (innermost last)
  = File=20 "c:\yjlee\worx\dissertation\python-related\python and tkinter=20 programming\grayson\examples\chapter11\plot.py", line 404, in=20 ?
    graph.draw(graphObject, 'automatic',=20 'automatic')
  File = "c:\yjlee\worx\dissertation\python-related\python=20 and tkinter programming\grayson\examples\chapter11\plot.py", line 226, = in=20 draw
    xticks =3D self._ticks(xaxis[0], = xaxis[1])
 =20 File "c:\yjlee\worx\dissertation\python-related\python and tkinter=20 programming\grayson\examples\chapter11\plot.py", line 363, in=20 _ticks
    ticks.append(t, format % = (t,))
TypeError:=20 append() takes exactly 1 argument (2 given)
 
Program disconnected.
 
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?
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?
 
Thanks.
------=_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: Message-ID: 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: 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: 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 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 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 . | 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
Hi, I'm a newbie trying to learn=20 Python.
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 could run it on = the=20 command window of windows 2000 os.
 
Thanks in advance.
 
YJ
------=_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 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 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 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: <3BE19C9D.7040603@venix.com> Message-ID: <20011102011209.B3353@pino.selwerd.nl> On 0, Lloyd Kvam 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 . > > | 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 "", 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
Hi Young-Jin
 
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")
Example:
 
####
>>> import sys
>>> sys.path
['C:\\Python21\\Tools\\idle',=20 'C:\\Python21', 'C:\\Python21\\DLLs', 'C:\\Python21\\lib',=20 'C:\\Python21\\lib\\plat-win', 'C:\\Python21\\lib\\lib-tk']

>>> import monkey
Traceback (most = recent call=20 last):
  File "<pyshell#3>", line 1, in = ?
   =20 import monkey
ImportError: No module named monkey
>>>=20 sys.path.append('c:\\monkey')
>>> import monkey
His = nature was -=20 IRREPRESSIBLE!
###
 
Regards,
Andrew
 
----- Original Message -----
From:=20 Young-Jin = Lee=20
Sent: Friday, November 02, 2001 = 7:49=20 AM
Subject: [Tutor] [Q] IDLE = setting

Hi, I'm a newbie trying to learn=20 Python.
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 could run = it on the=20 command window of windows 2000 os.
 
Thanks in advance.
 
YJ
------=_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: Message-ID: > > 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: > > 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 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: 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("", testPrint) frame.pack() root.mainloop() It's pretty much the same as the one printed, except I've swapped the reference for a 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: ; from kaffeen@mac.com on Fri, Nov 02, 2001 at 04:52:12PM -0500 References: 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("", testPrint) > frame.pack() > > root.mainloop() > > It's pretty much the same as the one printed, except I've swapped the > reference for a 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("", 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" : >> >> 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 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. will cause the SGML-parser to choke but 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: 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 Subject: Re: [Tutor] OOP programming principles overview? [Complex numbersand OOP] To: Danny Yoo 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) >>> (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" 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

------------------------------------------------------------
--=====================_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: 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__ >>> 4 .__add__ >>> 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> <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: Message-ID: <3BFBFB19.E7A48392@ccvcorp.com> > > On Wed, 21 Nov 2001 08:05:04 -0800, > Kirby Urner 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> <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> <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 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: 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: Message-ID: 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> <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 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: Message-ID: 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: ------=_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 6x6 InterNetwork Group
Hello!
 
 


PLEASE EXCUSE THE DISTURBANCE BUT WE CONSIDER IT OUR DUTY TO MAKE YOU AN OFFER THAT WILL HELP YOU BECOME WEALTHIER, FREER AND HAPPIER!
 

 


   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!
 

Let's get down to business!
 
 


   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.
   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.
   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.
 

The product
 
 


   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...
   So allow us to recommend the book by Andrew Lloyd "How to Be Successful in Advertising on the Internet". 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.
   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.
   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.
   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.
   Our business is international and you can work anywhere on the planet with Internet access and attract clients from any country.
 

Earnings
 
 


   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.
   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.
 
month
co-workers
commissions
1
5
$30
2
5*5+5=30
$180
3
30*5+5=155
$930
4
155*5+5=780
$4,680
5
780*5+5=3,905
$23,430
6
3,905*5+5=19,530
$117,180
total
24,405
$146,430


   In other words, in just six months you will bring in 24,405 co-workers and make $146,430! All you need to do it is bring in five co-workers a month!
   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.
   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?
   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!

How to start
 
 


   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!

   1) To start you need to register with the founder of the 6x6 business system. Registration costs $10.

   Transfer $10 to the account of the founder of the 6x6 business system:

1107736234 Igor Tistsenkov
Hansapank, Liivalaia 8, 15040 Tallinn, Estonia
S.W.I.F.T. code: HABA EE2X

   Then send a telegram (or a mail) containing the following:

1) This number: 6x6-000000-z-001
2) Your full name
3) E-mail

   to the address:

Igor Tistsenkov
Laanemere 20-96
13913 Tallinn
Estonia

   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.
   3) Immediately by the book from co-workers. The cost is $36. Details in the letter.
   4) When you receive the book start working right away. Success is just around the corner!

   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!

And now let's start!

We wish You Great Success!!!

 
 


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.




Æåëàåì Âàì ïðèÿòíîãî è óñïåøíîãî äíÿ!
 
 


ÏÐÎÑÈÌ ÏÐÎÙÅÍÈß ÇÀ ÁÅÑÏÎÊÎÉÑÒÂÎ, ÍÎ Ñ×ÈÒÀÅÌ ÑÂÎÈÌ ÄÎËÃÎÌ ÑÄÅËÀÒÜ ÂÀÌ ÎÄÍÎ ÏÐÅÄËÎÆÅÍÈÅ, ÊÎÒÎÐÎÅ ÏÎÌÎÆÅÒ ÂÀÌ ÑÒÀÒÜ ÁÎÃÀ×Å, ÑÂÎÁÎÄÍÅÉ È Ñ×ÀÑÒËÈÂÅÉ!
 

 


   Ìû ïðåäëàãàåì Âàì óíèêàëüíóþ âîçìîæíîñòü áèçíåñà ïî ñèñòåìå 6õ6. Ñîòðóäíè÷àòü ñ íàìè ìîæåò êàæäûé, êòî ñïîñîáåí óäåëÿòü áèçíåñó 2-3 ÷àñà â äåíü è óìååò ðàáîòàòü íà ïåðñîíàëüíîì êîìïüþòåðå. Ðàáîòàÿ ñ íàìè, Âû ñìîæåòå óëó÷øèòü ñâîå ôèíàíñîâîå ïîëîæåíèå èëè æå ïðîñòî ïîëó÷àòü ñòàáèëüíûé äîïîëíèòåëüíûé äîõîä, ïîìîãàÿ äåëàòü òî æå ñàìîå âñåì ëþäÿì ìèðà!
 

ÈÒÀÊ, ÑÐÀÇÓ Ê ÄÅËÓ!
 
 


   Ìû ïðåäëàãàåì Âàì çàðàáàòûâàòü íà ðàñïðîñòðàíåíèè ïðîäóêöèè âûñîêîé ïîòðåáèòåëüñêîé öåííîñòè ïîñðåäñòâîì 6-òè óðîâíåãî ñåòåâîãî ìàðêåòèíãà ñ äîñòàâêîé òîâàðà ïî êàíàëàì ñâÿçè ñåòè Èíòåðíåò. Âàøà ðàáîòà áóäåò çàêëþ÷àòüñÿ â ïîñòðîåíèè ñåòè ñîòðóäíèêîâ è ðåàëèçàöèè ïîñðåäñòâîì íåå ïðîäóêöèè. Ò.å. Âàì íåîáõîäèìî ïðèâëåêàòü ëþäåé, æåëàþùèõ çàíèìàòüñÿ ýòèì áèçíåñîì è ïðîäàâàòü èì òîâàð. Çà êàæäîãî ïðèâëå÷åííîãî ÷åëîâåêà Âû ïîëó÷àåòå êîìèñèîííûå.
   Ìû ïðåäîñòàâëÿåì Âàì âîçìîæíîñòü ìóëüòèïëåêñíîãî äîõîäà. Âàø çàðàáîòîê áóäåò ñîñòîÿòü èç êîìèññèîííûõ, çàðàáîòàííûõ ëè÷íî Âàìè, è ïðîöåíòà îò êîìèññèîííûõ, çàðàáîòàííûõ Âàøèìè ñîòðóäíèêàìè. Ò.å. Âû ïîëó÷àåòå êîìèññèîííûå çà òî, ÷òî ñàìè ïðèâëåêàåòå ñîòðóäíèêîâ, è çà òî, ÷òî Âàøè ñîòðóäíèêè ïðèâëåêàþò ñîòðóäíèêîâ. Òå ñîòðóäíèêè, êîòîðûõ Âû ëè÷íî ïðèâåëè â ñâîþ ñåòü, áóäóò Âàøèìè ñîòðóäíèêàìè 1-ãî óðîâíÿ. Îíè áóäóò òàêæå ïðèâëåêàòü ñîòðóäíèêîâ, è âñå ïðèâëå÷åííûå èìè ëè÷íî ñîòðóäíèêè áóäóò Âàøèìè ñîòðóäíèêàìè 2-ãî óðîâíÿ. Âñåãî â Âàøåé ñåòè ìîæåò áûòü ñêîëüêî óãîäíî óðîâíåé, íî îïëà÷èâàþòñÿ òîëüêî ïåðâûå øåñòü, ò.å. Âû ïîëó÷àåòå êîìèññèîíûå çà òî, ÷òî ëè÷íî ïðèâåëè â áèçíåñ ñîòðóäíèêà ïåðâîãî óðîâíÿ, çà òî, ÷òî ñîòðóäíèê ïåðâîãî óðîâíÿ ïðèâåë ñîòðóäíèêà âòîðîãî óðîâíÿ è ò.ä. äî øåñòîãî óðîâíÿ. Îãðàíè÷åíèé íà êîëè÷åñòâî ñîòðóäíèêîâ íà êàæäîì óðîâíå íåò.
   Áëàãîäàðÿ ìóëüòèïëåêíîìó äîõîäó, Âû ñìîæåòå, ðàáîòàÿ 2-3 ÷àñà â äåíü, â êðàò÷àéøèå ñðîêè ïîñòðîèòü ñåòü ñîòðóäíèêîâ è ïîñðåäñòâîì íåå ðåàëèçîâàòü äîñòàòî÷íîå êîëè÷åñòâî ïðîäóêöèè äëÿ ïîëó÷åíèÿ âûñîêîãî äåíåæíîãî âîçíàãðàæäåíèÿ.
 

ÏÐÎÄÓÊÖÈß
 
 


   Íå äëÿ êîãî íå ñåêðåò, ÷òî â ñåòè Èíòåðíåò ìîæíî çàðàáàòûâàòü - ýòî î÷åâèäíûé ôàêò. Íî êàê? Åñëè Âû íàáåðåòå â ëþáîé ïîèñêîâîé ñèñòåìå ôðàçó çàðàáîòîê â ñåòè èëè ÷òî-òî âðîäå ýòîãî, ïðåä Âàìè ïðåäñòàíóò òûñÿ÷è ñàéòîâ, ïîñâÿùåííûõ ýòîé òåìå. Íî äàæå îçíàêîìèâøèñü ñ ñîäåðæàíèåì 99,9% èç íèõ è ïðîðàáîòàâ ïî ïðåäëàãàåìûì èìè ñõåìàì, Âû âðÿä ëè ÷åãî-íèáóäü çàðàáîòàåòå! Ò.ê. îíè ïðåäëàãàþò âî ìíîãîì ñõîæèå ìåæäó ñîáîé ñèñòåìû çàðàáîòêà, êîòîðûå ïîçâîëÿþò çàðàáîòàòü òîëüêî èõ ñîçäàòåëÿì. Íî òåì íå ìåíåå ìíîãèå ëþäè æèâóò çàðàáàòûâàÿ â Èíòåðíåòå è æèâóò äîñòàòî÷íî õîðîøî! È íà ñàìîì äåëå ýòî íå òàê ñëîæíî, êàê ìîæåò ïîêàçàòüñÿ íà ïåðâûé âçãëÿä - íå òàê ñëîæíî, åñëè ñðàçó âûáðàòü ïðàâèëüíûé ïóòü! ×òî ìîæåò îêàçàòüñÿ çíà÷èòåëüíî ñëîæíåå...
   Â ñâÿçè ñ ýòèì ïîçâîëüòå Âàì ïðåäëîæèòü êíèãó Ýíäðþ Ëëîéäà (Andrew Lloyd) "Êàê äîáèòüñÿ óñïåõà, çàíèìàÿñü ðåêëàìîé â ñåòè Èíòåðíåò". Àâòîð êíèãè, áèçíåñìåí èç Ëîíäîíà, óæå äîëãîå âðåìÿ óñïåøíî çàíèìàåòñÿ áèçíåñîì â Èòåðíåòå è îáëàäàåò îãðîìíûì îïûòîì.  ñâîå âðåìÿ îí ïðîðàáîòàë ïî âñåì îñíîâíûì ñèñòåìàì çàðàáîòêà è ñàì ëè÷íî èñïûòàë âñå âèäû ðåêëàìû â ñåòè. Î ñàìûõ ýôôåêòèâíûõ è ëó÷øèõ èç íèõ îí ðàññêàçàë â ñâîåé êíèãå.
   Ýòà êíèãà â ïåðâóþ î÷åðåäü áóäåò ïîëåçíà âñåì, êòî çàíèìàåòñÿ áèçíåñîì â ñåòè Èíòåðíåò è õî÷åò äîáèòüñÿ óñïåõà. Ïðî÷èòàâ åå, Âû óçíàåòå î ñàìûõ ýôôåêòèâíûõ âèäàõ ðåêëàìû Èíòåðíåòà, î òîì ãäå ìîæíî ñî ñêèäêîé ïðåîáðåñòè ïðîãðàììíîå îáåñïå÷åíèå, êîòîðîå çíà÷èòåëüíî îáëåã÷àåò æèçíü èíòåðíåò-ïðåäïðèíèìàòåëÿ è äåëàåò ýòè âèäû ðåêëàìû åùå áîëåå ýôåêòèâíåé, î òîì êàê, îïòèìàëüíî èñïîëüçóÿ ïîñëåäíèå äîñòèæåíèÿ ýëåêòðîííîé êîììåðöèè è ñåòåâîãî ìàðêåòèíãà, äîáèòüñÿ óñïåõà â ïðèâëå÷åíèè ñîòðóäíèêîâ â áèçíåñ, ïîñòðîåíèè ñåòè è ðåàëèçàöèè ïîñðåäñòâîì íåå áîëüøèõ îáúåìîâ ïðîäóêöèè è ìíîãîì äðóãîì.
   Îñîáåííî êíèãà ðåêîìåíäóåòñÿ òåì, êòî ñîáèðàåòñÿ çàíèìàòüñÿ áèçíåñîì â Èíòåðíåòå, íî åùå íå íà÷àë, è òåì, êòî íà÷àë íåäàâíî, ò.ê. îíà íàâåäåò Âàñ ñðàçó íà ïðàâèëüíûé ïóòü è ïîçâîëèò Âàì âî ìíîãîì ñýêîíîìèòü âðåìÿ è ñðåäñòâà è èçáåæàòü ìíîãèõ íåïðèÿòíûõ ñèòóàöèé. Òàêæå íàñòîÿòåëüíî ðåêîìåíäóåì êíèãó òåì, êòî óæå çàíèìàåòñÿ èíòåðíåò-áèçíåñîì, íî íèêàê íå ìîæåò äîáèòüñÿ óñïåõà è òåì, êòî ïî êàêèì-ëèáî ïðè÷èíàì âîîáùå íå âåðèò â âîçìîæíîñòü òàêîãî ðîäà çàðàáîòêà, ïåðâûå, ïðî÷èòàâ åå, ñðàçó óâèäÿò ñâîè îøèáêè è, ïåðåñòàâ èõ ñîâåðøàòü, äîñòèãíóò óñïåõà, âòîðûå - ïîéìóò, ÷òî îíè çàáëóæäàëèñü, è ïåðåñìîòðÿò ñâîå îòíîøåíèå ê çàðàáîòêó â ñåòè.
   Ââèäó öåííîñòè è âîñòðåáóåìîñòè èíôîðìàöèè, ñîäåðæàùåéñÿ â êíèãå, îíà ïîëüçóåòñÿ âåëèêîëåïíûì ñïðîñîì âî âñåì ìèðå. Êíèãà ðàñïðîñòðàíÿåòñÿ â ýëåêòðîííîì âèäå íà ðóññêîì è àíãëèéñêîì ÿçûêàõ ïîñðåäñòâîì êàíàëîâ ñâÿçè ñåòè Èíòåðíåò.
   Íàø áèçíåñ ìåæäóíàðîäíûé, Âû ìîæåòå ðàáîòàòü èç ëþáîé òî÷êè çåìíîãî øàðà ãäå åñòü äîñòóï â Èíòåðíåò è ïðèâëåêàòü êëèåíòîâ èç ëþáûõ ñòðàí.
 

Î ÇÀÐÀÁÎÒÊÅ
 
 


   Çà êàæäîãî ïðèâëå÷åííîãî ñîòðóäíèêà Âû ïîëó÷àåòå êîìèññèîííûå â ðàçìåðå 6 äîëëàðîâ ÑØÀ. Íèêàêîãî îãðàíè÷åíèÿ íà çàðàáîòîê íåò - âñå çàâèñèò òîëüêî îò Âàøåãî æåëàíèÿ õîðîøî çàðàáîòàòü. Íî âñå æå êîíêðåòíûå öèôðû.
   Íà÷íåì ñ ìèíèìóìà, äîïóñòèì ÷òî êàæäûé ìåñÿö Âû è âñå Âàøè ñîòðóäíèêè áóäåòå ïðèâëåêàòü âñåãî ïî 5 ÷åëîâåê.
 
ìåñÿö
ñîòðóäíèêè
êîìèñèîííûå
1
5
$30
2
5*5+5=30
$180
3
30*5+5=155
$930
4
155*5+5=780
$4,680
5
780*5+5=3,905
$23,430
6
3,905*5+5=19,530
$117,180
âñåãî
24,405
$146,430


   Ò.å. çà 6 ìåñÿöåâ Âû ïðèâëå÷åòå â ñâîþ ñåòü 24,405 ñîòðóäíèêîâ è çàðàáîòàåòå $146,430! Äëÿ ÷åãî Âàì íåîáõîäèìî ïðèâëåêàòü âñåãî ïî 5 ñîòðóäíèêîâ â ìåñÿö!
   Ýòî òåîðèòè÷åñêèé ðàñ÷åò, à ïðàêòèêà âñåãäà îòëè÷àåòñÿ îò òåîðèè, ïîýòîìó òàêèõ óñïåõîâ íå äîáèâàëñÿ åùå íèêòî, õîòÿ âîçìîæíî Âàì ïîâåçåò! Íî âñå æå ñêîëüêî ìîæíî çàðàáîòàòü íà ïðàêòèêå.  ïåðâûé ìåñÿö Âàì íåîáõîäèìî èçó÷èòü îñíîâíûå ìåòîäû ïðèâëå÷åíèÿ ñîòðóäíèêîâ è ïðåîáðåñòè íåîáõîäèìûå äëÿ ðàáîòû íàâûêè, òàê ÷òî çàðàáîòîê â ýòîò ïåðèîä áóäåò ìèíèìàëåí. Õîòÿ âñå çàâèñèò òîëüêî îò Âàøåãî æåëàíèÿ çàðàáîòàòü, ðàáîòà íåñëîæíàÿ è ïðè ñèëüíîì æåëàíèè Âû óæå â ïåðâûé ìåñÿö ïðèâëå÷åòå áîëåå 5 ñîòðóäíèêîâ, ÷òî äåëàþò ïðèìåðíî 30% ó÷àñòíèêîâ. Âî âòîðîì ìåñÿöå Âû óæå áóäåòå òî÷íî çíàòü ÷òî äåëàòü è ïðèâëå÷åòå áîëüøå ñîòðóäíèêîâ ÷åì â ïåðâîì, îáû÷íî íå ìåíåå ÷åì â 2 ðàçà, òàêæå â ðàáîòó âîéäóò òå ñîòðóäíèêè, êîòîðûõ Âû ïðèâëåêëè â ïðîøëîì ìåñÿöå, ò.å. Âàø çàðàáîòîê ñîñòàâèò áîëåå $100. Åñëè Âû äåéñòâèòåëüíî ñòàðàëèñü è åæåäíåâíî óäåëÿëè áèçíåñó 2-3 ÷àñà ïðîäóêòèâíîé ðàáîòû, òî íà÷èíàÿ ñ 3-ãî ìåñÿöà Âû íà÷íåòå ïîëó÷àòü çà ýòî äîñòîéíîå Âàñ äåíåæíîå âîçíàãðàæäåíèå, êîòîðîå áóäåò åæåìåñÿ÷íî óâåëè÷èâàòüñÿ.
   Íî ïîìíèòå, ÷òî ýòî íå õàëÿâà è íå ñïîñîá áûñòðîãî îáîãàùåíèÿ - òàêîãî ïðîñòî íå áûâàåò! Áèçíåñ ïî ñèñòåìå 6õ6 - ýòî äîñòîéíàÿ Âàñ âûñîêîîïëà÷èâàåìàÿ ðàáîòà, êîòîðàÿ ïîçâîëèò Âàì èçìåíèòü æèçíü ê ëó÷øåìó, íî ëèøü â òîì ñëó÷àå åñëè Âû îòíåñåòåñü ê ýòîé ðàáîòå ñåðüåçíî. Åñëè Âû äåéñòâèòåëüíî õîòèòå ñòàòü ñâîáîäíûì è ôèíàíñîâî íåçàâèñèìûì ÷åëîâåêîì è õîòèòå ýòîãî äîáèòüñÿ - ó Âàñ âñå ïîëó÷èòñÿ, ò.ê. 6õ6 - ïðàâèëüíûé ïóòü! Åñëè æå Âû ïðîñòî ñ÷èòàåòå, ÷òî âåñü ìèð çàäîëæàë Âàì äåíåã è Âû íåïðåìåííî ïîëó÷èòå ìèëëèîí íàõàëÿâó - êðåïêî ïîäóìàéòå, ðàçâå òàêîå áûâàåò?
   Áëàãîäàðÿ íîâåéøèì ðàçðàáîòêàì ýëåêòðîííîé êîììåðöèè, ñåòåâîãî ìàðêåòèíãà è ýôôåêòèâíåéøèì ñïîñîáàì ðåêëàìû, èçëîæåíûì â êíèãå, è êîíå÷íî æå ñîáñòâåííîìó æåëàíèþ, Âû ñìîæåòå åæåìåñÿ÷íî ëè÷íî ïðèâëåêàòü äåñÿòêè íîâûõ ñîòðóäíèêîâ è íåñîìíåííî äîáüåòåñü óñïåõà!

ÊÀÊ ÍÀ×ÀÒÜ
 
 


   Èòàê, Âû òâåðäî ðåøèëè èçìåíèòü ñâîþ æèçíü ê ëó÷øåìó è ñòàòü ôèíàíñîâî íåçàâèñèìûì ÷åëîâåêîì! Ïîçäðàâëÿåì! Âû âûáðàëè äåéñòâèòåëüíî âåðíûé ïóòü!

   1) Äëÿ íà÷àëà Âàì íåîáõîäèìî çàðåãèñòðèðîâàòüñÿ ó îñíîâàòåëÿ áèçíåñ ñèñòåìû 6õ6. Ðåãèñòðàöèÿ ïëàòíàÿ, ñòîèìîñòü 10 äîëëàðîâ ÑØÀ. Çàðåãèñòðèðîâàòüñÿ ìîæíî äâóìÿ ñïîñîáàìè, âûáåðèòå íàèáîëåå äëÿ Âàñ ïîäõîäÿùèé.

   A) Äëÿ ëþäåé, ïðîæèâàþùèõ íà òåððèòîðèè Ðîññèè:

   Ïåðåâåäèòå 300 ðóáëåé òåëåãðàôíûì ïåðåâîäîì íà ñëåäóþùèå ðåêâèçèòû:

Ñàíêò-Ïåòåðáóðã 197342
Òèùåíêîâ Èãîðü Àëåêñàíäðîâè÷
Äî âîñòðåáîâàíèÿ

   Â ñîîáùåíèè, ñîïðîâîæäàþùåì ïåðåâîä, óêàæèòå ñëåäóþùèå äàííûå (â ñëó÷àå íåîáõîäèìîñòè èõ ìîæíî âûñëàòü òåëåãðàììîé íà ýòîò æå àäðåñ):

1) Ýòîò íîìåð: 6x6-000000-z-001
2) Âàøè Ô.È.Î.
3) Âàø e-mail

   B) Äëÿ ëþäåé, ïðîæèâàþùèõ íå íà òåððèòîðèè Ðîññèè:

   Ïåðåâåäèòå 10 USD íà ñ÷åò îñíîâàòåëÿ áèçíåñ ñèñòåìû 6õ6:

1107736234 Igor Tistsenkov
Hansapank, Liivalaia 8, 15040 Tallinn, Estonia
S.W.I.F.T. code: HABA EE2X

   Çàòåì îòïðàâüòå òåëåãðàììó, ñîäåðæàùóþ (â ñëó÷àå íåîáõîäèìîñòè èõ ìîæíî âûñëàòü ÀÂÈÀ ïèñüìîì):

1) Ýòîò íîìåð: 6x6-000000-z-001
2) Âàøè Ô.È.Î.
3) Âàø e-mail

   íà àäðåñ:

Igor Tistsenkov
Laanemere 20-96
13913 Tallinn
Estonia

   2)  òå÷åíèå ñóòîê Âàì íà e-mail ïðèéäåò ïèñüìî, ñîäåðæàùåå Âàø ðåãèñòðàöèîííûé íîìåð, ðåêâèçèòû âñåõ ñîòðóäíèêîâ, ó êîòîðûõ Âàì íåîáõîäèìî êóïèòü êíèãó, è ïîëíîå îïèñàíèå ìåõàíèçìà è âñåõ òîíêîñòåé ñèñòåìû.
   3) Ñðàçó êóïèòå êíèãó ó ñîòðóäíèêîâ, ñòîèìîñòü 36 äîëëàðîâ ÑØÀ. Ïîäðîáíåå â ïèñüìå.
   4) Ïîëó÷èâ êíèãó, ñðàçó ïðèñòóïàéòå ê ðàáîòå. Óäà÷à íå çàñòàâèò ñåáÿ æäàòü!

   P.S. Åñëè ó Âàñ âîçíèêëè êàêèå-ëèáî âîïðîñû ïî ïîâîäó ñèñòåìû 6õ6 - íå ñòåñíÿéòåñü, ïðèñûëàéòå íàì èõ è ñâîé e-mail òåëåãðàììîé èëè ïî ïî÷òå, è ìû Âàì ñ ðàäîñòüþ íà íèõ îòâåòèì!

À òåïåðü çà äåëî!

Æåëàåì Âàì îãðîìíûõ óñïåõîâ!!!

 
 


Copyright © 2000-2001 6x6 InterNetwork Group. Âñå ïðàâà çàùèùåíû. Ëþáîå èçìåíåíèå òåêñòà ýòîãî ïèñüìà è ïîñëåäóþùåå åãî ðàñïðîñòðàíåíèå ïðåñëåäóåòñÿ ïî çàêîíó îá àâòîðñêèõ ïðàâàõ.
 
------=_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: 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 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-- 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 "", line 1 type(print) SyntaxError: invalid syntax (I didn't know, what to expect) and also: >>> type(print 3) File "", 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 "", 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) 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: 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 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" To: 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: 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() => 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() => 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() 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: 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 To: Danny Yoo 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: <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: > One often says: in Python everything is an object. > > In preparing some lecture for my students I met > the following: > > >>> type(print) > File "", 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 "", 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 "", line 1 map(print, range(42)) ^ SyntaxError: invalid syntax >>> map(lambda x: print x, range(42)) File "", 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 "", line 1 + ^ SyntaxError: invalid syntax ### doesn't apply in the Scheme language: ### dyoo@coffeetable:~$ guile guile> + # ### > 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: 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
 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?  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.
thanks.
PS. I have now most books on Python; = yet I still=20 feel that the indices are not comprehensive enough for novices.  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 .=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.
 
 
  tony
------=_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: 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 > >>> 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() => 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() => 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() 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
Dear Tony!
 
Your problem seems to have a=20 platform-specific
character.
Maybe the following points = to a=20 solution of your
problem (i. e. if you are using = Windows).=20 It uses
the msvcrt-module contained in = the=20 windows-distribution.
 
import msvcrt
while 1:
    a =3D =  msvcrt.getch()
    if a =3D=3D = chr(13):=20 break
    print = a
 
This is a slightliy modified = snippet from=20 Python 2.1 - Bible
(p. 669) which in my opinion is = worth=20 reading (or at least
using).
 
However, if you already are = stuffed with=20 Python literature:
there is also an example in = Lundh's Python=20 Standard Library
on msvcrt. Could be found for = example in=20 the index under the
keyword:
 
    kbhit = function, using=20 the msvcrt module
         and, = 233
 
Hope that helps
 
Gregor
----- Original Message -----
From:=20
tonycervone
Sent: Friday, November 23, 2001 = 5:37=20 PM
Subject: [Tutor] how does one = poll the=20 keyboard?

 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?  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.
thanks.
PS. I have now most books on Python; = yet I still=20 feel that the indices are not comprehensive enough for novices.  = 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 . 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.
 
 
  tony
------=_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
Dear Pythonistas!
 
Problem-Description (questions = ca 35 lines=20 below):
 
I have a well working = Active-Python 2.1=20 installation in C:\Python21
This includes the installation = of Tkinter=20 and IDLE.
Starting IDLE loads the=20 Python2.1.1-Interpreter into the shell.
 
Now I additionally installed = Python2.2b2=20 from python.org. into
C:\Betas\Python22
This works well including (its = own copy of)=20 IDLE
 
BUT NOW the Python2.1 - IDLE=20 (C:\Python21\Tools\idle\idle.pyw)
shows the following strange=20 behaviour:
 
1. It starts up with the wrong=20 interpreter:
 
Python 2.2b2 (#26, Nov 16 2001, = 11:44:11)=20 [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or = "license" for=20 more information.
IDLE 0.8 -- press F1 for help
>>> =
 
2. It uses a mixed = sys.path:
 
>>> import = sys
>>>=20 sys.path
['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']
Moreover several things don't = work properly=20 anymore, especially one
cannot close IDLE via the = File-menu.=20 Instead the following error-message occurs:
 
>>> Exception in = Tkinter=20 callback
Traceback (most recent call last):
  File=20 "C:\Betas\Python22\lib\lib-tk\Tkinter.py", line 1292, in=20 __call__
    return apply(self.func, args)
  = File=20 "C:\Python21\Tools\idle\PyShell.py", line 421, in = close
   =20 return PyShellEditorWindow.close(self)
TypeError: unbound method = close() must=20 be called with PyShellEditorWindow instance as first argument (got = PyShell=20 instance instead)
 
>>>
 
So here my = QUESTIONS:
 
Where does IDLE get the = information from=20 concerning the Interpreter to use and also
the information converning the=20 path?
NOTE 1: My Path (DOS-Shell) = contains only=20 C:\Python21 and NOT C:\Betas\Python22
NOTE 2: After deinstalling = Python2.2b2 IDLE=20 works as before (with Python2.1.1)
 
What changes are performed on = my system=20 through installing Python2.2b2?
 
Are there configuration files, = which can be=20 edited to repair this situation?
If you don't know the answer, = where should=20 I look for it?
 
Gregor
 
------=_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
Dear Pythonistas!
 
This concerns the problem = posted half an=20 hour before:
 
The following made the = repair:
 
Changed the connection between = .pyw-files=20 and the
open-ing program from=20 C:\Betas\Python22\pythonw.exe
to = C:\Python21\pythonw.exe
 
Now BOTH = installations WORK=20 WELL.
 
Sorry for the = inconvenience!
 
Gregor
------=_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
Dear Pythonistas!
 
Sometimes formulating a = question=20 initiates
some (sometimes unconscious) = thoughts in=20 ones
own brain - often with = a short delay -
so one can find the answer *on = oneselfs=20 own*
(this formulation is hardly correct?)
 
Certainly some of you also = experienced=20 this.
Regards!
 
Gregor
------=_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: 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: 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

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-- 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: Message-ID: <3BFED62D.96AF213F@ccvcorp.com> > On Fri, 23 Nov 2001 12:08:32 -0500, > Andrei Kulakov 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: <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: 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: <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 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: 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: 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 | | 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: 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: References: 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: 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 Sat Nov 24 20:14:20 2001 From: Pjotr (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: > > 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: 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 "", 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: 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: Message-ID: <3C016AF0.218680F0@gmx.de> Pjotr 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: 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 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: References: 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 > 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: 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 To: Danny Yoo 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 > 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
Thanks for your help. More questions to = come...
------=_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: Message-ID: <3C027924.1EFEDD5@ccvcorp.com> > On Fri, 23 Nov 2001 18:08:19 -0500, > Andrei Kulakov 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: 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 -"-"----| _________________________ ______________________________________________________________________________ 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: <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 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: <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: <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: 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: 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: 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: 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 " 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: 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 " 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: Message-ID: 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: 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: 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: 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: 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 . 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
what is the basic command for python and they=20 function
------=_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: 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
Hi,
How do I create a two dimensional=20 list?
       =20             =    =20             =    =20             =    =20             =    =20 Ganapathy
------=_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" 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

------------------------------------------------------------
--=====================_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 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 "", 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 "", 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: 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 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: 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 Para: Pijus Virketis 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: 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
Dear Pythonistas!
 
Several weeks (months) ago = somebody (maybe=20 Danny Yoo?
or Alan Gauld?) posted a reference to an interactive =
online-text-game concerning aspects of computer=20 programming.
Then I didn' know how to use it = properly,=20 didn't have
much time and left = it.
 
Now I came across something = similar in=20 German and I'd
like to compare those two. But = I can'=20 remember neither
the name of the thing nor the = reference to=20 it.
 
Does anybody have it=20 ready? 
 
Gregor
------=_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: 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: 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 wrote: > > -----Mensaje original----- > De: Pablo Prieto > Para: Pijus Virketis > 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> 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 <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: <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> <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: 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 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 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: 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: 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: References: <002e01c177f4$78294260$156710ac@pablo> 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 > > > >
>
------------------------------------------------------------
> > >
------------------------------------------------------------
< div>PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
------------------------------------------------------------
------------------------------------------------------------ PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/linkswww.fas.harvard .edu/~virketis/links My weblog: www.fas.harvard.edu/~virketiswww.fas.harvard .edu/~virketis --=====================_111074614==_.ALT Content-Type: text/html; 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 




------------------------------------------------------------
--=====================_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: 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: Message-ID: 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: References: 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: Message-ID: 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: Message-ID: 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: Message-ID: 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: > 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: <002e01c177f4$78294260$156710ac@pablo> 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: 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 | | 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
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.
------=_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: 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 | | 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 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: 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 | | 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: 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 | | 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

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-- 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: 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: 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!? > 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 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!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.


------------------------------------------------------------
--=====================_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: 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: 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: 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 -- 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 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: 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: 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 ) 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: Message-ID: 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: Message-ID: 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 "", line 1, in ? myObject("jim") File "", 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 "", line 1, in ? omy = myObject("Duh") File "", 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 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-- 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: 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: Message-ID: 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: ; from karthikg@aztec.soft.net on Fri, Nov 30, 2001 at 10:02:55AM +0530 References: 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: References: 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 (startstop and inc>0): raise ValueError,"Illegal parameters" while start>> 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 "", 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: 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 (startstop and inc>0): raise ValueError,"Illegal" while start>> 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() # 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: 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 <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 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-- 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 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: <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: <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 "", 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: 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> <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: 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 | | 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: > > 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: 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 | | 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: 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 | | 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: 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 | | 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: 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 | | 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: Message-ID: <3C07CD75.5321E25@ccvcorp.com> > On Fri, 30 Nov 2001 10:27:15 -0500, > "Lee-Shanok, Bruce" 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: 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" To: 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 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" > To: > 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: Message-ID: 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: Message-ID: 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: 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 | | 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: 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: 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