From deng@ms.shlftdc.net.cn Fri Sep 1 02:30:17 2000 From: deng@ms.shlftdc.net.cn (deng wei) Date: Fri, 1 Sep 2000 9:30:17 +0800 Subject: [Tutor] Q? Message-ID: <20000901004023093.AAA259.316@wd> tutorHello: The Python said this is wrong.But I think it's right.Why? # The while practice: a=['hello','world','i','am','a','worker'] i=0 while i Hello All: If I want to duplicate a list,how should I do? I had tried,for example: a=['Hello','world'] b=a but obviously it's not right. Anyone knows? Thanks! DengWei deng@ms.shlftdc.net.cn From rsmaker@bom7.vsnl.net.in Fri Sep 1 05:39:29 2000 From: rsmaker@bom7.vsnl.net.in (Rishi Maker) Date: Fri, 1 Sep 2000 10:09:29 +0530 Subject: [Tutor] Q? In-Reply-To: <20000901004023093.AAA259.316@wd>; from deng@ms.shlftdc.net.cn on Fri, Sep 01, 2000 at 09:30:17AM +0800 References: <20000901004023093.AAA259.316@wd> Message-ID: <20000901100929.A1318@bom7.vsnl.net.in> --y0ulUmNC+osPPQO6 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable This does not work for various reason .. Look at this script , you should f= igure out why. # The while practice: a=3D['hello','world','i','am','a','worker'] print a i=3D0 x=3Dlen(a)-1 b=3D[] while i tutorHello: > The Python said this is wrong.But I think it's right.Why? >=20 > # The while practice: > a=3D['hello','world','i','am','a','worker'] > i=3D0 > while i b[i]=3Da[len(a)-i] > i=3Di+1 > print b >=20 >=20 > =20 >=20 > DengWei > deng@ms.shlftdc.net.cn >=20 >=20 > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor --=20 ---------------------------------------------------------------------------= ---- Signature Follows :- Rishi Maker |------------Quote Of The Mail----------------| Web Developer |The church saves sinners, but science seeks |=09 rishim@cyberspace.org |to stop their manufacture. -- Elbert | Tel : 91-22-5374892 |Hubbard | ICQ UIN :-56551784 | | ---------------------------------------------------------------------------= ---- ----------------The Following has been stolen from fortune cookies---------= ---- ---------------------------------------------------------------------------= ---- | ----:----:----:-----:----:----:----:----:----:----:----:----:| --------| guru, n: A computer owner who can read the manual. |-------= =09 | ----:----:----:-----:----:----:----:----:----:----:----:----:| ---------------------------------------------------------------------------= ---- if (argc > 1 && strcmp(argv[1], "-advice") =3D=3D 0) { printf("Don't Panic!\n"); exit(42); } (Arnold Robbins in the LJ of February '95, describing RCS) ---------------------------------------------------------------------------= ---- We are using Linux daily to UP our productivity - so UP yours! (Adapted from Pat Paulsen by Joe Sloan) ---------------------------------------------------------------------------= ---- `When you say "I wrote a program that crashed Windows", people just stare at you blankly and say "Hey, I got those with the system, *for free*".' (By Linus Torvalds) ---------------------------------------------------------------------------= ---- Copyleft --:- =AE=D8=A7h=EC M=E5k=EBr -:-- ---------------------------------------------------------------------------= ---- --y0ulUmNC+osPPQO6 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 5.0i for non-commercial use MessageID: BkAtZlMcBXnBJJJ0CW/tQsS2NXGJzEyn iQA/AwUBOa8zAMjbonC6FpvoEQKUjQCeL+63BE0IPOiHxz/b0/pb4v3VB2AAoIFF 3Rx4coXna78h+kVf2TLPjj9C =w544 -----END PGP SIGNATURE----- --y0ulUmNC+osPPQO6-- From dyoo@hkn.EECS.Berkeley.EDU Fri Sep 1 05:23:33 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Thu, 31 Aug 2000 21:23:33 -0700 (PDT) Subject: [Tutor] Q? In-Reply-To: <20000901004023093.AAA259.316@wd> Message-ID: On Fri, 1 Sep 2000, deng wei wrote: > The Python said this is wrong.But I think it's right.Why? > > # The while practice: > a=['hello','world','i','am','a','worker'] > i=0 > while i b[i]=a[len(a)-i] > i=i+1 > print b I'm guessing that this piece of code reverses the order of list 'a', and places it into list 'b'. This would work, except that we haven't sized 'b' yet as a new list. Try it on the interpreter: ### >>> a = ['hello', 'world', 'i', 'am', 'a', 'worker'] >>> i = 0 >>> while i < len(a): ... b[i] = a[len(a) - i] ... i = i + 1 ... Traceback (innermost last): File "", line 2, in ? IndexError: list index out of range ### To fix this, we need to properly set b to a list of equal size to a. Here's one quick way of doing it: ### >>> b = list(range(len(a))) >>> b [0, 1, 2, 3, 4, 5] ### I create a tuple 'b' of size 'len(a)', and convert it to a list, so that we can change elements of b. Afterwards, we should be ok: ### >>> i = 0 >>> while i < len(a): ... b[i] = a[len(a) - i] ... i = i + 1 ... Traceback (innermost last): File "", line 2, in ? IndexError: list index out of range ### Hmm... I spoke too soon! Let's think about this. When i=0, then we try to execute: b[i] = a[5 - 0] Ah! That's off the list! We can read from a[0], a[1], a[2], ..., a[4], but not a[5]. This is why we're getting the IndexError. The solution is to subtract 1 from the offset. If we do this, then the loop will go through through b[4], b[3], ..., b[0]. ### b[i] = a[len(a) - i - 1] ### should be the corrected line. From rsmaker@bom7.vsnl.net.in Fri Sep 1 06:08:17 2000 From: rsmaker@bom7.vsnl.net.in (Rishi Maker) Date: Fri, 1 Sep 2000 10:38:17 +0530 Subject: [Tutor] Q? One additional query In-Reply-To: <20000901100929.A1318@bom7.vsnl.net.in>; from rsmaker@bom7.vsnl.net.in on Fri, Sep 01, 2000 at 10:09:29AM +0530 References: <20000901004023093.AAA259.316@wd> <20000901100929.A1318@bom7.vsnl.net.in> Message-ID: <20000901103817.A1569@bom7.vsnl.net.in> This is a reply of my own mail Some one just wrote a script in which b is initialized b = list(range(len(a))) I guess My script will be much slower than his script as memory has to be allocated at each loop Just a point a=['hello','world','i','am','a','worker'] print a i=0 x=len(a)-1 b=[] while i > And Then deng wei wrote ............. > > > tutorHello: > > The Python said this is wrong.But I think it's right.Why? > > > > # The while practice: > > a=['hello','world','i','am','a','worker'] > > i=0 > > while i > b[i]=a[len(a)-i] > > i=i+1 > > print b > > > > > > > > > > DengWei > > deng@ms.shlftdc.net.cn > > > > > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > http://www.python.org/mailman/listinfo/tutor > > -- > ------------------------------------------------------------------------------- > Signature Follows :- > > Rishi Maker |------------Quote Of The Mail----------------| > Web Developer |The church saves sinners, but science seeks | > rishim@cyberspace.org |to stop their manufacture. -- Elbert | > Tel : 91-22-5374892 |Hubbard | > ICQ UIN :-56551784 | | > ------------------------------------------------------------------------------- > ----------------The Following has been stolen from fortune cookies------------- > ------------------------------------------------------------------------------- > | ----:----:----:-----:----:----:----:----:----:----:----:----:| > --------| guru, n: A computer owner who can read the manual. |------- > | ----:----:----:-----:----:----:----:----:----:----:----:----:| > ------------------------------------------------------------------------------- > if (argc > 1 && strcmp(argv[1], "-advice") == 0) { > printf("Don't Panic!\n"); > exit(42); > } > (Arnold Robbins in the LJ of February '95, describing RCS) > ------------------------------------------------------------------------------- > We are using Linux daily to UP our productivity - so UP yours! > (Adapted from Pat Paulsen by Joe Sloan) > ------------------------------------------------------------------------------- > `When you say "I wrote a program that crashed Windows", people just stare at > you blankly and say "Hey, I got those with the system, *for free*".' > (By Linus Torvalds) > ------------------------------------------------------------------------------- > Copyleft --:- ®Ø§hì Måkër -:-- > ------------------------------------------------------------------------------- -- ------------------------------------------------------------------------------- Signature Follows :- Rishi Maker |------------Quote Of The Mail----------------| Web Developer |I have a hard time being attracted to anyone | rishim@cyberspace.org |who can beat me up. -- John McGrath, | Tel : 91-22-5374892 |Atlanta sportswriter, on women weightlifters.| ICQ UIN :-56551784 | | ------------------------------------------------------------------------------- ----------------The Following has been stolen from fortune cookies------------- ------------------------------------------------------------------------------- | ----:----:----:-----:----:----:----:----:----:----:----:----:| --------| guru, n: A computer owner who can read the manual. |------- | ----:----:----:-----:----:----:----:----:----:----:----:----:| ------------------------------------------------------------------------------- if (argc > 1 && strcmp(argv[1], "-advice") == 0) { printf("Don't Panic!\n"); exit(42); } (Arnold Robbins in the LJ of February '95, describing RCS) ------------------------------------------------------------------------------- We are using Linux daily to UP our productivity - so UP yours! (Adapted from Pat Paulsen by Joe Sloan) ------------------------------------------------------------------------------- `When you say "I wrote a program that crashed Windows", people just stare at you blankly and say "Hey, I got those with the system, *for free*".' (By Linus Torvalds) ------------------------------------------------------------------------------- Copyleft --:- ®Ø§hì Måkër -:-- ------------------------------------------------------------------------------- From dyoo@hkn.EECS.Berkeley.EDU Fri Sep 1 09:39:20 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Fri, 1 Sep 2000 01:39:20 -0700 (PDT) Subject: [Tutor] (no subject) In-Reply-To: <20000901015039109.AAA259.386@wd> Message-ID: On Fri, 1 Sep 2000, deng wei wrote: > Hello All: > If I want to duplicate a list,how should I do? > I had tried,for example: > > a=['Hello','world'] > b=a > > but obviously it's not right. > > Anyone knows? Thanks! The quick answer is: b = a[:] which will make a shallow copy of the list. What this does is take a slice of all of 'a'. A better answer would be to use the 'copy' module, which will make "deep" copies: ### import copy b = copy.deepcopy(a) ### which guarantees that b has a completely separate copy of whatever 'a' contained. Here's a slightly more detailed explanation of what's happening: For the immutable types (strings, tuples, numbers), you usually don't have to worry about copying stuff. ### >>> a = 42 >>> b = a >>> b = 24 >>> a,b (42, 24) ### does what you expect. Since these things don't change, it's fine when they share the same thing. This is, in fact, what's happening --- it's sharing. Here's a diagram of what it looks like in your computer after 'b = a': |-| |a|----------| |-| | |--| |----> |42| |-| | |--| |b| ---------| |-| However, since lists are "mutable", that is, modifiable, this rule causes difficulties, as you noticed, if you're making changes to the shared thing. >>> a = ['hello', 'world'] >>> b = a >>> a[0] = 'goodbye' >>> a ['goodbye', 'world'] >>> b ['goodbye', 'world'] Diagrammically, this looks like: |-| |a|----------| |-| | |----------------------| |----->| ['goodbye', 'world'] | |-| | |----------------------| |b| ---------| |-| As explained above, the way to fix this is to give 'b' an independent copy of the list: >>> a = ['hello', 'world'] >>> import copy >>> b = copy.deepcopy(a) >>> a[0] = 'goodbye' >>> a ['goodbye', 'world'] >>> b ['hello', 'world'] By using the [:] slice, or the copy.deepcopy() function, we'll get this picture instead: |-| |----------------------| |a|--------->| ['goodbye', 'world'] | |-| |----------------------| |-| |--------------------| |b|--------->| ['hello', 'world'] | |-| |--------------------| which does the thing you expect for your particular program. Usually, sharing is fine, but there are cases when you want to explicitly copy stuff. I hope this makes things clearer, even if the ASCII is a bit ugly... *grin* From arcege@shore.net Fri Sep 1 12:25:59 2000 From: arcege@shore.net (Michael P. Reilly) Date: Fri, 1 Sep 2000 07:25:59 -0400 (EDT) Subject: [Tutor] Q? One additional query In-Reply-To: <20000901103817.A1569@bom7.vsnl.net.in> from "Rishi Maker" at Sep 01, 2000 10:38:17 AM Message-ID: <200009011125.HAA27872@northshore.shore.net> > This is a reply of my own mail > Some one just wrote a script in which b is initialized > b = list(range(len(a))) > I guess My script will be much slower than his script as memory has to be allocated at each loop > Just a point If you are going to reverse a sequence, then I suggest copying the sequence and then reversing the resulting list. >>> a = ('hello', 'world', 'i', 'am', 'a', 'worker') >>> b = list(a) # a could be a tuple or even a string, so do not use `[:]' >>> b.reverse() >>> print b If you are looking for how to perform this manually in Python (without using the reverse method), loop and insert at index zero. >>> a = ['hello', 'world', 'i', 'am', 'a', 'worker'] >>> b = [] >>> for item in a: ... b.insert(0, item) ... >>> print b In terms of the memory, the same amount of memory is to be allocated so there is no real performance hit except with large lists (realloc on many systems is fairly efficient). But this is also why using the list().reverse() idiom is more efficient. -Arcege -- ------------------------------------------------------------------------ | Michael P. Reilly, Release Manager | Email: arcege@shore.net | | Salem, Mass. USA 01970 | | ------------------------------------------------------------------------ From deng@ms.shlftdc.net.cn Sat Sep 2 11:41:29 2000 From: deng@ms.shlftdc.net.cn (deng wei) Date: Sat, 2 Sep 2000 18:41:29 +0800 Subject: [Tutor] (no subject) Message-ID: <20000901095139593.AAA301.419@192> Hi,all: There is a mistake in the Python Manuals at "5.3 Tuples and Sequences".It said: a tuple with one item is constructed by following a value with a comma (it is not sufficient to enclose a single value in parentheses). but if you type: >>> b=('hello') >>> b 'hello' No problem!? Am I right? DengWei deng@ms.shlftdc.net.cn From deng@ms.shlftdc.net.cn Sat Sep 2 12:43:12 2000 From: deng@ms.shlftdc.net.cn (deng wei) Date: Sat, 2 Sep 2000 19:43:12 +0800 Subject: [Tutor] Fw: Message-ID: <20000901105322921.AAA301.350@192> =C4=FA=BA=C3=A3=A1 *******=CF=C2=C3=E6=CA=C7=D7=AA=B7=A2=B5=C4=D3=CA=BC=FE***** Hi,dyoo: I think the answer is not quite right. For example : When sum=3D99,then next loop.and maybe I input 199,therefore= sum=3D99+199>100. I think it should be added a *if* statement: ### sum =3D 0 while sum < 100: print "Sum so far:", sum number =3D input("Please enter a number: ") sum =3D sum + number if sum>100: print "your number is exceeded 100." ### By the way: Your comments about how to program is helpful to me .Thank You= very much. Sheng deng@ms.shlftdc.net.cn *****=D7=AA=B7=A2=C4=DA=C8=DD=BD=E1=CA=F8***** =D6=C2 =C0=F1=A3=A1 DengWei deng@ms.shlftdc.net.cn From insyte@emt-p.org Fri Sep 1 16:32:07 2000 From: insyte@emt-p.org (Ben Beuchler) Date: Fri, 1 Sep 2000 10:32:07 -0500 Subject: [Tutor] (no subject) In-Reply-To: <20000901095139593.AAA301.419@192>; from deng@ms.shlftdc.net.cn on Sat, Sep 02, 2000 at 06:41:29PM +0800 References: <20000901095139593.AAA301.419@192> Message-ID: <20000901103204.A11705@emt-p.org> On Sat, Sep 02, 2000 at 06:41:29PM +0800, deng wei wrote: > Hi,all: > There is a mistake in the Python Manuals at "5.3 Tuples and Sequences".It said: > a tuple with one item is constructed by following a value with a comma (it is not sufficient to enclose a single value in parentheses). > > > but if you type: > >>> b=('hello') > >>> b > 'hello' > > No problem!? > > Am I right? Nope. >>> b=('hello') >>> type(b) >>> >>> b=('hello',) >>> type(b) Ben -- Ben Beuchler insyte@bitstream.net MAILER-DAEMON (612) 321-9290 x101 Bitstream Underground www.bitstream.net From gwperry@tva.gov Fri Sep 1 18:33:46 2000 From: gwperry@tva.gov (Perry, George W.) Date: Fri, 1 Sep 2000 13:33:46 -0400 Subject: [Tutor] First OOP Attempt Message-ID: <2DACABE127B3D1119FC40000F8014EFC0184C799@chachaois4.cha.tva.gov> The following appears to work, but I just now learning about OOP concepts, and I was wondering if there is anything that is obviously wrong or poor technique. Comments would be appreciated. Thanks George Perry """ Apartments can have 0 or 1 persons as occupants. Persons may move to an empty apartment but not to an occupied apartment. Persons may have 0 or 1 pets. Persons may give their pet to another person who has no pet. """ import sys class Apt: def __init__(self,address=None,name=None): self.addr = address self.occ = name if address != None: dicApt[address] = self class Person: def __init__(self,name=None,addr=None,pet=None): self.name = name self.addr = addr self.petname = pet if name != None: dicPer[name] = self def moveFrom(self): a1 = dicApt[self.addr] if a1.occ != self.name : print "Bug1 %s != %s" % (a1.occ,self.name) sys.exit() print "%s moving from %s." % (self.name,self.addr) a1.occ = None # apartment is now empty self.addr = None # person is temporarily homeless def moveTo(self,dest): a1 = dicApt[dest] if a1.occ != None: print "%s moving to %s. Occupied by %s" % (self.name,a1.addr,a1.occ) sys.exit() a1.occ = self.name self.addr = a1.addr print "%s moved to %s." % (self.name,self.addr) def moving(self,dest): self.moveFrom() self.moveTo(dest) class Pet: def __init__(self,petname,owner=None): self.petname = petname self.owner = owner def givePet(self): p1 = dicPer[self.owner] if p1.name != self.owner : print "Bug2 %s != %s" % (p1.name,self.owner) sys.exit() print "%s giving away %s." % (self.owner,self.petname) p1.petname = None # owner now has no pet self.owner = None # pet is temporarily ownerless def takePet(self,receiver): p1 = dicPer[receiver] print "%s being given to %s. Now owns %s" % (self.petname,p1.name,p1.petname) if p1.petname != None: sys.exit() p1.petname = self.petname self.owner = p1.name print "%s taken by %s." % (self.petname,self.owner) def giving(self,receiver): self.givePet() self.takePet(receiver) def newPerson(name,addr): p1 = Person(name,addr) a1 = Apt(addr,name) return (p1,a1) def main(): global dicPer, dicApt dicApt = {} # to lookup Apt instance given an apartment address dicPer = {} # to lookup Person instance given a person's name p1,a1 = newPerson("Pat","Az1") # Create a person & apartment p1.pet = 'Doggy' # ...with a pet d1 = Pet('Doggy','Pat') a2 = Apt("Az2") # Create 2 empty apts a3 = Apt("Az3") p1.moving("Az2") # Move Pat from Az1 to Az2 p1.moving("Az3") # Move Pat from Az2 to Az3 p1.moving("Az1") # Move Pat from Az3 to Az1 p4,a4 = newPerson("Mikie","Az4") # Create a person & apartment # p4.petname = 'Kitty' # pgm exits if these are uncommented # d4 = Pet('Kitty','Mikie') d1.giving("Mikie") for apt in (a1,a2,a3,a4): print 'Apt',apt.addr,apt.occ,dicApt.has_key(apt.addr) for per in (p1,p4): print 'Per',per.name,per.addr,per.petname,dicPer.has_key(per.name) for pet in (d1,): print 'Pet',pet.petname,pet.owner main() From shaleh@valinux.com Fri Sep 1 19:56:26 2000 From: shaleh@valinux.com (Sean 'Shaleh' Perry) Date: Fri, 01 Sep 2000 11:56:26 -0700 (PDT) Subject: [Tutor] First OOP Attempt In-Reply-To: <2DACABE127B3D1119FC40000F8014EFC0184C799@chachaois4.cha.tva.gov> Message-ID: On 01-Sep-2000 Perry, George W. wrote: > The following appears to work, but I just now learning about OOP concepts, > and I was wondering if there is anything that is obviously wrong or poor > technique. Comments would be appreciated. > looks good for a first run Now, to really use this, we modify it slighty. > > main() > becomes : if __name__ == '__main__: main() What this does is check that the script is being run as a script by the interpreter, if so, run main(). By adding this check you can now do: import Apartment # or whatever you call the foo.py script dog = Apartment.pet('fifi') and use the classes in other code. From dyoo@hkn.EECS.Berkeley.EDU Sat Sep 2 04:00:17 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Fri, 1 Sep 2000 20:00:17 -0700 (PDT) Subject: [Tutor] (no subject) In-Reply-To: <20000901095139593.AAA301.419@192> Message-ID: On Sat, 2 Sep 2000, deng wei wrote: > There is a mistake in the Python Manuals at "5.3 Tuples and > Sequences".It said: > a tuple with one item is constructed by following a value with a > comma (it is not sufficient to enclose a single value in parentheses). > > but if you type: > >>> b=('hello') > >>> b > 'hello' Parenthesis have two separate meanings in Python. For example, parenthesis are used to group stuff and lead Python to do certain things first: ### >>> 5 - (4 - 3) 4 >>> (5 - 4) - 3 -2 ### This shows how parenthesis can be used to indicate "precedence", that is, what should be done first in an expression. The other use for parenthesis is in creating tuples. ### >>> x = ('hello', 'world') >>> x ('hello', 'world') ### Usually, these two usages don't conflict, except for the case when you want to make a tuple of one element. Because x = (5 + (4 - 3)) can be taken both ways by someone reading the code, we need to make it perfectly clear to Python what we mean. That's why we have the "comma at the end" rule: ### >>> (5 - (4 - 3)) 4 >>> (5 - (4 - 3),) (4,) ### Hope this clears things up. From dyoo@hkn.EECS.Berkeley.EDU Sat Sep 2 04:12:29 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Fri, 1 Sep 2000 20:12:29 -0700 (PDT) Subject: [Tutor] A timer of some sort. In-Reply-To: <20.ae48cb6.26e028bf@aol.com> Message-ID: On Thu, 31 Aug 2000 FxItAL@aol.com wrote: > Hello, > Does anyone know of a timer or a timimg module that I can use to activate a > loop at 15 minute intervals? Yes, you'll probably want to look at the 'sched' module to do this: http://www.python.org/doc/current/lib/module-sched.html I don't have experience with this module, but the documentation looks ok enough to get something running. From dyoo@hkn.EECS.Berkeley.EDU Sat Sep 2 04:16:26 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Fri, 1 Sep 2000 20:16:26 -0700 (PDT) Subject: [Tutor] Python In-Reply-To: Message-ID: On Thu, 31 Aug 2000, Guilherme wrote: > I would like to know if python can be used to program CGI > scripts, and where can I find a good tutorial on python? Hello! You'll definitely want to look at the tutorials and introduction section of the Python website --- it has exactly what you're looking for. http://www.python.org/topics/web/basic-cgi.html http://www.python.org/doc/Intros.html Also, you might want to look at: http://www.faqts.com/knowledge-base/index.phtml/fid/199/ It's a Python FAQ respository, and has a lot of good information and links. If you have any questions, feel free to ask us again. Good luck! From rm1@student.cs.ucc.ie Sat Sep 2 21:25:28 2000 From: rm1@student.cs.ucc.ie (Robert Moloney) Date: Sat, 2 Sep 2000 21:25:28 +0100 (BST) Subject: [Tutor] Shelve error Message-ID: I keep getting this error I think it might be to do with the size of the file >>> sh = shelve.open("searchPhrase") >>> sh.keys() Traceback (innermost last): File "", line 1, in ? File "/usr/lib/python1.5/shelve.py", line 55, in keys return self.dict.keys() bsddb.error: (22, 'Invalid argument') >>> sh["http://rory.calhoone.ie/manual/sections.html"] ['Help'] >>> I can access individual key values but it won't give me a list of keys Please Help Rob From chris_esen@hotmail.com Sun Sep 3 03:04:48 2000 From: chris_esen@hotmail.com (Chris Esen) Date: Sun, 03 Sep 2000 02:04:48 GMT Subject: [Tutor] Arrays Message-ID: Hey, I just spent the last hour looking over some python tutorials and I have a question, how can I define an array of classes or any other data type? I don't think a list would work for me. Let me show you what i mean in c: int myArray[5]; myArray[0] = 22; ... myArray[4] = 2; how can you do something similar in python? I've looked through the docs. and I guess I'm over looking something. Thanks _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com. From poste_br@yahoo.com Sun Sep 3 04:12:46 2000 From: poste_br@yahoo.com (Guilherme) Date: Sun, 3 Sep 2000 00:12:46 -0300 Subject: [Tutor] Python CGI Message-ID: I was looking at some host web sites that support CGI, and they all talk about perl. I was wondering if I can use python on those instead of perl. Thanks!!! poste_br@yahoo.com __________________________________________________ Do You Yahoo!? Talk to your friends online with Yahoo! Messenger. http://im.yahoo.com From dyoo@hkn.EECS.Berkeley.EDU Sun Sep 3 08:41:03 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Sun, 3 Sep 2000 00:41:03 -0700 (PDT) Subject: [Tutor] Arrays In-Reply-To: Message-ID: > question, how can I define an array of classes or any other data type? I > don't think a list would work for me. Let me show you what i mean in c: > > int myArray[5]; > > myArray[0] = 22; > ... > myArray[4] = 2; Yes, you can use Python's lists to do this. The thing you have to do is initialize the list to be long enough. For example, you probably ran into the problem of IndexError's popping up: ### >>> myArray = [] >>> myArray[0] = 22 Traceback (innermost last): File "", line 1, in ? IndexError: list assignment index out of range ### This is because 'myArray = []' doesn't quite capture the idea of 'int myArray[5];'. At the very least, we need our myArray to hold 5 elements. This isn't too hard to fix, though. Take a look: ### >>> myArray = [0] * 5 # Initialize myArray to a list of 5 zeros >>> myArray [0, 0, 0, 0, 0] >>> myArray[0] = 22 >>> myArray [22, 0, 0, 0, 0] ### I'm not sure if it's the Pythonic way of doing things; there may be a more idiomatic way of sizing the list. However, '[0] * length' seems to be sufficient for many casual cases, and it's nicer because we can still do things like append() or insert() with our lists. Furthermore, the list is still heterogeneous --- we can put numbers, or strings, or whatever we want in that list, and it will still work. ### >>> myArray[4] = ('Ruronin', 'Kenshin') >>> myArray [22, 0, 0, 0, ('Ruronin', 'Kenshin')] ### If you really need efficient arrays, you might want to look at Numerical Python, which is a module that's specialized for very fast and lightweight arrays and matrices: http://numpy.sourceforge.net/ Good luck! From shaleh@valinux.com Sun Sep 3 08:42:54 2000 From: shaleh@valinux.com (Sean 'Shaleh' Perry) Date: Sun, 3 Sep 2000 00:42:54 -0700 Subject: [Tutor] Arrays In-Reply-To: ; from chris_esen@hotmail.com on Sun, Sep 03, 2000 at 02:04:48AM +0000 References: Message-ID: <20000903004254.C15561@valinux.com> On Sun, Sep 03, 2000 at 02:04:48AM +0000, Chris Esen wrote: > Hey, > > I just spent the last hour looking over some python tutorials and I have a > question, how can I define an array of classes or any other data type? I > don't think a list would work for me. Let me show you what i mean in c: > > int myArray[5]; > > myArray[0] = 22; > ... > myArray[4] = 2; > Python 1.5.2 (#0, Apr 3 2000, 14:46:48) [GCC 2.95.2 20000313 (Debian GNU/Linux)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam .>>> # just like C way .>>> myArray = [0,0,0,0,0] .>>> myArray[0] = 22 .>>> myArray[4] = 2 .>>> print myArray [22, 0, 0, 0, 2] .>>> # python way .>>> otherArray = [] # make an empty list .>>> otherArray.append(22) .>>> otherArray.append(0) .>>> otherArray.append(0) .>>> otherArray.append(0) .>>> otherArray.append(2) .>>> print otherArray [22, 0, 0, 0, 2] From shaleh@valinux.com Sun Sep 3 08:45:50 2000 From: shaleh@valinux.com (Sean 'Shaleh' Perry) Date: Sun, 3 Sep 2000 00:45:50 -0700 Subject: [Tutor] Python CGI In-Reply-To: ; from poste_br@yahoo.com on Sun, Sep 03, 2000 at 12:12:46AM -0300 References: Message-ID: <20000903004550.D15561@valinux.com> On Sun, Sep 03, 2000 at 12:12:46AM -0300, Guilherme wrote: > I was looking at some host web sites that support CGI, and they all talk > about perl. > I was wondering if I can use python on those instead of perl. > Thanks!!! > there is a python cgi module, 'import cgi', there is also a python apache module. For almost all cases, if you can do it in perl it can be done in python and vice versa. That is the point of a general purpose programming language -- you can write arbitrary programs in it. The difference is simply choice and learning the idioms of the language. As we tell every other new poster to the list, read www.python.org. It has tutorials, docs, other lists, etc. From rsmaker@bom7.vsnl.net.in Sun Sep 3 09:17:56 2000 From: rsmaker@bom7.vsnl.net.in (Rishi Maker) Date: Sun, 3 Sep 2000 13:47:56 +0530 Subject: [Tutor] Python CGI In-Reply-To: ; from poste_br@yahoo.com on Sun, Sep 03, 2000 at 12:12:46AM -0300 References: Message-ID: <20000903134756.A1842@bom7.vsnl.net.in> Actually most of the CGi stuff we do these days is in python .... read the cgi.py module...... There are scores of methods that would impress you And Then Guilherme wrote ............. > I was looking at some host web sites that support CGI, and they all talk > about perl. > I was wondering if I can use python on those instead of perl. > Thanks!!! > > > poste_br@yahoo.com > > > __________________________________________________ > Do You Yahoo!? > Talk to your friends online with Yahoo! Messenger. > http://im.yahoo.com > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor -- ------------------------------------------------------------------------------- Signature Follows :- Rishi Maker |------------Quote Of The Mail----------------| Senior Developer |VICARIOUSLY experience some reason to LIVE!! | rishim@cyberspace.org | | Tel : 91-22-5374892 | | ICQ UIN :-56551784 | | www.rishimaker.com | | ------------------------------------------------------------------------------- ----------------The Following has been stolen from fortune cookies------------- ------------------------------------------------------------------------------- | ----:----:----:-----:----:----:----:----:----:----:----:----:| --------| guru, n: A computer owner who can read the manual. |------- | ----:----:----:-----:----:----:----:----:----:----:----:----:| ------------------------------------------------------------------------------- if (argc > 1 && strcmp(argv[1], "-advice") == 0) { printf("Don't Panic!\n"); exit(42); } (Arnold Robbins in the LJ of February '95, describing RCS) ------------------------------------------------------------------------------- We are using Linux daily to UP our productivity - so UP yours! (Adapted from Pat Paulsen by Joe Sloan) ------------------------------------------------------------------------------- `When you say "I wrote a program that crashed Windows", people just stare at you blankly and say "Hey, I got those with the system, *for free*".' (By Linus Torvalds) ------------------------------------------------------------------------------- Copyleft --:- ®Ø§hì Måkër -:-- ------------------------------------------------------------------------------- From spirou@aragne.com Sun Sep 3 14:16:58 2000 From: spirou@aragne.com (Denis) Date: Sun, 3 Sep 2000 15:16:58 +0200 Subject: [Tutor] Python CGI In-Reply-To: ; from poste_br@yahoo.com on Sun, Sep 03, 2000 at 12:12:46AM -0300 References: Message-ID: <20000903151658.E24394@aragne.com> Le Sun, Sep 03, 2000 at 12:12:46AM -0300, Guilherme pianota: > I was looking at some host web sites that support CGI, > and they all talk about perl. The old-fashioned ones do ... The modern ones talk about Python. ;-) > I was wondering if I can use python on those instead > of perl. First, go and have a look at : http://starship.python.net/crew/davem/cgifaq/faqw.cgi Just like you were told : start with a "Hello World" cgi-script, go on with the Cgi module, the Cookie module, ... And then have a look at http://webware.sourceforge.net I've just started playing with Webware, it's quite pleasant and I hope it'll be a good alternative to http://www.zope.org. (Well, at least, it's clear, documented and more python-minded than Zope, IMHO). -- Denis FRERE P3B : Club Free-Pytho-Linuxien Caroloregien http://www.p3b.org Aragne : Internet - Reseaux - Formations http://www.aragne.com From protrans" This is a multi-part message in MIME format. ------=_NextPart_000_0007_01C01600.B81B93C0 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: base64 SGVsbG8sIGFsbCENCg0KQXMgSSBhbSB0aGlua2luZyBvZiBkb2luZyBteSBob21lcGFnZXMgd2l0 aCBweXRob24gY2dpLCBJIHdvbmRlciB3aGV0aGVyIHRoZXJlIGFyZSBhbnkgc2l0ZXMgcHJvdmlk aW5nIGZyZWUgd2ViIHNwYWNlIHdpdGggUHl0aG9uIGNnaSBzdXBwb3J0Lg0KDQpBbnkgaGludCB3 b3VsZCBiZSBtdWNoIGFwcHJlY2lhdGVkLg0KDQoNCkpvc2VwaCBZLg0K ------=_NextPart_000_0007_01C01600.B81B93C0 Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: base64 PCFET0NUWVBFIEhUTUwgUFVCTElDICItLy9XM0MvL0RURCBIVE1MIDQuMCBUcmFuc2l0aW9uYWwv L0VOIj4NCjxIVE1MPjxIRUFEPg0KPE1FVEEgY29udGVudD0idGV4dC9odG1sOyBjaGFyc2V0PWdi MjMxMiIgaHR0cC1lcXVpdj1Db250ZW50LVR5cGU+DQo8TUVUQSBjb250ZW50PSJNU0hUTUwgNS4w MC4yOTIwLjAiIG5hbWU9R0VORVJBVE9SPg0KPFNUWUxFPjwvU1RZTEU+DQo8L0hFQUQ+DQo8Qk9E WSBiZ0NvbG9yPSNmZmZmZmY+DQo8RElWPjxGT05UIHNpemU9Mj5IZWxsbywgYWxsITwvRk9OVD48 L0RJVj4NCjxESVY+Jm5ic3A7PC9ESVY+DQo8RElWPjxGT05UIHNpemU9Mj5BcyBJIGFtIHRoaW5r aW5nIG9mIGRvaW5nIG15IGhvbWVwYWdlcyB3aXRoIHB5dGhvbiBjZ2ksIEkgDQp3b25kZXIgd2hl dGhlciB0aGVyZSBhcmUgYW55IHNpdGVzIHByb3ZpZGluZyBmcmVlIHdlYiBzcGFjZSB3aXRoIFB5 dGhvbiBjZ2kgDQpzdXBwb3J0LjwvRk9OVD48L0RJVj4NCjxESVY+Jm5ic3A7PC9ESVY+DQo8RElW PjxGT05UIHNpemU9Mj5BbnkgaGludCB3b3VsZCBiZSBtdWNoIGFwcHJlY2lhdGVkLjwvRk9OVD48 L0RJVj4NCjxESVY+Jm5ic3A7PC9ESVY+DQo8RElWPjxGT05UIHNpemU9Mj48L0ZPTlQ+Jm5ic3A7 PC9ESVY+DQo8RElWPjxGT05UIHNpemU9Mj5Kb3NlcGggWS48L0ZPTlQ+PC9ESVY+PC9CT0RZPjwv SFRNTD4NCg== ------=_NextPart_000_0007_01C01600.B81B93C0-- From denis@aragne.com Sun Sep 3 17:50:31 2000 From: denis@aragne.com (Denis Frere) Date: Sun, 3 Sep 2000 18:50:31 +0200 Subject: [Tutor] free web space with Python cgi In-Reply-To: <000a01c015bd$aa5eb6b0$c5f49e3d@w2k>; from protrans@371.net on Sun, Sep 03, 2000 at 11:43:11PM +0800 References: <000a01c015bd$aa5eb6b0$c5f49e3d@w2k> Message-ID: <20000903185031.I24394@aragne.com> Le Sun, Sep 03, 2000 at 11:43:11PM +0800, protrans pianota: > Hello, all! > > As I am thinking of doing my homepages with python cgi, > I wonder whether there are any sites providing free web > space with Python cgi support. Just find a free host and check http://starship.python.net/crew/lemburg/mxCGIPython.html Have fun -- Denis FRERE P3B : Club Free-Pytho-Linuxien Caroloregien http://www.p3b.org Aragne : Internet - Reseaux - Formations http://www.aragne.com From dyoo@hkn.EECS.Berkeley.EDU Mon Sep 4 02:17:57 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Sun, 3 Sep 2000 18:17:57 -0700 (PDT) Subject: [Tutor] Python CGI In-Reply-To: Message-ID: On Sun, 3 Sep 2000, Guilherme wrote: > I was looking at some host web sites that support CGI, and they > all talk about perl. > I was wondering if I can use python on those instead of perl. > Thanks!!! Sure, Python is a good CGI language --- However, you might also want to look at the material for Perl too. A lot of the information is translatable between the two languages. Here is a link to resources you'll want to look at: http://www.python.org/topics/web/basic-cgi.html It has specific details and tutorials on learning CGI programming. I hope this is helpful for you. From c.gruschow@prodigy.net Mon Sep 4 02:33:01 2000 From: c.gruschow@prodigy.net (Charles Gruschow, Jr.) Date: Sun, 3 Sep 2000 20:33:01 -0500 Subject: [Tutor] how do you code Python to produce and/or generate a sound? Message-ID: <005801c01610$10fbd040$2cdf6520@gruschow> how do you code Python to produce and/or generate a sound? c.gruschow@prodigy.net From c.gruschow@prodigy.net Mon Sep 4 02:37:17 2000 From: c.gruschow@prodigy.net (Charles Gruschow, Jr.) Date: Sun, 3 Sep 2000 20:37:17 -0500 Subject: [Tutor] another ?, can Python be learned and used instead of CGI, Perl, and Java/JavaScript or are those still necessary? Message-ID: <007301c01610$a9b3e200$2cdf6520@gruschow> another ?, can Python be learned and used instead of CGI, Perl, and Java/JavaScript or are those still necessary? c.gruschow@prodigy.net From c.gruschow@prodigy.net Mon Sep 4 02:41:25 2000 From: c.gruschow@prodigy.net (Charles Gruschow, Jr.) Date: Sun, 3 Sep 2000 20:41:25 -0500 Subject: [Tutor] 3rd ? for today: can Python do integration (numeric and/or trigonometric) and how is the best way to go about this? Message-ID: <007f01c01611$4066ade0$2cdf6520@gruschow> 3rd ? for today: can Python do integration (numeric and/or trigonometric) and how is the best way to go about this? and if it can: can f(x) and/or f(x,y) functions be plotted? more important part is the integration ? of this posting. thank you c.gruschow@prodigy.net From dyoo@hkn.EECS.Berkeley.EDU Mon Sep 4 03:19:57 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Sun, 3 Sep 2000 19:19:57 -0700 (PDT) Subject: [Tutor] 3rd ? for today: can Python do integration (numeric and/or trigonometric) and how is the best way to go about this? In-Reply-To: <007f01c01611$4066ade0$2cdf6520@gruschow> Message-ID: I'll try to answer your three questions here: 1. "how do you code Python to produce and/or generate a sound?" I haven't done this myself yet, but there's a Python module for Windows called 'winsound'. You'll need to learn enough Python to use modules, but it shouldn't be too bad. Here's a link to the reference material on winsound: http://www.python.org/doc/current/lib/module-winsound.html 2. "can Python be learned and used instead of CGI, Perl, and Java/JavaScript or are those still necessary?" Computer languages are made to do different things --- It is true that some things are more appropriate to do in the other languages. It really depends on what sort of stuff you'll be doing. It wouldn't hurt at all to expand your knowledge by learning the other languages. Of course, I'm answering this way because, otherwise, it would inflame the advocates of those other languages... *grin* For clarification: CGI isn't really a language but a way of tying programs to HTML forms. CGI can be done with any reasonable programming language. 3. "can Python do integration (numeric and/or trigonometric) and how is the best way to go about this?" Sure! You can write a quick Python program to do numerical integration. Doing things symbolically might be more work though, and I don't have the background yet to talk about symbolic integration. There are languages suited to do symbolic stuff --- there's Maple and Mathematica. However, both of those programs cost money. Does anyone know of a free symbolic math package? It's not too hard to write a program to do integration. There are several methods to choose from. Here's one method: Let's say we're working with the function y(x) = x. We'd like to find the area underneath this curve. For now, we'll pretend that we don't know it's a triangle with area A = (x**2)/2. y | . | . | . |. --------x 0 1 An approximate way of doing this is to fit a rectangle underneath the triangle, like this: -----. .| . | . | . | . | -----| We can take the area of this rectangle easily. This is admittedly silly --- a triangle isn't a rectangle! But let's say we use two rectangles instead of just one: ---. | .| |. | --- | .| | . | | -----| It's still silly, but not quite as much. Let's try three thinner rectangles: --- |.| --| | |.| | -| | | | | | -----| In fact, calculus says that as we use more rectangles, this silly way of approximating the integral through rectangles approaches the true area underneath that curve. I think the term for this method is called a "Riemann Sum". This description is meant to be fuzzy --- you'll want to experiment with the idea, and then write it as a program. Try to program it yourself first, and we can help you if you run into problems. From scarblac@pino.selwerd.nl Mon Sep 4 07:46:04 2000 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Mon, 4 Sep 2000 08:46:04 +0200 Subject: [Tutor] another ?, can Python be learned and used instead of CGI, Perl, and Java/JavaScript or are those still necessary? In-Reply-To: <007301c01610$a9b3e200$2cdf6520@gruschow>; from c.gruschow@prodigy.net on Sun, Sep 03, 2000 at 08:37:17PM -0500 References: <007301c01610$a9b3e200$2cdf6520@gruschow> Message-ID: <20000904084604.A22582@pino.selwerd.nl> On Sun, Sep 03, 2000 at 08:37:17PM -0500, Charles Gruschow, Jr. wrote: > another ?, can Python be learned and used instead of CGI, Perl, and > Java/JavaScript or are those still necessary? It depends on what you need to do. "CGI" is not a programming language, it's a protocol. You could do CGI with any programming language. You write "Java/JavaScript", but don't think they are at all alike! Netscape bought the "JavaScript" name from Sun to hop on the bandwagon with their own language, but the two have nothing to do with each other otherwise. Java can be used for many things, and most of those can be done by other languages as well. The exception is mostly applets; there are things like a Python applet plugin, but your users won't have it installed; and there is JPython, which runs on the Java machine so in applets too, but it's even slower than Java itself and should only be used as a tool, not to write a whole Java app in, I think. So Java is good for applets, but then, when was the last time you saw a really useful applet? :-) JavaScript is usually used inside pages to work in the client's browser, and it doesn't have a lot of competition there (but I feel a site shouldn't depend on it, it should work without JS too). For many things JS is used for, Flash may be a good alternative. Flash is pretty cool (but shuts out some browsers again). You can't use Python client-side that way. So, the question if you can stick to Python and do without the other languages still depends on what you need to do :). -- Remco Gerlich, scarblac@pino.selwerd.nl From david@verso.org Mon Sep 4 08:32:23 2000 From: david@verso.org (David Maclagan) Date: Mon, 4 Sep 2000 17:32:23 +1000 Subject: [Tutor] Python in windows Message-ID: <39B3DCA7.20877.C80162@localhost> Can anyone reccomend any primers out there for using python in Windows? Particularly the GUI/windowing bits. The primers I have managed to find seem to assume you're working on a *nix machine, and I'm finding the help in pythonwin not very obvious. Thanks David ------- David Maclagan David@verso.org From dyoo@hkn.EECS.Berkeley.EDU Mon Sep 4 10:57:57 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Mon, 4 Sep 2000 02:57:57 -0700 (PDT) Subject: [Tutor] input() on IDLE? Message-ID: I've been trying to figure out how to use raw_input()/input() in an IDLE session. For me, the *Output* window seems to not respond to input, and someone else has reported getting EOF from it. I'm using IDLE 0.5 under a Linux system. Here's the sample program: ### print "Hello world!" x = input() print "Here's what x has:", x ### And a partial output: ### Hello world! 42 # but nothing happens. ### Does anyone know if these input functions work well in IDLE? Thanks for any help on this. From dyoo@hkn.EECS.Berkeley.EDU Mon Sep 4 11:24:08 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Mon, 4 Sep 2000 03:24:08 -0700 (PDT) Subject: [Tutor] Python in windows In-Reply-To: <39B3DCA7.20877.C80162@localhost> Message-ID: On Mon, 4 Sep 2000, David Maclagan wrote: > Can anyone reccomend any primers out there for using python in > Windows? Particularly the GUI/windowing bits. Here's documentation on using IDLE: http://www.python.org/idle/doc/idlemain.html It appears to be Windows oriented, so it should help you learn your editing environment. Ideally, the tutorials attempt to be os-agnostic and focus more on the language itself. Also, you might want to try looking at the Windows section on Josh Cogliati's "Non-Programmers Tutorial For Python": http://www.honors.montana.edu/~jjc/easytut/easytut/ Finally, I found another site which goes through a sample "Hello World" in PythonWin: http://www.best.com/~cphoenix/python/ Hopefully, those resources should make your transition to these tools easier. Good luck! From wesm@the-bridge.net Mon Sep 4 14:22:43 2000 From: wesm@the-bridge.net (Wes Millis) Date: Mon, 04 Sep 2000 08:22:43 -0500 Subject: [Tutor] input problem Message-ID: <39B3A223.6930@the-bridge.net> Hi, Every time I try to run the 5th example ,Area Calculation Program, it sends me an error on the 12th line of code. The line of code looks like this. shape = input ("> ") I'm doing all of this through "Python Idel/The Python Shell. Thank you for all of your help and effort. CYA Ryan*Halo* From marcos@ifctr.mi.cnr.it Mon Sep 4 14:37:10 2000 From: marcos@ifctr.mi.cnr.it (Marco Scodeggio) Date: Mon, 4 Sep 2000 15:37:10 +0200 (MET DST) Subject: [Tutor] a question on the BLT plotting library Message-ID: <200009041337.PAA27101@hestia.ifctr.mi.cnr.it> Hallo everybody. I'm still completely new to Python, and I'm trying to figure out a = relatively simple method to produce some "decent looking" (scientific) plots. Looking around on the web I have found Python megawidgets, that provide = an=20 interface to the BLT plotting library. I have installed the current verison of BLT (version 2.4u), to go along = with the=20 tcl/tk installation that is standard on my workstation (version 8.2), = and I did=20 put in the lib/python1.5/site-packages/ directory the Pmw installation. I'm working on a Sun worstation using Solaris 2.5.1, and I have = installed both=20 Python and the BLT library in my private directories. Now, I can use the BLT library (which means I can run succesfully the = self-test=20 program provided with it), and the Pmw widgets (again, the self-test = works), but=20 when I try to run any simple demo using the Pmw.Blt class I get error = messages=20 like this one: >>> from Tkinter import *=20 >>> import Pmw >>> root =3D Tk() >>> g =3D Pmw.Blt.Graph(root) Traceback (innermost last): File "", line 1, in ? g =3D Pmw.Blt.Graph(root) File=20 "/hestia/marcos/software/Python-1.5.2/lib/python1.5/site-packages/Pmw/Pmw= _0_8_4/ lib/PmwBlt.py", line 260, in __init__ Tkinter.Widget.__init__(self, master, _graphCommand, cnf, kw) File = "/hestia/marcos/software/Python-1.5.2/lib/python1.5/lib-tk/Tkinter.py",=20 line 1084, in __init__ self.tk.call( TclError: invalid command name "::blt::graph" >>>=20 Also the initialisation suggested by the Pmw folks ( >>> import Pmw >>> root =3D Pmw.initialise() ) produces the same identical error message. Along the same lines, when I run the Pmw demos program, if I try the BLT = related=20 tests, I get the message=20 "Sorry, the BLT package has not been installed on this system. Please = install it=20 and try again" Does anyone have any idea on what is happening ??? I presume Python = cannot find=20 the BLT installation, but how do I let it know about it ?? Your help on this would be much appreciated. Thanks a lot. Marco Scodeggio From alan.gauld@bt.com Mon Sep 4 17:32:04 2000 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 4 Sep 2000 17:32:04 +0100 Subject: [Tutor] another ?, can Python be learned and used instead of CGI, Perl, and Java/JavaScript or are those still necessary? Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D2F1@mbtlipnt02.btlabs.bt.co.uk> > then, when was > the last time you saw a really useful applet? :-) Smiley noted but I do have to jump in and defend applets. There are a lot of real world applications being written for the web now that use full client/server applet/servlet technology. For instance in house I book my timeevery month using a Java applet to replace the previous VB application. I also log faults in our in house reporting tool using an applet to replace an Oracle Forms application. Finally the Genesys Internet Suite is a commercial application that uses applet technmology to allow co-browsing, web chat etc etc into a traditional call-centre environment. I think the applet has become well established as the means to get performant UI's on the web - far beyond the early Mickey Mouse animations etc. Sorry, I guess you hit one of my 'hot buttons' there :-) Alan G. PS This has nothing to do with the original question since you can use JPython for applets....albeit slowly! From alan.gauld@bt.com Mon Sep 4 17:38:02 2000 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Mon, 4 Sep 2000 17:38:02 +0100 Subject: [Tutor] input() on IDLE? Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D2F2@mbtlipnt02.btlabs.bt.co.uk> > I've been trying to figure out how to use raw_input()/input() > in an IDLE session. Works OK in the Windows version of IDLE 0.5 > Here's the sample program: > And a partial output: > > ### > Hello world! > 42 > # but nothing happens. > ### I get: Program: print "Hello world" x = input() print "x = ", x Python 1.5.2 (#0, Apr 13 1999, 10:51:12) [MSC 32 bit (Intel)] on win32 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam IDLE 0.5 -- press F1 for help >>> Hello world 42 x = 42 Have you tried putting a prompt into the input() just to check its really getting there: Alan G. From scarblac@pino.selwerd.nl Tue Sep 5 01:48:03 2000 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Tue, 5 Sep 2000 02:48:03 +0200 Subject: [Tutor] another ?, can Python be learned and used instead of CGI, Perl, and Java/JavaScript or are those still necessary? In-Reply-To: <302F8EC50419D411ABA500508B44DEFB4BDD2D@smit002.naa.gov.au>; from simond@naa.gov.au on Tue, Sep 05, 2000 at 10:23:03AM +1000 References: <302F8EC50419D411ABA500508B44DEFB4BDD2D@smit002.naa.gov.au> Message-ID: <20000905024803.A23261@pino.selwerd.nl> On Tue, Sep 05, 2000 at 10:23:03AM +1000, Simon Davis wrote: > > Remco Gerlich wrote: > [snip] > >Java can be used for many things, and most of those can be done by other > >languages as well. The exception is mostly applets; there are things like > >a Python applet plugin, but your users won't have it installed; > > Is there a Python virtual machine plug-in for web browsers that would allow > me to write Python applets a la Java applets? If so does anybody know where > it is? It doesn't seem to be on a prominent part of python.org (but perhaps > I'm just blind). I knew, somewhere in the back of my mind, that such a beast existed. But it's obscure. (That's why I said "your users won't have it installed", usually I would add a "probably" there). Now I went searching for it, and it seems the last version is from '96, was still 16-bit, and for Netscape 2.0 (http://www.python.org/psa/Projects.html). Other search results seem to indicate that there's still work going on on a modern version (http://classic.zope.org/pipermail/zope/1999-April/003789.html), well that's still one and half years ago... So it would have been more accurate if I had said "there *used to be* a Python plugin", I guess... -- Remco Gerlich, scarblac@pino.selwerd.nl From deng@ms.shlftdc.net.cn Wed Sep 6 11:58:07 2000 From: deng@ms.shlftdc.net.cn (deng wei) Date: Wed, 6 Sep 2000 18:58:7 +0800 Subject: [Tutor] (no subject) Message-ID: <20000905100826718.AAA335.511@192> Hi: My OS is Windows98.And I found the same problem.But I don't know how to deal with. DengWei deng@ms.shlftdc.net.cn From deng@ms.shlftdc.net.cn Wed Sep 6 12:00:46 2000 From: deng@ms.shlftdc.net.cn (deng wei) Date: Wed, 6 Sep 2000 19:0:46 +0800 Subject: [Tutor] (no subject) Message-ID: <20000905101105421.AAA335.406@192> Hi: Sorry for the pre-reply. Again,I found the same problem in the IDLE under Windows98.:) Message: 9 Date: Mon, 4 Sep 2000 02:57:57 -0700 (PDT) From: Daniel Yoo To: tutor@python.org Subject: [Tutor] input() on IDLE? I've been trying to figure out how to use raw_input()/input() in an IDLE session. For me, the *Output* window seems to not respond to input, and someone else has reported getting EOF from it. I'm using IDLE 0.5 under a Linux system. Here's the sample program: ### print "Hello world!" x = input() print "Here's what x has:", x ### And a partial output: ### Hello world! 42 # but nothing happens. ### Does anyone know if these input functions work well in IDLE? Thanks for any help on this. DengWei deng@ms.shlftdc.net.cn From deng@ms.shlftdc.net.cn Wed Sep 6 12:37:01 2000 From: deng@ms.shlftdc.net.cn (deng wei) Date: Wed, 6 Sep 2000 19:37:1 +0800 Subject: [Tutor] help! Message-ID: <20000905104720968.AAA335.481@192> Hi,all: Maybe it's not a question.Sorry for disturbing you. When I finished the tutorial,I lost my way.What I should do next? Can someone give me any suggestion? Thanks a lot. DengWei deng@ms.shlftdc.net.cn From scarblac@pino.selwerd.nl Tue Sep 5 12:56:21 2000 From: scarblac@pino.selwerd.nl (Remco Gerlich) Date: Tue, 5 Sep 2000 13:56:21 +0200 Subject: [Tutor] help! In-Reply-To: <20000905104720968.AAA335.481@192>; from deng@ms.shlftdc.net.cn on Wed, Sep 06, 2000 at 07:37:01PM +0800 References: <20000905104720968.AAA335.481@192> Message-ID: <20000905135621.A24617@pino.selwerd.nl> On Wed, Sep 06, 2000 at 07:37:01PM +0800, deng wei wrote: > Hi,all: > Maybe it's not a question.Sorry for disturbing you. > When I finished the tutorial,I lost my way.What I should do next? > Can someone give me any suggestion? Well, why did you start learning Python? Pick something interesting to make and try to find out how to make it? -- Remco Gerlich, scarblac@pino.selwerd.nl From c.gruschow@prodigy.net Wed Sep 6 04:01:42 2000 From: c.gruschow@prodigy.net (Charles Gruschow, Jr.) Date: Tue, 5 Sep 2000 22:01:42 -0500 Subject: [Tutor] I found a module set called PyOpenGL, but I can't find documentation, can you help please? Message-ID: <000b01c017ae$c9e74860$10df6520@gruschow> I found a module set called PyOpenGL, but I can't find documentation, can you help please? It acts as an interface between Python and OpenGL. c.gruschow@prodigy.net From dyoo@hkn.EECS.Berkeley.EDU Wed Sep 6 09:36:47 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Wed, 6 Sep 2000 01:36:47 -0700 (PDT) Subject: [Tutor] help! In-Reply-To: <20000905104720968.AAA335.481@192> Message-ID: On Wed, 6 Sep 2000, deng wei wrote: > Maybe it's not a question.Sorry for disturbing you. > When I finished the tutorial,I lost my way.What I should do next? > Can someone give me any suggestion? > Thanks a lot. Hmmm... it really does depend on your interests. Many people get into CGI programming, which is pretty practical and fun. Others have done database programming, or user interfaces, or scientific computing. As a starter, you might want to take a look at the topic guides for some suggested additional reading: http://www.python.org/topics/ Also, if you want, we can suggest sample problems for you to try out, to solidify your knowledge of Python. Tell us more about your interests --- perhaps we can point you toward something relevant to your interests that's Python related. *grin* From phillipmross@hotmail.com Wed Sep 6 13:57:49 2000 From: phillipmross@hotmail.com (Phillip Ross) Date: Wed, 06 Sep 2000 05:57:49 PDT Subject: [Tutor] Win 2k "pro" environment -or- Out of coffe and ready for some help Message-ID: I would love to have someone spoon feed me the steps for getting Microsoft's cmd shell to "see" python. I can't seem to get it to run even though... 1) I know where Python lives... c:\python16 2) I know where the control panel for environment settings are. (although I am not sure how to set them so python can be run from the MS cmd line.) :P Thank you -Phillip _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com. From griff@netdoor.com Wed Sep 6 14:34:50 2000 From: griff@netdoor.com (R. A.) Date: Wed, 06 Sep 2000 08:34:50 -0500 Subject: [Tutor] Installing Python 1.6 Message-ID: <39B647FA.AA5F1302@netdoor.com> Does anyone know if it would be a good idea to uninstall 1.5 before installing 1.6? From alan.gauld@bt.com Wed Sep 6 17:25:15 2000 From: alan.gauld@bt.com (alan.gauld@bt.com) Date: Wed, 6 Sep 2000 17:25:15 +0100 Subject: [Tutor] Win 2k "pro" environment -or- Out of coffe and ready for some help Message-ID: <5104D4DBC598D211B5FE0000F8FE7EB20751D309@mbtlipnt02.btlabs.bt.co.uk> > I would love to have someone spoon feed me the steps for > getting Microsoft's > cmd shell to "see" python. I can't seem to get it to run > even though... > 1) I know where Python lives... c:\python16 > 2) I know where the control panel for environment settings I don't know W2K but assume that PATH still works? in which case it should be: PATH ;C:\python16 ie tag on ;C:\python16 to whatever value of path is there already. Alan G. Should therefore suffice.... Alan G. From dyoo@hkn.EECS.Berkeley.EDU Wed Sep 6 18:52:09 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Wed, 6 Sep 2000 10:52:09 -0700 (PDT) Subject: [Tutor] Win 2k "pro" environment -or- Out of coffe and ready for some help In-Reply-To: Message-ID: On Wed, 6 Sep 2000, Phillip Ross wrote: > I would love to have someone spoon feed me the steps for getting Microsoft's > cmd shell to "see" python. I can't seem to get it to run even though... > 1) I know where Python lives... c:\python16 > 2) I know where the control panel for environment settings are. (although I > am not sure how to set them so python can be run from the MS cmd line.) :P Ok, you'll want to get to the environment settings window. You'll see two large textfields, one for system environment variable, and the other for user environment variables. The environment variable you'll touch is PATH --- Windows searches the directories in PATH whenever you enter a command through the cmd window. It's probably best to edit the PATH variable for the system environment. (I think that you'll need to be an Administrator account to do this.) Append to the end of the PATH variable: [bunch of other path statements];C:\Python16 Afterwards, apply your settings, save, and see if a newly-opened command prompt allows you to call Python from any directory. If that works, you should be all set up. From CaliGirl62540486@aol.com Wed Sep 6 21:08:38 2000 From: CaliGirl62540486@aol.com (CaliGirl62540486@aol.com) Date: Wed, 6 Sep 2000 16:08:38 EDT Subject: [Tutor] tutor Message-ID: <6d.8f7356e.26e7fe46@aol.com> I need help in learning to program with python From peep427@ptdprolog.net Wed Sep 6 22:00:50 2000 From: peep427@ptdprolog.net (carol engle) Date: Wed, 6 Sep 2000 17:00:50 -0400 Subject: [Tutor] open files Message-ID: <000901c01845$8cdd5760$9f0ffea9@d8nf001> This is a multi-part message in MIME format. ------=_NextPart_000_0005_01C01824.025B48C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable how do i open files. I read a book about Python and i wright programs = but i cannot open them what is wrong somebody please tell me. ------=_NextPart_000_0005_01C01824.025B48C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
how do i open files. I read a book = about Python and=20 i wright programs but
i cannot open them what is wrong = somebody please=20 tell me.
------=_NextPart_000_0005_01C01824.025B48C0-- From shaleh@valinux.com Wed Sep 6 22:25:19 2000 From: shaleh@valinux.com (Sean 'Shaleh' Perry) Date: Wed, 06 Sep 2000 14:25:19 -0700 (PDT) Subject: [Tutor] open files In-Reply-To: <000901c01845$8cdd5760$9f0ffea9@d8nf001> Message-ID: On 06-Sep-2000 carol engle wrote: > how do i open files. I read a book about Python and i wright programs but > i cannot open them what is wrong somebody please tell me. fp = open('/path/to/file', 'r') for line in fp.readlines(): print line, # comma is to suppress the new line character close(fp) A robust version would catch the exception open raises when it errors out. From deng@ms.shlftdc.net.cn Fri Sep 8 02:00:17 2000 From: deng@ms.shlftdc.net.cn (deng wei) Date: Fri, 8 Sep 2000 9:0:17 +0800 Subject: [Tutor] Help! Message-ID: <20000907001038859.AAA272.363@192> Hi: Thank you for your kindness. Hmm....Now I have found a interest problem. I want to write something like Matlab. When I write Python script and run it,it should be act like Matlab do. For example: In Matlab: t=0:0.01:1; plot(t,sin(t)); it would plot a sine curve. My goal would be write a function like plot in Matlab. Now I found I had to make a choice between Tcl and VC++.I am confused. What should I do? I am unfamiliar with programming under windows although I can write C code under DOS. DengWei deng@ms.shlftdc.net.cn From dyoo@hkn.EECS.Berkeley.EDU Thu Sep 7 03:12:15 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Wed, 6 Sep 2000 19:12:15 -0700 (PDT) Subject: [Tutor] tutor In-Reply-To: <6d.8f7356e.26e7fe46@aol.com> Message-ID: On Wed, 6 Sep 2000 CaliGirl62540486@aol.com wrote: > I need help in learning to program with python Hmmm... What questions do you have? If you want, you can take a look at the introductions and tutorials on python.org. They should help get you up to speed: http://www.python.org/doc/Intros.html Hope this helps! From rcb@babione.com Thu Sep 7 03:55:15 2000 From: rcb@babione.com (Robert C. Babione) Date: Wed, 06 Sep 2000 21:55:15 -0500 Subject: [Tutor] Installing Python 1.5.2, where is C compiler Message-ID: <4.3.2.20000906213741.00c4ec90@mail.anet-stl.com> I am trying to upgrade to Python 1.5.2. I've done almost nothing with 1.5.1-10 that came with the installation. I am just starting and want to have Idle. I've downloaded 1.5.2, unzipped it, and extracted the files. When I do ./configure, I get a message that there is no gcc or cc in $PATH. If I add --without -gcc, I get "C compiler cannot create executables." I have Red Hat 6.0, Linux 2.2.5-15. I am working at the command line and am very new to Linux - I'm not even sure what the question is. Do I need to install a C compiler? Just find where the C compiler already installed is and fix the path? (I know about path in DOS, but do not know what the parallel command is in Linux.) Thanks for any information or pointers (I found nothing in the FAQ, the tutor, or by searching the Python site). Bob From dyoo@hkn.EECS.Berkeley.EDU Thu Sep 7 06:20:13 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Wed, 6 Sep 2000 22:20:13 -0700 (PDT) Subject: [Tutor] Installing Python 1.5.2, where is C compiler In-Reply-To: <4.3.2.20000906213741.00c4ec90@mail.anet-stl.com> Message-ID: > When I do ./configure, I get a message that there is no gcc or cc in $PATH. > > If I add --without -gcc, I get "C compiler cannot create executables." > > I have Red Hat 6.0, Linux 2.2.5-15. > > I am working at the command line and am very new to Linux - I'm not even > sure what the question is. > > Do I need to install a C compiler? Just find where the C compiler already > installed is and fix the path? (I know about path in DOS, but do not know > what the parallel command is in Linux.) Hmmm... Can you check to see if you have gcc? Try: which gcc and see if that turns up anything. Here's what shows up for me: ### [dyoo@c82114-a dyoo]$ which gcc /usr/bin/gcc ### You do need the gcc compiler to do a source install. However, why not upgrade your Python installation using RPM's? It's easier to do: rpm -Uvh python-1.5.2-13.i386.rpm RPM is a package management system --- it allows you to install/uninstall software very easily. You can find the Python RPM here: http://www.rpmfind.org/RPM/redhat/6.2/i386/python-1.5.2-13.i386.html The RPM is meant for Redhat 6.2, but it should install on your system with few problems. From phillipmross@hotmail.com Thu Sep 7 06:25:41 2000 From: phillipmross@hotmail.com (Phillip Ross) Date: Wed, 06 Sep 2000 22:25:41 PDT Subject: [Tutor] Win 2k "pro" environment -or- Out of coffe and ready for some help Message-ID: Thank you. The step by step really helped... and yes you need to be logged on as admin for this to work... oops ;-p -Phillip ----Original Message Follows---- From: Daniel Yoo To: Phillip Ross CC: tutor@python.org Subject: Re: [Tutor] Win 2k "pro" environment -or- Out of coffe and ready for some help Date: Wed, 6 Sep 2000 10:52:09 -0700 (PDT) On Wed, 6 Sep 2000, Phillip Ross wrote: > I would love to have someone spoon feed me the steps for getting Microsoft's > cmd shell to "see" python. I can't seem to get it to run even though... > 1) I know where Python lives... c:\python16 > 2) I know where the control panel for environment settings are. (although I > am not sure how to set them so python can be run from the MS cmd line.) :P Ok, you'll want to get to the environment settings window. You'll see two large textfields, one for system environment variable, and the other for user environment variables. The environment variable you'll touch is PATH --- Windows searches the directories in PATH whenever you enter a command through the cmd window. It's probably best to edit the PATH variable for the system environment. (I think that you'll need to be an Administrator account to do this.) Append to the end of the PATH variable: [bunch of other path statements];C:\Python16 Afterwards, apply your settings, save, and see if a newly-opened command prompt allows you to call Python from any directory. If that works, you should be all set up. _________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. Share information about yourself, create your own public profile at http://profiles.msn.com. From deirdre@deirdre.net Thu Sep 7 10:02:39 2000 From: deirdre@deirdre.net (Deirdre Saoirse) Date: Thu, 7 Sep 2000 02:02:39 -0700 (PDT) Subject: [Tutor] tutor In-Reply-To: <6d.8f7356e.26e7fe46@aol.com> Message-ID: On Wed, 6 Sep 2000 CaliGirl62540486@aol.com wrote: > I need help in learning to program with python Please ask a specific question. -- _Deirdre * http://www.sfknit.org * http://www.deirdre.net "More damage has been caused by innocent program crashes than by malicious viruses, but they don't make great stories." -- Jean-Louis Gassee, Be Newsletter, Issue 69 From tim_one@email.msn.com Thu Sep 7 10:27:06 2000 From: tim_one@email.msn.com (Tim Peters) Date: Thu, 7 Sep 2000 05:27:06 -0400 Subject: [Tutor] Installing Python 1.6 In-Reply-To: <39B647FA.AA5F1302@netdoor.com> Message-ID: [R. A.] > Does anyone know if it would be a good idea to uninstall 1.5 before > installing 1.6? Unless you're an expert, it never hurts! If something goes wrong, and you didn't uninstall 1.5 first, you'll have a darned hard time trying to figure out whether that's because you didn't uninstall 1.5 first <0.9 wink>. If you're just starting out, don't complicate your life. From Melissa Holden Thu Sep 7 20:33:19 2000 From: Melissa Holden (Melissa Holden) Date: 07 Sep 2000 14:33:19 -0500 Subject: [Tutor] string matching and replacement Message-ID: <3051181938melissa@thinice.com> I am trying to learn Python, and have used it for a few cgi scripts, but = am still very much a beginner. Any help with this problem would be = appreciated: I am trying to search a file for 2 markers, and replace the text in = between them. My first thought was to use regular expressions, but I = haven't been able to get it to work. So far, I have come up with = something like this: p =3D re.compile(r'') m =3D p.search( file ) if m: print 'Match found: ', m.group() else: print 'No match' As it is, this works, but when I try to add something in the middle and = the end text marker (e.g., p=3Dre.compile(r'.*')), it breaks. If I could get this part to work, I was = planning to use sub to replace the section with something else. Basically,= I want to find the beginning and ending tags, and replace what's in = between them (which will vary in length). Any help will be greatly appreciated. Thanks! Melissa From shaleh@valinux.com Thu Sep 7 20:51:00 2000 From: shaleh@valinux.com (Sean 'Shaleh' Perry) Date: Thu, 07 Sep 2000 12:51:00 -0700 (PDT) Subject: [Tutor] string matching and replacement In-Reply-To: <3051181938melissa@thinice.com> Message-ID: $ python >>> import re >>> p = re.compile('(.*)') >>> string = 'This is a comment' >>> m = p.search(string) >>> if m: ... print 'Match', m.group() ... else: ... print 'No Match' ... Match This is a comment >>> m.groups() # returns a tuple of the matched groups ('This is a comment',) There ya go (-: From Melissa Holden Thu Sep 7 21:07:02 2000 From: Melissa Holden (Melissa Holden) Date: 07 Sep 2000 15:07:02 -0500 Subject: [Tutor] string matching and replacement Message-ID: <3051183989melissa@thinice.com> Thank you for your help. This may be a dumb question, but is it possible = to search a file? For example, instead of string =3D 'This is a comment' m =3D p.search(string) I was trying to get it to search an external file that I had referenced = earlier in the program by=20 file =3D open('../index5.html').read() Thanks for your assistance! On 9/7/00, Sean 'Shaleh' Perry wrote: >$ python >>>> import re >>>> p =3D re.compile('(.*)') >>>> string =3D 'This is a comment' >>>> m =3D p.search(string) >>>> if m: >... print 'Match', m.group() >... else: >... print 'No Match' >...=20 >Match This is a comment >>>> m.groups() # returns a tuple of the matched groups >('This is a comment',) > >There ya go (-: > From shaleh@valinux.com Thu Sep 7 21:17:34 2000 From: shaleh@valinux.com (Sean 'Shaleh' Perry) Date: Thu, 07 Sep 2000 13:17:34 -0700 (PDT) Subject: [Tutor] string matching and replacement In-Reply-To: <3051183989melissa@thinice.com> Message-ID: On 07-Sep-2000 Melissa Holden wrote: > Thank you for your help. This may be a dumb question, but is it possible to > search a file? For example, instead of string = 'This > is a comment' > m = p.search(string) > I was trying to get it to search an external file that I had referenced > earlier in the program by > file = open('../index5.html').read() > I am sure with some playing you could do this. The regex search has to have a string to look thru though. From form1l1b@Rotorua-Intermediate.org.nz Fri Sep 8 02:45:32 2000 From: form1l1b@Rotorua-Intermediate.org.nz (form1l1b) Date: Fri, 8 Sep 2000 13:45:32 +1200 Subject: [Tutor] python Message-ID: please please! can you send me a email with a lesson in python in it. please email me at midolawton@hotmail.com From dyoo@hkn.EECS.Berkeley.EDU Fri Sep 8 05:44:55 2000 From: dyoo@hkn.EECS.Berkeley.EDU (Daniel Yoo) Date: Thu, 7 Sep 2000 21:44:55 -0700 (PDT) Subject: [Tutor] string matching and replacement In-Reply-To: <3051183989melissa@thinice.com> Message-ID: On 7 Sep 2000, Melissa Holden wrote: > Thank you for your help. This may be a dumb question, but is it > possible to search a file? For example, instead of string = 'Tools subdirectory. I have also looked on the python.org web site but can't find it. Can anyone tell me where I can find this and if it works well? Paul Yachnes From griff@netdoor.com Sat Sep 30 18:04:55 2000 From: griff@netdoor.com (R. A.) Date: Sat, 30 Sep 2000 12:04:55 -0500 Subject: [Tutor] Freeze References: <001701c02aef$0207f480$51d0f4d1@safwan> Message-ID: <39D61D37.CCB62A55@netdoor.com> I haven't used it yet, m'self, but the Python FAQ reads thusly: Even though there are Python compilers being developed, you probably don't need a real compiler, if all you want is a stand-alone program. There are three solutions to that. One is to use the freeze tool, which is included in the Python source tree as Tools/freeze. It converts Python byte code to C arrays. Using a C compiler, you can embed all your modules into a new program, which is then linked with the standard Python modules. On Windows, another alternative exists which does not require a C compiler. Christian Tismer's SQFREEZE (http://starship.python.net/crew/pirx/) appends the byte code to a specially-prepared Python interpreter, which will find the byte code in executable. Gordon McMillian offers with Installer (http://starship.python.net/crew/gmcm/distribute.html) a third alternative, which works similar to SQFREEZE, but allows to include arbitraty additional files in the stand-alone binary as well. Rob Andrews Paul Yachnes wrote: > > I have a fairly simple script that I want to turn into a standalone > application. I read that I can do this with a tool calle "Freeze" but I > cannot find it in my Python -->Tools subdirectory. I have also looked on the > python.org web site but can't find it. Can anyone tell me where I can find > this and if it works well? > > Paul Yachnes > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor -- GIT/P/TW d---(++) s++:s a? C+++++ U$>+++ P+ L+>++++ E@ W++ N++ o? K- w$ ?O ?M ?V PS+++ PE Y+@ PGP- t+@ 5 X@ R+ tv+ b+++ DI+@ D+ Q3A++ e++* h* r y++* UF+++ From duckpond@early.com Sat Sep 30 19:48:32 2000 From: duckpond@early.com (Tom Connor) Date: Sat, 30 Sep 2000 14:48:32 -0400 Subject: [Tutor] Re: Tutor digest, Vol 1 #440 - 1 msg References: <20000930160107.21B3C1CDEF@dinsdale.python.org> Message-ID: <39D63580.A8C04D92@early.com> This is a multi-part message in MIME format. --------------94C77CB9089356769B55753B Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit > Learning Python, P. 138, has a box which discusses this briefly. I just > read it 2 days ago. It suggests a search on the Python web site for > details. (Disucussion includes "squeeze", and compiled code. Tom Connor > I have a fairly simple script that I want to turn into a standalone > application. I read that I can do this with a tool calle "Freeze" but I > cannot find it in my Python -->Tools subdirectory. I have also looked on the > python.org web site but can't find it. Can anyone tell me where I can find > this and if it works well? > > Paul Yachnes > > --__--__-- > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://www.python.org/mailman/listinfo/tutor > > End of Tutor Digest --------------94C77CB9089356769B55753B Content-Type: text/x-vcard; charset=us-ascii; name="duckpond.vcf" Content-Transfer-Encoding: 7bit Content-Description: Card for Tom Connor Content-Disposition: attachment; filename="duckpond.vcf" begin:vcard n:Connor;Tom x-mozilla-html:FALSE adr:;;;;;; version:2.1 email;internet:duckpond@early.com note:Remove (no spam) from email address to respond. x-mozilla-cpt:;-10272 fn:Tom Connor end:vcard --------------94C77CB9089356769B55753B-- From DOUGS@oceanic.com Sat Sep 30 20:22:06 2000 From: DOUGS@oceanic.com (Doug Stanfield) Date: Sat, 30 Sep 2000 09:22:06 -1000 Subject: [Tutor] Freeze Message-ID: <8457258D741DD411BD3D0050DA62365907A36A@huina.oceanic.com> [ Paul Yachnes wrote: ] > > > > I have a fairly simple script that I want to turn into a standalone > > application. [To which Rob Andrews with a list of options] > There are three solutions to that. > > the freeze tool, which is included in the Python source tree as Tools/freeze. > On Windows, another alternative ...Christian Tismer's SQFREEZE > (http://starship.python.net/crew/pirx/) > Gordon McMillian offers with Installer > (http://starship.python.net/crew/gmcm/distribute.html) These days I think the consensus is that the best choice is Gordan McMillan's installer. This message was posted recently on c.l.py: ------------included message------------- jpl@remotejava.NOSPAM.com (Jan Ploski) writes: > This is certainly a very newbie-ish question, but is it possible to write > code in Python and then compile it into a win32 executable? It's not really compiling, but you can use Gordan McMillan's installer package (at http://www.mcmillan-inc.com/install1.html). This automatically tracks down the various dependencies of your script and puts it all together (along with some very nice archive formats for the various library routines) into an executable that can be run directly. You generally end up with the exe, a pyz for python library files a few standlone files (like exceptions.pyc) and any external modules (dll/pyd). That collection of files is all you need to run your application. The installer package has a simple installation script (console based - prompts for a directory and unpacks), but you can combine the installer with a Windows installation package. That can be InstallShield, Wise, or for my purposes, I use the free Inno Setup (http://www.jrsoftware.org), and you end up with your Python application looking just like a native installed Windows application, and being totally self-contained within its installation directory. Users install/uninstall it just like any other Windows application. > Specifically, I would like to know whether it makes sense to try to write > a custom installer in Python for a Java application (some file copying, > extraction, and manipulation of the Windows registry is needed). I would not > like to buy nor learn Visual C++ for that purpose. Buying a shrink-wrapped > installer like InstallAnywhere is an alternative, but I am curious if Python > could come to rescue. If that's completely unrealistic (i.e. a 5 MB Python > interpreter needed to get started), let me know. I have no idea. I'd probably go with an established solution (which doesn't have to mean commercial) if it were me. Not because Python couldn't do it - I'm sure you could - but because there can be a lot of messiness with Windows installations (locked files, DLL registration, etc...). Also, while it wouldn't be 5MB, any Python installation tool would certainly take at least the 500-600K of the Python DLL and whatever extensions (such as the win32 registry module) you used. That contrasts with about 275K for Inno Setup, for example. Not much of an issue with network based installs, but could hurt on a diskette setup. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l@fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ -- http://www.python.org/mailman/listinfo/python-list From FxItAL@aol.com Sat Sep 30 21:12:02 2000 From: FxItAL@aol.com (FxItAL@aol.com) Date: Sat, 30 Sep 2000 16:12:02 EDT Subject: [Tutor] winsound Message-ID: <7f.a531b0e.2707a312@aol.com> Hello, I'm having difficulty getting the SND_LOOP flag to work. The sound will play if I use SND_ASYNC, but only once. I'd like to loop the sound and then be able to stop it with SND_PURGE. Any help is greatly appreciated. Python 1.6 on Windows ME Thanks Al