From olivierS.dagenaisP at canadaA.comM Sat Aug 12 13:07:03 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sat, 12 Aug 2000 17:07:03 GMT Subject: an indexed list - how to do it in python References: <8n3tm2$jug$1@nnrp1.deja.com> Message-ID: It looks to me like you're trying to reproduce the behaviour of VB's collection class. When I reproduced it, I was using a linked list (for O(1) insertion, but O(n) integer index retrieval) as well as a hash table, where the data of a pair was a reference to a linked list node. You could use an array for O(n) insertion but O(1) integer index retrieval, but there isn't (as far as I know) a data structure that permits O(1) _ordered_ insertion and retrieval. The closest you get is O(log(n)), and that's using a balanced tree, like AVL... -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III wrote in message news:8n3tm2$jug$1 at nnrp1.deja.com... > I want to create, in Python, an object that mixes the behavior of a > sequence and a mapping. The primary behavior should be that of a > mutable sequence, or list, but the objects in the list should also be > accessible by a key value. > > In my mind, this object would be defined something like this: > > Class IndexedSequence: > def __init__(self): > self.data = [] > self.keys = [] > self.index = {} > > > At some point in time, this data structure might look like this: > self.data = ["nurk", "bazar"] > self.keys = ["fred", "jill"] > seld.index = {"fred":0, "jill":1} > > Operations that append to this data structure operate just fine. > The problem is that there is no way to eliminate the renumbering > required by insertion or deletion. > > I could rebuild the index on the next index access operation after > insertion or deletion, but this seems overly stupid to me. > > Given an object and a list to which it belongs, how can I find its > position in a list in O(1) operations. > > > > Sent via Deja.com http://www.deja.com/ > Before you buy. From rbill at digisprings.com Wed Aug 16 16:56:42 2000 From: rbill at digisprings.com (Robert W. Bill) Date: Wed, 16 Aug 2000 14:56:42 -0600 Subject: how can i pass through authrization box when i use urllib module? In-Reply-To: References: Message-ID: On Thu, 17 Aug 2000, Cho Yoonbae wildly tapped out: > hi, > > i'm making a client program which is update my dynamic ip to dns automatically. > > i want to open such a web page. > but it shows authrization box to me when i enter. > > i am trying to solve this problem with urllib module. > but, i couldn't find passing tools about authrization. > > is there module or argument about that problem? You just need to add an 'Authorization' header to send with the request. Below is a simple example with httplib that may point you in the right direction: import httplib import base64 #make encoded Authorization string username="choyoonbae" passwd="LetMeIn" authinfo = base64.encodestring(username + ":" + passwd) h = httplib.HTTP('www.somesecretplace.com') h.putrequest('GET', '/top/secret/document') #put any needed headers here h.putheader('Authorization', "Basic " + authinfo) h.endheaders() responsecode, responsemsg, headers = h.getreply() #do what you want with responsecode, responsemsg, headers here f = h.getfile() data = f.read() f.close() print data ---------- Hope this helps. -robert From cut_me_out at hotmail.com Tue Aug 8 14:41:32 2000 From: cut_me_out at hotmail.com (Alex) Date: 08 Aug 2000 14:41:32 -0400 Subject: installing idle on Suse Linux 6.4 References: Message-ID: > ImportError: No module named _tkinter > bkraabel at linux:/opt/Python-1.5.2/Tools/idle > > > can anyone help me? If you installed python using an rpm, perhaps the easiest thing to do would be to get the rpm off rpmfind.net. If you compiled python yourself, have a look at the _tkinter section of the Modules/Setup file, edit it approopriately, and recompile. Alex. From aahz at netcom.com Fri Aug 25 16:13:26 2000 From: aahz at netcom.com (Aahz Maruch) Date: 25 Aug 2000 20:13:26 GMT Subject: gratuitous new features in 2.0 References: <7ba5.39a2ccf0.27c0b@yetix.sz-sb.de> <39A6B6B8.23D69134@endea.demon.nl> Message-ID: <8o6k16$lip$1@slb0.atl.mindspring.net> In article <39A6B6B8.23D69134 at endea.demon.nl>, Niels Diepeveen wrote: > >I would much prefer making redirecting output from the print statement >easier by separating it from sys.stdout. Why not provide a function >sys.printto() [or possibly __builtin__.printto()] that will redirect >output from the print statement, but does not change sys.stdout? No, this is a direction we *definitely* don't want to go in. One of the most important uses of the extended print is that it is easy to interleave writes to multiple output sources. For example, one might want *all* output going to stdout but only certain output to stderr. This is one point on which I'm emphatically in agreement with Guido. (Actually, I'm emphatically in agreement with Guido on most points; it just doesn't look like it right now because I'm a cantankerous arguer.) -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The difference between "intelligence" and "wisdom": Londo and G'Kar --Aahz From denalione at my-deja.com Wed Aug 16 11:12:35 2000 From: denalione at my-deja.com (Dale Burnett) Date: Wed, 16 Aug 2000 15:12:35 GMT Subject: CreateProcess handle immediatly signaled References: <8nblic$61d$1@nnrp1.deja.com> Message-ID: <8neb0e$tn5$1@nnrp1.deja.com> In article <8nblic$61d$1 at nnrp1.deja.com>, Dale Burnett wrote: > When using python.exe as the process to spawn in the CreateProcess > method, the handle that is returned cannot be waited on with > WaitForSingleObject. WaitForSingleObject immediatly returns 0 stating > that the process has ended when I know for sure it is not. I have > replaced python.exe with notepad.exe as a test and everything works as > expected. > > I also tried pythonw.exe and it did work either. > > Im already guessing Ill need to find another method to signal the parent > process that the child is finished but hopefully someone will have > encountered this before. > > Thanks > Dale > > Sent via Deja.com http://www.deja.com/ > Before you buy. > After further invetigation I have discovered that I just dont know what Im doing. The child process spawns secondary threads then the main thread exits. It appears that when the main thread exits the secondary threads exit automatically, while I thought the secondary threads would continue to keep the process running and the process would stay non signaled. If anyone knows if that is right or wrong please let me know. Thanks Dale Sent via Deja.com http://www.deja.com/ Before you buy. From g2 at seebelow.org Sun Aug 6 12:48:30 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sun, 06 Aug 2000 17:48:30 +0100 Subject: Questions for Guido van Rossum (Was: ...Tim Peters) References: <398CDB2E.3A81806A@san.rr.com> Message-ID: <398D96DE.4B03@seebelow.org> Courageous wrote: > > > > > CNRI's agreement as the copyright holder is the only thing that > > > gives anyone else the right to distribute, use, or modify the code. > > > > Which is why BeOpen... > > All Rights Reserved > > Permission to use, copy, modify, and distribute this software and its > documentation for any purpose and without fee is hereby granted, > provided that the above copyright notice appear in all copies and that > both that copyright notice and this permission notice appear in > supporting documentation, and that the names of Stichting Mathematisch > Centrum or CWI or Corporation for National Research Initiatives or > CNRI not be used in advertising or publicity pertaining to > distribution of the software without specific, written prior > permission. > > ------------- > > Can this license be revoked or superseded? While I am not an > attorney, somehow I am doubting it. Anyone who holds an instance > of this license is a valid license holder of it. I.M.O. IANAL (APOI*), but notice that the license term is not specified. One is tempted to infer "perpetual" from the text above (that is, "_Perpetual_ permision..."), but that is not stated explicitly (as it is in many licenses--for example, dspGuru's own.) But take heart: many a thorny problem has been solved by using the "Lone Ranger" technique, wherein one asks oneself "What would the Lone Ranger do in a case like this?" Therefore, if I speculate on what my _lawyer_ might say about this, my guess is that he probably would say it can be read either way. (which-kindda-makes-you-wonder-why-he-makes-the-big-bucks-) -ly y'rs, =g2 *and proud of it. ;-) -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From ekw1 at my-deja.com Sat Aug 5 17:58:52 2000 From: ekw1 at my-deja.com (ekw1 at my-deja.com) Date: Sat, 05 Aug 2000 21:58:52 GMT Subject: dbiRaw object Message-ID: <8mi2mr$4ul$1@nnrp1.deja.com> How can I manipulate a dbiRaw object? example: db = odbc.odbc("dsn") cursor = db.cursor() cursor.execute("select * from table") results = cursor.fetchall() obj = results[0][1] The variable obj points to a dbiRaw object, but I can't perform any operations on it, like obj[2:3]. And other operations says that obj is a read-only buffer. Is there a way to make a copy of obj and manipulate that? thanks, ekw Sent via Deja.com http://www.deja.com/ Before you buy. From cjensen at bioeng.ucsd.edu Tue Aug 1 17:42:48 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Tue, 01 Aug 2000 14:42:48 -0700 Subject: writting classes to file Message-ID: <39874458.5A7C71C7@bioeng.ucsd.edu> I have several data classes that just contain data; no functions. I also have some dictionaries. I want to write them to one file in a database form. Shelve doesn't seem to let me do operations on classes. Pickle doesn't let me save several classes to one file. I can't seem to shelve pickled objects. So, what is the best way to go about this. Thanks. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From g2 at seebelow.org Fri Aug 18 17:59:44 2000 From: g2 at seebelow.org (Grant Griffin) Date: Fri, 18 Aug 2000 22:59:44 +0100 Subject: Still no new license -- but draft text available References: <3991C762.1E8C@seebelow.org> <399321BC.735D3F7@basho.fc.hp.com> <8mvdgp$7ai$5@newshost.accu.uu.nl> <39997465.A9BC44BD@basho.fc.hp.com> <8nc0m0$5e8@drn.newsguy.com> <399AD784.F1DC6429@basho.fc.hp.com> <399B0989.C42346C8@seebelow.org> <399D1FF3.AD1E5CF0@seebelow.org> Message-ID: <399DB1D0.86164F76@seebelow.org> Pat McCann wrote: > Grant Griffin writes: > > > If that's a hint, I guess I'll have to just say that I've already got too many irons in > > the fire. So I mainly just try to "educate" the public a little when the opportunity > > presents itself. However, one small effort I've made in this way is the "Wide Open > > License" (WOL), which you'll find at http://www.dspguru.com/wol.htm. > > Looks good. I don't have time to read the whole page just now, but I > will. I'm suprised you didn't mention it before. Well, as a Great Rabbit once said, "Ain't I a stinker?" ;-) Actually, I've hawked it here before (sorry, Bugs!), but just not recently. > Excellent name! I wish I'd thought of that first. > Thanks! ("Marketing, Benjamin--marketing".) > Just curious: The license requires the license to appear in the source > of derivatives. Please explain why that doesn't make it apply to the > derivative. (Say I just changed some code.) If the WOL and my > closed-source licenses both appear in the source, which takes > precedence? How does anyone know which license applies to what code? I > have some (unsatisfying) answers, but am curious to hear yours. (I > don't recall you answering a similar question about Python a couple > weeks ago. Sorry if you did.) Darn you lawyers... ;-) In all honesty, I hadn't thought of that aspect of it. (This license text has been kicking around for years; I didn't write it and I don't know who did.) I guess as a practical matter, if one makes improvements to WOL software that one wants to be "Wide Open" there's no problem: just use the license as-is. But if you want to _restrict_ those improvements in some way, probably the best thing to do would be just to keep them closed. (That doesn't cover the case of some rogue employee madly opening your closed software, but then again, nothing's perfect.) Alternatively, I suppose a sentence could be added to the effect that "users are free to create licenses whose terms superceed these". However, then we get in to the problem somebody pointed out here awhile back that plugging one hole in the legal dyke tends to open up at least two more. (if-lawyers-were-paid-like-HMOs-we-wouldn't-have-this-problem-)-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From alwagner at tcac.net Thu Aug 24 00:49:28 2000 From: alwagner at tcac.net (Albert Wagner) Date: Wed, 23 Aug 2000 22:49:28 -0600 Subject: Idle command line args? Message-ID: <39A4A958.70B0C66B@tcac.net> The Idle 0.5 doc says that Idle has command line args and to check the help file for info. Yet, the help file makes no ref to command line args. Can someone point me to the idle CLA docs? Specifically, I want to have idle come up with the editor open on a specific file. Can this be done? -- We didn't inherit the land from our fathers. We are borrowing it from our children. From tgagne at ix.netcom.com Mon Aug 7 22:22:33 2000 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Mon, 07 Aug 2000 22:22:33 -0400 Subject: How many bytes long is a string? Message-ID: <398F6EE9.F96AED75@ix.netcom.com> Hmm. I need to know how many bytes a String is going to be. Given s = "Now is the time" I would expect one of the following to work (it would seem intuitive...) print s.length print s.length() print s.size print s.size() print length(s) print size(s) I would prefer to stick with objectname.methodname() but the obvious ones aren't working. From dbroadwell at mindspring.com Mon Aug 21 01:00:16 2000 From: dbroadwell at mindspring.com (David Broadwell) Date: Mon, 21 Aug 2000 01:00:16 -0400 Subject: binary representaion of a number References: <39A0986C.632EBBE3@mindspring.com> Message-ID: <39A0B760.3A0379AE@mindspring.com> Neil Schemenauer wrote: > > import string > > hexmap = { > "0": "0000", > "1": "0001", > "2": "0010", > "3": "0011", > "4": "0100", > "5": "0101", > "6": "0110", > "7": "0111", > "8": "1000", > "9": "1001", > "a": "1010", > "b": "1011", > "c": "1100", > "d": "1101", > "e": "1110", > "f": "1111", > } > > def bin(n): > bits = [] > for digit in ("%0.8x" % n): > bits.append(hexmap[digit]) > return string.join(bits, '') Straitforward, I believe almost precisely what I was looking for. Thank you. Now, with the 'for digit in ("%0.8x" % n):' statement I am haveing some difficulty understanding the '("%0.8x" % n)' notaion ... From shang.spam.block at st.jyu.fi Fri Aug 25 11:52:56 2000 From: shang.spam.block at st.jyu.fi (Sami Hangaslammi) Date: Fri, 25 Aug 2000 18:52:56 +0300 Subject: converting an html table to a tree References: <8o2lok0160q@news2.newsguy.com> <8o3hjf0na9@news1.newsguy.com> <3ufp5.440$bw2.8538@newsread2.prod.itd.earthlink.net> <8o5eo0$aep7$1@learnet.freenet.hut.fi> <8o5pfs0ujc@news2.newsguy.com> Message-ID: <8o64o1$t7q$1@mordred.cc.jyu.fi> Alex Martelli wrote in message news:8o5pfs0ujc at news2.newsguy.com... > There's no end to the amount of such trouble you can get into, > trying to parse HTML (or XML) documents by regular expressions. > I _strongly_ urge anybody having to parse HTML (or XML) to > rely on suitable parsers rather than trying to roll their own. > > Python's htmllib and sgmllib may not be perfect, but they're > much better than nothing, and I'm positive they will reduce > your stress-level (and number of obscure never-tested bugs > waiting to happen) compared with the roll-your-own approach. Yes, I fully agree with you. The ready-made libraries are definately the way to go if you are parsing arbitrary HTML pages. Regexps IMHO work as a quick solution if the form of the input is well-known beforehand. -- Sami Hangaslammi -- From db3l at fitlinxx.com Fri Aug 11 00:20:49 2000 From: db3l at fitlinxx.com (David Bolen) Date: 11 Aug 2000 00:20:49 -0400 Subject: Win32 DLL problem: Extension crashes when using FILE * References: <8mvla1$k5u$1@nnrp1.deja.com> <8F8CED476gmcmhypernetcom@199.171.54.155> Message-ID: gmcm at hypernet.com (Gordon McMillan) writes: > rwgk at my-deja.com wrote: > > ... > > >I have been trying very hard to find out how I can force Visual C++ 6.0 > >to link against MSVCRT.dll. > ... > >From the main VC60 menu select Project -> Settings. The "Project > >Settings" dialog appears. Click the "C/C++" tab. > > In VC 5, this same dialog has a drop down box for the c runtime. Pick > "Multithreaded DLL". It's also there for VC6 - but for the original poster, you also have to select the "Code Generation" category first. You won't see the Runtime library option with the default "General" category that comes up when you first pick the C/C++ tab. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From pahajoki at voimax.cygnnet.jkl.fi Mon Aug 28 15:35:57 2000 From: pahajoki at voimax.cygnnet.jkl.fi (Kalle A. Pahajoki) Date: Mon, 28 Aug 2000 19:35:57 GMT Subject: Still no new license -- but draft text available References: <3996EF53.7362@seebelow.org> <399ED8AE.C41FD8F7@seebelow.org> Message-ID: Pat McCann wrote: >It doesn't seem to me to have paid off. I'd be interested in a better >(but concise) explanation of +/- freedom. In this case, it's probably my English skills that are to blame, rather than my philosophy teacher. It's been around a year now since I took that course, so my recollection is a bit sketchy, but I'll try to clarify. Negative freedom is the total freedom of any restrictions. The less regulations, the more negative freedom you have. Plain and simple. Positive freedom to do something means it is possible for one to do something _in practice_. Imagine two young persons, a black person of a poor family living in a poor area and an average middle-class white person. Let's assume they are of the same intelligence level. The black person goes to a school whose level of teaching is very low and the white person goes to an average public school with an OK level of teaching. When they are looking into their options of future education, do you think it is reasonable to say that they have the same possibility to get into an OK university and get an education in the field they find interesting?[1] Do you think they even have an equal chance of getting through high school? It is clear that the black person (of same intelligence) does not have an equal _positive freedom_ to pursue higher education. >I just find GNU's use of the term to be an arbritrary and >unconventional use which is unfairly implies things about copyleft >software that is true only of other forms of priceless software. I've heard terms such as 'libre' software suggested to remedy this situation. In Finnish, we have two different words for gratis and free. The situation is muddy. To what level does libre software imply free of cost in itself? I think the GNU use of 'free software' to describe their particular idea of free software is a minor complain (there are bigger ones). >> By writing a piece of free software and placing it under GPL, the >> author is in a way protecting his right to the source code, much the > >Where "his right to the source code" means "his right to other people's >source code". We're not complaining that you choose this form of >self-slavery in which you DO find certain freedoms; we're complaining >that you so often use "the" instead of "other people's" The whole point is, that I choose to inflict this restriction on myself and others who wish to use my source code. It is _my_ choice. If it renders the source code unusable for you, then I can give you my sympathy but no more. If I deem it right to use copyleft, then I must have the right to do so. You could always ask the author to relicense it with a less (to you) restrictive license. If you're arguments are reasonable, then maybe the author will be too. >and that >YOU us the broad term "freedom" instead of your using your "positive >freedom" and supplying a definition for the naive. I could argue that YOU use the broad term "freedom" instead of your using "negative freedom". You have the right to do so. GNU has the same right, and they do tell what they mean by their use of the term in their web page. IMHO It is silly to argue about the terms used, unless you are trying to imply that it is a concious choice of confusing terminology to further their marketing effort (or some other sinister motive). [1] In Finland, the universities most commonly consider a student's senior high school grades (usually the average of specific subjects) and the results of an exam similiar to the English A levels. You can also be accept by just doing well in a test the Universities arrange. (There are no tuitions) Even this system is unfair to the person receiving inferior elementary and high school education. A system based solely on tuitions is even more unfair to the poor person. In general, the higher the cost of pursuing higher education, the less equal chance a well-doing and a poor person are of getting the same level of higher education. -- Kalle Pahajoki "So many have said. But her name is not mine. Though maybe my doom will be not unlike hers." -- Arwen, in the World's Most Subtle Pick-Up Line (The favourite LotR quote of Mark Wells) From elb at cfdrc.com Wed Aug 9 18:51:14 2000 From: elb at cfdrc.com (Ed) Date: Wed, 09 Aug 2000 17:51:14 -0500 Subject: htmllib Example? Message-ID: <3991E062.458EE97E@cfdrc.com> I want to parse an HTML file and then be able to get at the contents with function calls like: parsed_html.title() parsed_html.body() parsed_html.paragraphs() Is this the type of thing one would do with the htmllib module? I wasn't able to easily find any examples of its use. Can someone refer me to a simple example? Thanks for your help. From paulduffin at my-deja.com Wed Aug 23 07:55:31 2000 From: paulduffin at my-deja.com (paulduffin at my-deja.com) Date: Wed, 23 Aug 2000 11:55:31 GMT Subject: Newbie switching from TCL References: <8noo7c$4et$1@news.online.de> <8nornc$1li$1@slb3.atl.mindspring.net> <3799AC8F18F40B22.120B7952059DF9AB.F280265F91BC2016@lp.airnews.net> <8nr6en0mh5@news2.newsguy.com> Message-ID: <8o0e3c$7ls$1@nnrp1.deja.com> In article , Robin Becker wrote: > In article <8nr6en0mh5 at news2.newsguy.com>, Alex Martelli > writes > >(P.S.: Visual Basic does allow threading [reluctantly, and only > >in recent releases], but event-handling is definitely at its core; > >considering that it probably has more users than Tcl, Python, and > >any one other scripting language you can name put together, it > >might be considered "prominent"...). > > > > > >Alex > .... > true, but underneath a lot of the VB events are threads/processes that > do the event notification. The windows loop itself which you need to do > any significant events is often in a separate thread; when it's not you > get the awful unresponsive M$ window which can't be moved while the main > app is calculating. A nice article by Steve Uhler (DDJ Sep/99) on Event- > Based Servers in Tcl is quite honest about when event or threads are > good/bad. I think he asserts that non-blocking I/O is a requirement for > event driven servers and I seem to remember that the tcl implementation > uses a separate thread for that. Tcl only uses a thread for non blocking I/O on platforms which do not support non blocking I/O. I think that this only applies to Windows sockets. Sent via Deja.com http://www.deja.com/ Before you buy. From jbauer at rubic.com Tue Aug 29 22:03:39 2000 From: jbauer at rubic.com (Jeff Bauer) Date: Tue, 29 Aug 2000 21:03:39 -0500 Subject: sleep function References: Message-ID: <39AC6B7B.2A117649@rubic.com> Arnaldo Riquelme wrote: > Does python has a function similar to sleep() in perl? > If so what is it? How do I make a function to execute > every (5,15,10) minutes ? >>> from time import sleep >>> for t in range(3): ... sleep(300) ... print 5*(t+1), "minutes have elapsed ..." ... 5 minutes have elapsed ... 10 minutes have elapsed ... 15 minutes have elapsed ... --- Jeff Bauer Rubicon Research From tanzer at swing.co.at Wed Aug 2 12:16:55 2000 From: tanzer at swing.co.at (tanzer at swing.co.at) Date: Wed, 02 Aug 2000 18:16:55 +0200 Subject: new bitwise module [was Re: Discussion: new operators ...] In-Reply-To: Your message of "Wed, 02 Aug 2000 09:40:19 +0200." <3987D063.2682F842@fft.be> Message-ID: Gregory Lielens wrote: > The advantage is that it would make translation of current python > trivial : just change | to ~or, ... He said and changed all his regular expressions along the way... -- Christian Tanzer tanzer at swing.co.at Glasauergasse 32 Tel: +43 1 876 62 36 A-1130 Vienna, Austria Fax: +43 1 877 66 92 From pahajoki at voimax.cygnnet.jkl.fi Sun Aug 20 13:02:53 2000 From: pahajoki at voimax.cygnnet.jkl.fi (Kalle A. Pahajoki) Date: Sun, 20 Aug 2000 17:02:53 GMT Subject: Still no new license -- but draft text available References: <3996EF53.7362@seebelow.org> <399ED8AE.C41FD8F7@seebelow.org> Message-ID: Grant Griffin wrote: >> but I think this reveals a high level of ignorance > >(Now let's not rush to judgement...haven't you been reading this thread? >;-) I have now and have reached the conclusion that misunderstanding (or maybe, as you say, simple disagreement) might be a better word. >Much of "marketing" boils down to what you focus on and how you present >it. Yes. But, in your message you imply that the fundamental difference between your philosophy and that of Stallman's is a poor marketing insight on Stallman's part. This is what I objected to. [Now look what you've done. You dragged me into this; and all I ment to do was object to a single sentence of yours) ;-)] >In GNUspeak, the "free" part means both "free in a cost sense" and "free >in a freedom sense". With a strong emphasis on "free in a freedom sense" (quoting "What is Free software" by GNU project): `Free software'' is a matter of liberty, not price. To understand the concept, you should think of `free speech'', not `free beer.'' No-one (AFAIK) has argued that GNU software is always completely gratis. In practice, the costs are so minimal that I have not heard anyone bitch about them. A point that we should not ignore is that when you have once obtained a piece of free software, you can legally copy that to as many friends of yours as possible. When the the amount of your friends (that you have copied the software) approaches infinite, the cost of that piece of free software approaches zero. >Yet GPL software is manifestly not "free" in >either sense. I think it is cheap to complain about the price of GNU software. If you have any practical complaints, then please state them. >(BTW, I remain baffled why so many highly intelligent, >literate, and educated people fail to notice this--especially when I >repeatedly point it out. ;-) Maybe they simply disagree with you. >Users of GPL source code >must provide source code copies to their software's users. This >certainly is a "cost"--in terms of distribution disks, web sites, legal >vetting, or whatever. I think you are referring to the part about GPL that says you must provide the sources for your software for three years (if requested), if you distribute your software as binaries. It is explicitly stated that you can charge for the media costs. >But for us commercial users, probably a much more >*significant* cost is in terms of having to disclose the remainder of >our application's source code; then we undertake a little cost called >"competitive advantage". So the idea that GPL software is "free of >cost" is manifestly false: real and substantial costs are involved. That is the way GPL works. There are other, less "restrictive" licenses. I can understand that you might not be prepared to release your product's source code. In that case, the problem is yours; not GPL's and certainly not those who use GPL. Within the community, the license works perfectly. >The GPL somehow is supposed to >preserve _user's_ freedom (or _software's_ freedom--I'm not quite sure >which) by placing restrictions on how users (authors) can use it, per >the above. It is axiomatic that freedom is not created by restricting >freedom. Repeating your (false) mantra does not make it true, regardless of how many times you repeat it. We need to separate the concepts of negative freedom and positive freedom (I knew those philosophy courses would pay off ;-)). Negative freedom is the freedom to do anything one pleases. Positive freedom guarantees everyone the possibility to do something. In your writings you are using the word freedom to refer to the concept of negative freedom. In effect, your are applying "a broad term in a narrow sense". Yes, GPL restricts some of your negative freedoms. This is the fundamental nature of GPL. I think it is pointless to complain about it. There are places where LGPL or even less restrictive license might be better (GNU acknowledges this too[1]). By writing a piece of free software and placing it under GPL, the author is in a way protecting his right to the source code, much the same way you feel you have to protect your code (from competitors) >Therefore, whatever the practical merits of the GPL's >obligations may be, we can at least, by definition, state that they do >not preserve freedom. It preserves the freedom for everyone in the community to access that source code. This can be seen as a positive freedom that GPL enforces. Those who support GPL see this as a greater good than the possible drawbacks. >But frankly, I think there's every reason to be >suspicious when really smart guys like Richard Stallman tell you things >that you can easily prove for yourself are simply false. Understanding is a three-edged sword. Your side, their side and the truth. I do not claim that I know what the truth is, but I try to apply some critical thinking before jumping into any ideology. >But from strictly a marketing perspective, it >certainly has a powerful appeal, since it's an idealogy. After all, who >but a turd wouldn't want to be part of a movement? . I would be inclined to agree, but I thought that strong ideologies (particularily when they are somehow associated with *COMMUNISM*) are not very good selling points in America. I am surprised that any big companies -- not to name any names -- are not already using this for FUD (and let's not get into any argument about communism here). >Copyleft has had some major >successes (e.g. Linux...er, "The Gnu/Linux System"), but, contrariwise, >many other good things like Python seem to do just fine without it. So can we not keep both systems? [1] _Why you shouldn't use the Library GPL for your next library_, Richard Stallman 1999 [2] Is this a Seinfeld-reference? -- Kalle Pahajoki "We can't take the future of freedom for granted. Don't take it for granted! If you want to keep your freedom, you must be prepared to defend it." -- Richard Stallman From jasonic at nomadicsltd.com Wed Aug 30 23:37:02 2000 From: jasonic at nomadicsltd.com (Jason Cunliffe) Date: Wed, 30 Aug 2000 23:37:02 -0400 Subject: dont laugh References: <8oi3s4$8km$1@nobel2.pacific.net.sg> Message-ID: > I have some JUNIOR staff > and they are asking > if there any CBT or multi-media > courses for Python Hello. This is long post because you touched a nerve here... I am not only laughing, but crying too - at you folks for not appreciating what a good question this really is! In fact I am wondering if in part this does not get at the heart of CP4E [computer programming for everyone]..or what is missing in that regard.. Personally I would love to spend a couple of hours sitting next to an experienced Python programmer who could show for example the process of putttng to together a program, testing it, shaping, how they react to error mesasges, how they sculpt the code, how they might look at the probelm a coule of ways, how they use the tools, how many windows open, what they look at.. the real-world rhythm of a few hours in the life of a python program.. even ebtter if this was intelligenly structured adn replayable with examples. It wold be nice to have a humn abeing talk and type me thourgh some code. Yes there is no subsitute for hands-on leaarngin doing. But ther is no substitute for great teachers either! And since we don t have the joys of python class in school or at our corner adult-eduxcation center, we go to tthe web and read and donwload adn hack explore til hopefully it clicks. Soem experienced folks can transfer theoir previous learning fast, but for others who may have no esperiecne or com from another background, the first steps are very important.. But consider for example what happens when you open a high powered version 9 peiece of multimedia or 3dmodellinganimatoin software.. How many of your here woudl last 15 minutes before a deep and overwhelming sense of drowning mingled with your wide-eyeed ambitoin ans fascination. But try to get something done... Ok so you get your hands on 1 hour video which shows you the basic features, some examples adn give you a reasonable grasp of what it the rhythm of working and how many times you have click and open, where some shortcuts are etc.. Lord I would love a Python video from the masters at work and play. In any field there are rare few people who _really_ understand it, and even rarer are the ones who can teach it. Python seems easy, well documented, has a great community etc.. and it does. But fundamentally all the source code in the world does not help one understand the process of programming. It does not show a newbie what to do with all those modules and definitions after your put them under your pillow! [http://www.python.org/doc/current/lib/lib.html] Would someone just explain what all this stuff is and what are the 20 most importnat things needed to know to get going..and then put the rest into some context so one undersatnds what to look forwards to. I will give you a very simple few example of the sorts of things which drove me nuts when I first tried to run python on win32 1 - PYTHONPATH... wher is this thing and how do I set it [in DOS ?, in Python under some menu, by editing autostart.bat, in some hidous registry sub.sub.sub.location.atribute 2 - Teh manual sayas jsut make this cute 'helloworld.py' example and save it. So you do, but you don't save/drop it into the main python directory [that would be dumb right?] .. no like a good kid you make a nice folder four yourself and put your first examnpkes there. 3 - Now when you do this and go 'import helloworld' you immediately get an infromative precise error reply written in Python[babylonian]! What's with that? For god sakes the newbie default for python shoudl be a: make a folder called 'newbies' and tell newbies to save their scripts ther so they WILL run first time b: add an auto-include folder paths python routine which means any folder added to the default installation will be seen and run ok. 4 - You get enthusisatic and a little braver and dowload some cool package. unzip and put it into you python directory or mayeb eben somewhere else [god help you poor soul]. Try to import that more errors..arggh. Eventually you find somewhere after scouring the docs and newsgroups a coupleof VITAL commands: import sys, os sys.path.append('c:\program files\python\coolnewpackage\') os.chdir('c:\program files\python\coolnewpackage\') os.listdir(os.getcwd()) - And after this there is the problem of packages and how modules behave with namespace voodoo like the difference between import * from somewher import something from somwhere import * - how to get them work properly - how to deal with the typical top 20 error mesages python throws at you in zealous yet zenlike bliss - What is the relationship of import, os.getcwd(), os.chdir(), '__dir__', '__builtins__', '__doc__', '__name__' to the mysteriously named, ubiquitous, but frequently blank files named __init__.py ??? Can you explain that one to you mother? All the super tools in the world do nto help if one does not knwo how to use them or have a grasp of what they are capable of. IDL and PythonWin get better all the time, and now we are about to see lots more cool Python on Windows via ActiveState etc. But this only ups the ante for what a great idea it is to make some Python training Videos/DVD/CBT. Go to Barnes and Noble for example, there are precious few python books visible and they are scattered around in odd corners. This is sad but not surprising since the Python booklist has grown well over the past year. I fear the situation may not change much in the future unless there is widespead adoption of Python ++ big marketing push to make it happen like WROX, MS, QuickStart, EASYthisEasyTHAT. Even if a newbie cannot afford the satck of $40+ dollar books VB adn others tout, at least they can hang out their for an afternoon and browse adn read and scan the range of uses, abuses, approaches and devotions of all those authors. Python is slim but elegantly represented. Yes the online docs are admirable, but believe me there are many beginners who need all the help they can to get going. What are you going to recommend to the nearest 12-year old who is itching to learn some programming? RealBASIC, Python, VB, Javascript, C, C++, Dflat, Rebol, HTML, DHTML, XML, GML, Lingo, LegoMindstorms... ??? My answer is: 1. Start with Madromedia Flash5 and maybe LegoMindstorms for Xmas 2. And then learn Python... [but what am I going to give them for help?] 3. Then Blender v2.x [gaming version with python scripting http://www.blender.nl] Flash it turns out is a brilliant intro to object-oriented programming and a ton of instant fun for all ages also. The new Flash5 has a real language in it now [ActionScript = Java/ECMAScript sytnax] behind a cool multimensional interface and frees humans from most of all the ghastly nvisible stuff which object-oriented programming was supposed to.. TEST A: - try making an interface in Flash and then in Tkinter or wxPython or some such..yeooow!@#. the difference is newbie heaven and hell TEST B: - or Next time anyone you know has to make Powerpoint slides, crack open a version of Flash and try that instead. Immediately it makes one think in terms of sequence, rhythm, flow, aesthetics, reusable compoents.. perfect for presenting ideas and teaching. Cmon - The question I ask you is what would make a good contents for a video, and who here would like to work with me [as camera wielding newbie] to develop some great CBT/Training Videos for Python ? CP4E indeed. Before re-inventing yet another language {RIYAL}, how about first learning how to teach this one? Python is cool, it has some ideosyncracies. I love it and hope it continues to thrive. regards - Jason ________________________________________________________________ Jason CUNLIFFE = NOMADICS.(Interactive Art and Technology).Design Director Ken Mossman wrote in message news:8oi3s4$8km$1 at nobel2.pacific.net.sg... > I have some JUNIOR staff > and they are asking > if there any CBT or multi-media > courses for Python > > They are NEWBIES !! From robin at jessikat.fsnet.co.uk Wed Aug 16 18:58:06 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 16 Aug 2000 23:58:06 +0100 Subject: Printing PDF files (win32) References: <8nehbv+jga1@eGroups.com> <399AE84E.63AE1144@mail.com> <9B3X3jAk+um5EwKT@jessikat.fsnet.co.uk> Message-ID: <4+hmYKA+xxm5EwZF@jessikat.fsnet.co.uk> In article , Joel Lucsy writes >I used a different approach. I just called the .exe with command line >parameters of "/p /h" along with the file and, bam, it prints using the >current default printer. Just put a bunch of these together and you're all >set. > >-- >Joel Lucsy (jjlucsy at concentric.net) ... that works for me as well. -- Robin Becker From thomas at xs4all.net Thu Aug 3 06:12:06 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Thu, 3 Aug 2000 12:12:06 +0200 Subject: CP4E Video In-Reply-To: ; from neilh@scintilla.org on Thu, Aug 03, 2000 at 05:59:34AM +0000 References: Message-ID: <20000803121206.A266@xs4all.nl> On Thu, Aug 03, 2000 at 05:59:34AM +0000, Neil Hodgson wrote: > There is a video of a talk by GvR on CP4E watchable at > http://www.technetcast.com/tnc_play_stream.html?stream_id=240 Did anyone else notice how they misspell Guido's name, and inconsistently at that ? He isn't named Guido Von Rossum, and I gather he's not happy with Guido _V_an Rossum either ;) Now I understand why my girlfriend's distant relatives (family name 'Poiesz') had such a trouble when they emigrated to America; each one of them now has a strange and novel way to misspell 'Poiesz' as their family name. > Looks like it was given to an educational group rather than a Pythonic > audience but still interesting. The date on the page is 1/Aug/2000 but from > references to CNRI it must be fairly old. I think I see 'March 2000' on one of the sheets. Guido also references the 'conference last January', and raising some controversial issues there (like case insensitivity ;) so I think that's about accurate. Of course, you never know with that damned Time Machine :) > I've been watching a few net videos recently from US conferences and > something that was noticeable was the way those USAns pronounce Python. The > second syllable is emphasised much more than with us Aussies and the 'o' is > purer. We say it closer to "Pythn". So do I, actually, but the way Guido pronounces it is the way Monty Python is introduced in BBC commentaries (more like Py-thAon), so I can see where it comes from. Me, I'm used to the dutch pronunciation (hard P, hard T, round O), so when speaking English I kind of swallow the entire word anyway, ending up with something close to you aussies, I guess. Just-try-pronouncing-my-name-in-English--I-bet-you'll-get-it-wrong-ly y'rs, -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From johngrayson at home.com Thu Aug 31 06:31:18 2000 From: johngrayson at home.com (John Grayson) Date: Thu, 31 Aug 2000 10:31:18 GMT Subject: Need Help with Tkinter Plotting References: <39ADB94F.E62A9A08@home.com> Message-ID: <8olc5m$142$1@nnrp1.deja.com> In article <39ADB94F.E62A9A08 at home.com>, timin at homeSPAMNOT.com wrote: > Hello, > > I want to draw graphs with Tkinter. I have this little script (below) that (snip) You can add a button to the root ... canvas=Canvas(root,width=810,height=600) canvas.pack() Button(root, text='Quit', command=root.quit).pack(side=BOTTOM, anchor=SE) BTW, If you don't have my book, take a look at: www.Manning.com/Grayson/Chapters.html. You can pick up Chapter11 (in pdf format) which has some fairly useful generic graph code (the source code is on the site, too). Good Luck! John Sent via Deja.com http://www.deja.com/ Before you buy. From robin at jessikat.fsnet.co.uk Thu Aug 3 06:58:52 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 3 Aug 2000 11:58:52 +0100 Subject: Still no new license -- but draft text available References: <398909B2.607E4419@home.com> Message-ID: In article <398909B2.607E4419 at home.com>, Michael Dyck writes >Tim Peters wrote: >> >> Indeed, I would love to release Python under this license: >> >> ... >> 6. Licensee agrees that there is only one way to do it. > >Shouldn't that be: > > 6. Licensee agrees that there is NO clause 6. > 7. Licensee agrees that there is only one way to do it. > >G'day, >Bruce I move this thread be moved to comp.lang.lawyers or comp.lang.licenses or whatever or pretty soon someone will mention Adolf Hitler (oops sorry) in order to make the thread generic. -- Robin Becker From Bill.Scherer at VerizonWireless.com Wed Aug 2 11:37:11 2000 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Wed, 02 Aug 2000 11:37:11 -0400 Subject: [JOB] Python Programmers Needed Message-ID: <39884027.F46D4DB2@VerizonWireless.com> Verizon Wireless is seeking to fill a few contract positions for Python coding of intranet applications. The candidiates must be able to work full time on site in Orangeburg, NY, US. Experience with Python is required. Currently, we expect the job to last 3 to 4 months, possibly more. The positions may be Right-To-Hire. Please send your resume and cover letter to: Bill.Scherer_at_VerizonWireless.com -- William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From mark.w.daley at intel.com Tue Aug 1 19:45:57 2000 From: mark.w.daley at intel.com (Daley, Mark W) Date: Tue, 1 Aug 2000 16:45:57 -0700 Subject: .pyw Message-ID: <75F7304BB41CD411B06600A0C98414FCB36834@ORSMSX54> I thought that the way to eliminate the console popping up for GUI stuff was to rename the .pyc file to .pyw. I did that and the .pyw file won't work at all. Am I missing something? I realize this pops up from time to time on the newsgroup, but I can't find the last time it was addressed. From mwh21 at cam.ac.uk Fri Aug 25 16:25:52 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 25 Aug 2000 21:25:52 +0100 Subject: Python threads question References: <8np7j8$763$1@news7.svr.pol.co.uk> <8npa5b$rfo$1@slb3.atl.mindspring.net> Message-ID: aahz at netcom.com (Aahz Maruch) writes: > Note^2: One of the side effects of Christian Tismer's Stackless Python > is that it removes the Global Interpreter Lock. Sure about this? Cheers, M. -- If a train station is a place where a train stops, what's a workstation? -- unknown (to me, at least) From gpepice1 at nycap.rr.com Sat Aug 5 00:21:53 2000 From: gpepice1 at nycap.rr.com (gbp) Date: Sat, 05 Aug 2000 04:21:53 GMT Subject: Newbie DATA STRUCTURES Question. References: <398248BC.32DE3CC@nycap.rr.com> Message-ID: <398B9763.C6304B5D@nycap.rr.com> Thanks to everyone who replied. After using Python for a week I'm a lot more comfortable with it. After a couple days I figued out how to make a list of objects. I got a little hung up on thinking in Perl terms. Once I stepped back and let python be a different langauge stuff made more sense. In Perl you can't really make a list of records you have to make a list of pointers to records. In Python it seems you can make a list of anything you want. Huaiyu Zhu wrote: > > On Sat, 29 Jul 2000 02:57:03 GMT, gbp wrote: > > > >I have experience with Perl but non with Python. > > > >I need to write a script to read a large text file into a structured > >format. > > > >In Perl one can create a list of records using something like pointers. > >So really you have a list of pointers-- each one pointing to an > >anonymous record. Each record is some data from a line in the file. > > > > Others have given more general answers, but I think you might have this > specific question in mind: you have a file of form > > 11 12 13 > 21 22 23 > ... > > and you want to get a list of dictionaries (ie an array of hashes in Perl) > > result = [{'a':11, 'b':12, 'c':13}, > {'a':21, 'b':22, 'c':23}, > ... > ] > > You can do it as the following (not tested) > > file = open(filename) # or file = sys.stdin > names = ['a','b','c'] > result = [] > for line in file.readlines(): > fields = string.split(line) # or use re to extract the fields > record = {} > for name, field in map(None, names, fields): > record[name] = field > result.append(record) > > Hope this helps. > > Huaiyu From daniel.green at ncf.ca Tue Aug 8 11:32:41 2000 From: daniel.green at ncf.ca (Daniel Green) Date: Tue, 8 Aug 2000 11:32:41 -0400 Subject: Web Application Server Message-ID: <000701c0014d$e48f73d0$0200000a@threepwood> I've just placed a very beta release of Fenster, a web application server written entirely in Python, similar to ASP and PHP (but, obviously, using Python as their scripting language) on SourceForge. I wouldn't call it release qualiy, but it's certainly pretty cool given that it's only about 500 lines of code. :) What I really need right now is as much feedback as possible. So if you're at all interested, I urge you to head over to http://fenster.sourceforge.net and have a look. It'd be especially cool if we could get some real discussions going on the mailing list. As a "Python rocks!" testimonial, the actual coding time between conceptualization and this beta was probably about a total of 6 hours of coding -- and that included many re-writes and tweaks. Dan Green Software Developer P.S. I'm not on the list, but feel free to reply to me if you have any questions/comments. From richard_chamberlain at ntlworld.com Tue Aug 8 17:05:02 2000 From: richard_chamberlain at ntlworld.com (Richard Chamberlain) Date: Tue, 08 Aug 2000 22:05:02 +0100 Subject: the eliza algorithm References: <398E6336.3A3989A3@structurex.net> <8mm4in$pph$1@nnrp1.deja.com> <87bsz5xpgu.fsf@eugene.prosa.it> Message-ID: <399075FE.981373@ntlworld.com> Cool. I'm supposedly using Alice in a ecommerce project I'm involved in. I don't know whether you've used it but the java server is way too slow. I considered porting it to Python (not for speed obviously) because I'd prefer it to be in python. Not got much further than considering it (new baby,new job, no time, woe is me!) Richard "David N. Welton" wrote: > > I haven't published it anywhere, but I pulled apart MegaHAL, and wrote > a Python front end to the basic functions... It's kind of fun:-) > > -- > David N. Welton, Responsabile Progetti Open Source, Linuxcare Italia spa > tel +39.049.8043411 fax +39.049.8043412 cel +39.348.2879508 > davidw at linuxcare.com, http://www.linuxcare.com/ > Linuxcare. Support for the revolution. From gmcm at hypernet.com Thu Aug 3 21:11:42 2000 From: gmcm at hypernet.com (Gordon McMillan) Date: Thu, 3 Aug 2000 21:11:42 -0400 Subject: Still no new license -- but draft text available In-Reply-To: References: <8F85BB341gmcmhypernetcom@199.171.54.155> Message-ID: <1246770992-84597189@hypernet.com> > [Tim] > > ... > > 5. Licensee agrees that defining the difference between > > clicking and not clicking is an epistimological > > impossibility. Licensee further agrees that this clause has > > always said "epistimological". > > [Gordon McMillan] > > Jeez, what does the BDFL annoint his representives with? > > Defining the difference is trivial; > > Ha! Didn't see *you* try to define it just now, did we, Mr. > Smarty-Pants Epistomlogical Troublemaker? I'm a philosopher[1]. The fact that it can be defined (in terms of the phase of the moon, or the refractive index of fish scales, say) makes it of no further interest to me. To a quotidian revisionist[2] bot-infested host organism whose idea of the higher things in life is that which he sees when lying supine and looking towards his feet, an anal obsession with the realization of a defintion is only to be expected. quiddity-lyy'rs - Gordon [1] Well, sometimes I play one on usenet. [2] Yes, I saw that. From piet at cs.uu.nl Sun Aug 6 08:10:30 2000 From: piet at cs.uu.nl (Piet van Oostrum) Date: 06 Aug 2000 14:10:30 +0200 Subject: [Python-Dev] Still no new license -- but draft text available References: Message-ID: >>>>> "Tim Peters" (TP) writes: TP> if I grab a GPL'ed program that entity X holds copyright on, TP> then X is free to change the license to anything at all upon any future TP> release. That is true for every license. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From alex at magenta.com Fri Aug 25 05:06:16 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 25 Aug 2000 11:06:16 +0200 Subject: gratuitous new features in 2.0 References: <7ba5.39a2ccf0.27c0b@yetix.sz-sb.de> <8o026t0rdi@news1.newsguy.com> <3dg0nuspxp.fsf@kronos.cnri.reston.va.us> <8o4e4o$mat$1@slb3.atl.mindspring.net> Message-ID: <8o5d740hhr@news2.newsguy.com> "Aahz Maruch" wrote in message news:8o4e4o$mat$1 at slb3.atl.mindspring.net... > In article , > Neil Schemenauer wrote: > >Andrew Kuchling wrote: > >> > >>Agreed; there is a small (but apparently growing) number of people > >>unhappy with the unprecedented slew of added features to 2.0. I'm > >>particularly irked by weird special cases, like the .setdefault(key, > >>default_value) method of dictionaries that was recently added. > > > >My beef is with the new syntax for print. I don't like new > >syntax unless absolutely necessary. What would have been wrong > >with: > > > > write(sys.stderr, "foo", "bar", "baz") > > > >instead of: > > > > print >>sys.stderr, "foo", "bar", "baz" > > > >Yuck, it looks like C++ or Perl. I'm with Andrew on the > >setdefault() method as well. > > I've been exchanging some e-mail with Guido and Barry about this; > Guido particularly isn't following the discussion here. Unfortunately, > I seem to be unable to find a sufficiently powerful argument to sway > BDFL's mind. My primary argument at this point is that I *shouldn't* > have to argue against PEP 0214: the onus should be on whoever is > proposing a language change to develop a powerful argument in favor. So > far, I haven't seen one. Let's see if I can help supply some arguments, since you may have the ear[s] of the BDFL and friends -- feel totally free to make any selective or total use of the following material. I haven't seen one either, including the URL you kindly give for Tim Peters' comments. Apparently, the 'print>>bah' syntax is only being compared with the current situation, rather than with the many alternative ways of exposing the same functionality: print >> bah, foo, bar, baz println(bah, foo, bar, baz) println(foo, bar, baz, file=bah) sys.println as above bah.println(foo, bar, baz) I absolutely can't see why the first syntax is deemed to be "more pythonic" than the others; on the contrary, it strikes me (and apparently most other respondants) as a hack -- with the notable exceptions of the BDFL and timbot. Now, if they could just articulate how and why the ">>hack" is more Pythonic than any of the ways to expose the same functionality as a function and/or method (without changing the language itself), I guess us peons might, if not share their superior understanding, at least acquiesce in it more quietly. The "powerful argument" is presumably made for the functionality to exist; assigning and restoring sys.stdout is no doubt somewhat cumbersome, what with the try/finally needs, etc. On general principles, reliance on global status, even with the ability of saving/changing/restoring such status, is dirtier than explicit passing of the (local) status information needed. But why need this functionality be presented as a language change, when it seems so much more natural to offer it as a function or method instead? _That_ is the part I really can't fathom. Choosing between a function (either builtin or in some module, that is a secondary, naming issue) and a method (on file like objects) is a different thing. I believe a function might be better here, as the need to customize for specific files, that the method would enable, does not seem present; on the other hand, if the function is there, it will presumably just rely on the .write method of the file-like object, so the object itself (which may pre-exist the introduction of the println function) need not be further enriched/customized. But I'd be relatively happy with either resolution of this secondary stuff, as long as the language itself does not get 'wantonly' (as it appears to me) extended with functionality that might be at least as well exposed as a function (or method). The advantages of exposing a given functionality as a function or method, rather than by a language-change to the print statement, should be pretty clear. If I have a function for a task, it's a full-fledged object, which I can save, pass around, compose, subject to map/apply/etc; a statement does not give me anywhere as much functional flexibility. E.g., consider the 'tee' functionality that is often requested -- printing to a set of files. How do you implement 'print this info to this set of files' if print is a statement, not a function? You presumably have to implement a tee-object, say: class teeObject: def __init__(self, *files): self.files=files def write(self, stuff): for file in self.files: write(file, stuff) and do something like: print >> teeObject(afile, another), foo, bar, baz as opposed to wrapping it easily in a function: teePrint((afile,another), foo, bar, baz) with def teePrint(files, *stuff): for file in files: println(file, *stuff) The class-based solution, made necessary by the statement, appears to be about twice as complicated as the function based solution which a println function would enable. If I just wanted to output, for debugging purposes, a bunch of stuff which I have received as arguments, the function shines again, I think: def trace1(header,*stuff,file=sys.stdout): println(file,header,*stuff) def myfunc(*stuff): trace1("myfunc args:",*stuff): # now do the real work versus def trace2(header,*stuff,file=sys.stdout): print >> file, header, for stiff in stuff[:-1]: print >> file, stiff, if len(stuff)>0: print >> file, stuff[-1] Again, having to work with a print statement rather than a println function does seem to me to make things much, much more complicated -- several times as much. What would be the offsetting advantages of having the statement instead of the function? I can't see them! Rebuttals by charter members of the "Friends of print>> Society" are of course welcome...! > Note that while I don't have a strong visceral reaction against > dict.setdefault(), I have to agree with the dismay at the speed with > which it's going in. I don't know anything about this "dict.setdefault" thing; can you please provide an URL where I might learn something? Thanks! Alex From vogler at innercite.com Fri Aug 11 17:06:32 2000 From: vogler at innercite.com (vogler at innercite.com) Date: Fri, 11 Aug 2000 21:06:32 GMT Subject: strange behaivor with 1.5.2/tcl8.0 drawing lines Message-ID: <8n1psl$7a5$1@nnrp1.deja.com> I ran into some strange behaivor and noticed it when I upgraded from Python1.4 to Python1.5.2. It involves drawing lines using Tcl/Tk 8.0. Drawing a one inch line worked on Python1.4 using the create_line in a canvas widget, but on P1.5.2 it was much longer. I went and tested this directly in Tcl/Tk and it worked fine. It appears that errors are being introduced in the unit conversion between P1.5.2 and Tcl/Tk? Does anyone out there know the solution to this problem? FYI the operating system in WinNT 4.0. TIA Bill Vogler Sent via Deja.com http://www.deja.com/ Before you buy. From eric at estinc.com Fri Aug 25 17:52:38 2000 From: eric at estinc.com (Eric Lee Green) Date: Fri, 25 Aug 2000 14:52:38 -0700 Subject: Looking for Python programmers--where to search? References: <3998C541.4FC15982@san.rr.com> <39a3d9cb.4496054@news.laplaza.org> Message-ID: <39A6EAA6.1E6FC421@estinc.com> Mats Wichmann wrote: > On Mon, 14 Aug 2000 23:48:28 -0700, Paul Schreiber > wrote: > >You can pick up python in a hour; all you need is a good reference book > >to look stuff up in. _Python Essential Reference_ is that book. :) > >(Typically people get confused about lists and tuples; or strings being > >immutable -- minor junk.) > > I really think you're slightly overstating the simplicity. You still > have to get used to things like namespaces and how modules impact > them, import/from/reload, etc. - i.e. there are some subtleties; and > you have to gain some kind of familiarity with the tools that are > available - standard modules and how to make effective use of them; > connectors to other languages, etc. I'm training a C++ programmer to program in Python as we speak. The thing that seems to give him willies is the sheer dynamic nature of the language. C++, as you know, is statically typed (nevermind the STL ball-of-cruft). We assigned him to write a database access class that incorporated self-reflection, i.e., it created its attributes at run-time based upon the contents of a list of attribute/type pairings in the subclass that was inheriting the database access class, and you could almost see the fuses blowing in his mind. So far he has been plugging away for two weeks, and still takes 2 days to do what I could do in the course of an hour, and still has trouble dealing with the fact that he can, e.g., operate upon lists without having to write oodles of list-manipulation code and etc. (e.g. there was one database operation where the most efficient way of handling things was to query all the data out into one list then iterate over the list with a 'for' loop, and he went through a bunch of hooplah with cursors to implement the same thing -- because in "C", you can't work on lists without writing a bunch of code). My only conclusion can be that while C++ programmers can learn the basics of the Python language in an hour, it takes them a lot longer than an hour to be able to write real programs in a timely manner using the language. > (Hint to employers: there are lots of competent folks who are willing > to help on projects - part-time or full-time, consulting or permanent, > who don't understand why that should mean being tied to the SF Bay > Area... think: telecommuting. I've done it productively for years. > If you bend a little on location your lives will get a whole lot > easier trying to fill those difficult spots! A few years ago I would have agreed with you. The problem is that projects are becoming more and more complex, and as they become more complex, interactions become more complex. A typical project ten years ago had one component type -- a client program, that maybe communicated with a centralized database server via a socket if it were particularly sophisticated (but usually it used an ISAM library and relied on a Novell network's built-in file locking mechanisms to provide consistency control). The various screens could be broken into independent programs, none of which knew about any other program or communicated with any of them. Today's projects have multiple "thin" clients (CLI, GUI, web), a very sophisticated server that incorporates the actual business logic, they perhaps access an LDAP server and an SQL server, etc. etc. etc.... if I am writing the server, I need to communicate swiftly with the person writing the GUI interface, because when something comes up that is not incorporated in the design documents, I need to know how we can handle it so that I can create output that he can parse (and vice-versa). If he is in the cubicle across from mine, I can poke my head over the wall and ask him. If we are hundreds of miles away and in different time zones, that becomes a problem. The last time I successfully telecommuted was 5 years ago, working on a database application that consisted of numerous standalone modules hooked together via a menu program. I would not even dream of attempting that with the current project, where the interactions between the various components are critical despite every attempt on my part to keep things as isolated and independently-testable as possible. -- Eric Lee Green eric at estinc.com Software Engineer "The BRU Guys" Enhanced Software Technologies, Inc. http://www.estinc.com/ (602) 470-1115 voice (602) 470-1116 fax From piet at cs.uu.nl Thu Aug 31 15:58:02 2000 From: piet at cs.uu.nl (Piet van Oostrum) Date: 31 Aug 2000 21:58:02 +0200 Subject: Python Path References: <20000830211458.16019.00000382@ng-ch1.aol.com> Message-ID: >>>>> poparosa at aol.com (Poparosa) (P) writes: P> On another thread, how can I create a file with a .pth extension (notepad P> always appends .txt)? Enter the filename in "". Better: use a real editor e.g. PFE or Emacs. -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From tim_one at email.msn.com Sun Aug 13 13:18:41 2000 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 13 Aug 2000 13:18:41 -0400 Subject: incrementation operators? In-Reply-To: <3996B14F.5BE77F8D@connection.com> Message-ID: [Colin J. Williams] > ... > The PEP gives a full description of the various operators, but > provides no rationale for their introduction. > > I wonder how frequently this sort of operation in place would be > used in practice. > Does the frequency of likely use balance the increased clutter? I was thinking about that yesterday (for about the 10,000th time ) while writing this loop: for i in range(pad): term = term * ((i-d) * b) / (c*(i+1)) sum = sum + term if term == 0: sum = sum >> pad break and wishing like mad I could have written for i in range(pad): term *= ((i-d) * b) / (c*(i+1)) sum += term if term == 0: sum >>= pad break instead. The latter reduces the clutter I *care* about on 50% of the lines: mental clutter. At the algorithmic level, I *think* "add term to sum", and "shift sum right by pad" etc, not "add sum to term and then replace sum by that" etc. I don't really care about the savings in typing! It's the ability to say what I *mean* more directly. So it will be used frequently, at least by me . The semantic clutter is one general new rule (learning what += means, then learning that *= etc mean the obvious variations on that); the internal implementation clutter is relatively immense but pretty much the same business of implementing it once then plugging in minor variations repeatedly. Thanks to Thomas Wouters, that "hard part" is done now. > One of the attractive features of Python is its relative simplicity. > Would we lose some of this simplicity for little practical gain? It's a tradeoff, of course, and not all people will judge that the same way. In this case I think it's a major gain in expressive simplicity (how much hassle it takes to say what I mean, and to later *reconstruct* what I meant from what I was allowed to say <0.5 wink>), versus a minor blow to syntactic minimality. You may not agree, and that's why Guido is elected Benevolent Dictator for Life. > These operators exist in other languages. Is there a > justification for including them in Python? Guido reports they're the single most-requested new feature in Python's history, so even if you don't like dictators, it's the Will of the People . > I hope that I am not too late for some sober second thoughts. Probably too late by about 5 years, which is about how long ago Guido told the Numeric Python people he would eventually add this. When x and y are, for example, matrices with millions of elements, the *semantic* difference between x = x + y and x += y can be the difference in whether the program can run at all: a matrix class can arrange so that the latter overwrites x in-place, but the former will allocate another multi-million element temp array to hold the sum, only to copy the temp over x immediately and then deallocate it. That's a case where the "mental clutter" of not being able to say "add y to x" directly translates into megabytes of RAM and cache clutter too. So while this debate has been going on for years, it essentially ended in Guido's mind in the mid-90's. I think he stopped at just the right place, too. While everyone thinks "add 1 to i" from time to time, *nobody* thinks "plus plus i" . "incr-i"-is-a-nice-thing-to-think-but-remains-unspeakable-ly y'rs - tim From sharris at nospam.primus.com Mon Aug 28 13:34:22 2000 From: sharris at nospam.primus.com (Steven E. Harris) Date: Mon, 28 Aug 2000 17:34:22 GMT Subject: gratuitous new features in 2.0 References: Message-ID: Roy Katz writes: [...] > That last point is what especially concerns me. C++ is full of these > one-context throw-away grammatical oddities such as 'unsigned short > BIT_FIELD_NAME: N' (the colon) and 'using namespace ...' (could you > *ever* put anything other than 'namespace' in the 'using' > declaration??) Yes. You're describing a "using Directive," but are forgetting about the arguably more useful "using Declaration." I can post a descriptive example if you're interested. -- Steven E. Harris :: sharris @primus.com Primus :: http://www.primus.com From * at spam.ruud.org Fri Aug 4 11:38:24 2000 From: * at spam.ruud.org (Ruud de Rooij) Date: 4 Aug 2000 17:38:24 +0200 Subject: Newbie Q: Pythin scripting References: <8mefk3$pu2$1@news1.skynet.be> <8men9l$h65$1@slb7.atl.mindspring.net> Message-ID: <87u2d13ukv.fsf@hobbes.home.ruud.org> aahz at netcom.com (Aahz Maruch) writes: > In article <8mefk3$pu2$1 at news1.skynet.be>, > Dave Van den Eynde wrote: > > > >Consider me a newbie, but I have the following problem. When I make a script > >to run under bash, the first line that I make is : > > > > #! /usr/bin/python > > Don't use a space: > > #!/usr/bin/python $ cat > test.py #! /usr/bin/python print "It-Works-For-Me(TM)" $ chmod +x test.py $ ./test.py It-Works-For-Me(TM) - Ruud de Rooij. -- ruud de rooij | *@spam.ruud.org | http://ruud.org From hinsen at cnrs-orleans.fr Fri Aug 11 05:26:01 2000 From: hinsen at cnrs-orleans.fr (Konrad Hinsen) Date: 11 Aug 2000 11:26:01 +0200 Subject: [PEP draft 2] Adding new math operators References: <3991243D.D987955@fft.be> <3991891F.6B054A9@fft.be> Message-ID: hzhu at localhost.localdomain (Huaiyu Zhu) writes: > The real problem is that the variables happen to come in the flavor suitable > for the input of your formula, and the output of your formula happen to be > in a flavor suitable for the rest of your program. This formula therefore Which happens to be the case in all situations that I am familiar with. > >I have never seen any situation in which matrix objects (i.e. objects > >which are the result of matrix operations) are subsequently used in > >elementwise operations, with a result that has to be used in a matrix > >operation immediately afterwards. > > Well, the majority of these cases come from using the "broadcasting rules". > You compute x and y (two axes) from linear algebra. You compute a function > of them using elementwise operation instead of meshdomain as in matlab. Then > you transform z by linear algebra operations again. This kind of operations > are quite common in data visualization, for example. I have such situations in my own code. I tend to write the function as a Python function expecting array arguments, thus inside the function all operations are elementwise. Then I call it from within the matrix-operation code, adding ".array" to the arguments. > In statistical computations it is common to switch context of doing > elementwise computation (ie assuming independence between the components) > and do full matrix operation (taking into account correlation, etc). Sounds familiar as well - and my solution is the same. The statistical operation is encapsulated in a function or method (as one would do anyway!), which contains all the matrix operations. In both of these cases, the "diferent-logic" parts of the code are complex enough that they would be seen as separate algorithmis steps and written as functions or methods. This is very different from the articifial examples you used in which switches between the "array" and "matrix" point of view occur three times in a single line. -- ------------------------------------------------------------------------------- Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24 Rue Charles Sadron | Fax: +33-2.38.63.15.17 45071 Orleans Cedex 2 | Deutsch/Esperanto/English/ France | Nederlands/Francais ------------------------------------------------------------------------------- From robin at jessikat.fsnet.co.uk Tue Aug 22 18:50:59 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 22 Aug 2000 23:50:59 +0100 Subject: No destructor References: <39a1711d_2@news2.vip.uk.com> <8nrsnb$h4f$1@news5.svr.pol.co.uk> <8ns4mu$9c4$1@la-mail4.digilink.net> <39A19954.57408AA3@alcyone.com> <39a19f5f_1@news1.vip.uk.com> <8ntc9p02grk@news2.newsguy.com> <1541370114.20000822214659@vega.bg> Message-ID: In article <1541370114.20000822214659 at vega.bg>, spahievi writes >>> How does Python < 2.0 handle circular references? Is the programmer >>> expected to handle them via weak refs etc? > >AM> There are no 'weak references' in Python 1.5.2 (nor, I think, in 1.6). >AM> Circular references need to be explicitly broken by the programmer, >AM> else there will be a resource leak. > >There is extension module for weak dicts. > >Niki ... there's an optional garbage collector in the latest CVS so I guess circular refs aren't absolutely horrible any longer. -- Robin Becker From mfletch at tpresence.com Wed Aug 9 16:21:33 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Wed, 9 Aug 2000 16:21:33 -0400 Subject: "Stringizing" a list Message-ID: Something like the following: import types allowedMap = { types.ListType:1, types.TupleType:1 } You could also add classes that have "for" interfaces to get them expanded along with the lists/tuples. Alternately, you could leave off the tuples if you only want to expand lists. Incidentally, here's my original version, which was much simpler :) def collapse(inlist, type=type, ltype=types.ListType, maxint= sys.maxint): ''' Destructively flatten a list hierarchy to a single level. Non-recursive, and (as far as I can see, doesn't have any glaring loopholes). Further speedups and obfuscations by Tim Peters :) ''' try: # for every possible index for ind in xrange( maxint): # while that index currently holds a list while type(inlist[ind]) is ltype: # expand that list into the index (and subsequent indicies) inlist[ind:ind+1] = inlist[ind] #ind = ind+1 except IndexError: pass return inlist def collapse_safe(inlist): ''' As collapse, but works on a copy of the inlist ''' return collapse( inlist[:] ) Enjoy, Mike -----Original Message----- From: Peter Schneider-Kamp [mailto:nowonder at nowonder.de] Sent: Wednesday, August 09, 2000 5:43 PM To: Mike Fletcher Cc: 'cg at cdegroot.com'; Python Listserv (E-mail) Subject: Re: "Stringizing" a list Mike Fletcher wrote: > > Something like > string.join(hyperCollapse( data)) > > Should be fairly fast and general. If it would work. What has to supplied as allowedmap? hyperCollapse requires 2 parameters. Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de -- http://www.python.org/mailman/listinfo/python-list From nowonder at nowonder.de Tue Aug 22 09:23:04 2000 From: nowonder at nowonder.de (Peter Schneider-Kamp) Date: Tue, 22 Aug 2000 13:23:04 +0000 Subject: Recommendations please References: <39A0F611.152D52A1@nowonder.de> <39a22874$1_1@news.chariot.net.au> Message-ID: <39A27EB8.3482B3E2@nowonder.de> Matthew Schinckel wrote: > > In message <39A0F611.152D52A1 at nowonder.de>, Peter Schneider-Kamp wrote: > > Not the same Peter Schneider-Kamp who used to work for Commodore? When would that have been? A long time ago? Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From darrell at dorb.com Sun Aug 13 17:25:51 2000 From: darrell at dorb.com (Darrell Gallion) Date: Sun, 13 Aug 2000 17:25:51 -0400 Subject: srtring to int question References: <04f501c0053e$4990c6f0$6401a8c0@home> Message-ID: <051e01c0056d$0e681450$6401a8c0@home> From: "Bernhard Herzog" > > > > import re, sys > > globalNames={'hex':__builtins__.hex, 'int':__builtins__.int, > > 'raw_input':__builtins__.raw_input} > > Putting these into globalNames is not really necessary because exec and > eval will add the __builtin__ module to the dict passed in as the > globals dict anyway, unless there is already a __builtins__ entry in the > dict. That's how resticted execution works, btw, by having a custom > __builtins__ dictionary in the globals dict. > Now that was surprising. --Darrell From hzhu at localhost.localdomain Tue Aug 8 16:13:06 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Tue, 08 Aug 2000 20:13:06 GMT Subject: [PEP draft 2] Adding new math operators Message-ID: This incorporates the comments I received. It is to be merged (linked) with the official PEP 211. Python Extension Proposal: Adding New Math Operators Huaiyu Zhu 2000-08-08, draft 2 Introduction ------------ This PEP describes a proposal to add new math operators to Python, and summarises discussions in the news group comp.lang.python on this topic. Issues discussed here include: 1. Background. 2. Description of proposed operators and implementation issues. 3. Analysis of alternatives to new operators. 4. Analysis of alternative forms. 5. Compatibility issues 6. Description of wider extensions and other related ideas. A substantial portion of this PEP describes ideas that do not go into the proposed extension. They are presented because the extension is essentially syntactic sugar, so its adoption must be weighed against various possible alternatives. While many alternatives may be better in some aspects, the current proposal appears to be overall advantageous. Background ---------- Python provides five basic math operators, + - * / **. (Hereafter generically represented by "op"). They can be overloaded with new semantics for user-defined classes. However, for objects composed of homogeneous elements, such as arrays, vectors and matrices in numerical computation, there are two essentially distinct flavors of semantics. The objectwise operations treat these objects as points in multidimensional spaces. The elementwise operations treat them as collections of individual elements. These two flavors of operations are often intermixed in the same formulas, thereby requiring syntactical distinction. Many numerical computation languages provide two sets of math operators. For example, in Matlab, the ordinary op is used for objectwise operation while .op is used for elementwise operation. In R, op stands for elementwise operation while %op% stands for objectwise operation. In python, there are other methods of representation, some of which already used by available numerical packages, such as 1. function: mul(a,b) 2. method: a.mul(b) 3. casting: a.E*b In several aspects these are not as adequate as infix operators. More details will be shown later, but the key points are 1. Readability: Even for moderately complicated formulas, infix operators are much cleaner than alternatives. 2. Familiarity: Users are familiar with ordinary math operators. 3. Implementation: New infix operators will not unduly clutter python syntax. They will greatly ease the implementation of numerical packages. While it is possible to assign current math operators to one flavor of semantics, there is simply not enough infix operators to overload for the other flavor. It is also impossible to maintain visual symmetry between these two flavors if one of them does not contain symbols for ordinary math operators. Proposed extension ------------------ 1. New operators ~+ ~- ~* ~/ ~** ~+= ~-= ~*= ~/= ~**= are added to core Python. They parallel the existing operators + - * / ** and the (soon to be added) += -= *= /= **= operators. 2. Operator ~op retains the syntactical properties of operator op, including precedence. 3. Operator ~op retains the semantical properties of operator op on built-in number types. They raise syntax error on other types. 4. These operators are overloadable in classes with names that prepend "alt" to names of ordinary math operators. For example, __altadd__ and __raltadd__ work for ~+ just as __add__ and __radd__ work for +. 5. As with standard math operators, the __r*__() methods are invoked when the left operand does not provide the appropriate method. The symbol ~ is already used in Python as the unary "bitwise not" operator. Currently it is not allowed for binary operators, so using it as a prefix to binary operators will not create incompatibility. The proposed implementation is to patch several files relating to the parser and compiler to duplicate the functionality of existing math operators as necessary. All new semantics are to be implemented in the application that overloads them, but they are recommended to be conceptually similar to existing math operators. It is not specified which version of operators stands for elementwise or objectwise operations, leaving the decision to applications. A prototype implementation already exists. Alternatives to adding new operators ------------------------------------ Some of the leading alternatives, using the multiplication as an example. 1. Use function mul(a,b). Advantage: - No need for new operators. Disadvantage: - Prefix forms are cumbersome for composite formulas. - Unfamiliar to the intended users. - Too verbose for the intended users. - Unable to use natural precedence rules. 2. Use method call a.mul(b) Advantage: - No need for new operators. Disadvantage: - Asymmetric for both operands. - Unfamiliar to the intended users. - Too verbose for the intended users. - Unable to use natural precedence rules. 3. Implement a shadowing "elementwise class" and use casting to indicate the operators. For example a*b for matrix multiply, and a.E*b for elementwise multiply. Advantage: - No need for new operators. - Benefits of infix operators with correct precedence rules. - Clean formulas in applications. Disadvantage: - Hard to maintain in current Python because ordinary numbers cannot have class methods. (a.E*b will fail if a is a pure number.) - Difficult to implement, as this will interfere with existing method calls, like .T for transpose, etc. - Runtime overhead of method lookup. - The shadowing class cannot replace a true class, because it does not return its own type. So there need to be a M class with shadow E class, and an E class with shadow M class. - Unnatural to mathematicians. 4. Using mini parser to parse formulas written in arbitrary extension placed in quoted strings. Advantage: - Pure Python, without new operators Disadvantage: - The actual syntax is within the quoted string, which does not resolve the problem itself. - Introducing zones of special syntax. - Demanding on the mini-parser. Among these alternatives, the first and second are used in current applications to some extent, but found inadequate. The third is the most favorite for applications, but it will incur huge implementation complexity. The fourth creates more problems than it solves. Alternative forms of infix operators ------------------------------------ Two major forms and several minor variants of new infix operators were discussed: 1. Bracketed form (op) [op] {op} :op: ~op~ %op% 2. Meta character form .op @op ~op Alternatively the meta character is put after the operator. 3. Less consistent variations of these themes. These are considered unfavorably. For completeness some are listed here - Use @/ and /@ for left and right division - Use [*] and (*) for outer and inner products 4. Use __call__ to simulate multiplication. a(b) or (a)(b) Criteria for choosing among the representations include: - No syntactical ambiguities with existing operators. - Higher readability in actual formulas. This makes the bracketed forms unfavorable. See examples below. - Visually similar to existing math operators. - Syntactically simple, without blocking possible future extensions. With these criteria the overall winner in bracket form appear to be {op}. A clear winner in the meta character form is ~op. Comparing these it appears that ~op is the favorite among them all. Some analysis are as follows: - The .op form is ambiguous: 1.+a would be different from 1 .+a. - The bracket type operators are most favorable when standing alone, but not in formulas, as they interfere with visual parsing of parenthesis for precedence and function argument. This is so for (op) and [op], and somewhat less so for {op} and . - The form has the potential to be confused with < > and =. - The @op is not favored because @ is visually heavy (dense, more like a letter): a at +b is more readily read as a@ + b than a @+ b. - For choosing meta-characters: Most of existing ASCII symbols have already been used. The only three unused are @ $ ?. Semantics of new operators -------------------------- There are convincing arguments for using either set of operators as objectwise or elementwise. Some of them are listed here: 1. op for element, ~op for object - Consistent with current multiarray interface of Numeric package - Consistent with some other languages - Perception that elementwise operations are more natural - Perception that elementwise operations are used more frequently 2. op for object, ~op for element - Consistent with current linear algebra interface of MatPy package - Consistent with some other languages - Perception that objectwise operations are more natural - Perception that objectwise operations are used more frequently - Consistent with the current behavior of operators on lists - Allow ~ to be a general elementwise meta-character in future extensions. It is generally agreed upon that - there is no absolute reason to favor one or the other - it is easy to cast from one representation to another in a sizable chunk of code, so the other flavor of operators is always minority - there are other semantic differences that favor existence of array-oriented and matrix-oriented packages, even if their operators are unified. - whatever the decision is taken, codes using existing interfaces should not be broken for a very long time. Therefore not much is lost, and much flexibility retained, if the semantic flavors of these two sets of operators are not dictated by the core language. The application packages are responsible for making the most suitable choice. This is already the case for NumPy and MatPy which use opposite semantics. Adding new operators will not break this. See also observation after subsection 2 in the Examples below. The issue of numerical precision was raised, but if the semantics is left to the applications, the actual precisions should also go there. Examples -------- Following are examples of the actual formulas that will appear using various operators or other representations described above. 1. The matrix inversion formula: - Using op for object and ~op for element: b = a.I - a.I * u / (c.I + v/a*u) * v / a b = a.I - a.I * u * (c.I + v*a.I*u).I * v * a.I - Using op for element and ~op for object: b = a.I @- a.I @* u @/ (c.I @+ v@/a@*u) @* v @/ a b = a.I ~- a.I ~* u ~/ (c.I ~+ v~/a~*u) ~* v ~/ a b = a.I (-) a.I (*) u (/) (c.I (+) v(/)a(*)u) (*) v (/) a b = a.I [-] a.I [*] u [/] (c.I [+] v[/]a[*]u) [*] v [/] a b = a.I <-> a.I <*> u (c.I <+> va<*>u) <*> v a b = a.I {-} a.I {*} u {/} (c.I {+} v{/}a{*}u) {*} v {/} a Observation: For linear algebra using op for object is preferable. Observation: The ~op type operators look better than (op) type in complicated formulas. - using named operators b = a.I @sub a.I @mul u @div (c.I @add v @div a @mul u) @mul v @div a b = a.I ~sub a.I ~mul u ~div (c.I ~add v ~div a ~mul u) ~mul v ~div a Observation: Named operators are not suitable for math formulas. 2. Plotting a 3d graph - Using op for object and ~op for element: z = sin(x~**2 ~+ y~**2); plot(x,y,z) - Using op for element and ~op for object: z = sin(x**2 + y**2); plot(x,y,z) Observation: Elementwise operations with broadcasting allows much more efficient implementation than Matlab. Observation: Swapping the semantics of op and ~op (by casting the objects) is often advantageous, as the ~op operators would only appear in chunks of code where the other flavor dominate. 3. Using + and - with automatic broadcasting a = b - c; d = a.T*a Observation: This would silently produce hard-to-trace bugs if one of b or c is row vector while the other is column vector. Miscellaneous issues: --------------------- 1. Need for the ~+ ~- operators. The objectwise + - are important because they provide important sanity checks as per linear algebra. The elementwise + - are important because they allow broadcasting that are very efficient in applications. 2. Left division (solve). For matrix, a*x is not necessarily equal to x*a. The solution of a*x==b, denoted x=solve(a,b), is therefore different from the solution of x*a==b, denoted x=div(b,a). There are discussions about finding a new symbol for solve. [Background: Matlab use b/a for div(b,a) and a\b for solve(a,b).] It is recognized that Python provides a better solution without requiring a new symbol: the inverse method .I can be made to be delayed so that a.I*b and b*a.I are equivalent to Matlab's a\b and b/a. The implementation is quite simple and the resulting application code clean. 3. Power operator. Python's use of a**b as pow(a,b) has two perceived disadvantages: - Most mathematicians are more familiar with a^b for this purpose. - It results in long augmented assignment operator ~**=. However, this issue is distinct from the main issue here. 4. Additional multiplication operators. Several forms of multiplications are used in (multi-)linear algebra. Most can be seen as variations of multiplication in linear algebra sense (such as Kronecker product). But two forms appear to be more fundamental: outer product and inner product. However, their specification includes indices, which can be either - associated with the operator, or - associated with the objects. The latter (the Einstein notation) is used extensively on paper, and is also the easier one to implement. By implementing a tensor-with-indices class, a general form of multiplication would cover both outer and inner products, and specialize to linear algebra multiplication as well. The index rule can be defined as class methods, like, a = b.i(1,2,-1,-2) * c.i(4,-2,3,-1) # a_ijkl = b_ijmn c_lnkm Therefore one objectwise multiplication is sufficient. 5. Bitwise operators. Currently Python assigns six operators to bitwise operations: and (&), or (|), xor (^), complement (~), left shift (<<) and right shift (>>), with their own precedence levels. This is related to the new math operators in several ways: - The proposed new math operators use the symbol ~ that is "bitwise not" operator. This poses no compatibility problem. - The symbol ^ might be better used for pow than bitwise xor. But this depends on the future of bitwise operators. It does not immediately impact on the proposed math operator. - The symbol | was suggested to be used for matrix solve. But the new solution of using delayed .I is better in several ways. - The bitwise operators assign special syntactical and semantical structures to operations that are not as fundamental as math. Most of their usage could be replaced by a bitwise module with named functions. Removing ~ as a single operator could also allow unification between bitwise and logical operators (see below). However, this issue is separate from the current proposed extension. 6. Lattice operators. It was suggested that similar operators be combined with bitwise operators to represent lattice operations. For example, ~| and ~& could represent "lattice or" and "lattice and". But these can already be achieved by overloading existing logical or bitwise operators. On the other hand, these operations might be more deserving for infix operators than the built-in bitwise operators do (see below). 7. Alternative to special operator names used in definition, def "+"(a, b) in place of def __add__(a, b) This appears to require greater syntactical change, and would only be useful when arbitrary additional operators are allowed. 8. There was a suggestion to provide a copy operator :=, but this can already be done by a=b.copy. Impact on possible future extensions: ------------------------------------- More general extensions could lead from the current proposal. Although they would be distinct proposals, they might have syntactical or semantical implications on each other. It is prudent to ensure that the current extension do not restrict any future possibilities. 1. Named operators. The news group discussion made it generally clear that infix operators is a scarce resource in Python, not only in numerical computation, but in other fields as well. Several proposals and ideas were put forward that would allow infix operators be introduced in ways similar to named functions. The idea of named infix operators is essentially this: Choose a meta character, say @, so that for any identifier "opname", the combination "@opname" would be a binary infix operator, and a @opname b == opname(a,b) Other representations mentioned include .name ~name~ :name: (.name) %name% and similar variations. The pure bracket based operators cannot be used this way. This requires a change in the parser to recognize @opname, and parse it into the same structure as a function call. The precedence of all these operators would have to be fixed at one level, so the implementation would be different from additional math operators which keep the precedence of existing math operators. The current proposed extension do not limit possible future extensions of such form in any way. 2. More general symbolic operators. One additional form of future extension is to use meta character and operator symbols (symbols that cannot be used in syntactical structures other than operators). Suppose @ is the meta character. Then a + b, a @+ b, a @@+ b, a @+- b would all be operators with a hierarchy of precedence, defined by def "+"(a, b) def "@+"(a, b) def "@@+"(a, b) def "@+-"(a, b) One advantage compared with named operators is greater flexibility for precedences based on either the meta character or the ordinary operator symbols. This also allows operator composition. The disadvantage is that they are more like "line noise". In any case the current proposal does not impact its future possibility. These kinds of future extensions may not be necessary when Unicode becomes generally available. 3. Object/element dichotomy for other types of objects. The distinction between objectwise and elementwise operations are meaningful in other contexts as well, where an object can be conceptually regarded as a collection of homogeneous elements. Several examples are listed here: - List arithmetics [1, 2] + [3, 4] # [1, 2, 3, 4] [1, 2] ~+ [3, 4] # [4, 6] ['a', 'b'] * 2 # ['a', 'b', 'a', 'b'] 'ab' * 2 # 'abab' ['a', 'b'] ~* 2 # ['aa', 'bb'] [1, 2] ~* 2 # [2, 4] - Tuple generation [1, 2, 3], [4, 5, 6] # ([1,2, 3], [4, 5, 6]) [1, 2, 3]~,[4, 5, 6] # [(1,4), (2, 5), (3,6)] This has the same effect as the proposed zip function. - Bitwise operation (regarding integer as collection of bits, and removing the dissimilarity between bitwise and logical operators) 5 and 6 # 5 5 or 6 # 5 5 ~and 6 # 4 5 ~or 6 # 7 - Elementwise format operator (with broadcasting) a = [1,2,3,4,5] print ["%5d "] ~% a # print ("%5s "*len(a)) % tuple(a) a = [[1,2],[3,4]] print ["%5d "] ~~% a - Using ~ as generic elementwise meta-character to replace map ~f(a, b) # map(f, a, b) ~~f(a, b) # map(lambda *x:map(f, *x), a, b) More generally, def ~f(*x): return map(f, *x) def ~~f(*x): return map(~f, *x) ... There are probably many other similar situations. This general approach seems well suited for most of them. In any case, the current proposal will not negatively impact on future possibilities. Note that this section discusses compatibility of the proposed extension with possible future extensions. The desirability or compatibility of these other extensions themselves are specifically not considered here. -- Huaiyu Zhu hzhu at users.sourceforge.net Matrix for Python Project http://MatPy.sourceforge.net From loewis at informatik.hu-berlin.de Thu Aug 10 15:44:46 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 10 Aug 2000 21:44:46 +0200 Subject: file handling References: <8mtt9m$90j$1@nnrp1.deja.com> Message-ID: tjernstrom at my-deja.com writes: > I have written a small script that process html-files. All I need to do > is find a way to send all html files in a directory to this file while > ignoring the rest of the files in this directory (and do the same for > all the subdirectories). For a single directory, os.listdir gives a list of file names; you could filter the .html files yourself. Or you could use glob.glob to filter *.html. For a hierarchy, you can use os.path.walk; again, you'd have to filter file names yourself - there is no recursive version of glob.glob. However, the filtering can be easily done with fnmatch.fnmatch. Regards, Martin From just at letterror.com Sun Aug 27 05:47:55 2000 From: just at letterror.com (Just van Rossum) Date: Sun, 27 Aug 2000 10:47:55 +0100 Subject: Getting the reference count References: <8oaguf$imj$1@newsg2.svr.pol.co.uk> Message-ID: <39A8E3BC.CB177B6D@letterror.com> Makhno wrote: > > Is it possible to get the reference count of a PyObject* object? > I'm surre it must be, but I can't see it documented anywhere. > > Something similar to Perl's SvREFCNT() Macro would be great. sys.getrefcount(object) Note that this always returns one more than the actual value, as there's always an additional ref when inside sys.getrefcount(). Just From alex at magenta.com Mon Aug 14 11:51:22 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 14 Aug 2000 17:51:22 +0200 Subject: [win32com] Print html References: <39945697.F47A13EE@VerizonWireless.com> <8n1poe0mah@news1.newsguy.com> <3997DBBF.E727F1DB@VerizonWireless.com> <8n8nlq02uu@news2.newsguy.com> <3997F205.3034BBBF@VerizonWireless.com> Message-ID: <8n94oh0dc1@news2.newsguy.com> "Bill Scherer" wrote in message news:3997F205.3034BBBF at VerizonWireless.com... [snip] > > > This is how I get my handle to IE: > > > I ran makepy.py for shdocvw.dll > > > import win32com.client > > > ie = win32com.client.Dispatch("InternetExplorer.Application.1") > > > > So ie.ExecWB(6,2) should work just fine, I think. > > Yup, this works fine. The only snag I found is that I have to put a small > delay between the Navigate call and the ExecWB call (time.sleep(1)). Not very reliable; it would, I think, be better to wait for document-complete. Unfortunately, the document-complete event is not currently working (sigh). See separate thread about that; I've managed to reproduce the problem but not to diagnose it, yet; something is eating the document-complete, before-navigate, and navigate-complete events, only when the event handler is Python (they get received all right by a generic event handler written in C++/ATL). The best temporary work-around is probably to loop *checking that the ReadyState becomes 4*, which means completion. This will let you print documents which take a long time arriving, too. Alternatively, you could hook another event, which tells you about what's happening to commands (are they enabled/disabled), but if I were you I would avoid events until and unless they're fixed or you're truly stuck without them; the "busy loop" in this case, where you can check say every 0.1 seconds, is not too bad. Inelegant, but pragmatically OK. > Being IE, this call will print doc files, too. I expect that should work for > any file that ie can display via an embedded com server... Yes, any ActiveDocument should work if it's set up that way (to let the IE user print it out with File/Print, say). Basically, IE is, among many other useful things, an excellent generic container for documents, controls, etc, and it seems to be that you're using it in this capacity here (plus, as an HTML renderer when the document is specifically an HTML one; of course, the HTML rendering is actually performed by another component, but IE houses that component [a control] "transparently" for you). > Thanks for your help! You're most welcome! Alex From hniksic at iskon.hr Tue Aug 8 10:52:19 2000 From: hniksic at iskon.hr (Hrvoje Niksic) Date: 08 Aug 2000 16:52:19 +0200 Subject: Creating Python "executables" on Windows? References: <8mp4at$e38$1@news1.wdf.sap-ag.de> Message-ID: "Daniel Dittmar" writes: > - if you're using the DOS prompt, you can set the environment variable > PATHEXT to include .py. How do I do that? When I try `echo %PATHEXT%', I only get "ECHO is on". Something like `SET PATHEXT=.py' doesn't seem to do the trick either. > If Python is properly installed (the command 'assoc .py' prints > '.py=Python.File'), `assoc .py' prints "Bad command or file name". > python scripts can now be placed in your path and will be found. That would be very cool. I've installed Python using the installer provided on www.python.org (py152.exe). I'm not sure how I missed the assoc thing. > From the docs: To use PythonLauncher to start a script named > 'foo.py', make a copy of PythonLauncher named 'foo.exe' and place it > somewhere in the path. That seems similar to the .BAT solution -- two files per script. From alex at magenta.com Sat Aug 26 03:48:53 2000 From: alex at magenta.com (Alex Martelli) Date: Sat, 26 Aug 2000 09:48:53 +0200 Subject: Looking for Python programmers--where to search? References: <3998C541.4FC15982@san.rr.com> <39a3d9cb.4496054@news.laplaza.org> <39A6EAA6.1E6FC421@estinc.com> Message-ID: <8o7t1t01tov@news1.newsguy.com> "Eric Lee Green" wrote in message news:39A6EAA6.1E6FC421 at estinc.com... [snip] > where the most efficient way of handling things was to query all the data out > into one list then iterate over the list with a 'for' loop, and he went > through a bunch of hooplah with cursors to implement the same thing -- because > in "C", you can't work on lists without writing a bunch of code). My only > conclusion can be that while C++ programmers can learn the basics of the > Python language in an hour, it takes them a lot longer than an hour to be able > to write real programs in a timely manner using the language. A real C++ programmer, as opposed to a C one, would not have had a problem in your example, since in C++, as opposed to C, you *can* work with sequences and mappings without writing much extra code. The standard C++ library promotes the 'generic programming' paradigm, which has very close parallels with Python's ways. Sure, lots of so-called C++ programmers aren't -- they have never bothered exploiting the standard language features; those will take a bit more time to get up to speed in Python. > > If you bend a little on location your lives will get a whole lot > > easier trying to fill those difficult spots! > > A few years ago I would have agreed with you. The problem is that projects are > becoming more and more complex, and as they become more complex, interactions > become more complex. A typical project ten years ago had one component type -- Funny, the trend as I've noticed it is exactly the other way around -- our company has been opening development labs in a lot of sites around the world, to maximize our chances of getting the best people on board even if they want to live far from our main location, and my experience is that the technology's progress is making it easier, not harder, to handle. That little word 'component' is the key. A few years ago our applications were rather monolithic -- interactions between theoretically separate subsystems rather "thick", etc. Now, there are a lot of components, their interactions constrained to architected interfaces. We're not all the way there yet, but, as a trend, it's getting much more feasible, not less, to move development to a bunch of separate locations. Alex From mikeb at mitre.org Thu Aug 10 08:19:35 2000 From: mikeb at mitre.org (Mike Brenner) Date: Thu, 10 Aug 2000 08:19:35 -0400 Subject: WxPython tutorial References: <20000810002402.49F131D1FB@dinsdale.python.org> Message-ID: <39929DD7.A106662C@mitre.org> > Thanks. I tried the demos. They are a bit over the top of my level. I > will give them a try again. Also I will probably have to wait till a > good tutorial comes up. > > BTW: If you have written any medium sized application or even something > that demonstrates creation of a complete application of anysize I could > use it as a great help. The demos seem good enough to teach how to put simple gui and other stuff on the screen. The hidden secret is: Start with the Hangman Game. There are 2 examples that would be nice to have: (1) how to cut and paste pixels from the screen and the clipboard (2) how to set up the frames for an application The missing examples is a wxPaint app that draws, cuts, and pastes pixels, with mouse-hot regions that jump to other parts of the program. From MarkH at ActiveState.com Wed Aug 9 22:30:52 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 10 Aug 2000 02:30:52 GMT Subject: import from file not on the PYTHONPATH References: <8mscaq$6h6$1@nnrp1.deja.com> Message-ID: wrote in message news:8mscaq$6h6$1 at nnrp1.deja.com... > Is there a way to specify a path for the file that a module is located > in? > > something like: > import '/dir1/dir2/mymodule.py' Try: import sys sys.path.insert(0, "/dir1/dir2") import mymodule del sys.path[0] > I'm pretty new to python, so I am scared that this is a really dumb > question :-) Nah - it just takes a while to get used to how consenting Python really is - lets you poke almost anywhere :-) Mark. From niels at endea.demon.nl Mon Aug 28 12:08:26 2000 From: niels at endea.demon.nl (Niels Diepeveen) Date: Mon, 28 Aug 2000 18:08:26 +0200 Subject: gratuitous new features in 2.0 References: <7ba5.39a2ccf0.27c0b@yetix.sz-sb.de> <39A6B6B8.23D69134@endea.demon.nl> <8o6k16$lip$1@slb0.atl.mindspring.net> <8o9it1$fle$1@nntp9.atl.mindspring.net> Message-ID: <39AA8E7A.AD2F664E@endea.demon.nl> Andrew Dalke schreef: > I already do that. print is for interactive mode (just like "import *"), > debugging and for top-level code which will never be used in a library. > Everything else takes a file-like object using write. Much the same here. > Hmm, there is a problem mixing the two mechanisms. Some of my code > just passes the 'write' function/method, and not the file object. This > could not be passed to a library expecting a file object for use with > '>>', at least, not without a wrapper object. Don't you have that problem already with some of the standard library? > Allowing '>>' means you > can have libraries which don't talk to each other very easily. Unless > "print >> write_function" checks for the "write" method and if that > fails, if it's callable. Ugh. That would be tricky, because print doesn't only need the .write() method, but also the .softspace flag. I suppose it could use write.__self__.softspace or something, but eh... -- Niels Diepeveen Endea automatisering From gvwilson at nevex.com Tue Aug 22 10:34:09 2000 From: gvwilson at nevex.com (gvwilson at nevex.com) Date: Tue, 22 Aug 2000 14:34:09 GMT Subject: Software Carpentry Testing Category Restarting Message-ID: <8nu311$gg5$1@nnrp1.deja.com> August 22, 2000 The Software Carpentry Project (http://www.software-carpentry.com) is pleased to announce that the design competition for an Open Source regression testing tool is being re-started. Information regarding background, requirements, and procedure can be found at: http://www.software-carpentry.com/sc_test/ If you would like to participate, please join the discussion list by sending mail to "sc-discuss-subscribe at software-carpentry.com" (or to "sc-discuss-digest-subscribe at software-carpentry.com" for the digestified version), or contact Greg Wilson at "info at software-carpentry.com", or on +1 (416) 504 2325 ext. 229. Participants in the first design competition earlier this year are asked to note that there have been some procedural changes, which are described on the page URL'd above. We look forward to hearing from you, Greg Wilson Software Carpentry Project Coordinator http://www.software-carpentry.com Sent via Deja.com http://www.deja.com/ Before you buy. From syver.enstad at sensewave.com Sat Aug 12 19:44:24 2000 From: syver.enstad at sensewave.com (Syver Enstad) Date: Sun, 13 Aug 2000 01:44:24 +0200 Subject: PythonWin and Norwegian characters. References: <8n1ilq$pd2$1@troll.powertech.no> <5_2l5.1924$gP5.19865@news-server.bigpond.net.au> Message-ID: <8n4ntk$ubl$1@troll.powertech.no> >you may prefer the results. Great, that did the trick. PythonWin 132 (its always a good idea to mention the version number when > reporting a problem) uses code page 65001 which is UTF-8, as do recent > versions of IDLE. I'm using Pyhon ver. 1.5.2 and win32all 132. I didn't experience the problem with IDLE. Thank you very much, for a moment I thought I had to use IDLE instead of PythonWin. While IDLE is cool, PythonWin has a couple of features I really like, and feel a bit crippled without. From herzog at online.de Fri Aug 11 12:29:32 2000 From: herzog at online.de (Bernhard Herzog) Date: 11 Aug 2000 18:29:32 +0200 Subject: python: bug or feature? References: <8msimd$bia$1@nnrp1.deja.com> <8n137t$kkn$1@nnrp1.deja.com> Message-ID: Keith Murphy writes: > why not use &&, ||, etc for boolean and &, |, etc for bitwise? A better question to ask IMO is why does Python use keywords for the logical operators but special characters for the bitwise operators? This may just be a different phrasing of your question. I think one reason might have been that "and" and "or" influence the control flow (the second operand is only evaluated if necessary to determine the result) and that they can't be overloaded (if they could be overloaded, the second operand would always have to be evaluated) The other keyword operators (is, is not, in, not in) can't be overloaded either, although that's going to change for in, IIRC. I don't think introducing && and || for the logical operators would be a good idea for Python. OTOH, keywords for the bitwise operations would be OK, IMO, but that's something for Python 3K. -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://sketch.sourceforge.net/ From scarblac-spamtrap at pino.selwerd.nl Wed Aug 30 13:25:01 2000 From: scarblac-spamtrap at pino.selwerd.nl (Remco Gerlich) Date: 30 Aug 2000 17:25:01 GMT Subject: Problem with JPython! References: <8ibr5.33599$g53.601044@news5.giganews.com> Message-ID: ARG3000 wrote in comp.lang.python: > Running the following string > "\nif 1.0 > 2.0:\n\tprint 1.0\nelse:\n\tprint 2.0\n" > using > org.python.util.PythonInterpreter > > exec I get result '2.0' printed to stdout. this is what I would expect > > Running the same string through eval it bombs. > Is there anything I should be aware of that i'm doing wrong? Eval takes expressions. 'if' is a command, just like 'print', so that string isn't an expression. -- Remco Gerlich, scarblac at pino.selwerd.nl Hi! I'm a .sig virus! Join the fun and copy me into yours! From mark.w.daley at intel.com Mon Aug 7 14:54:31 2000 From: mark.w.daley at intel.com (Daley, Mark W) Date: Mon, 7 Aug 2000 11:54:31 -0700 Subject: time.strptime() not supported in windows? what the..... Message-ID: <75F7304BB41CD411B06600A0C98414FCB3684B@ORSMSX54> When I went looking for this, someone provided me with a solution they had already written. The .pyc file is attached, since the .py file just contains the following text: """ strptime version 1.3, Time-stamp: <96/09/23 21:22:24 flognat> The reverse of strftime. Copyright (C) 1996 Andy Eskilsson, flognat at fukt.hk-r.se This is free software; unrestricted redistribution is allowed under the terms of the GPL. For full details of the license conditions of this software, see the GNU General Public License. And here comes the documentation: Throw a string and a format specification at strptime and if everything is ok you will get a tuple containing 9 items that are compatible with pythons time-module. interface: strptime(inputstring, formatstring) Little errorchecking... so you'd better now what you are doing. example: from strptime import * mktime(strptime("26/6 1973", "%d/%m %Y")) And voila you have the second when the author of this function was born. The supported format identifiers are: %a weekday in short text-form, e.g. Mon %A weekday in long text-form, e.g. Monday %b month in short text-form, e.g. Jul %B month in long text-form e.g. July %c the format specified by DateAndTimeRepresentation %d the day in month in numeric form, e.g. 24 %H hour in 24 hour form %j julian day (day of year) %m month in numeric format %M minute %S second %T Time in '%H:%M:%S'-format %w weekday, 0=monday %x date in format represented by DateRepresentation %X time in format represented by TimeRepresentation %y year in short form %Y year in long form %% %-sign I have done some thinking here (*REALLY*) and it is possible to configure this module so it uses other languages by adding their names to the dictionaries first in the file, and setting the variable LANGUAGE. For your exercise I have inserted the swedish names ;-) The lfind, name, complex, numbers and parse functions are for internal use, called by strptime. Uh.. oh yeah.. if you want to get in touch with me.. I am reachable at flognat at fukt.hk-r.se, the newest version of this file can probably be found somewhere close to http://www.fukt.hk-r.se/~flognat If you like it, send a postcard to Andy Eskilsson K?mn?rsv. 3b228 S-226 46 Lund Sweden So, if you like, send him a postcard, but I think the code is pretty useful. - Mark ---------------------------------------------- The opinions expressed are mine, and are not necessarily those of my employer. -----Original Message----- From: David C. Ullrich [mailto:david_ullrich at my-deja.com] Sent: Monday, August 07, 2000 9:47 AM To: python-list at python.org Subject: Re: time.strptime() not supported in windows? what the..... In article , "Michael Morrison" wrote: > > Now this is odd.... > > windows: > >>> time.strptime("08/07/2000 11:03", "%m/%d/%Y %H:%M") > Traceback (innermost last): > File "", line 0, in ? > AttributeError: strptime > > unix: > >>> time.strptime("08/07/2000 11:03", "%m/%d/%Y %H:%M") > (2000, 8, 7, 11, 3, 0, 0, 220, 0) > >>> time.asctime(time.strptime("08/07/2000 11:03", "%m/%d/%Y %H:%M")) > 'Mon Aug 7 11:03:00 2000' > > Okay...WHY isn't this function supported in windows? When I asked about this the answer appeared to be "because it isn't". I'd already worked around _my_ problem, so I didn't notice the posts a little later pointing out that there are also date-parsing functions in the rfc822 module that may help. > That's got to be the > craziest thing I've ever seen in python so far. If you need, _ILL_ make the > function for the windows platform. > > -- Oh, dejanews lets you add a sig - that's useful... Sent via Deja.com http://www.deja.com/ Before you buy. -------------- next part -------------- A non-text attachment was scrubbed... Name: strptime.pyc Type: application/octet-stream Size: 8986 bytes Desc: not available URL: From matt at matty.dyndns.org Wed Aug 9 20:38:20 2000 From: matt at matty.dyndns.org (Matthew R. MacIntyre) Date: Thu, 10 Aug 2000 00:38:20 GMT Subject: variable variables? Message-ID: Hello all, Does python support "variable variables"? I've been trying something like this, but to no avail: var1 = "foo" varname = "var1" then i want to do something like: {varname} = bar print var1 => bar Is this do-able? More specifically, i'm trying to set instance variables in a class using an argument containing a dictionary in the constructor .... something like this: class TestClass: def __init__(self,dict): for x in dict.keys() self._{x} = dict[x] def show(self): print self._var1 print self._var2 args = { 'var1' : "value1", 'var2' : "value2" } test = TestClass(args) test.show() I want the test.show() to print : value1 value2 but I'm having no such luck on the various variations of this theme that I've been dreaming up. Is this even possible to do? Is it an outrageous thing to try to do? If so, what is a better way to do it? Thanks, -matt From quinn at ngwee.ugcs.caltech.edu Wed Aug 16 22:24:50 2000 From: quinn at ngwee.ugcs.caltech.edu (Quinn Dunkan) Date: 17 Aug 2000 02:24:50 GMT Subject: PYTHON IS CRAP References: <8ndg6e01kci@news2.newsguy.com> <8ner5q$48d$1@slb7.atl.mindspring.net> Message-ID: On 16 Aug 2000 17:47:57 -0400, David Bolen wrote: >aahz at netcom.com (Aahz Maruch) writes: >> Use Lynx! > >While certainly textual, it's still too "heavy" for my tastes when all >I want is a simple 'man' lookup. Also, I don't think you can search >directly from the command line, can you? I use w3m for python docs and find it quite convenient. / works as forward search just like in all right-thinking programs. 'w3m /usr/doc/python/index.html' makes for a nice man replacement. From rob at hooft.net Wed Aug 2 08:24:11 2000 From: rob at hooft.net (Rob Hooft) Date: 02 Aug 2000 14:24:11 +0200 Subject: improper position of continue? Message-ID: no203[146]~%3% python Python 2.0b1 (#31, Aug 2 2000, 10:19:01) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam Copyright 1995-2000 Corporation for National Research Initiatives (CNRI) >>> while 1: ... try: ... continue ... finally: ... pass ... SyntaxError: 'continue' not properly in loop (line 3) >>> Why? I was attempting this in a setting like: while 1: os.chdir('subdir') try: [stuff with continue] finally: os.chdir('..') Regards, Rob -- ===== rob at hooft.net http://www.hooft.net/people/rob/ ===== ===== R&D, Nonius BV, Delft http://www.nonius.nl/ ===== ===== PGPid 0xFA19277D ========================== Use Linux! ========= From tgagne at ix.netcom.com Wed Aug 2 11:30:30 2000 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Wed, 02 Aug 2000 11:30:30 -0400 Subject: smtplib and Python 1.5.1 References: Message-ID: <39883E96.2B472D4@ix.netcom.com> This sounds like the anomaly of running on a Windows-like system. If you could attach to another unix mailer I'd be curious if you would have the same problem. It may be a problem with the flavor of sendmail being used by your ISP--unless the proclivities of \c\n and \n are supposed to be system dependent where sendmail is concerned. From olivierS.dagenaisP at canadaA.comM Fri Aug 11 22:58:26 2000 From: olivierS.dagenaisP at canadaA.comM (Olivier Dagenais) Date: Sat, 12 Aug 2000 02:58:26 GMT Subject: Loading new code... References: <8F8DD8044gmcmhypernetcom@199.171.54.194> Message-ID: Gordon, First, thanks for answering, I didn't think I was going to get an answer... > What you're trying to do can't be done, because there is no "global" > namespace. If you have 2 modules that both want to see module X, they both > must "import X". Only one of those imports will involve any actual work, > the second one will just gain access to the already imported module Fair enough, I had to at least ask... It would have been silly to do as you say if it wasn't necessary... And the last thing I want to do is to code something silly... > You want to use ihooks or imputil (Greg Stein's module on lyra.org). You'll > probably find the latter easier to use. The imp module really only gives > you access to some low level routines in the import process. There's a lot > more than goes on than just getting the code object. (And what you actually > want to do at the bottom level is unmarshal a compiled code object, not > exec it.) Sorry, I should have been more precise: there's actual Python instructions in the database, not "compiled code objects"... Does that make it easier? I get that idea from the documentation, saying a function or class definition must be "declared" before it is used (sort of like not using forward declarations in C), so, if I exec some code that has a class definition before I attempt to construct it, am I good to go? For example: # open database cursor.execute ( "SELECT Instructions FROM Code" ) for class_definition in cursor.fetchall ( ): exec ( class_definition[0] ) ...so, knowing that I have just loaded [from the database] a class called, say, "Blarg", can I do: exec ( "self.aNewBlarg = Blarg ( 'arg1', 'arg2' )" ) > But reloading a module is another can of worms. For one thing, reloading > does no good unless everyone is accessing the module through the module > object (IOW, one "from X import ..." and you're screwed). Understood. So, assuming there are no "from X import ..." (or no "import ...", either), can I simply re-exec the class definition(s) that have been changed? (reloading isn't THAT important, however loading arbitrary classes whose names are unknown is a priority) Thanks! -- ---------------------------------------------------------------------- Olivier A. Dagenais - Carleton University - Computer Science III From tgagne at ix.netcom.com Wed Aug 9 12:15:28 2000 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Wed, 09 Aug 2000 12:15:28 -0400 Subject: A class for C-like structuures in Python References: <3990CD96.ADF0A0D8@ix.netcom.com> <8mr2t101c5v@news2.newsguy.com> <399145B4.B3771618@ix.netcom.com> Message-ID: <3991839F.B5783118@ix.netcom.com> Hmm... Now I get the following instantiating the structure: Traceback (innermost last): File ".//isdclient.py", line 4, in ? h = IsdHeader() File "./IsdIO.py", line 7, in __init__ CStructure.__init__(self, ( File "./CStructure.py", line 11, in __init__ self.fmt = self.fmt + f File "./CStructure.py", line 22, in __setattr__ self.__checkname(name) File "./CStructure.py", line 15, in __checkname raise AttributeError, "No struct-field is named " + name AttributeError: No struct-field is named fmt I think there's a problem mixing __dict__ with standard variable definitions. Whether I use __dict__['fmt'] = '' or the simpler self.fmt = '' I get the same result (above) tgagne:/home/tgagne/work/isect/python head -20 CStructure.py import struct class CStructure: def __init__(self, theTuples): self.__dict__['members'] = {} self.__dict__['fmt'] = '' self.__dict__['shape'] = theTuples for n,f in self.shape: self.members[n] = None self.fmt = self.fmt + f def __checkname(self, name): if not self.members.has_key(name): raise AttributeError, "No struct-field is named " + name def __getattr__(self, name): self.__checkname(name) return self.members[name] From yanivk at my-deja.com Mon Aug 21 09:36:17 2000 From: yanivk at my-deja.com (yanivk at my-deja.com) Date: Mon, 21 Aug 2000 13:36:17 GMT Subject: print to stdout and to a log file..... References: Message-ID: <8nrb8f$aql$1@nnrp1.deja.com> In article , "Amir Mistric" wrote: > Hi > If I have a command > os.system("program.exe %s %s" %(file1,file2)) > how can I capture the output of this execution to both stdout and to a lets > say log file..... > > I tried > > log_detail = os.popen("program.exe %s %s" %(file1,file2)) > LogFile.write("%s" % log_detail.read()) > > but this did not write output to neither stdout nor my log file...... I'm not sure this will help you, but you might want to try (on Unix): stdout, stdin, stderr = os.popen3("program.exe") then you need to bind these to a callback that will be called whenever any kind of input arrives. > > Also another question I have is : > Is it possible to have one print statement that wil write to stdout and to a > file? For example: > print "---------------------------------------------------------" > LogFile.write("--------------------------------------------------------- \n") > > Can this be accomplished in some other fashion where only one line of code > can be written???? > Not that I know of > Thanks > Amir > > Yaniv Sent via Deja.com http://www.deja.com/ Before you buy. From cjw at connection.com Sun Aug 13 10:31:43 2000 From: cjw at connection.com (Colin J. Williams) Date: Sun, 13 Aug 2000 10:31:43 -0400 Subject: incrementation operators? References: <8n5qrg12h1o@news2.newsguy.com> <20000813151344.L14470@xs4all.nl> Message-ID: <3996B14F.5BE77F8D@connection.com> Thomas, Apologies for entering this so late in the game. The PEP gives a full description of the various operators, but provides no rationale for their introduction. I wonder how frequently this sort of operation in place would be used in practice. Does the frequency of likely use balance the increased clutter? One of the attractive features of Python is its relative simplicity. Would we lose some of this simplicity for little practical gain? These operators exist in other languages. Is there a justification for including them in Python? I hope that I am not too late for some sober second thoughts. Colin W. Thomas Wouters wrote: > On Sun, Aug 13, 2000 at 01:29:23PM +0300, Moshe Zadka wrote: > > On Sun, 13 Aug 2000, Alex Martelli wrote: > > > > "CHRIS" wrote in message news:399659A1.477A4A85 at unk.ororr... > > > > Are there any incrementation or decrementation operators in Python? > > > > Not yet, but they're scheduled to be in the forthcoming Python 2.0. > > > Just to clear up the issues here: += and ilk are scheduled for Python 2.0. > > ++ and -- are not scheduled for any future release, and probably don't > > belong in Python at all. > > Indeed. And if you want to test the augmented assignment operators > (+=/-=/etc that is, not ++/--) give the patch on SourceForge a try: > > http://sourceforge.net/patch?func=detailpatch&patch_id=100699&group_id=5470 > > and/or provide feedback on the PEP on this subject: > > http://python.sourceforge.net/peps/pep-0203.html > > Now is the last chance to provide any useful feedback, 2.0 is going in a > feature freeze on Monday! > > -- > Thomas Wouters > > Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From dalke at acm.org Tue Aug 1 22:58:53 2000 From: dalke at acm.org (Andrew Dalke) Date: Tue, 1 Aug 2000 20:58:53 -0600 Subject: Debugging strategy? References: <8m78ee$dds$1@news7.svr.pol.co.uk> Message-ID: <8m82mi$63b$1@slb0.atl.mindspring.net> Duncan Smith wrote in message <8m78ee$dds$1 at news7.svr.pol.co.uk>... >Has anyone any idea how I might tackle this problem? Does it >sound characteristic of a particular type of coding error (bearing in mind >I'm no computer scientist)? When I was working on some graph theory code, I designed it around a set of transformations where the results of the transformations had certain properties, sometimes called 'invariants'. Then in my code I could ask at various points "does it it meet the right invariants?" The debugging time went up a lot, but I could use it to figure out where the problem was and limit it to (usually) just a short set of code paths. > I find that either the tree has not been permuted > correctly, or the weight has not been calculated correctly So you have a tree and a transformation and a permuted tree, and the new tree wasn't permuted correctly. Can you write a test for incorrectly permuted trees then execute it after every transformation? If you know the final good tree, you can use that as the basis for debugging, so you won't have to do another 20K iterations. Once you have a good error case, try winnowing the input set down. For example, take one of the children of the top node of the tree and see if there's an error there. Then try the next. Descend until there are no more errors, the back up one and try to do it manually, comparing results. Or figure out if there's anything which makes that case unusual. Andrew From K.Mossman at adb.com.ph Wed Aug 30 00:49:15 2000 From: K.Mossman at adb.com.ph (Ken Mossman) Date: Wed, 30 Aug 2000 12:49:15 +0800 Subject: dont laugh Message-ID: <8oi3s4$8km$1@nobel2.pacific.net.sg> I have some JUNIOR staff and they are asking if there any CBT or multi-media courses for Python They are NEWBIES !! From kpmurphy at my-deja.com Mon Aug 7 17:02:54 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Mon, 07 Aug 2000 21:02:54 GMT Subject: changing parents Message-ID: <8mn85p$lpu$1@nnrp1.deja.com> how do you change a widget's parent? i expected it would look something like this: mywidget.config(parent=my_frame) ...but alas, this doesn't work. help! thanks, -->keith Sent via Deja.com http://www.deja.com/ Before you buy. From alex at magenta.com Mon Aug 28 14:45:21 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 28 Aug 2000 20:45:21 +0200 Subject: gratuitous new features in 2.0 References: <7ba5.39a2ccf0.27c0b@yetix.sz-sb.de> <8o026t0rdi@news1.newsguy.com> <3dg0nuspxp.fsf@kronos.cnri.reston.va.us> <8o4e4o$mat$1@slb3.atl.mindspring.net> <39A78701.720CCEA4@seebelow.org> <8o8qi302ls5@news1.newsguy.com> <39A9638D.CAE7308A@seebelow.org> <8od58h0rdo@news1.newsguy.com> Message-ID: <8oeca0016ph@news2.newsguy.com> "Keith Ray" wrote in message news:k_j_r_a_y-68E378.09043128082000 at nntp.ix.netcom.com... [snip] > >Practicality dictates not breaking good working code. Python has [snip] > What if 'print' and 'printto' were not treated as language keywords, > but as global identifiers, which could be overridden by user-defined > identifiers? Then the "dont't break working code" mantra would not be relevant. But, AFAI understand the Python compiler, such "global identifiers" would only serve for function calls (or methods), not statements. I'd be delighted to see the print-to-file functionality exposed as a function rather than a statement. But, AFAIK, it's just not going to happen. Somebody will no doubt wonder how comes that I (and other) are raising such a ruckus about "print>>file", far more than about other more massive changes forthcoming in Python 2.0. There are several reasons. In my case, I find most of the proposed changes deep and difficult to fully grasp -- with pluses and minuses, but, quite likely, more pluses than minuses. I'm quite willing to acquiesce in the BDFL's judgment about such difficult matters, beyond my full grasp. But "print >> file" is simple enough that I believe I can understand every implication -- because there aren't all that many; so, I feel able to come to my own judgment... and find that the core language is being changed (in a syntactically dubious and unpleasant way) to expose a functionality which could perfectly well (indeed better) exposed as a function instead. As the issue is simple enough for me to feel that I grasp its implications, I feel empowered to speak out on the subject. In a way, it's a manifestation of one of "Parkinson's Laws" -- the committee time devoted to an issue being in inverse proportion to its actual depth and importance. Maybe list comprehensions, Unicode support, range literals, or augmented assignments, are ill-conceived; I doubt so, they seem very well designed to me, and I don't consider that I have grasped all the implications pro and con, anyway -- so, I'm not going to advance my personal judgment. OTOH, 'print>>file' is a wart -- and moreover, a simple enough one that even I can see that. So, I express my opinions in the matter -- just as, I suspect, are most others doing. Parkinson, no doubt, is meanwhile laughing from Empyreon...:-). Alex From cpr at emsoftware.com Fri Aug 18 18:44:06 2000 From: cpr at emsoftware.com (Chris Ryland) Date: Fri, 18 Aug 2000 22:44:06 GMT Subject: PEP 0214 - extended print statement Message-ID: Please forgive a relative Python newbie's whining (and forgive me if this has already been discussed in public), but I think the proposed extended print syntax is TERRIBLE. (Viz., simplifying, print >> outfile, something .) This seems very un-Pythonic in that it's overloading the >> operator and giving it a completely unrelated meaning in this one, lonely context. Since the print statement is already quite special, why overload an existing valid operator? Just add another (non-reserved, perhaps) keyword, along the lines of print something to outfile Comments? -- Cheers! / Chris Ryland, President / Em Software, Inc. / www.emsoftware.com From nicolas.menoux at wanadoo.fr Fri Aug 18 02:22:54 2000 From: nicolas.menoux at wanadoo.fr (nico) Date: Fri, 18 Aug 2000 08:22:54 +0200 Subject: How to build the PyXML module ? References: <8ngu0c$o1i$1@wanadoo.fr> <8nh39e$h7v$1@wanadoo.fr> Message-ID: <8nikq8$qf6$1@wanadoo.fr> Hi, Thanks to your help and the answers of the other members of this newsgroup, since I've rpmed the python-devel package and now it works fine ! Best Regards, "Bernhard Herzog" wrote in message news:m3zomb6agq.fsf at greebo.nodomain.de... > "nico" writes: > > > Hi, > > > > I've just installed Distutils package but when I setup the xlm package I got > > some errors due certainly to a wrong path for the Distutils. It seems it > > seeks in /var/tmp/Distutils-buildroot/usr/lib/python1.5..... instead of > > /usr/lib/python1.5... I guess. How to define this path or am I doing > > something wrong ? > > It would have helped if you had posted the traceback you sent me by mail > here as well. Anyway, the relevant bit of the traceback indicates that > the file /usr/lib/python1.5/config/Makefile is missing (since this is > only one line of an error message, I think it's OK to quote from a > private mail): > > distutils.errors.DistutilsPlatformError: invalid Python installation: > unable to open /usr/lib/python1.5/config/Makefile (Aucun fichier ou > r?pertoire de ce type) > > That file and the other files in /usr/lib/python1.5/config/ is part of > the python-devel RPM which should be on your Red Hat 6.2 CDs (it should > be available from Red Hat's ftp-servers as well, of course). Installing > that package should fix your problems. > > -- > Bernhard Herzog | Sketch, a drawing program for Unix > herzog at online.de | http://sketch.sourceforge.net/ From aahz at netcom.com Fri Aug 25 10:35:37 2000 From: aahz at netcom.com (Aahz Maruch) Date: 25 Aug 2000 14:35:37 GMT Subject: compiling with SSL support on Windows References: <14758.33287.507315.396536@bitdiddle.concentric.net> Message-ID: <8o607p$vkj$1@slb1.atl.mindspring.net> [posted & e-mailed] In article <14758.33287.507315.396536 at bitdiddle.concentric.net>, Jeremy Hylton wrote: > >https://sourceforge.net/bugs/?func=detailbug&bug_id=110683&group_id=5470 > >We have a bug report about compilation problems in the socketmodule on >Windows when using SSL support. Is there any Windows user with >OpenSSL who can look into this problem? Unfortunately, I don't have an NT box, but at my former job we were definitely able to compile SSL support on NT (I'm not certain it was OpenSSL, though). I hope that knowing it *can* be done is of some help. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The difference between "intelligence" and "wisdom": Londo and G'Kar --Aahz From ge at nowhere.none Thu Aug 31 15:10:49 2000 From: ge at nowhere.none (Grant Edwards) Date: Thu, 31 Aug 2000 19:10:49 GMT Subject: use COM remotely on Unix in python? References: <8om8cg$3um$1@nnrp1.deja.com> <8om90a$4ni$1@nnrp1.deja.com> Message-ID: jerry_spicklemire at my-deja.com wrote: > tiddlerdeja at my-deja.com wrote: >> Is it possible to use COM objects on a NT machine remotly from a UNIX >> machine using python? Possibly in a DCOM or RPC fashion? >See: http://www.vex.net/parnassus/apyllo.py/126307487.549099265 OK, did that. I didn't see any mention of Win32 COM objects. To which item on the page are you referring? -- Grant Edwards grante Yow! Are we live or at on tape? visi.com From grey at despair.rpglink.com Fri Aug 4 10:35:44 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 04 Aug 2000 14:35:44 GMT Subject: GTK/Gnome or TKinker? References: <398A4F06.A05D7B4D@yale.edu> <8me07o$29i$3@snic.vub.ac.be> Message-ID: On 4 Aug 2000 08:52:08 GMT, apardon at trout.vub.ac.be wrote: >Now there is one thing I don't like about Windows and that is how >it forces all kind of things on you. e.g. it isn't possible that >the window with the focus is not on top. This is an issue with the Z order at the OS level and has nothing to do with the interface. There are utilities out there that will give window focus yet not increase its Z order to the top of the stack just like the mouse (sloppy) focus on X. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From db3l at fitlinxx.com Tue Aug 29 17:23:40 2000 From: db3l at fitlinxx.com (David Bolen) Date: 29 Aug 2000 17:23:40 -0400 Subject: Weird Error References: <8ogukn$r3q$1@nnrp1.deja.com> <8ogv66$rrh$1@nnrp1.deja.com> Message-ID: dwassena at julian.uwo.ca writes: > Opps forgot the Attribute Error is: > > AttributeError: getQPath not attribute/undefined (whatever) Hmm, can you show the actual code where the error is occurring? You seem to have defined the getQPath method in the code you posted, so it may be that your problem is in how you try to refer to the method rather than the method itself. Unless there is proprietary information in there that you just can't post, trying to let us see code that is the actual code running (with as few edits as possible) and as completely as possible would be the most helpful. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From cut_me_out at hotmail.com Wed Aug 9 11:33:53 2000 From: cut_me_out at hotmail.com (Alex) Date: 09 Aug 2000 11:33:53 -0400 Subject: Can you use gprof to profile python extensions? Message-ID: Hi. I'd like to profile an extension I've written, and I'm having some trouble doing it. The extension is statically linked into python (version 2.0), and I recompiled python with OPT= -g -pg However, running python does not produce a file called gmon.out. Is it possible to use gprof with python, and if so, does anyone have a suggestion about what I might be doing wrong? Alex. From richard_chamberlain at ntlworld.com Sun Aug 20 03:18:18 2000 From: richard_chamberlain at ntlworld.com (Richard Chamberlain) Date: Sun, 20 Aug 2000 08:18:18 +0100 Subject: Python Strings References: <399F7547.734A249E@unk.ororr> Message-ID: <399F863A.48853BCD@ntlworld.com> Hi Chris, fromstr="aslfdj" tostr=fromstr Is that what you want? If you change fromstr to another string tostr will remain pointing at the first object "aslfdj". Or you could do something like tostr="" tostr.append(fromstr) strings are immutable so you don't have to worry about putting const in front of them ;-) immutable types in python are useful for dictionaries essentially. For a hashtable to be efficient it requires an unchanging key, so strings fit this bill. Richard CHRIS wrote: > > How can you make a character-by-character copy of one string to a target > string, with out using a temporary list type variable? IE (with out > doing somethin like this): > > fromstr = 'aslfdj'; > target = []; > for i in range(len(fromstr)): > #procssing done here > target.append(fromstr[i]); > > Also, what's the point of strings being immutable ?? If you want a > particular variable to be immutable, why not have some sort of constant > option? Like in C: > > static const char str[] = "Constant immutable string"; From neilh at scintilla.org Wed Aug 23 21:48:30 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Thu, 24 Aug 2000 01:48:30 GMT Subject: ANN: PyStream - a C++ stream emulation References: <7ba5.39a2ccf0.27c0b@yetix.sz-sb.de> <39A2EF6E.D21B7E35@seebelow.org> Message-ID: > Given that 1.6 and 2.0 are virtually 100.0% backward compatible, how do > these new constructs actually hurt anybody? If anything, aren't the > programs that _use_ the new constructs--not the new interpreter that > provides them--the problem? (But I'll bet you a dollar you won't write > "x = x + 1" very often once you've got "x += 1". ;-) You may be right there - we'll see. Adding to and subtracting from a number are very common so some feature to achieve this would be OK. I think Modula got this right with increment and decrement procedures, called "Inc" and "Dec" IIRC. > i've-never-found-myself-inclined-to-write-C-when-i-was-using-a-C++ > -compiler--ly y'rs, But I have found myself writing Perl as if it was Python. Neil From gregory.lielens at fft.be Wed Aug 9 04:34:34 2000 From: gregory.lielens at fft.be (Gregory Lielens) Date: Wed, 09 Aug 2000 10:34:34 +0200 Subject: [PEP draft 2] Adding new math operators References: <3I1k5.94984$5l3.1886335@afrodite.telenet-ops.be> Message-ID: <3991179A.7820AD52@fft.be> ben at co.and.co wrote: > > Huaiyu Zhu wrote: > > > Proposed extension > > ------------------ > > > > 1. New operators ~+ ~- ~* ~/ ~** ~+= ~-= ~*= ~/= ~**= are added to core > > Python. > > Some minor remark: > the '~' is an awful character to type a 'azerty'-keyboard (Alt Gr + '=' > on Belgian keyboard, '=' is located on '/'(qwerty)). Now, remember > the reason Belgian and French people like Python is of the relative > absence of braces '{}', which are located on an even more > finger-breaking position (Alt-Gr + 9 and Alt-Gr + 0, again on > Belgian keyboard). > > We do have ?, ?, ?, ?, ? and ? at very conveniant places. Perhaps > you could localize the operators ? On azerty (belgian version also, as you could guess from my name :-)), ? (degree symbol) is a quite obvious choice for this usage, in fact better than ~ because it is nor curently used in Python, and is (warning - highly personal opinion) more representative of the intended elementwise behavior (closer to matlab .*, for example). However, beeing ASCII, ~ is at least accessible on all types of keyboards, while trying to find ? on a qwerty keyboard could be fun - not to mention that some fonts does not have ?... The problem of lack of keyboard/font support is even stronger for unicode symbols, which imho support the proposed ~. Greg. From ronjeffries at acm.org Mon Aug 7 13:45:36 2000 From: ronjeffries at acm.org (Ronald E Jeffries) Date: Mon, 07 Aug 2000 13:45:36 -0400 Subject: Newbie question: Python Not Answering HTTP Page Message-ID: <79F23C65D6B57107.38C7B8C40F4A0514.D32F431AB2DD50B6@lp.airnews.net> I've had my ISP set up .py files in the cgi-bin directory to run Python. He thinks he's done that. But when I access those files, IE hangs and finally complains of a timeout, with the message CGI Timeout The specified CGI application exceeded the allowed time for processing. The server has deleted the process. I've put up a simple hello.py, which is: #! /usr/bin/python #hello print "Content-type: text/html\r" print "\r" print "\r" print " \r" print " Hello World\r" print " \r" print " \r" print "

Greetings, Terrans!

\r" print " \r" print "\r" (I've also used the same program with \n for \r and just plain print, e.g. print "" They all hang. Am I doing something wrong, or is it likely the setup on my ISP? Thanks! Ron Jeffries http://www.XProgramming.com From cjensen at bioeng.ucsd.edu Thu Aug 31 14:06:56 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Thu, 31 Aug 2000 11:06:56 -0700 Subject: XML creation Message-ID: <39AE9EC0.2FE1CF1D@bioeng.ucsd.edu> We have several arrays, some are multidimensional arrays, created with NumPy. We'd like store these arrays in an XML data structure. Is there a python script similar to shelve or pickle that will take an array and convert it to XML code? Thanks. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From gerryq at indigo.ie Wed Aug 30 06:05:24 2000 From: gerryq at indigo.ie (Gerry Quinn) Date: Wed, 30 Aug 2000 10:05:24 GMT Subject: Python in game development? References: <964351215.18988.0.pluto.d4ee0942@news.demon.nl> <8lh588$oti$3@news.fsu.edu> Message-ID: In article , kragen at dnaco.net (Kragen Sitaker) wrote: >In article , >Gerry Quinn wrote: >>Changing things at random and hoping the problem goes away is not the >>way to fix bugs. > >In general, I agree with you. But there are exceptions. > Good points. (Though incremental compilation means that it only takes a few seconds to change these things even with a compiler.) Still, plenty of coffee and pondering the source leads to the most bulletproof code, IMO. Most of the examples aren't really to do with bug-fixing. Gerry Quinn -- http://bindweed.com Puzzle / Strategy Games and Kaleidoscope for Windows Download evaluation versions free, no time limits New: Unique 2-player strategy game "Zen" >There are times when you don't know what your program should be doing >--- for example, what size to make a window border for a pleasant >visual effect, or which options to put on the main menu and which to >relegate to a submenu. > >At these times, instant turnaround is a very useful thing to have. >These times seem to occur rather frequently in my development >experience. > >There's also the argument that, if I make ten changes and then rerun my >test suite, a failure can be caused by any of the ten changes; while if >I rerun the test suite after each change, the failure can only be >caused by the change I just made. > >And there are times when the libraries or platform simply are not doing >what the documentation claims they will do; I run into this constantly >when programming in JavaScript. Instant feedback makes characterizing >their behavior much more pleasant. > >There's the final argument that correcting errors in your understanding >of your program as soon as possible is a very useful thing. When I'm >programming in environments with a single-stepping debugger, I usually >single-step through every line of my code the first time I run it to >make sure it's doing what I think it's doing. Read-eval-print loops >are also helpful for this kind of thing. From alex at magenta.com Fri Aug 4 14:27:27 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 4 Aug 2000 20:27:27 +0200 Subject: Registration errors on win32all.exe installation References: <20000804115222.13819.00001495@ng-cv1.aol.com> Message-ID: <8mf22b0242c@news1.newsguy.com> "FxItAL" wrote in message news:20000804115222.13819.00001495 at ng-cv1.aol.com... > Hello, > > I received the following 3 error msg's during the win32all.exe installation. > > "Registration of AXScript Engine COM > Python Interpreter COM > Python Dictionary COM server failed. > > Installation will continue, but this server will require manual registration > before it will function. > > exception.ImportError: DLL load failed: A device attached to the system is not > functioning." > > Running Win95 on a 486 DX2 66. (Don't laugh, will be upgrading soon:-) > > How do I manually register these items? It is possible that your system is lacking some up-to-date system DLL's, if it's that ancient. Installing a recent release of IE would likely fix that -- if IE 5.5 runs, you're likely to have very up-to-date system DLL's, and the IE installer sees to that (or used to; not sure if IE 5.5's installer still works that way). Alex From alex at magenta.com Wed Aug 9 05:30:01 2000 From: alex at magenta.com (Alex Martelli) Date: Wed, 9 Aug 2000 11:30:01 +0200 Subject: .NET available References: <3dn1invppe.fsf@kronos.cnri.reston.va.us> <8mpls3$3kr$1@agate.berkeley.edu> Message-ID: <8mr8ia01g1a@news2.newsguy.com> "Edward Jason Riedy" wrote in message news:8mpls3$3kr$1 at agate.berkeley.edu... > And Andrew Kuchling writes: > - > - Does the documentation include the specs for the common language runtime? > - (I'd have no way to run the code, but would download it for those specs.) > > And if anyone knows how to unpack that file on a non-MS system (Linux > or Solaris), feel free to mail me. Blah. I just want the specs, too. > unzip doesn't like it. I don't really understand why they don't just put the docs online. It _was_ a bother to download 80 megs, find a Win2000 box, upgrade its IE to 5.5, and install, when all I want for now are the docs, too. Oh well! Alex From effbot at telia.com Wed Aug 30 03:15:27 2000 From: effbot at telia.com (Fredrik Lundh) Date: Wed, 30 Aug 2000 07:15:27 GMT Subject: Should enum values be class instances? Or is this inefficient? References: Message-ID: tom wrote: > Will this consume huge amounts of memory (one instance of the enum class for > every enum variable) or will the interpreter only create as many instances > as there are unique values of the enumeration? judging from fred's code, the latter. everything is a reference in python, and python never copies objects by itself. > So, I want to have value in my class that refers to an enumeration which has > 6 unique enumerators. My program might create 1000 instances of this class. > So each of the 1000 instances of my class will have a reference to an > instance of the enumeration class. (That's 1000 references, but I assume > that references don't take too much memory.) Will Python create 6 > instances of the enumeration class, or 1000? neither. assuming you only call the "enum" constructor once (to create the enumeration), you'll end up with one enumeration instance, six values stored inside it, and any number of pointers to those values. # create one object with six values lang = enum("python", "java", "c++", "sh", "tcl", "assembler") # create a couple of objects for i in range(10000): # add reference to a value maintained by lang # (but not to lang itself) obj = myclass(lang.python) ::: > Instances are mutable aren't they? And Python only invokes this efficiency > for immutables doesn't it? python doesn't care -- it's up to the type implementation to reuse values, if it knows that they can never be changed in place. (and the easiest way to do that is to make sure you don't have any methods ;-) ::: personally, I find enumerations being rather un-pythonish (why not just use named constants in namespaces), but that's another story. From see at message.body Tue Aug 15 22:32:53 2000 From: see at message.body (Sam Penrose) Date: Tue, 15 Aug 2000 19:32:53 -0700 Subject: Python job in Berkeley, California Message-ID: Since everyone seems OK with it, I'm going to post the following job ad. I've been working for the company for over a year, and they're (we're) a very good group of folks. isn't-it-amazing-we-get-paid-to-do-something-so-much- fun-ly y'rs, Sam Deluxe Digital Media, a merry little band of Internet workers and misfits, is going slightly crazy with overwork. We need a programmer to help us develop richly dynamic web sites. Our web site at http://www.ddmweb.com/ explains a bit more about our work. We're in Berkeley, California and looking for onsite employees only. Currently our biggest sites run on several thousand lines of Python and pump out tens of thousands of dynamically- generated pages a day. You will be working on projects of comparable and larger size. Some knowledge of SQL is helpful, but we can teach you. Comfort working in a Linux/Unix environment is a plus, as is basic familiarity with Apache. Excellent Python programmers with limited web experience are encouraged to apply, as are excellent web programmers with limited Python experience. We are constantly evaluating new technologies, so let us know what you know. While we certainly care about your qualifications to handle such a position, we care as much about who you are. We look for people who are smart, get things done, and are good to be around. We do not operate in a sell-the-clients-hard, drive-the-employees-harder mode--at 7 pm we are home having a life. We are honest with each other and with our clients. We have a good time and do excellent work. Respond to resumes at ddmweb.com. Please paste your resume into the body of the email. -- spenrose at well dot com From robin at jessikat.fsnet.co.uk Wed Aug 9 06:34:17 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 9 Aug 2000 11:34:17 +0100 Subject: [PEP draft 2] Adding new math operators References: <3991243D.D987955@fft.be> Message-ID: In article <3991243D.D987955 at fft.be>, Gregory Lielens writes ... >> I think this approach deserves a much more serious study, because it >> is much more "Python-like", and requires no syntactical changes. >> Lobbying for attributes on number types will be a lot easier than >> lobbying for new operators. > >Yep, I agree...I hope this message qualify as a part of this study! ... As I understand it the classes involved determine what happens. There fore in general if A is KlassA and B is KlassB then A*B --> KlassA.__mul__(A,B) else KlassB.__rmul__(B,A) B*A --> KlassB.__mul__(B,A) else KlassA.__rmul__(A,B) so in general you won't be able to determine in a module what happens by switching a flag. You can do this sort of thing if you have an intermediate abstract class that is neither KlassA or KlassB, you can then do stuff like build the abstract syntax tree of the computation or whatever. In Ada they do this sort of thing all the time to accomplish differentiation, optimal matrix multiplication ordering etc. Doing it dynamically is more difficult. -- Robin Becker From mak at imakhno.freeserve.co.uk Sun Aug 27 15:57:43 2000 From: mak at imakhno.freeserve.co.uk (Makhno) Date: Sun, 27 Aug 2000 20:57:43 +0100 Subject: Getting the reference count References: <8oaguf$imj$1@newsg2.svr.pol.co.uk> <39A8E3BC.CB177B6D@letterror.com> Message-ID: <8obtim$1a5$1@news5.svr.pol.co.uk> >> Is it possible to get the reference count of a PyObject* object? >> I'm sure it must be, but I can't see it documented anywhere. >> >> Something similar to Perl's SvREFCNT() Macro would be great. > >sys.getrefcount(object) I'm sure there must be a better way than messing about importing modules and deferencing attributes. Presumably the reference count is stored inside the PyObject struct? From truixl at j.j Sun Aug 20 19:32:28 2000 From: truixl at j.j (truixl at j.j) Date: 20 Aug 2000 23:32:28 GMT Subject: I sell some software for 50$ 4444 Message-ID: <8nppqc$4dn$169@cer.yubc.net> I sell CAD/CAM, Graphic, Image processing, Programming software. All software is only 50$ Email me for more information Vanessa Roberts mailto:vroberts at mailbox.co.yu skjbwmpzipdzvs From see at message.body Tue Aug 22 00:23:22 2000 From: see at message.body (Sam Penrose) Date: Mon, 21 Aug 2000 21:23:22 -0700 Subject: debugging CGI scripts References: <39a0ab79$1_2@news.nwlink.com> Message-ID: 1) cgi.py has a built-in traceback exception function. I think it's called print_traceback_exec, but a quick read of the source should tell you. You can also redirect sys.stderr to sys.stdout, along the lines of Adam's suggestion. 2) I have my own little function which prints a variable of choice. def bail(message): """Print message to browser window and call sys.exit()""" import sys print BASIC_HEADER #'Content type: text/html\n' if type(message) is type({}): for k, v in message.items(): print k, ': ', v else: print message sys.exit() You can certainly embellish it further. My top level flow-control then reads: try: main() except SystemError: pass #calling bail() except: cgi.print_traceback_exec() #or whatever it's called. 3) I find after doing this for a year the errors fall into certain predictable types; string substitution mismatches being the most common (and thoroughly frustrating until you get a feel for them). I used to lose about a half a day a week to one or two absolutely baffling errors. Now I'm rarely stuck for more than a couple minutes. Usually dropping bail(suspiciousVariable) into the code, saving, and reloading makes the problem immediately evident. In article <39a0ab79$1_2 at news.nwlink.com>, "Adam Vandenberg" wrote: > lynx wrote in message > news:pJ%n5.43052$QD5.426611 at news.corecomm.net... > > any good, simple work-even-remotely-alike for perl's CGI::Carp out > > there, > > Here is something I use for debugging Python CGI scripts. > It's based on various other similar debugging scripts I found and glommed > together. > --- debug.py --- > #!/usr/bin/python > import os, sys, string > import cgi > > filename = os.environ["PATH_TRANSLATED"] > > # Grab the real stdout from the script we are trying to debug > import StringIO > real_stdout = sys.stdout > sys.stdout = StringIO.StringIO() > > try: > execfile(filename) > real_stdout.write( sys.stdout.getvalue() ) > except: > real_stdout.write ("Content-type: text/html\n\n") > > real_stdout.write ("debugging: " + filename + "

") > > import traceback > > IOBuffer = StringIO.StringIO() > traceback.print_exc(file=IOBuffer) > > HTML = IOBuffer.getvalue() > HTML = string.replace(HTML,"&","amp;") > HTML = string.replace(HTML,"<","<") > HTML = string.replace(HTML,">",">") > HTML = string.replace(HTML,"\n","
") > HTML = string.replace(HTML,"\t","   ") > > real_stdout.write("") > real_stdout.write(HTML) > real_stdout.write("") > > sys.exit(0) > > > I place this in my web's root folder and include it in the path. > Debug, send tracebacks to browser: http://adamv.com/debug.py/toy/test.py > > Hope this helps, > Adam Vandenberg, Pythoneer 3rd class. -- spenrose at well dot com From hzhu at localhost.localdomain Wed Aug 9 18:51:23 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Wed, 09 Aug 2000 22:51:23 GMT Subject: python: bug or feature? References: <8msimd$bia$1@nnrp1.deja.com> Message-ID: This just shows that the current arrangements of logical operators and bitwise operators is a misfeature. Bitwise operations do not deserve cryptic symbols, especially ones with their own precedence levels. :-) Huaiyu On 10 Aug 2000 00:32:20 +0200, Bernhard Herzog wrote: >Keith Murphy writes: > >> the first one works, but the second one always returns a 0. >> >> ( (e%4 == 0) & (self.current == e-1) ) > >You probably meant to use 'and' instead of '&' (& is bitwise and): > > ( (e%4 == 0) and (self.current == e-1) ) > >which is indeed the same as > > ( e%4 == 0 and self.current == e-1 ) > >> ( e%4 == 0 & self.current == e-1 ) > >This one is equivalent to > > ( e%4 == (0 & self.current) == e-1 ) > >which is indeed always 0, assuming e is an integer. > >If you come from C or C++, note, that &, | and ^ have higher precedence >than the comparison operators and that the comparison operators can be >chained, i.e. a < b < c does what you'd expect from maths and not what >you'd expect from C. > From dannyboy at here.com Wed Aug 16 16:19:27 2000 From: dannyboy at here.com (dannyboy at here.com) Date: Wed, 16 Aug 2000 20:19:27 GMT Subject: reducing fractions References: <7j2qmsstdgrh66sf625eeekqgt7jdn7gh7@4ax.com> Message-ID: On Wed, 16 Aug 2000 15:10:17 GMT, "Greg Scott" wrote: >I taught my son to >do this. With a rigid inflexible curriculum, kids are bludgeoned into hatred >of a subject that they could love. Yes, I used to teach in a conventional >classroom. I quit because I loved teaching, and found myself incapable of >doing so in that context. So there is a substantial kernal of truth in your >assessment. Just don't overlook the substantial kernal of truth in mine. Duly noted. Without a directed curriculum there is often chaos. You must surely have had some sort of plan in mind. That constitutes a curriculum guideline. *Who* diagnosed your son? Such difficulties are often diagnosed and found in the public school system. Granted, they do not have the facilities for the one-on-one training that can be provided privately. Your son is indeed fortunate to have had a teacher parent. However that is the only difference I perceive. Pay more taxes, a LOT more taxes, and you can get what you wish for in the public sector; personal private attention. I must repeat that it is a far more difficult task to teach ALL of the millions than just one or two. The concept is quite different. If you want to change the system, you'll really have to pay for that privelege. As I've pointed out to parents many times, if you want a personal tutor, you must pay extra. A teacher with 36 students of varied abilities in one room has 36 minutes (?) to spend with them. That's one minute each if *nothing* else was done. Add attendance and other such duties and you have only a few seconds unless you concentrate only upon the most vulnerable. Even you at home could not get around such problems as readily. A real comparison can not be made. Also, please consider that there remains the distinct possibility that your son was misdiagnosed to have been ultimately so successful. Also, the "hatred" you talk about does exist, but the primary cause is not the methodology, but the lack of pre-requisites. Students are passed far beyond their capabilities and so are understandably utterly confused in later years. Allow justified failure, and that phenomenon will be reduced remarkably. Dan. ---------------------------- submissions: post to k12.ed.math or e-mail to k12math at sd28.bc.ca private e-mail to the k12.ed.math moderator: kem-moderator at thinkspot.net newsgroup website: http://www.thinkspot.net/k12math/ newsgroup charter: http://www.thinkspot.net/k12math/charter.html From frankn=nuws at cs.vu.nl Mon Aug 14 15:19:18 2000 From: frankn=nuws at cs.vu.nl (Frank Niessink) Date: Mon, 14 Aug 2000 19:19:18 GMT Subject: [PEP 203] Augmented Assignment References: <20000814180327.U14470@xs4all.nl> Message-ID: <8n9gnm$gmg@cs.vu.nl> Thomas Wouters wrote: > --7JfCtLOvnd9MIVvH > Content-Type: text/plain; charset=us-ascii > Content-Disposition: inline > I've attached the current draft for the Augmented Assignment proposal. Due > to popular demand I've added a Rationale section that tries to > (*briefly*) explain why augmented assignment is a Good Thing. If you prefer > HTML over text, you can find the HTML version on the python PEP page: Maybe a stupid question, but why is there no hook for the regular assignment in this proposal? The proposal talks about 12 assignment operators, of which 11 are 'inplace' and 1 regular. But there is no hook for the regular assignment. If a hook would be created for regular assignment the object can decide what happens if something is assigned to it. Silly example: class Undoable: def __init__(self, value=None): self.data = value self.history = [] def __repr__(self): return repr(self.data) def __assign_ab__(self, value): self.history.append(self.data) self.data = value def undo(self): self.data = self.history[-1] del self.history[-1] >>> x = Undoable(1) >>> print x 1 >>> x = 2 >>> print x 2 >>> x.undo(); print x 1 Cheers, Frank -- He lay, panting heavily in the wet air, and tried feeling bits of himself to see where he might be hurt. Wherever he touched himself, he encountered a pain. After a short while he worked out that this was because it was his hand that was hurting. -- Douglas Adams, 'Life, the Universe, and Everything' From stephen_ferg at worldnet.att.net Sat Aug 19 18:21:16 2000 From: stephen_ferg at worldnet.att.net (Stephen Ferg) Date: Sat, 19 Aug 2000 22:21:16 GMT Subject: Newbie question - calling external Python programs Message-ID: My name is Steve Ferg. I am a newbie convert to Python from Rexx. I want to port a big Rexx application to Python, and I need some guidance on Python design philosophy for moderately large applications. In Rexx, you call an external Python program like this: return_value = subpgm2( arg1, arg2, arg3) When you do this, external subpgm2 is located, loaded, its byte-code is interpreted (as in Python), and it runs. When subpgm2 finishes, it returns return_value and releases the memory it has used. I've read about Python's ability to import external modules, but I'm concerned about using the import mechanism for the application that I'm porting. The Rexx application is moderately large -- it is a menu-driven system where each menu program may have options to call as many as 5 other submenu programs, to a depth of 4 or 5 levels. All together, there are over 100 small menu programs (about 200-1500 lines each), for a total of about 100,000 lines of Rexx code in the application. My concern is that if I write a top-level Python module that imports its 5 submenu programs, and all the submenu programs import THEIR submenu programs, etc., that the system will import the entire application at one shot at startup time -- that is, import the Python-equivalent of 100,000 lines of Rexx -- and keep it in memory. My concern is that doing this would (1) make the program very slow to start up, and (2) make it a memory hog when running. I'm running under Win98, on a 350 mHz machine, so speed and memory are not the concerns that they would have been a few years ago, but still... So my question is: how should I do this in Python? Should I use import? If so, will I find that my fears of slowness don't materialize? Or is there some other Python technique that should be used for this kind of application? Any advice would be greatly appreciated. As a Rexx programmer, I regard Python as a better Rexx than Rexx, and I'm really looking forward to using Python. -- Steve Ferg (Stephen_Ferg at att.net) From mwh21 at cam.ac.uk Mon Aug 28 15:37:05 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 28 Aug 2000 20:37:05 +0100 Subject: PyDict_GetItemString converse References: <39A40BBF.FDEB84A9@ncsa.uiuc.edu> Message-ID: Randy Heiland writes: > I know that, given a name of a variable, I can do: > > PyObject *result = PyDict_GetItemString(globals, varname); > > how do I do the converse -- given a PyObject, get its associated > variable name? You can't in general. If you're sure it's in the dictionary "globals", I think the moral equivalent of for (key,value) in globals.items(): if value is result: return key is your best bet. Cheers, M. -- In general, I'd recommend injecting LSD directly into your temples, Syd-Barret-style, before mucking with Motif's resource framework. The former has far lower odds of leading directly to terminal insanity. -- Dan Martinez From Bill.Scherer at VerizonWireless.com Mon Aug 14 08:43:44 2000 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Mon, 14 Aug 2000 08:43:44 -0400 Subject: CASE tool for python References: <3997BC9E.C2ABCB41@weihenstephan.org> <8n8fuh$f6$1@soap.pipex.net> <8n8n6d$kvh$1@news.kth.se> Message-ID: <3997E980.BDDF2FBD@VerizonWireless.com> Oivvio Polite wrote: > > > > > You could take a look at http://www.objectdomain.com/ > > > > > > I haven't used it myself but I believe it supports Python. Its written in > > > Java so should run on either platform. > > > > > It does support Python, but it does not seem very stable. I toyed with it > for half a day and it crashed on me quite a few times. Try R3, it's *much* more stable. > > > oivvio > > -- > http://www.python.org/mailman/listinfo/python-list -- William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From see at my.signature Wed Aug 30 01:20:33 2000 From: see at my.signature (Greg Ewing) Date: Wed, 30 Aug 2000 17:20:33 +1200 Subject: Python and COBOL References: Message-ID: <39AC99A1.72A28C98@my.signature> Fran?ois Pinard wrote: > > There is a PEP suggesting the introduction of a whole > flurry of new operators, I'm sad to say it really goes against COBOL spirit. Oh, yes. I'm sure the mathematicians would just *love* to be able to write MULTIPY MATRIX_A BY MATRIX_B ELEMENTWISE GIVING MATRIX_C all the time :-) :-) :-) -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From sean at digitome.com Thu Aug 10 15:51:12 2000 From: sean at digitome.com (Sean Mc Grath) Date: Thu, 10 Aug 2000 19:51:12 GMT Subject: Book References: Message-ID: <39930150.30787079@news.iol.ie> On Tue, 08 Aug 2000 00:29:59 GMT, "Don Tuttle" wrote: > > After installing the XML >software, the "testsax.py" fails. The author says if this happens to check >his web site ( www.pyxie.org) for information on how to correct it. Fine, >except he hasn't posted anything! Oh well, maybe later. > Don, There is now a trouble shooting page and an e-mail address to send bug info to on www.pyxie.org. There is a bug to do with the output the book says should appear when testsax is executed. The correct output is shown on the errata page. regards, Sean From piet at cs.uu.nl Thu Aug 24 05:05:42 2000 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 24 Aug 2000 11:05:42 +0200 Subject: Creating Python "executables" on Windows? References: <8nh8kl$4kc$1@la-mail4.digilink.net> <399CEC26.59C0DC79@nowonder.de> Message-ID: >>>>> Peter Schneider-Kamp (PS) writes: PS> Azratax wrote: >> >> rslt.append(k, v.__file__) >> TypeError: append requires exactly 1 argument; 2 given PS> replace by: PS> rslt.extend((k, v.__file__)) PS> There will be at least one more show stopper of that PS> kind. Modifiy in the same way. I noticed that in the 3g version this line was replaced by rslt.append((k, v.__file__)) (append, not extend). -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From jkraska1 at san.rr.com Sun Aug 13 15:02:49 2000 From: jkraska1 at san.rr.com (Courageous) Date: Sun, 13 Aug 2000 19:02:49 GMT Subject: some comments for Python 3000 References: <8n2ijv$o8t$1@nnrp1.deja.com> <8n3c6e05li@news2.newsguy.com> <8n3ppd$rv0$1@slb7.atl.mindspring.net> <8n4n47$50t$1@nnrp1.deja.com> <3995E6D8.96DA23B4@san.rr.com> <8n5he1$lbr$1@nnrp1.deja.com> Message-ID: <3996F17F.BE84F0CB@san.rr.com> > I agree with you! they are not _directly_ of any interest to the > programmer - their results are. List as first class objects, functions > like map, reduce etc were of no interest to the mainstream programmer - > if you'd ask them nobody would vote for them - yet they were put in > Python. Nowadays they allow much shorter as well as much safer code. I'm not sure how many people are using these functions, actually. But no matter; I do like them, don't get me wrong. As a lisp programmer, map, reduce, remove-if, lambda, et al. are my friends. > > Python ... needs a native compiler that compiles ... > I do not argue that the language issues are the only ones - performance > may be important in some areas. Your average Python program is outperformed by C by 6:1 and in some cases this is worse. It's an issue. > I would also propose that having higher level constructs may lead > to speed improvements - as it enables different mappings into > underlying implementation code. For example - far fetched, just to show > the concept, the map function can be applied in parallel to all > elements of the list - each in a separate thread. Not much win in the > single processor environment - but Python is also used for scripting in > multiprocessor servers... This will become more important very, very soon. Within 2 cpu generations, on-die SMP will be mainstream. Go to http://www.ibm.com and do a search on "POWER4" to get a preview of things to come. > > It doesn't have to be as fast a C, mind you. > > I wouldn't mind Python being faster - for free :-). But if I need > something _running_ fast I'll use C++ - hard to beat. But that's the point! Python is a wonderful environment! It's a shame to be *forced* to switch. Makes me wanna cry, veritably. Every time I write Python for a while and then have to go do write in Lesser Languages (tm), I feel *dirty*. :)- Anyway, regarding your comments via features versus performance: I believe that the compiler effort has the right idea with optional type tags and optional "strict" objects. Personally, I like the notion of "strict"; it's a way for the programmer to say, "hey, I'm done with this now". I think the concept could be deeply exploited; one or more optional keywords which disable entire categories of python dynamism both because doing so speeds things up and also because it's no longer needed in that section of the code. C// From kent at tiamat.goathill.org Tue Aug 1 20:43:34 2000 From: kent at tiamat.goathill.org (Kent Polk) Date: 2 Aug 2000 00:43:34 GMT Subject: ftplib problems with firewall References: <26Eh5.8665$dr.65179@news1.zwoll1.ov.nl.home.com> <65Hh5.8846$dr.68388@news1.zwoll1.ov.nl.home.com> Message-ID: <965175268.312456@fezzik.endicor.com> On Tue, 01 Aug 2000 22:18:06 GMT, "lance wrote: >David Bolen wrote: > >> (Oh, and I'm presuming you mean a real FTP client and not a web >> browser to an FTP: URL, right? The latter can be proxied differently >> than a pure FTP client) > >No browser, just the standard FTP client. > >> >> Since you mention tcpdump - it would be really interesting to see what >> was happening with your other FTP client that works, when for example, >> you do a directory listing, since that might give a hint as to how it >> could possibly work with outbound rules only, since that's sort of >> perplexing. Maybe the IP filter is looking for a specific format of >> the PORT command which is different with ftplib. I'm just guessing >> though :-) ftp and firewalls can get interesting because there are 'active' and 'passive' ftp clients. It's not an issue of 'real' or 'pure' or fake. Older 'real' ftp clients may still use active mode (solaris' ftp client for example). Most browsers (all?) and most modern ftp clients use passive mode ftp. http://www.proftpd.org/proftpd-l-archive/99-08/msg00028.html http://help.netscape.com/kb/consumer/19960513-36.html From piet at cs.uu.nl Fri Aug 18 11:48:09 2000 From: piet at cs.uu.nl (piet at cs.uu.nl) Date: 18 Aug 2000 17:48:09 +0200 Subject: Binary to Hex conversions References: <2B1262E83448D211AE4B00A0C9D61B03013013F5@msgeuro1.creo.be> Message-ID: >>>>> Pieter Claerhout (PC) writes: PC> And how can a hex number (which i have as string) PC> be converted to an integer?? import string i = string.atoi(hexstring,16) or l = string.atol(hexstring,16) to get a long int -- Piet van Oostrum URL: http://www.cs.uu.nl/~piet [PGP] Private email: P.van.Oostrum at hccnet.nl From alex at magenta.com Wed Aug 9 04:14:17 2000 From: alex at magenta.com (Alex Martelli) Date: Wed, 9 Aug 2000 10:14:17 +0200 Subject: ???? Hardware-accellerated python ???? References: <87u2cv7xy8.fsf@galactica.it> <8mr18c$12s9@drn.newsguy.com> Message-ID: <8mr44b01d1s@news2.newsguy.com> "Armin Steinhoff" wrote in message news:8mr18c$12s9 at drn.newsguy.com... > In article , "Olivier says... > > > >If the dictionary lookups are hash-based, there isn't very much improvement > >to be done, as hash tables are usually O(1). I'd say the best accelerator > >for Python is RAM. You can buy more RAM (at your local computer hardware > >store) and add it to your computer and EVERYTHING will go faster! > > > >The nature of an interpreted language (and many other features of python) > >makes it hard to put it on a chip (or to compile). At least, that's how I > >understand it. Maybe I'm wrong? > > You are wrong ... tokens processed as machine code ist just faster. It's a bit more complex than you make it out, Armin. A general-purpose CPU (like other similarly general-purpose pieces of hardware -- RAM, caches, &c) has a huge market: it can amortize huge investments in technology and design to shrink it down to the best that's technologically feasible at any given time. A special-purpose CPU designed/built to similar economic constraints cannot hope to match the design-rules/process-learning-curve/etc of the general purpose component. So the "ist just faster" need not apply -- more often than a naive intuition would expect, the solution relying on general-purpose tech is going to beat or leapfrog the one relying on special-purpose hardware. E.g., one may be able, starting a special-purpose hardware design project when the fastest general-purpose CPU on the mass-market runs at 133MHz, to produce a special-purpose CPU that (for that single specific task only) is twice as fast... but when it comes out on the market, the general-purpose CPU's have leap-frogged to 300MHz, and so easily beat the special-purpose one (that's equivalent to a 266-MHz general-purpose one). And the special purpose project just doesn't have a wide-enough market to finance enormous continuing investments to try to catch up with mainstream technology. You need a *huge* 'leverage' factor to defeat this Moore-curve effect; or a "niche" for your special-purpose hardware that is actually pretty large (video & advanced-graphics processing, maybe). Most of the time, neither applies. Alex From gpepice1 at nycap.rr.com Fri Aug 4 23:49:31 2000 From: gpepice1 at nycap.rr.com (gbp) Date: Sat, 05 Aug 2000 03:49:31 GMT Subject: scripting language newbie - compatibility References: Message-ID: <398B8FCD.381C4FF7@nycap.rr.com> Java is the best bet for cross platform, but isn't a scripting langauge! Server side web programming is very crossplatform in a way. The client is the web browser. I've used Perl and Python. Go ahead and try Python first. I think its a little better as far as the cross platform ability. Perl was a child of Unix. Kurt Aistinger wrote: > > Hello everybody! > I recently decided to learn a scripting language like perl, tcl or python > and can't decide which I should choose. > Someone told me that perl is source-compatible, you can take the source from > unix, copy it to windows and it runs, which is reallly cool I think. > Nevertheless, I think that programs in python are easier to read and to > understand and that they're shorter, which makes it more sympathic to me. > are python-programs source-compatible, too? > > regards, > Harald From matt at fusion4.co.uk Sat Aug 5 10:20:45 2000 From: matt at fusion4.co.uk (Matthew Bull) Date: Sat, 05 Aug 2000 15:20:45 +0100 Subject: accessing child Pmw elements Message-ID: <398C22BD.2030600@fusion4.co.uk> Hi all, a quick newbie question how would I access a tk widget which is the child of a Pmw Notebook widget?? I've already tried using page() to access the parent but couldn't access the child text element it contained. Does anyone know a quick and easy way of accessing these from the toplevel?? Matt From alex at magenta.com Wed Aug 16 16:57:53 2000 From: alex at magenta.com (Alex Martelli) Date: Wed, 16 Aug 2000 22:57:53 +0200 Subject: (no subject) References: Message-ID: <8nevbi0rsn@news1.newsguy.com> "mang wang" wrote in message news:F168ZpEVmkWFBXZGYmX00000d67 at hotmail.com... > Hi: > Is there any function call or module I can use to find out the capacity of > my C drive in Python Script? Here's one way out of many, perhaps the simplest -- instantiate the COM object of progid Scripting.FileSystemObject and get a Drive object: fso = win32com.client.Dispatch("Scripting.FileSystemObject") drv = fso.GetDrive('C:') print 'Total Bytes:',drv.TotalSize print 'Avail Bytes:',drv.AvailableSpace Alex From daniel at dittmar.net Fri Aug 11 20:29:29 2000 From: daniel at dittmar.net (Daniel Dittmar) Date: Sat, 12 Aug 2000 02:29:29 +0200 Subject: SlickEdit Users......Python setup... References: <3991A99A.9A5306B9@dittmar.net> <3994972D.395003E0@nowhere.com> Message-ID: <39949A69.154B90D5@dittmar.net> > It doesn't recognize text after a # as a comment. > Is there no better version ? I don't remember if I had the same problem when I installed it first, but this is pretty simple to change: Menu Tools->Configuration->Color Coding->Button Comments Daniel From jwbnews at scandaroon.com Fri Aug 25 16:00:31 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Fri, 25 Aug 2000 13:00:31 -0700 Subject: gratuitous new features in 2.0 References: <8o6eca$420$1@slb3.atl.mindspring.net> Message-ID: In article <8o6eca$420$1 at slb3.atl.mindspring.net>, aahz at netcom.com (Aahz Maruch) wrote: > In article , > Warren Postma wrote: > >"Rainer Deyke" wrote in message > >news:p%wp5.99116$6y5.68070091 at news2.rdc2.tx.home.com... > >> > >> I agree. print should be deprecated, not extended. > > > >Bah. > > > >Print is useful for two things: > > 1. debugging > > 2. demonstrating python interactively. > > > >It is an obvious "wave of the cap" to the interactive fashion in which > >many > >of us 1970's era Microcomputer BASIC programming types cut their teeth > >on > >programming. Sure it's not OOP'y, but the lack of "slavish adherence" > >to > >OOP is one of Python's strong points, not a weak point. ;-) > > Ooo. Nicely put! > -- > --- Aahz (Copyright 2000 by aahz at pobox.com) > The good thing about the print statement changes is that no no one has to use them. I *suspect* that I won't make much use of print >> ..., but instead keep on getting a file(-like) object and using its write(). Of course, I may change my mind before I start using Python 2 (we're staying with 1.5.2 for quite a while...*maybe* 1.6). --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From Gareth.McCaughan at pobox.com Wed Aug 2 18:26:55 2000 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Wed, 2 Aug 2000 23:26:55 +0100 Subject: A small proposed change to dictionaries' "get" method Message-ID: Consider the following piece of code, which takes a file and prepares a concordance saying on which lines each word in the file appears. (For real use it would need to be made more sophisticated.) word2lines = {} line_number = 0 for line in open(filename).readlines(): line_number = line_number+1 for word in map(string.lower, string.split(line)): existing_lines = word2lines.get(word, []) | existing_lines.append(line_number) | ugh! word2lines[word] = existing_lines | words = word2lines.keys() words.sort() for word in words: print "word\t%s", word, string.join(map(str, word2lines[word]), " ") All very simple and elegant. There's just one wart: the three lines I've labelled "ugh!" seem much more verbose and inefficient than they should be. We have to search word2lines twice for "word" (once to see if it's there, once to insert); we reassign even when there's no need to; a simple operation is taking three lines; we've had to introduce a new variable. Yuck. (The efficiency issues are probably very minor in practice, but *gratuitous* inefficiencies are almost always painful to behold.) This (update a mutable object that's a value in a dictionary, initialising it first if appropriate) is a common idiom, at least in my programs. It's a shame that it should be so ugly. * * * I suggest a minor change: another optional argument to "get" so that dict.get(item,default,flag) is equivalent to if dict.has_key(item): VALUE IS dict[item] else: if flag: dict[item] = default <-- This is all that's new VALUE IS default but presumably more efficient. This would enable those painful three lines to be written as word2lines.get(word, [], 1).append(line) (Ahhhh, much better!) The same issue arises, of course, if it's some other kind of mutable thing that's stored in the dictionary. For instance, if you didn't want to see duplicated line numbers, you could use a dictionary of dictionaries, and instead of existing_lines = word2lines.get(word, {}) existing_lines[line_number] = 1 word2lines[word] = existing_lines we'd write word2lines.get(word, {}, 1)[line_number] = 1 * * * Comments? -- Gareth McCaughan Gareth.McCaughan at pobox.com sig under construction From nick at nickbower.com Thu Aug 31 05:19:48 2000 From: nick at nickbower.com (Nick Bower) Date: Thu, 31 Aug 2000 17:19:48 +0800 Subject: Simple Interpolation in Numpy? Message-ID: <39AE2334.CB4BB5F2@nickbower.com> How do I do do simple interpolation using NumPy? I can see an interpolation function in the NumPy C source, so I'm not sure why it's not presented at the Python module level. My very basic need it to re-sample/shift 1D spectral data. But since it's so large (3e6 doubles), doing it in Python is not feasible/sensible. A lower-level solution is required, and I was hoping it would be provided by Numpy. Perhaps not? Thanks for any help, Nick. From peter at engcorp.com Wed Aug 30 03:07:42 2000 From: peter at engcorp.com (Peter Hansen) Date: Wed, 30 Aug 2000 03:07:42 -0400 Subject: Python Mac UI References: <39A9BE90.BAE7ED51@sympatico.ca> <39AB36BC.7232481B@engcorp.com> <39AC1C76.61798AB9@spacenet.tn.cornell.edu> Message-ID: <39ACB2BE.A21404E3@engcorp.com> Tom Loredo wrote: > > Peter Hansen wrote: > > > > Any reason you wouldn't look at http://www.wxpython.org/ and > > http://www.wxwindows.org/ ? > > But wxpython.org says the Mac version is "a distinct possibility"---not > even under development, and not even plans for development. Is this > not accurate? If it is, given that a Mac GUI was asked for, wxpython is > not an answer. > > wxpython.org says the Mac version is possible if "the Mac version of > wxWindows is brought up to par with the other platforms." My impression > from the wxWindows site is that this is essentially so---the Mac version > is at 2.0, with a 2.2 sync expected shortly. With all the hype about I didn't realize the Mac one wasn't supported on the Python side of things yet. Sorry to get anyone's hopes up. Looks like the Mac wxWindows looks pretty good, though, so it surely would be worth the effort to get a Mac wxPython up. From jal at faxnet.com Thu Aug 31 10:25:08 2000 From: jal at faxnet.com (Jonathan LaCour) Date: 31 Aug 2000 14:25:08 GMT Subject: Python Problem - Important! References: <39ABD9A1.A8ECDEC8@faxnet.com> <8ogqak$6jg@dispatch.concentric.net> Message-ID: <8olps4$ed4@dispatch.concentric.net> Okay! Sorry this took so long, but the solution to the PyApache issue has been found, thanks to the author of the mxDateTime module. He sent me a pre-release of the upcoming version, which (once I got it to compile), solved the problem. I am now running PyApache compiled into Apache with ODBC database access. This will allow me to start developing some really cool stuff! Thanks to this, my employer is switching almost entirely to python development. Thanks a lot to everyone that helped me out with this including Guido and Marc Lemburg. Ahh, what a great language =) Jon In article <8ogqak$6jg at dispatch.concentric.net>, "Jonathan LaCour" wrote: > Thanks for the tremendous response everyone. It appears that mxDateTime > has been fixed, and it may not be a python issue afterall. I will post > a followup documenting if it fixed the problem in a few hours. > > Thanks! > > - Jonathan From alan.gauld at gssec.bt.co.uk Tue Aug 8 08:47:46 2000 From: alan.gauld at gssec.bt.co.uk (Alan Gauld) Date: Tue, 08 Aug 2000 13:47:46 +0100 Subject: Python and Windows Scripting Host References: <8mnaep$qc4$1@troll.powertech.no> Message-ID: <39900172.3B6BE092@gssec.bt.co.uk> Mark Hammond wrote: > Note that WSH is a little silly with Python - there is nothing WSH can > do that Python can not - particularly as the WSH object model is > available directly from Python without WSH at all! So how do we access them? Can you provide an equivalent to the WSH program posted - assuming events were supported! I've been trying to figure out how to do the COM stuff but not succeeding. WSH seem,s an easier route somehow. I assume I'm missing something fundamental in winall/pythonwin? Alan G. -- ================================================= This post represents the views of the author and does not necessarily accurately represent the views of BT. From alex at magenta.com Sat Aug 26 07:01:37 2000 From: alex at magenta.com (Alex Martelli) Date: Sat, 26 Aug 2000 13:01:37 +0200 Subject: simulate mouse click across application (win32) References: <39A79054.9648A6FC@ku.ac.th> Message-ID: <8o886i026st@news1.newsguy.com> "Sugree Phatanapherom" wrote in message news:39A79054.9648A6FC at ku.ac.th... > I try to sendmessage across process to simulate mouse click but didn't > work. > > wnd = win32ui.FindWindow(None,"PythonWin") > wnd.SetForegroundWindow() > win32api.SetCursorPos(100,100) # somewhere in windows > wnd.SendMessage(win32con.WM_LBUTTONDOWN,0,0) > wnd.SendMessage(win32con.WM_LBUTTONUP,0,0) > > Any ideas? When you actually clic a mouse, there's a flurry of lower level messages, (WM_NC... and friends), which you're not fully reproducing here (and are pretty hard to reproduce!). That's why Win32, to allow simulating mouse-clics, provides the SendInput API (in NT4 SP4, and Win98, and later; there was a mouse_event API in older versions, but I'm not sue if it works well with modern platforms). Not sure if win32api covers it, though. Alex From mikael.lyngvig at toolwood.dk Sat Aug 19 19:38:40 2000 From: mikael.lyngvig at toolwood.dk (Mikael Lyngvig) Date: Sun, 20 Aug 2000 01:38:40 +0200 Subject: Announce: PythonLauncher v1.01 Released Message-ID: <6A4DECF51E2C68E5.A762C76EDD4CB831.31A3631345B54F2F@lp.airnews.net> PythonLauncher v1.01 has been released with full source code. Changes from v1.00: 1. Replaced MSVC executable with MINGW32 GCC executable contributed by Piet van Oostrum (piet at cs.uu.nl). This executable is only 4 Kbytes in size (the MSVC executable was 13 Kbytes in size). 2. Renamed build.bat to build-msvc.bat. 3. Added build-gcc.bat. 4. Added history.txt document. It can be downloaded from http://www.toolwood.dk/freeware/PythonLauncher. PythonLauncher.exe is a small program, which attempts to locate a Python script named similarly to itself, then locate a Python interpreter, and finally invoke the Python interpreter with the Python script, and any parameters to the .exe itself, as parameters. For instance, if you copy PythonLauncher.exe to foo.exe and run it using "foo bar", it will attempt to locate foo.py, foo.pyc, or foo.pyo. If that succeeds, it will attempt to locate python.exe, cgipython.exe, or pythonw.exe. If that succeeds, it will invoke the found Python interpreter with the parameters "fullpath\foo.py bar" (where fullpath is replaced by the full path of the foo.py script). The Python script and interpreter are searched in the following locations: 1. The home directory of the PythonLauncher executable (the home directory of foo.exe). 2. The directory defined by PYTHONHOME, if such an environment variable exists. 3. The directories defined in the PATH environment variable. Unlike batch files, PythonLauncher works fine with redirection. The license is (very) similar to that of Python itself; you can freely modify, redistribute, whatever the program and its source code as long as the original copyright notice is retained and you don't blame Toolwood for any problems. Sincerely, Mikael Lyngvig Toolwood From neilh at scintilla.org Tue Aug 8 10:09:09 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Tue, 08 Aug 2000 14:09:09 GMT Subject: .NET available References: <3dn1invppe.fsf@kronos.cnri.reston.va.us> Message-ID: <9wUj5.934$S96.8390@news-server.bigpond.net.au> > Does the documentation include the specs for the common language runtime? > (I'd have no way to run the code, but would download it for those specs.) What you are after is probably the stuff in the "NGWSSDK\Tool Developers Guide\Docs" directory such as the "Execution Engine Architecture" or "IL Instruction Set Specification" rather than in the main documentation blob. If so, they're there. Neil From alain at onesite.org Thu Aug 3 05:28:21 2000 From: alain at onesite.org (alain at onesite.org) Date: Thu, 03 Aug 2000 09:28:21 GMT Subject: How does Python compare to ? References: <3FF3ED6EC164DBD2.77C81740D77CD9FA.D247DC7D74D3B365@lp.airnews.net> <8m4bo1$3le2$1@nntp6.u.washington.edu> <8m9l9g$3gc$1@nnrp1.deja.com> Message-ID: <8mbdvh$da3$1@nnrp1.deja.com> In article , morpheus at here.not.there wrote: > On Wed, 02 Aug 2000 17:20:56 GMT, alain at onesite.org wrote: > >Anyone having an example of gotchas with frozen binaries ? > > What platforms does it work on? I have tested a hello world program on Linux RedHat, SunOS and AIX, no problem. I wondered if someone has a bad experience using specific modules. Alain Sent via Deja.com http://www.deja.com/ Before you buy. From frankn=nuws at cs.vu.nl Thu Aug 24 03:12:25 2000 From: frankn=nuws at cs.vu.nl (Frank Niessink) Date: Thu, 24 Aug 2000 07:12:25 GMT Subject: Dict can't update with dict-like objects References: <8o25us$ap0$1@nnrp1.deja.com> Message-ID: <8o2hsp$44q@cs.vu.nl> Guido van Rossum wrote: > It is my intention to *eventually* remove all such restrictions. This > goes slowly because it has to be done one operation at a time. > E.g. somewhere aling 1.5.x, (a,b,c) = [1,2,3] became legal. In 2.0, > [].extend(UserList()) will be legal. I'll make a mental note that > {}.update() needs to be expanded too. A separate method name is quite > unnecessary (the update() function can simply branch on the argument > type). Could you please make another mental note (or expand the first one) for eval()? Thanks, Frank -- "Ford!" he said, "there's an infinite number of monkeys outside who want to talk to us about this script for Hamlet they've worked out." -- Douglas Adams, 'The Hitch Hiker's Guide to the Galaxy' From eric at estinc.com Wed Aug 30 16:54:59 2000 From: eric at estinc.com (Eric Lee Green) Date: Wed, 30 Aug 2000 13:54:59 -0700 Subject: Looking for Python programmers--where to search? References: <3998C541.4FC15982@san.rr.com> <39a3d9cb.4496054@news.laplaza.org> <39A6EAA6.1E6FC421@estinc.com> <8o7t1t01tov@news1.newsguy.com> Message-ID: <39AD74A3.66696030@estinc.com> Alex Martelli wrote: > "Eric Lee Green" wrote in message > > A few years ago I would have agreed with you. The problem is that projects > are > > becoming more and more complex, and as they become more complex, > interactions > > become more complex. A typical project ten years ago had one component > type -- > > Funny, the trend as I've noticed it is exactly the other way around -- our > company has been opening development labs in a lot of sites around the > world, to maximize our chances of getting the best people on board even > if they want to live far from our main location, and my experience is that > the technology's progress is making it easier, not harder, to handle. That > little word 'component' is the key. Hmm... I suspect that we may have come from different worlds. Everything in Unix has theoretically been a "component" forever ("many small programs chained together"). In my experience, until recently, Unix database applications consisted of a) a menu program that invoked individual programs, and b) the individual programs themselves. The individual programs themselves generally did one thing, and one thing only, e.g., edit a customer demographics screen, and if the program allowed you to pull up another screen, what usually happened behind the scenes was that another program was being called with a record ID to display as its command line parameter, and the current program put to sleep until that other program returned. The move to GUI design changed this paradigm somewhat, in that monolithic programs became not only possible but, due to the rather idiotic design of currently-extant windowing toolkits, necessary. However, Unix database applications did not really start moving to GUI interfaces en-masse until the mid 90's. While the move to component design is certainly preferable to monolithic programs, there is still the problem of adequately defining the components and their interactions. And some "components" get mightily large, e.g. one component that I am currently writing pulls in some dozen-odd modules and deals with nearly a dozen individual object classes. Of course, this component is sort of the whole point of the entire application, i.e., it is the single most complex component in the system, and most components in the system are much smaller and cleaner, but the interactions are still there. -- Eric Lee Green eric at estinc.com Software Engineer "The BRU Guys" Enhanced Software Technologies, Inc. http://www.estinc.com/ (602) 470-1115 voice (602) 470-1116 fax From rumjuggler at cryptarchy.org Tue Aug 15 22:34:59 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Wed, 16 Aug 2000 02:34:59 GMT Subject: PYTHON IS CRAP References: <39986005.3A742278@nowonder.de> <461650299.20000815132250@virgin.net> <8ncqbt$7ga$1@nnrp1.deja.com> <3999F1BF.D18B3E@san.rr.com> Message-ID: On Wed, 16 Aug 2000 01:40:24 GMT, Courageous wrote: >Python will not outperform Java. If some performance savvy >wizard wants to prove me wrong, I'll gracefully accept >tons of egg on my face, but otherwise I believe that you >have made some sort of measurement error. isn't very objective, but there are reproducable tests, in some of which Python outperformed Java. -- Barnabas T. Rumjuggler's page of dumbth: members.home.net/rumjuggler puto deus fio. -- Vespasian, last words From herzog at online.de Mon Aug 21 13:48:07 2000 From: herzog at online.de (Bernhard Herzog) Date: 21 Aug 2000 19:48:07 +0200 Subject: trouble with the C API References: <39A1561D.DB9442FF@magellan.umontreal.ca> Message-ID: Stefan Seefeld writes: > I'm writing a C module for a python tool I'm working > on and I'm having trouble with the C API. What is the > distinction between the PyDict_xxx abd the PyMapping_xxx > functions ? I defined (in python) my own type containing > the methods __setitem__, haskey, etc. to make it 'dictionary > conformant'. Now I want to access and modify the content. > The key is a list of strings (which I map to a tuple on the > fly). There is no PyMapping_GetItem call for keys other than > strings. (but the equivalent dict function exists !). You could use PyObject_GetItem. > Unfortunately, it appears I can't mix Dict and Mapping functions > since they operate on different slices of the object. At least > I can't access an item via a dict call which I set via a mapping > call etc.... The PyDict functions only work with dictionary objects. The PyMapping funtions are more general and work with all objects that support the mapping protocol at the C-level. -- Bernhard Herzog | Sketch, a drawing program for Unix herzog at online.de | http://sketch.sourceforge.net/ From hgg9140 at seanet.com Tue Aug 8 23:40:32 2000 From: hgg9140 at seanet.com (Harry George) Date: 08 Aug 2000 20:40:32 -0700 Subject: ANN: Pdx 1.0 and mkpythonproj 0.8 released Message-ID: Both are packaged via Distutils 0.9. Pdx has improved treatment of nested includes. mkpythonproj is restructured to generate distutils 0.9 style setup.py files (with of course the main modules and the documentation). See: http://www.seanet.com/~hgg9140/comp/index.html -- Harry George hgg9140 at seanet.com From aahz at netcom.com Wed Aug 23 11:36:06 2000 From: aahz at netcom.com (Aahz Maruch) Date: 23 Aug 2000 15:36:06 GMT Subject: Telecommuting (was Re: Looking for Python programmers--where to search?) References: <3998C541.4FC15982@san.rr.com> <39a3d9cb.4496054@news.laplaza.org> Message-ID: <8o0r16$1cn$1@slb7.atl.mindspring.net> In article <39a3d9cb.4496054 at news.laplaza.org>, Mats Wichmann wrote: > >(Hint to employers: there are lots of competent folks who are willing >to help on projects - part-time or full-time, consulting or permanent, >who don't understand why that should mean being tied to the SF Bay >Area... think: telecommuting. I've done it productively for years. >If you bend a little on location your lives will get a whole lot >easier trying to fill those difficult spots! The Bay Area has priced >itself out of being a place most people can live). I dunno. It depends what kind of work you're doing, IMO. If it's something reasonably "standard", then what you're talking about makes sense. OTOH, I've certainly seen telecommuting fail miserably; while it's not clear that the telecommuting was the problem, I do think that telecommuting makes it easier to hide problems. In addition, I think there's no substitute for face-to-face brainstorming. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 The difference between "intelligence" and "wisdom": Londo and G'Kar From jjlucsy at concentric.net Thu Aug 10 18:51:13 2000 From: jjlucsy at concentric.net (Joel Lucsy) Date: Thu, 10 Aug 2000 18:51:13 -0400 Subject: Problem with win32com References: <8muoq0$pi4$1@wanadoo.fr> Message-ID: I tried your code, works great for me. I did modify it slightly. I used DAO.DBEngine.36 and I used "c:\\temp\\db1.mdb". From roebling at ruf.uni-freiburg.de Mon Aug 28 04:23:25 2000 From: roebling at ruf.uni-freiburg.de (Robert Roebling) Date: Mon, 28 Aug 2000 10:23:25 +0200 Subject: ANN: wxDesigner 1.1, commercial RAD tool for wxWindows and wxPython Message-ID: <39AA217D.5F666812@ruf.uni-freiburg.de> Hello, I'm the author of the Unix/GTK port of the wxWindows library and I would like to announce wxDesigner 1.1, a commercial tool that can be used in connection with wxWindows and its popular Python bindings called wxPython. wxDesigner is a dialog editor that allows its users to visually create dialogs using a simple point and click interface. The output produced by wxDesigner can be either of C++ code, Python code or XML, making co-development with wxWindows and wxPython much easier than before. New in version 1.1 is a syntax-highlighting editor (which doesn't try to be Emacs but is very functional) automatic generation of file skeletons, new GUI classes, event handlers and getters (to get access to controls in resources) - all of this is available with identical functionality for wxWindows and wxPython. wxDesigner is available for Windows and Linux. A single-user licence costs $69, owners of a wxDesigner 1.0 licence just need to download wxDesigner 1.1 in order to upgrade. More information including news, screenshots and exact pricing is available from: http://www.roebling.de For more information about wxWindows and wxPython, have a look at: http://www.wxwindows.org http://www.wxpython.org Regards, Robert Roebling

wxDesigner 1.1 - Commercial dialog editor for wxWindows and wxPython. (27-August-2000) From jesse at multimediacollective.com Wed Aug 16 13:55:28 2000 From: jesse at multimediacollective.com (jesse at multimediacollective.com) Date: Wed, 16 Aug 2000 17:55:28 -0000 Subject: manage_addProperty Message-ID: <8nekig+2pol@eGroups.com> Hey everyone, I've created a product that uses python.py's that creats a folder and adds documents and folders to it. This all works fine, however, when I try to add a property it gives me a aq_base attribute error. Heres the code. def manage_addMemberSite(self, id, title='',REQUEST=None): """Add a MemberSite folder.""" try: user=REQUEST['AUTHENTICATED_USER'] except: user=None folder = MemberSite(id, title) # _setObject must be the Zope hook that actually stores this instance in # the ZODB self._setObject(id, folder) folder.manage_addFolder(id='Images', title='') folder.manage_addDTMLDocument(id='index_html', title='', file=index_body) folder.manage_addDTMLDocument(id='navbar', title='', file=navbar_html) folder.manage_addDTMLDocument(id='content', title='enter page content here', file=default_dd_html) folder.manage_addProperty(id='nav_color', value='#483D8B', type='string') folder.manage_addProperty(id='content_color', value='#F0E68C', type='string') folder.manage_addProperty(id='background_color', value='#FFFFFF', type='string') if REQUEST: return self.manage_main(self, REQUEST, update_menu=1) If anyone has any ideas how I could add the properties correctly, please respond ASAP. From mal at lemburg.com Tue Aug 29 05:00:49 2000 From: mal at lemburg.com (M.-A. Lemburg) Date: Tue, 29 Aug 2000 11:00:49 +0200 Subject: [Python-Dev] Re: [PEP 224] Attribute Docstrings References: <39AABF1E.171BFD00@lemburg.com> Message-ID: <39AB7BC1.5670ACDC@lemburg.com> David Goodger wrote: > > on 2000-08-28 15:35, M.-A. Lemburg (mal at lemburg.com) wrote: > > > Christian Tanzer wrote: > >> > >> "M.-A. Lemburg" wrote: > >> > >>>> IMHO, David Goodger's () idea of using a > >>>> __docs__ dictionary is a better solution: > >>>> > >>>> - It provides all docstrings for the attributes of an object in a > >>>> single place. > >>>> > >>>> * Handy in interactive mode. > >>>> * This simplifies the generation of documentation considerably. > >>>> > >>>> - It is easier to explain in the documentation > >>> > >>> The downside is that it doesn't work well together with > >>> class inheritance: docstrings of the above form can > >>> be overridden or inherited just like any other class > >>> attribute. > >> > >> Yep. That's why David also proposed a `doc' function combining the > >> `__docs__' of a class with all its ancestor's __docs__. > > > > The same can be done for __doc____ style attributes: > > a helper function would just need to look at dir(Class) and then > > extract the attribute doc strings it finds. It could also do > > a DFS search to find a complete API description of the class > > by emulating attribute lookup and combine method and attribute > > docstrings to produce some nice online documentation output. > > Using dir(Class) wouldn't find any inherited attributes of the class. A > depth-first search would be required for any use of attribute docstrings. Uhm, yes... that's what I wrote in the last paragraph. > The advantage of the __doc__attribute__ name-mangling scheme (over __docs__ > dictionaries) would be that the attribute docstrings would be accessible > from subclasses and class instances. But since "these attributes are meant > for tools to use, not humans," this is not an issue. I understand that you would rather like a "frozen" version of the class docs, but this simply doesn't work out for the common case of mixin classes and classes which are built at runtime. The name mangling is meant for internal use and just to give the beast a name ;-) Doc tools can then take whatever action they find necessary and apply the needed lookup, formatting and content extraction. They might even add a frozen __docs__ attribute to classes which are known not to change after creation. I use such a function which I call freeze() to optimize many static classes in my applications: the function scans all available attributes in the inheritance tree and adds them directly to the class in question. This gives some noticable speedups for deeply nested class structures or ones which use many mixin classes. > Just to *find* all attribute names, in order to extract the docstrings, you > would *have* to go through a depth-first search of all base classes. Since > you're doing that anyway, why not collect docstrings as you collect > attributes? There would be no penalty. In fact, such an optimized function > could be written and included in the standard distribution. > > A perfectly good model exists in __dict__ and dir(). Why not imitate it? Sure, but let's do that in a doc() utility function. I want to keep the implementation of this PEP clean and simple. All meta-logic should be applied by external helpers. > on 2000-08-28 04:28, M.-A. Lemburg (mal at lemburg.com) wrote: > > This would not work well together with class inheritance. > > It seems to me that it would work *exactly* as does class inheritance, > cleanly and elegantly. Right, and that's why I'm proposing to use attributes for the docstrings as well: the docstrings will then behave just like the attributes they describe. > The __doc__attribute__ name-mangling scheme strikes > me as un-Pythonic, to be honest. It may look a bit strange, but it's certainly not un-Pythonic: just look at private name mangling or the many __xxx__ hooks which Python uses. > Let me restate: I think the idea of attribute docstring is great. It brings > a truly Pythonic, powerful auto-documentation system (a la POD or JavaDoc) > closer. And I'm willing to help! Thanks, -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From aahz at netcom.com Mon Aug 14 20:47:27 2000 From: aahz at netcom.com (Aahz Maruch) Date: 15 Aug 2000 00:47:27 GMT Subject: Separating __cmp__ from < and > ? References: Message-ID: <8na3uv$jl3$1@nntp9.atl.mindspring.net> In article , Huaiyu Zhu wrote: > >In many situations it is conceptually possible to have a!=b without either >ab. Mathematically, this is the case for objects that live in a >partially ordered space. Right. Problem is, though, that if you have a list of such objects and someone does list.sort(), you need to have a way of evaluating the sort order. My suggestion to you is that you define a new set of methods for these objects. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Gun-toting Naderite / socialized medicine libertarian From alawhead at vcn.bc.ca Thu Aug 10 16:35:11 2000 From: alawhead at vcn.bc.ca (Alexander Lawhead) Date: 10 Aug 2000 20:35:11 GMT Subject: Dynamic generation of images using pmz? References: <8mus76$tm$1@nnrp1.deja.com> <4e0f.3992fae4.a385a@yetix.sz-sb.de> <69Ek5.4489$6E.1237831@ptah.visi.com> Message-ID: <8mv3lv$18q$1@sylvester.vcn.bc.ca> :>Images in HTML pages are always external file that are :>referenced by an URL like . So you are :>refering to files on your file system or on your web server. No! : The same could be said of HTML pages, but you catch those : requests and generate data on the fly for them. : One would think that there would be a way to catch the requests : for the image files and generate them on the fly the same way : one catches requests for html files and generates HTML on the : fly. I'm not all that familiar with this topic, but I'm pretty sure that you can indeed catch the requests for the image files and generate them on the fly. In fact, the php example that the original poster included seems to do this, as does this linux journal article using perl http://www2.linuxjournal.com/lj-issues/issue43/2411.html So, it seems that it should be possible... has anyone out there done this with python and some graphics lib? I'd be interested in feedback as well. - Alexander From thomas at xs4all.net Wed Aug 23 05:36:29 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Wed, 23 Aug 2000 11:36:29 +0200 Subject: threads module question In-Reply-To: <75F7304BB41CD411B06600A0C98414FCB36894@ORSMSX54>; from mark.w.daley@intel.com on Tue, Aug 22, 2000 at 03:11:01PM -0700 References: <75F7304BB41CD411B06600A0C98414FCB36894@ORSMSX54> Message-ID: <20000823113629.O4933@xs4all.nl> On Tue, Aug 22, 2000 at 03:11:01PM -0700, Daley, Mark W wrote: > I don't understand what the threads module is telling me when it says 'first > arg must be callable'. Can anyone direct me on the correct syntax for using > this module? Here is my feeble attempt: > import thread > main = Main() > thread.start_new_thread(main.showvalues(), ) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ This, and your traceback: > File "C:\Python\gui.py", line 47, in interact > thread.start_new_thread(main, 'self') > TypeError: first arg must be callable don't add up. Are you sure you are giving us the right code and the right traceback ? :) In any case, the first argument to thread.start_new_thread should be a function, *not* a functionCALL. So in your example, it should be: thread.start_new_thread(main.showvalues, ) Note the absense of the ()'s after showvalues. You want to pass a reference to the function, not the result of the functioncall. That solves the 'first arg must be callable' error. As for the other arguments, you have to pass the arguments you want the new thread to call showvalues() with as a tuple. If you don't pass any arguments, it's called without arguments. Note that if this is a method, rather than a function, you do not need to pass 'self' explicitly! An easy way to see what arguments you want to pass is simply by writing the call you want the thread to make. If it's main.showvalues() you pass nothing as arguments. You just call thread.start_new_thread(main.showvalues) If you want it to call main.showvalues(x, y, z) you have to pass a tuple consisting of '(x, y, z)' as arguments: thread.start_new_thread(main.showvalues, (x, y, z)) And if you want it to pass keyword values as well: main.showvalues(x, y, z, likespam=spam) you have to pass those in a seperate dict: thread.start_new_thread(main.showvalues, (x, y, z), {'likespam': spam}) In other words, start_new_thread is exactly like the builtin apply() function. See the doc-string for either function for more information. Also, you are probably better off using the threading module, rather than the thread module. It's a tad more convenient to work with, though it costs you some flexibility (but not much, and you aren't likely to need it, anyway.) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From grey at despair.rpglink.com Thu Aug 3 20:00:11 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 04 Aug 2000 00:00:11 GMT Subject: k ... just got python for windoze References: Message-ID: On Thu, 3 Aug 2000 18:52:50 -0500, Chris wrote: >does anyone have any good "FREE" reference materials or web sites for >someone just getting started with programming in general but specifically >dealing with "Python"? www.python.org... Seriously. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From MarkH at ActiveState.com Fri Aug 25 21:48:37 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 26 Aug 2000 01:48:37 GMT Subject: Win32gui... file dialogs? References: <8o592h0cuo@news2.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:8o592h0cuo at news2.newsguy.com... > "Kevin Cazabon" wrote in message > news:I_kp5.201386$8u4.2042579 at news1.rdc1.bc.home.com... > There's a win32gui.GetOpenFileName function, but I can't find > usable docs on it; trying to call it elicits the info that it > requires a 76-byte string, but it's hard to fathom what is to > go into that string. It is worth recalling that win32gui was actually created for Windows CE, where I didnt want to bloat the module with support for all the win32 structures you may need. Hence I went the string route, and assume you will use struct etc to get at it. Far far from ideal, I agree. Longer term though, .py wrappers can hide this. win32ui.CreateFileDialog() is pretty close, but alas it does not support multiple selections either. It would not be hard to add this support tho - if you are interested and able to build from sources (or wait for a future build) I can add it. OTOH, maybe working out the struct magic for win32gui, and putting that into a .py file would be a better option? Mark. From kkinder at tridog.com Fri Aug 25 12:11:23 2000 From: kkinder at tridog.com (Ken Kinder) Date: Fri, 25 Aug 2000 10:11:23 -0600 Subject: Python/FastCGI hosting? Re: Python Hosting ISPs References: <1Wvp5.22241$i5.917917@news1.rdc2.on.home.com> Message-ID: <39A69AAB.563D85F3@tridog.com> Let me know if you come across one with FastCGI for Python. Colin Meeks wrote: > Just thought I'd let everyone know that the ISP we use > http://www.getwebspace.com now has Python available for web sites, version > 1.52. We've been using it now for a couple of weeks and no problems. The > guys there are great and if you need something tweaked or installed they do > their best to accommodate. Mention my name if you sign up and I get a free > months hosting :-) > > Colin > > -- > http://www.python.org/mailman/listinfo/python-list -- Ken Kinder Staff Engineer - Tridog Interactive, Inc. kkinder at tridog.com http://www.tridog.com/ - 303-415-2538 -------------- next part -------------- A non-text attachment was scrubbed... Name: kkinder.vcf Type: text/x-vcard Size: 257 bytes Desc: Card for Ken Kinder URL: From speed at ?.com Tue Aug 1 16:54:55 2000 From: speed at ?.com (Jake Speed) Date: Tue, 01 Aug 2000 20:54:55 GMT Subject: Hmmm, Beazley book missing something? References: Message-ID: morpheus at here.not.there (Steve Lamb) wrote in : >On Tue, 01 Aug 2000 20:39:56 GMT, Steve Lamb >wrote: >> I see readline and readlines in there. Only mention of it is in >> the >>multifile object. No __doc__ string for those methods, either. Did >>this get overlooked in this book? > To be honest, the web page doesn't appear to have it in the relevant >sections, either. Library Reference -> Built-in Types -> File Objects http://www.python.org/doc/current/lib/typesother.html#SECTION004179000000000000000 Actually, for the 'while(<>)' idiom, you probably want: import fileinput for line in fileinput.input(): do_stuff(line) http://www.python.org/doc/current/lib/module-fileinput.html Caveat: fileinput is a little slow, being written in Python rather than C, but if do_stuff() does a lot of stuff it probably doesn't matter. -Speed! From pduffin at hursley.ibm.com Tue Aug 29 12:42:31 2000 From: pduffin at hursley.ibm.com (Paul Duffin) Date: Tue, 29 Aug 2000 17:42:31 +0100 Subject: Looking for Python programmers--where to search? References: <3998C541.4FC15982@san.rr.com> <39a3d9cb.4496054@news.laplaza.org> <39A6EAA6.1E6FC421@estinc.com> <226eqss8q07haau8j32j9l6t9sqgu4pa2i@4ax.com> <8o7t2111tov@news1.newsguy.com> Message-ID: <39ABE7F7.BA78BD78@hursley.ibm.com> Alex Martelli wrote: > > "Dennis Lee Bieber" wrote in message > news:226eqss8q07haau8j32j9l6t9sqgu4pa2i at 4ax.com... > [snip] > > Ah, a coding specialist instead of a software engineer I > > sometimes think schools shouldn't let a student write a program until > > /after/ a few courses on algorithms, language design, etc. > > Writing programs (in a language that 'gets out of the way', ideally: > Scheme or Python come to mind:-) is among the best ways to > understand algorithms etc. > The algorithms and languages (not one but many) should be taught side by side, learning how to write quick sort for example in a few different languages gives you a better understanding of both the algorithm and the language than just doing it in one language. The languages should cover most of the different flavours of languages. Functional. Procedural. Object oriented. > > IMHO, this was an example of management focusing too much on the > > tool (Sybase, and getting a "Sybase programmer" working on it) and > > ignoring the experience and knowledge others had of the data. ANYONE > > Yes, good point; people who hire techies focus far too much on > knowledge of specific tools, as a rule. > At a recent interview I was asked what my "core competency" was and I realised that I didn't have one, at least not in the sense of a set of skills. I answered that my "core competency" was in solving problems. PS. I got the job. From pinard at iro.umontreal.ca Sun Aug 6 09:37:47 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 06 Aug 2000 09:37:47 -0400 Subject: Why are unified diffs only "grudgingly" accepted? In-Reply-To: Moshe Zadka's message of "Sun, 6 Aug 2000 10:49:15 +0300 (IDT)" References: Message-ID: [Moshe Zadka] > > We like context diffs. We grudgingly accept unified diffs. > > Straight ("ed-style") diffs are right out! > > I understand why ed-style diffs are out, but why the are context diffs > > favoured over unified? I've always found unified (-u) diffs to be > > infinitely easier to read (by human eyes/brain) than context (-c) diffs. > Guido doesn't. That's reason enough really -- it's the same as asking > "why should I follow the Python style guidelines?": no real reason for > that style, but Guido likes it, and there has to be some consistency. I understand that `ed-style' diffs are hardly useful, and that we can expect users to understand this. However, between `-c' and `-u' lies a matter of preference, and I always found sad having to know that this maintainer strictly prefers `-u', while this other strictly prefers `-c'. When one relates with many maintainers, it becomes pretty cumbersome to remember the little mania and methods for each of them. As I wrote a few times in the past, it progressively becomes more difficult for users to report bugs than it used to be, and this is not good news to me, as it taints a tiny bit the pleasure of using free software. It also conveys the message that our-maintainer-time-is-so-precious-that-yours-is-not-really. I'm a maintainer and a user; and I care about my time whatever hat I bear! For my correspondents, I hardly know their situation, but I avoid thinking that my time is necessarily more precious than theirs. Of course, I may object to unreasonable demands once in a while, but my tolerance level allows for some slack. I wish some maintainers be a little less self-centered. Back to the diff-style affair, I got a program `unify' from Wayne Davison (Borland) which I integrated into `wdiff' (as the `diffutils' maintainer was sadly not interested). This program converts from `-u' to `-c', or vice-versa, and is trivial to use. Best would be that maintainers who have a strong preference for one format over the other use this program, and just leave users alone about their own preferences over this detail. I do not remember if `unify' is part of the old stable `wdiff', but it is likely part of the latest pretest, at: http://www.iro.umontreal.ca/contrib/wdiff/wdiff-0.5g.tar.gz -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From thiele at muc.das-werk.de Mon Aug 7 08:41:43 2000 From: thiele at muc.das-werk.de (Thomas Thiele) Date: Mon, 07 Aug 2000 14:41:43 +0200 Subject: win32 docu? References: <398E95C1.4F012D7B@muc.das-werk.de> Message-ID: <398EAE87.EF899130@muc.das-werk.de> Hallo Mark! I found them of course. But I was looking for a discription(!) of the functions and not only a prototype of them..... I have no book about win32 extensions and how to use and so I need a better descriptionabout win32 modules and it's possibilities. I don'twant to ask the newsgroup for every small problem..... If you don't know the name and the modul of a function you spend a lot of time to look for it. ;-( BTW. Have you get my mail? From nascheme at news.cnri.reston.va.us Tue Aug 8 17:03:04 2000 From: nascheme at news.cnri.reston.va.us (Neil Schemenauer) Date: 08 Aug 2000 21:03:04 GMT Subject: Creating Python "executables" on Windows? References: Message-ID: Hrvoje Niksic wrote: >I'm now working in Python on Windows a little bit. So far I'm very >It's certainly quite annoying to have to type "python executabl args" >every time. If you want to distribute a Python application for Windows you may with to look at my "standalone" Python distribution. It is available on: http://www.enme.ucalgary.ca/~nascheme/python/ The server is down right now though. Neil From m.faassen at vet.uu.nl Mon Aug 7 15:32:29 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 7 Aug 2000 19:32:29 GMT Subject: Python and GNOME References: <398B1F22.E2E1A9E7@rma.edu> Message-ID: <8mn2sd$g9o$3@newshost.accu.uu.nl> Kirk Fort wrote: > Hmm, I have found the pygnome documentation to be pretty good, you get > several examples. It does sort of assume however, that you are already > familiar with C-style gnome development, so perhaps you should read the > tutorials at http://developer.gnome.org then read the pygnome documentaion > and examples? I came up to speed pretty quickly using some various GTK and Gnome tutorials around, along with the reference (for C) on developer.gnome.org. But you'll have to fill in on the Python bits yourself (I've found it useful to study the PyGTK and PyGnome sources). So if you don't know as much about C or GUI architecture that may not be the right way for you. I also highly recommend using Glade and LibGlade with all of this; libGlade basically lets you set up a UI (built with Glade) in a Python program taking just a few lines. I must've only spent three days with it all so far, but I've already toyed with the canvas and embedded a web browser component. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From NOSPAM_rdrew at cia-group.com Mon Aug 14 05:58:21 2000 From: NOSPAM_rdrew at cia-group.com (Ray Drew) Date: Mon, 14 Aug 2000 10:58:21 +0100 Subject: CASE tool for python References: <3997BC9E.C2ABCB41@weihenstephan.org> Message-ID: <8n8fuh$f6$1@soap.pipex.net> Dr. Peter Stoehr wrote in message <3997BC9E.C2ABCB41 at weihenstephan.org>... >I'm looking for a CASE tool that supports python --- You could take a look at http://www.objectdomain.com/ I haven't used it myself but I believe it supports Python. Its written in Java so should run on either platform. Ray From godzilla at netmeg.net Mon Aug 14 10:52:09 2000 From: godzilla at netmeg.net (Les Schaffer) Date: Mon, 14 Aug 2000 14:52:09 GMT Subject: Enums in Python? References: Message-ID: > Can you have enums in Python? O:-) kinda, sorta, ;-)))) les schaffer ------------------------ def enum(*limits): """create tuples for GUI ID's. enum(N) returns tuple(range(0, N)) while _num(M, N) returns tuple(range(M, M+N))""" sz = len(limits) if sz == 1: start = 0 end = limits[0] elif sz == 2: start = limits[0] end = start + limits[1] return tuple(range(start, end)) ## Window id's (ID_ABOUT, ID_EXIT, ID_DIR, ID_VENDOR, ID_BATCH, ID_ACQUIRE_DATA, ID_ANALYZE_DATA, ID_PLOT, ID_CLEAR_STDOUT, ID_RESET_STATE ) = enum(1001, 10) # ^ # |___ add one for each new entry From nowonder at nowonder.de Thu Aug 24 11:59:41 2000 From: nowonder at nowonder.de (Peter Schneider-Kamp) Date: Thu, 24 Aug 2000 15:59:41 +0000 Subject: Creating Python "executables" on Windows? References: <8nh8kl$4kc$1@la-mail4.digilink.net> <399CEC26.59C0DC79@nowonder.de> Message-ID: <39A5466D.1343098E@nowonder.de> piet at cs.uu.nl wrote: > > I noticed that in the 3g version this line was replaced by > rslt.append((k, v.__file__)) (append, not extend). According to http://www.python.org/1.6 append is right. now-I-know-why-they-removed-this---can-you-say-counterintuitive-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From kcazabon at home.com Mon Aug 21 01:16:43 2000 From: kcazabon at home.com (Kevin Cazabon) Date: Mon, 21 Aug 2000 05:16:43 GMT Subject: PYTHONPATH & Win 98 - seems broken References: <39A088F0.FFD14445@home.com> Message-ID: <%W2o5.189506$8u4.1850211@news1.rdc1.bc.home.com> Well, it doesn't do any good that your PYTHONPATH is set to include the directory that your prog.py file is in... it's not PYTHON that is interpreting your command, it's DOS. If you set your DOS "Path" to include the directory, it will work. you can do this by typing: PATH=%%PATH%%;"c:\My Documents" (I use the quotes because there's a space in the name, you could use the short name instead). You could also type: python -c "import prog" or: python "c:\my documents\prog.py" Kevin. "Mitchell Timin" wrote in message news:39A088F0.FFD14445 at home.com... | Admittedly, I'm a newbie, but it seems clear enough that the PYTHONPATH | variable should let me access a .py file in a different directory. details: | | I'm working in a DOS window. PYTHONPATH is set to: | c:\"my documents"\python. In that directory is a file prog.py. My current | directory is c:\Python16. I type: python prog.py, and I get the message | "can't open file 'prog.py'. | | ? | | Thanks in advance, | | m | From arnold at dstc.monash.edu.au Thu Aug 31 01:02:31 2000 From: arnold at dstc.monash.edu.au (David Arnold) Date: Thu, 31 Aug 2000 15:02:31 +1000 Subject: Sockets In-Reply-To: Your message of "Mon, 28 Aug 2000 14:25:57 GMT." <8odspl$l7i$1@nntp9.atl.mindspring.net> Message-ID: <200008310402.e7V42jK29854@xevious.dstc.monash.edu.au> -->"Aahz" == Aahz Maruch writes: In article <8odh9e$qqf$1 at nnrp1.deja.com>, wrote: >> I have a set of spiders running on my system, The spiders >> communicate with a urlserver & a processing server via internal >> sockets. The spiders are the only ones using Inet sockets. Yet >> after a while of say 1 or 2 spiders, a urlserver and process >> server running , say for 3 hours, then all of a sudden the system >> disallows any connections to the outside, eg inet sockets as well >> as Netscape cannot connect to other web located resources. Aahz> Yeah, sounds like you're not properly closing down the sockets Aahz> after you use them. i had a bug yesterday, on WinNT (it was on someone else's system so i'm not sure about this), where using socket.close() does not close the underlying socket, byt socket.shutdown() does. might be worth a go? d From nowonder at nowonder.de Tue Aug 15 11:32:50 2000 From: nowonder at nowonder.de (Peter Schneider-Kamp) Date: Tue, 15 Aug 2000 15:32:50 +0000 Subject: IDLE development - Call for participation Message-ID: <399962A2.D53A048F@nowonder.de> To (hopefully) speed up the devlopment of IDLE a temporary fork has been created as a seperate project at SourceForge: http://idlefork.sourceforge.net http://sourceforge.net/projects/idlefork The CVS version represents the enhanced IDLE version sed by David Scherer in his VPython. Besides other improvements this version executes threads in a seperate process. The spanish inquisition invites everybody interested in IDLE (and not keen to participate in any witch trials) to contribute to the project. Any kind of contribution (discussion of new features, bug reports, patches) will be appreciated. If we can get the new IDLE version stable and Python's benevolent dictator for life blesses our lines of code, the improved IDLE may go back into Python's source tree proper. at-least-it'll-be-part-of-Py3K--ly y'rs Peter P.S.: You do not have to be a member of the Flying Circus. P.P.S.: There is no Spanish inquisition <0.5 wink>! -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From mal at lemburg.com Wed Aug 30 04:35:00 2000 From: mal at lemburg.com (M.-A. Lemburg) Date: Wed, 30 Aug 2000 10:35:00 +0200 Subject: [Python-Dev] Re: [PEP 224] Attribute Docstrings References: Message-ID: <39ACC734.6F436894@lemburg.com> Christian Tanzer wrote: > > "M.-A. Lemburg" wrote: > > > > Triple quoted strings work -- that's what I'm constantly using. The > > > downside is, that the docstrings either contain spurious white space > > > or it messes up the layout of the code (if you start subsequent lines > > > in the first column). > > > > Just a question of how smart you doc string extraction > > tools are. Have a look at hack.py: > > Come on. There are probably hundreds of hacks around to massage > docstrings. I've written one myself. Ka-Ping Yee suggested > inspect.py... That's the point I wanted to make: there's no need to care much about """-string formatting while writing them as long as you have tools which do it for you at extraction time. > My point was that in such cases it is much better if the language does > it than if everybody does his own kludge. If a change of the Python > parser concerning this point is out of the question, why not have a > standard module providing this functionality (Ka-Ping Yee offered one > , ). Would be a nice addition for Python's stdlib, yes. Maybe for 2.1, since we are in feature freeze for 2.0... -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From g2 at seebelow.org Sun Aug 27 17:01:05 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sun, 27 Aug 2000 22:01:05 +0100 Subject: Python Trademark Status References: <39a7e6e2.41590183@news.telus.net> <39A8D660.230E53F8@seebelow.org> <39ab43e1.130946503@news.telus.net> Message-ID: <39A98191.DE0C287A@seebelow.org> David wrote: > ... > >So do you think they'll let call my auto repair shop "Kodak", or my new > >variety of apples "Xerox", or my new steel I-beams "Kleenex", or my new > >programming language "Coca-Cola"? > > You have presented a series of invented words. The owners of those words > have control over them. That's why those words exist: the owners aren't > willing to risk sharing their trademark. Sounds like a good idea to me. So do you think "Pyython" would fly? It not, is "Perl" still open? sorry--couldn't-resist--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From richard_chamberlain at ntlworld.com Fri Aug 4 19:19:30 2000 From: richard_chamberlain at ntlworld.com (Richard Chamberlain) Date: Sat, 05 Aug 2000 00:19:30 +0100 Subject: Getting HTTP info References: <8mf6hf$8k8$1@nnrp1.deja.com> Message-ID: <398B4F82.3C30D327@ntlworld.com> jidun at my-deja.com wrote: > > Hey, > I have a python script running. Everything is all kosher, but I would > like to get the IP (and other HTTP information) from the client > retrieving my page. > > What to do? > > Thanks! > > Sent via Deja.com http://www.deja.com/ > Before you buy. Hi, There stored in enviroment variables, so something like import cgi print cgi.os.environ['REMOTE_ADDR'] should get you the ip address. There are a obviously other variables in there so you'll need to experiment. Richard From rhicks at rma.edu Wed Aug 9 12:10:41 2000 From: rhicks at rma.edu (Robert) Date: Wed, 09 Aug 2000 16:10:41 GMT Subject: Bitmaps in Tkinter References: <3991592D.F6E77764@inenco.no> Message-ID: <3991837C.5D281039@rma.edu> Did you check the errata page at Manning? Hans Kristian Ruud wrote: > I am teaching myself Tkinter programming from the book > 'Python and Tkinter programming' by John E. Grayson. > > I have a problem with bitmaps: e.g.when I try to run the example on p. > 59: > > from Tkinter import * > import Pmw > > bitmap_path = 'D:\\usr\\X11R6.4\\include\\X11\\bitmaps\\' > root = Tk() > Pmw.initialise() > > balloon = Pmw.Balloon(root) > menuBar = Pmw.MenuBar(root, hull_relief=RAISED, hull_borderwidth=1, > balloon=balloon) > menuBar.pack(fill=X) > menuBar.addmenu('Buttons', 'Simple Commands') > menuBar.addmenuitem('Buttons', 'command', 'Close this window', > font=('StingerLight', 14), label='Close') > menuBar.addmenuitem('Buttons', 'command', bitmap="@bitmaps\\RotateLeft", > > foreground='Yellow') > menuBar.addmenuitem('Buttons', 'separator') > menuBar.addmenuitem('Buttons', 'command', > 'Exit the application', label='Exit') > > menuBar.addmenu('Cascade', 'Cascading Menus') > menuBar.addmenu('Checkbutton', 'Checkbutton Menus') > menuBar.addmenu('Radiobutton', 'Radiobutton Menus') > > root.mainloop() > > I get this output: > > D:\drsc\exercizes>MenuBar.py > Traceback (innermost last): > File "D:\drsc\EXERCI~1\MenuBar.py", line 16, in ? > foreground='Yellow') > File "D:\program files\Python\Pmw\Pmw_0_8_4\lib\PmwMenuBar.py", line > 171, in > addmenuitem > apply(command, (), kw) > File "D:\program files\Python\Lib\lib-tk\Tkinter.py", line 1517, in > add_command > self.add('command', cnf or kw) > File "D:\program files\Python\Lib\lib-tk\Tkinter.py", line 1510, in > add > self.tk.call((self._w, 'add', itemType) + > TclError: error reading bitmap file "bitmaps\RotateLeft" > > Any ideas? > > - thanks in advance - > -- > Hans Kristian Ruud > 22 18 63 08 (jobb) 22 65 22 34 (hjemme) 952 33 224 (mob) > Wash daily from nosetip to tailtip, drink deeply but not to deep > remember the night is for hunting, forget not the day is for sleep From alex at magenta.com Thu Aug 24 09:35:30 2000 From: alex at magenta.com (Alex Martelli) Date: Thu, 24 Aug 2000 15:35:30 +0200 Subject: updated version of David Ascher's compile.py? Message-ID: <8o38k40ff5@news1.newsguy.com> I've just tried installing ActiveState's distribution of Python 1.6 for Windows, and it seems to be fine (except for funny things, such as 'unicode' not being found by a search in the docs although unicode function _is_ correctly documented among the builtins -- go figure!), but I'm having problems trying to build C extensions with VC++6. I _think_ it's the compile.py version I have, originally downloaded from: http://starship.python.net/crew/skippy/ppw32/index.html It doesn't clearly state which version it is, nor its date, but the first (latest) line in 'Release History' is '0.21 [Mar 10, 1998]'. When I try to open either the .DSP or .DSW from VC++6, the latter crashes during the attempt to convert the format from VC++5 to 6. I know Ascher announced in 1999 an updated version (with a specific mention of VC++6), but I cannot access his starship homepage -- it seems to have been moved to port 9673, I even armtwisted our sysadm to open that port on our firewall for http traffic, but, no go; even trying to access it from a machine outside the firewall just won't connect. I've looked all around the net for an accessible version of the updated compile.py, but have not been able to find one. Any suggestions, hints, URLs, ... ? Thanks! Alex From nsiam at my-deja.com Sun Aug 20 04:51:50 2000 From: nsiam at my-deja.com (nsiam at my-deja.com) Date: Sun, 20 Aug 2000 08:51:50 GMT Subject: Python Strings References: <399F7547.734A249E@unk.ororr> <399F863A.48853BCD@ntlworld.com> Message-ID: <8no674$v7l$1@nnrp1.deja.com> fromstr = "aslfdj" tostr = fromstr[:] -or- import copy fromstr = "aslfdj" tostr = copy.copy(fromstr) both copy the string, if that's what you want... the way i've seen the term immutable/mutable used in some python literature is to help explain what parameters are passed by reference. sift through the handouts/slides available in python.org...one of them does a good job explaining immutable/mutables. In article <399F863A.48853BCD at ntlworld.com>, Richard Chamberlain wrote: > Hi Chris, > > fromstr="aslfdj" > tostr=fromstr > > Is that what you want? > > If you change fromstr to another string tostr will remain pointing at > the first object "aslfdj". > > Or you could do something like > > tostr="" > tostr.append(fromstr) > > strings are immutable so you don't have to worry about putting const in > front of them ;-) > > immutable types in python are useful for dictionaries essentially. For a > hashtable to be efficient it requires an unchanging key, so strings fit > this bill. > > Richard > > CHRIS wrote: > > > > How can you make a character-by-character copy of one string to a target > > string, with out using a temporary list type variable? IE (with out > > doing somethin like this): > > > > fromstr = 'aslfdj'; > > target = []; > > for i in range(len(fromstr)): > > #procssing done here > > target.append(fromstr[i]); > > > > Also, what's the point of strings being immutable ?? If you want a > > particular variable to be immutable, why not have some sort of constant > > option? Like in C: > > > > static const char str[] = "Constant immutable string"; > Sent via Deja.com http://www.deja.com/ Before you buy. From g2 at seebelow.org Sat Aug 19 06:07:04 2000 From: g2 at seebelow.org (Grant Griffin) Date: Sat, 19 Aug 2000 11:07:04 +0100 Subject: Still no new license -- but draft text available References: Message-ID: <399E5C48.FDBBA0C4@seebelow.org> Tim Peters wrote: > [Grant Griffin] > > ... > > If that's a hint, I guess I'll have to just say that I've already > > got too many irons in the fire. So I mainly just try to "educate" > > the public a little when the opportunity presents itself. However, > > one small effort I've made in this way is the "Wide Open License" > > (WOL), which you'll find at > > http://www.dspguru.com/wol.htm. > > [Pat McCann] > > Looks good. I don't have time to read the whole page just now, but I > > will. I'm suprised you didn't mention it before. > > Grant and Python are both subversive. > Thanks, Tim. (Am I that transparent?) > > Excellent name! I wish I'd thought of that first. > > I don't think it's trademarked yet -- go ahead and claim that you did > . It is a great name! Hey, that's a good idea! (See http://www.dspguru.com/wol.htm.) Per the license FAQ concept, I almost think that having a license FAQ is a better idea than having a verbose license, in order to combine the best of both worlds (brevity and verbosity). IANAL, but AFAIK, something officially "published" along with a license can be binding to an extent--or at least it's something to present in court about the intent of the license. (Of course, the plot thickens when some WOL software author claims that he didn't intend the explanatory stuff, just the license text. But we'll leave stuff like that to lawyers to lose sleep over. ;-) Continuing in that vein, here's some entry criteria I would like to suggest for any WOL-like license: 1) It should be clearly "not copylefted". (Those who want copyleft already have the GPL; the WOL should be the converse.) 2) The language should be clear and explicit enough that non-lawyers (and even lawyers) can easily understand it (or at least _think_ they do. ;-) 3) It should be as brief as possible. This is partly to contribute towards 2), and it's partly plain old-fashioned salesmanship: nobody wants to clutter their beloved source code with a bunch of legal gunge. Also, if you take the premise (unproven, I guess) that one plug in the legal dyke causes at least two more holes, then less must be more. > Alas, to eliminate the need for FAQs seems to require answering them clearly > in the license itself, and that means more words, and that makes the license > more imposing on first sight. And there is *nothing* people won't question! > For example, the WOL gives the user "permission to use, copy, modify, > distribute and sell this software" (so glad it *explicitly* says "sell"!), > but doesn't explicitly say they can, e.g., sell a modification: yes, they > can modify, and they can sell, but are those exclusive or do they "stack"? > You think that's a stupid question? I do. But it is in fact a question > asked about the CWI license (which had very similar phrasing) by more than > one *lawyer*. (Just think: lawyers get _paid_ to argue. And we do it here on Usenet *for free*!) > Add to that that the WOL appears to be as "bare" a license as CWI's, and > more lawyers will question whether it's revocable at-will. Don't know about > anybody else, but I'd be willing to chip in some real bux to get a WOL-like > license that 10 lawyers don't have 10 conflicting opinions about. Cool! I'd kick in some bux for that too (seriously)...but is it even statistically possible? (and-what-about-the-eleventh?-)-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From gunter_r at my-deja.com Thu Aug 24 21:28:12 2000 From: gunter_r at my-deja.com (Guenter Roehrig) Date: Fri, 25 Aug 2000 01:28:12 GMT Subject: Tkinter on NT (troubles with executing) Message-ID: <8o4i2p$2tj$1@nnrp1.deja.com> Hello All! I'm novice in Python and I have a question. I use Python on NT platform. I try to execute simple Tkinter example: import Tkinter Tkinter._test() (and other Tkinter examples...) but I recieved message that "Tcl probably may not installed" but I have installed Tcl on my computer and add the path to Tcl\BIN directory to system variable PATH. (this advice I found on www.python.org) But I recieved the same error message again. What did I make wrong ? and how can I connect this module? Thank you. Yaroslav Roehrig. Siberia, Russia PS: You may write also in Russian or German Sent via Deja.com http://www.deja.com/ Before you buy. From alex at magenta.com Mon Aug 21 08:10:02 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 21 Aug 2000 14:10:02 +0200 Subject: Newbie switching from TCL References: <8noo7c$4et$1@news.online.de> <8nornc$1li$1@slb3.atl.mindspring.net> <3799AC8F18F40B22.120B7952059DF9AB.F280265F91BC2016@lp.airnews.net> Message-ID: <8nr6en0mh5@news2.newsguy.com> "Cameron Laird" wrote in message news:3799AC8F18F40B22.120B7952059DF9AB.F280265F91BC2016 at lp.airnews.net... [snip] > At the same time, Tcl is relatively isolated as a language in > its emphasis of event handling. Most prominent languages today > promote threading as a multi-processing mechanism. This popu- > larity in itself constitutes an argument for Python's threading. "And if everybody else was jumping off a cliff, would you jump off a cliff, too"?-) (P.S.: Visual Basic does allow threading [reluctantly, and only in recent releases], but event-handling is definitely at its core; considering that it probably has more users than Tcl, Python, and any one other scripting language you can name put together, it might be considered "prominent"...). Alex From tgagne at ix.netcom.com Tue Aug 22 10:38:45 2000 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Tue, 22 Aug 2000 10:38:45 -0400 Subject: python interfacing to db2 on linux? References: <8nipub$3nt$1@nnrp1.deja.com> Message-ID: <39A29074.D81C31A7@ix.netcom.com> I would imagine that would require a DBAPI 2.0 compatible interface to the DB2 client libraries. I'm unsure if I've ever read of one. From g2 at seebelow.org Wed Aug 30 03:28:19 2000 From: g2 at seebelow.org (Grant Griffin) Date: Wed, 30 Aug 2000 08:28:19 +0100 Subject: Python questions from C/Perl/Java programmer References: <967563848.1595119837@news.silcom.com> <39AC0FF9.1E6E14ED@erols.com> Message-ID: <39ACB793.6C686AFB@seebelow.org> Tom Biggs wrote: > > Clarence Gardner wrote: > > > [Tom Biggs] > > >> I doubt I'll abandon Perl altogether - I try to pick the right > > >> tool for the right job - but Python looks very clean. > > > > > [Tim Peters ] > > >I was a Perl programmer before I picked up Python, but that was in '91(!). > > Well, Tim, you gave it up too early... Perl 5 is a blast. > > > >After a year or two, you may well find your Perl use reduced to 5-liners! > > > >And even then, over & over you find yourself saying "hmm! If I had written > > >that in Python instead, I wouldn't have had to track down this bug". > > > > Tom, just in case you might feel obliged to pick up Python gradually, let > > me tell you the way I did it. I was writing mostly Perl with some C when, > > about three years ago, I picked up "Programming Python", read it that night, > > and haven't written a Perl program since. That day, I started implementing > > a billing system for my company, completely in Python. When I occasionally > > need to go back and do something to it, it's a breeze and I prostrate myself > > before my icon of Guido and give thanks that I didn't write it in Perl. Yup. Just go cold turkey on Perl--you'll experience a sigh of relief rather than any withdrawal pains. And I've had to resist the urge To carry that a step further and rewrite all my old Perl scripts into Python (so I can maintain 'em ). But I haven't been able to completely resist: Python is such a pleasure that one finds excuses to use it. However, in translating some of my Perl code, I've been surprised to find that that it's mostly a mechanical exercise. For example, Python's 'dicts' are semantically about the same as Perl's...whatchamacallits?. The mechanicalness of the translation suggests the possibility of a translator program. <>. But from what I understand, there still are enough semantic differences to make a translator difficult to implement. (But one that handles only the mechanical part still would be pretty useful...) > > > > I also believe in using the right tool for the job, but somehow none of my > > jobs call for using Perl.... > > Obviously I must withhold judgment until I learn Python. Eric Raymond > loved Perl too but judging by the way he raved about Python (pretty much > the same as your reaction, "he ain't workin' on Larry's Farm no more" ) > I may end up the same as you guys. Now, don't believe everything Eric Raymond tells you. ;-) <> In my own case, I got steered to it when I read "Advanced Perl Programming": the author spends a chapter or two explaining Perl OO (which is partly why I bought the book--to try to figure that junk out), and then quietly slips in something like, "but Python is my favorite OO scripting language." <> I also was interested in doing TK programming, and I found the Perl interface to it to be *VERY* difficult to install. The Python installation of TKinter has one well-known pothole, but it's still much easier. (Ironically, though, I've never actually done any TK programming!) > I recently wrote a whole suite of Perl applications where the data was > so tightly integrated with the hash trees, that the program became > simplicity itself. I hope I'm not making too bold a claim here but > I've never seen any Perl code anywhere which looked at all like it. > The programs shrank to 20% of their original size after I came up > with the scheme I used, and became (IMO) more understandable. > I'm also very much a fanatic for readable code, too, so I flatter myself > that the programs were easy to someone besides me to pick up > (It's way to easy for the lazy to write totally indecipherable Perl.) That's one of the beauties of Python: writing indecipherable code is so difficult that only the most dilligent even try. > But of course Python has its own 'hash equivalent' data structure > (I'm such a newbie that I can't remember what they're called right > now) so who knows what I will come up with. Oh...that's right: "hash". Thanks--I remember now. just-as-C-succeeded-Pascal,-so-python-is-destined-to-succeed-perl ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From mal at lemburg.com Fri Aug 25 19:06:47 2000 From: mal at lemburg.com (M.-A. Lemburg) Date: Sat, 26 Aug 2000 01:06:47 +0200 Subject: .doc viewer/reader References: <04c501c00dd8$fe07b970$978647c1@DEVELOPMENT> Message-ID: <39A6FC07.6F78290F@lemburg.com> Ulf Engstr?m wrote: > > Has anyone done anything on reading .doc-files with Python? There are a > number of viewers out there, but I havn't been able to find any open source. > I think this would be very good, and I'm willing to work on it if needed. > But if it's done already I save myself a lot of job;). If it's not done, > anyone knows of any open source projects in any language doing this? Or some > kind of spec on how the .docs are saved? > Regards > Ulf These two are OSS: http://www.winfield.demon.nl/index.html http://www.wvware.com/wvInfo.html And there are more... the problem with the above two is that they are GPLed and any application linking against them would have to be GPLed too. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From nascheme at news.cnri.reston.va.us Tue Aug 8 18:47:03 2000 From: nascheme at news.cnri.reston.va.us (Neil Schemenauer) Date: 08 Aug 2000 22:47:03 GMT Subject: Creating Python "executables" on Windows? References: Message-ID: Steve Lamb wrote: > What about freeze.py? Can that be made to work on Windows? It works fine except for situations when you can't assume that people have Python installed or when your application needs to use extensions. Neil From mblessing at am.exch.hp.com Wed Aug 30 15:03:39 2000 From: mblessing at am.exch.hp.com (Michael Blessing) Date: Wed, 30 Aug 2000 13:03:39 -0600 Subject: HP-UX 11.0 Python binaries? References: <20000830183508.7799.qmail@web803.mail.yahoo.com> Message-ID: <8ojl9d$bm9$1@fcnews.fc.hp.com> "Stuart Zakon" wrote in message news:20000830183508.7799.qmail at web803.mail.yahoo.com... > I need to get a quick port of some Java and Python code to HP-UX 11.0 so I'm > looking for a binary distribution of Python for this environment. > > I saw several posts that indicated that building for threads on HP-UX could be > rather hairy and got scared off... I believe you can get a binary distribution from the HP-UX Porting and Archive Centre ( http://hpux.cae.wisc.edu/ ), although I have built Python from source on HP-UX 11.0 and was surprised by how smoothly it went. I didn't try anything with threads, however. Mike Blessing HP Developer's Resource http://devresource.hp.com/ From katz at Glue.umd.edu Sun Aug 20 12:22:49 2000 From: katz at Glue.umd.edu (Roy Katz) Date: Sun, 20 Aug 2000 12:22:49 -0400 Subject: how to get text between HTML tags with URLLIB?? In-Reply-To: <399FF9A4.6F13A31E@freenet.de> References: <8nljnl3285o@news2.newsguy.com> <399FF9A4.6F13A31E@freenet.de> Message-ID: Alright, I re-worked the classes as per your suggestion. Interesting note: the documentation for save_bgn and save_end indicate that nested execution is prohibited. What is that all about? the following code works fine (albeit written sloppily)! Thanks! Roey # book-keeping class link_type: def __init__( self, k ): # garnered from NS bookmark fields self.url=k[0][1]; self.vis=k[1][1]; self.lv=k[2][1]; self.lm=float(k[3][1]) # netscape uses long int self.name = '' # title of the site self.linkstack = [] # where in the heirarchy this link is # placeholders self.inf = None; self.checklink_status=0; self.u=0 # override HTMLlib's start_a to hook in our registration function class wcheck_parse( htmllib.HTMLParser ): links = [] linkbuf = None linkstack = [] def start_h3( self, attrs ): self.save_bgn() def end_h3( self ): self.linkstack.append( self.save_end() ) def end_dl( self ): if( len(self.linkstack) > 0 ): self.linkstack.pop() def start_a( self, attrs ): self.save_bgn() self.linkbuf = link_type( attrs ) def end_a( self ): self.linkbuf.name = self.save_end() self.linkbuf.linkstack = self.linkstack[:] self.links.append( self.linkbuf ) On Sun, 20 Aug 2000, Paolo G. Cantore wrote: > Your in_link processing is already provided by the two parser-methods > save_bgn() and save_end(). Your code would look like: > > def start_a(self, attrs): > self.save_bgn() > self.linkbuf=link_type(attrs) > > def end_a(self): > self.linkbuf.name=self.save_end() > self.links.append(self.linkbuf) > > that's all > -- > From sacher at ctv.es Sun Aug 6 14:51:36 2000 From: sacher at ctv.es (cræsh) Date: Sun, 6 Aug 2000 20:51:36 +0200 Subject: input question Message-ID: <8mkc61$cmp$1@lola.ctv.es> HI!! I've just started with python. I've already finished with the tutorial, but I still cant begin. I've programed before with BASIC (AmstradB, QB and VB(...jes, for windoze)), but I cant find a command to get some data from the user (like 'input "How do you feel?", a$' in Basic, or 'cin< Message-ID: <8nbrni$k2k@cs.vu.nl> Ryan LeCompte wrote: > Try this: > eval('x+1', {}, u.data) > That will give you what you're looking for. u is just a class instance, and > the 'data' attribute actually contains the dictionary. u is just a wrapper > around the dictionary object. Unfortunately, that doesn't help. I want to do lazy evaluation, so it's vital that u.__getitem__ is called, which doesn't happen if I just pass u.data. The expression may contain variables that need to be read from a database. I don't know beforehand which variables are used in the expression, and I don't want to read all possible variables from the database. [while I'm typing this I'm actually getting to the solution!] Another way to find out which variables are used in the expression is of course to use compile(). E.g.: >>> c = compile('x=1','','eval') >>> print c ", line 0> >>> print c.co_names ('x',) Cool. Problem solved. Cheers, Frank -- "Get to the ship," shouted Ford. "I don't want to know, I don't want to see, I don't want to hear," he yelled as he ran, "this is not my planet, I didn't choose to be here, I don't want to get involved, just get me out of here, and get me to a party, with people I can relate to!" -- Douglas Adams, 'Life, the Universe, and Everything' From SBrunning at trisystems.co.uk Tue Aug 22 06:13:08 2000 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Tue, 22 Aug 2000 11:13:08 +0100 Subject: unlambda.py Message-ID: <31575A892FF6D1118F5800600846864D5B103C@intrepid> > I wrote this a year ago, and had more sense than to let it out. > Now you've driven me to it, you beastly man. > Even if you hadn't let it out, it would have escaped eventually. > but-I-think-it'll-all-work-out-in-the-end- > as-long-as-no-one-does-Befunge-ly y'rs > Now that's a thought! Befunge-98, naturally. It would be nice to generalise for n dimensions, though. I-wonder-how-to-store-n-dimensional-source-ly-y'rs, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From Armin at Steinhoff_de Wed Aug 23 06:40:00 2000 From: Armin at Steinhoff_de (Armin Steinhoff) Date: 23 Aug 2000 03:40:00 -0700 Subject: Compiling Python under CYGWIN References: <0056900010961732000002L022*@MHS> Message-ID: <8o09m0$lqv@drn.newsguy.com> Hello, do you have plans to offer your port to the public ?? Regards Armin In article <0056900010961732000002L022*@MHS>, jurgen.defurne at philips.com says... > >Hello, > >I have been able to compile Python 1.5.2 with the Cygwin tools (latest = >release). > >Unfortunately, the support for all mathematics is broken. I can use Pyt= >hon, but when I >try to use mathematics functions (like sqrt, exp, ...) I an exception '= >math range error' is >raised. > >Does anyone have an idea how this could come, and what the remedy would= > be ? > >Jurgen= > From nick at nil_spam_videosystem.co.uk Thu Aug 31 14:10:01 2000 From: nick at nil_spam_videosystem.co.uk (Nick Trout) Date: Thu, 31 Aug 2000 19:10:01 +0100 Subject: newbie: Zope References: <39ae8a6a@news.xtml.co.uk> <8om3n8$bde$1@newshost.accu.uu.nl> Message-ID: <39aea000@news.xtml.co.uk> > Note that questions about Zope belong better on the Zope mailing > list. Point taken, I will try and join. Wish there was a news group, much better! Had trouble getting on the site earlier but now looks okay. > What about the Zope Guides? > http://www.zope.org/Documentation > And of course there's the Zope Documentation Project's site: > http://zdp.zope.org/ I find them a little too low level and sparse. Yes they introduce you to the concepts but when you want to actually do something the best I have found is a Quick Reference. There is hardly anything on the Document Project site! I like lots of examples. Even the How-Tos are a bit sparse and a little obscure for beginners. > I'm not quite sure if that information is available somewhere, or > whether it's mostly folklore. Lots of ZClasses don't have a base class > though. Often also they inherit from Folder or ObjectManager, to get > folderish behavior. Why, what, how?! What behaviour would this give etc...? > > DTML is horrible. > Ah, so you found out, huh? :) DTML is horrible compared to Python. > There are some guidelines to keep it simple. And move to Python > as soon as you feel your DTML becomes too horrible. There's not much info on interfacing with Python. And then the interface is DTML-ish?! > > How does persistence work for Python objects? > Basically, automatically (if you inherit from the right base classes in > Zope), as long as you treat all members of your objects as immutable. > That means that if you have an object a with a list l as an attribute: Which class?! > a.l = [1, 2, 3] > > And you change l by mutating it: > > a.l.append(4) > > The Zope object database won't detect it. You can signal it, but easier still > is just doing something like this: > > l = a.l > l.append(4) > a.l = l Bit messy, but I see the point. How do you flag it, out of interest? > A very good introduction to the ZODB is here: > http://starship.python.net/crew/amk/python/writing/zodb-zeo.html Thanks, thats a good link. > Good luck! > Regards, > Martijn Thanks for the advice, Nick From hzhu at localhost.localdomain Thu Aug 10 14:34:42 2000 From: hzhu at localhost.localdomain (Huaiyu Zhu) Date: Thu, 10 Aug 2000 18:34:42 GMT Subject: [PEP draft 2] Adding new math operators References: <3991243D.D987955@fft.be> Message-ID: On Thu, 10 Aug 2000 01:26:19 GMT, Tim Hochberg wrote: > >Why wouldn't it just be: > >z = (x.E + y.E).M > >given that you already know that x and y are vectors of matrix type. There appears to be a problem with this discussion: the "conversion approach" are actually several very different proposals, depending on - Is the flavor persistent after each operation? - Is the .E applicable to all objects? If .E is not applicable to pure numbers, there are further distinctions - do you always know that the objects are not pure numbers anywhere you want to use .E? (The emphasis is on "always".) - in functions, do you always check input type, or do you mandate that no pure number is passed in? I don't think these as realistic proposals unless all these distinctions are explicitly specified. At least Konrad and you are talking about quite different proposals (regarding .E on pure numbers). >I don't think it has anything to do with the type/class split. It >would be perfectly possible to add E and M methods to scalars. It's >just unlikely that they are going to grow such methods to suit >us. Heck even I don't think that would be a good idea. I meant that if there were no type/class split, then application developers could just write their own E and M methods and test whether they are suitable. But in current situation a design has to come first, dealing with all possible situations, before any code is written. >Values can be scalars, just not arbitrary scalars. I consider rank 0 >arrays scalars and they would work fine. It's core python numeric >types that would not work (ints, floats and complexes). This means >that it's at least possible to design functions that always return >matrix/array type objects, returning rank(0) arrays when they want to >return a scalar. Objects returned from these functions would then >play nicely with above notation. Not just output. You effectively require all the inputs to your formulas are not pure python numbers. I'm not sure if this is realistic. (Also see Konrad's note about NumPy history.) >The second issue, which I believe you've been referring to is what if >f returns an array when your in a matrix environment or vice-versa. In >this case, both notations are equally vulnerable (actually the .E >notation is slightly less vulerable, but not enough to really matter). > >a * f() >a ~* f() > >will both fail if f() doesn't have the prevailing type. The point I was making was: if you use the prevailing-type approach, you can just write wrapper functions accepting given type and return given type, so you do know the return type. This is not possible in mixed-type approach, because you don't know in what context the function will be used. That's what I meant earlier by "not having enough information to decide". In essence, I really don't like a programming language in which the semantics of operation depends on far away context. >> This would be a problem only if objects change flavor frequently. Given the >> convenience of using ~op there's really no need to do that, at least no more >> than what is already the case now between NumPy and MatPy interfaces. > >This is also an issue if you don't know what type (array or matrix) >get's returned by function. I see this as very similar to the scalar issue. No. If they don't change flavor, you can implement functions accordingly. [ discussion about why both approaches fail snipped ] You could say both of them fail equally under the assumption that in both approach you are unsure of the type of return values of functions. But this assumption is not true. In one approach it is very easy to fix the return type, in the other it is impossible. >> The shadow type does introduce a lot of additional problems, but it at least >> ensures that you know the flavors of _all_ objects in a piece of code. > >As long as you check _all_ the objects at the boundaries and check >_all_ values returned by functions this is true. No checking is necessary at all, if in a given module you only import functions with a given flavor. >You don't need to write it up. Just supply the code and how you would >write it up in ~* notation. I'll write it up in .E notation and point >out the relevant pitfalls in the ~* version and then you can return >the favor. OK, you asked for it. Here's what I got by rgrep'ing one of my neural network modules. However, to really see the effects, keep in mind that: - They occur in the middle of (substantially more lines of) matrix computations, - Some of the variables can be pure numbers. lambda y:(1-y.__dotpow__(2)), lambda y:2*y.__dotmul__(1-y.__dotpow__(2)), f1_2 = f1.__dotpow__(2) u = f1.__dotmul__(w) S = f1_2.__dotmul__(R) - f2.__dotmul__(v) dAA = S * xT.__dotpow__(2) rA = self.dA.__dotdiv__(self.dAA) rb = self.db.__dotdiv__(self.dbb) s = x.__dotmul__(o*a) y = r.__dotmul__(o*b) e = mean(v.__dotpow__(2))/2 u = v.__dotmul__(o*b) S = 1-r.__dotpow__(2) w = S.__dotmul__(u*bet - s) dbb = mean(r.__dotpow__(2)) dab = mean(x.__dotmul__(S).__dotmul__(v+y)) daa = mean((x.__dotmul__(S).__dotmul__(b)).__dotpow__(2)) db = mean(r.__dotmul__(v)) da = mean(x.__dotmul__(w)) Does anybody consider this as very Pythonic? :-) Huaiyu From kenzy at my-deja.com Wed Aug 30 20:29:47 2000 From: kenzy at my-deja.com (kenzy at my-deja.com) Date: Thu, 31 Aug 2000 00:29:47 GMT Subject: OpenSSL & Python -the Saga Continues Message-ID: <8ok8t5$pm0$1@nnrp1.deja.com> Ok... I finally installed OpenSSL and Python Correctly. I you saw in my previous posting I was having some trouble. Now I want to see if you one has seen this error before... my code: #!/usr/local/bin/python import urllib, urlparse, string, time, httplib, os, socket, mimetools def get_temp2(): url = httplib.HTTPS('login.isend.com') url.putrequest('GET', '/') url.putheader('Accept', 'text/html') url.putheader('Accept', 'text/plain') url.endheaders() errcode, errmsg, headers = url.getreply() print ("error code = %s" % errcode) f = url.getfile() data = f.read() f.close() print data and this is the error: Traceback (most recent call last): File "/home/kyoung/test.py", line 45, in ? get_temp2() File "/home/kyoung/test.py", line 25, in get_temp2 url = httplib.HTTPS('login.isend.com') File "/usr/local/lib/python1.6/httplib.py", line 84, in __init__ if host: self.connect(host, port) File "/usr/local/lib/python1.6/httplib.py", line 213, in connect ssl = socket.ssl(sock, self.key_file, self.cert_file) socket.sslerror: SSL_connect error Thank you for your time. Ken Sent via Deja.com http://www.deja.com/ Before you buy. From caribou2 at yahoo.com Tue Aug 8 16:03:53 2000 From: caribou2 at yahoo.com (Karl Ulbrich) Date: Tue, 8 Aug 2000 16:03:53 -0400 Subject: website python engine (slashdot) In-Reply-To: <39905F5F.78B36D39@toy.eyep.net>; from toyboy@toy.eyep.net on Tue, Aug 08, 2000 at 03:28:31PM -0400 References: <39905F5F.78B36D39@toy.eyep.net> Message-ID: <20000808160353.L30636@exeter.exeter.org> SquishDot, which runs on Zope (which is written in Python), is already a pretty-well-developed SlashDot clone. Last I looked, it could use some technology updates to take advantage of some of the new frameworks and features available in the latest versions of Zope. Especially with something like Slashdot, understanding the Perl code isn't nearly as useful as understanding a model of the data you want to work with. Zope http://www.zope.org Squishdot http://www.squishdot.org Karl Ulbrich """"@""""""".org (turn my name into my email address) Quoting jtoy (toyboy at toy.eyep.net): > Hi, > I was wondering if anyone is interested in helping me write a html > website engine (or whatever you call it) based on the slashdot code > written in perl that websites such as http://www.deadly.org and > http://www.slashdot.org (There are at least 20 other sites). My main > reason for wanting to do this is to get some good hands on experience > writing in Python (Im 18 yrs old and new to all programming) and I would > like to help the python community grow. I also see this as a test to > see if python can handle such huge loads of code. This project would > probably need people who have some good web/cgi/html/xml developing and > python and perl (have perl knowledge so we can understand the slashdot > code, not for actually writting perl code)programming knowledge. I am > really serious about this and will start the project even if no one > helps, so please make suggestions, comments, and questions via this > newsgroup and by email. Thanks all! From thomas at xs4all.net Mon Aug 14 16:12:10 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 14 Aug 2000 22:12:10 +0200 Subject: [PEP 203] Augmented Assignment -- Dermatologist needed In-Reply-To: <200008141914.OAA04959@rgate2.ricochet.net>; from eaj@ricochet.net on Mon, Aug 14, 2000 at 03:23:01PM -0400 References: <200008141914.OAA04959@rgate2.ricochet.net> Message-ID: <20000814221210.Q17176@xs4all.nl> On Mon, Aug 14, 2000 at 03:23:01PM -0400, Eric Jacobs wrote: > The phrases "behave exactly like __add__" and "which could be `self'" > are contradictory. Since __add__ never self-modifies, and __add_ab__ > may, their behavior is not exactly alike! This is an important > distinction! Indeed. I've adjusted the text to point this out. (just commited, HTML version takes a bit of time.) It now says 'should behave similar to ...', which together with the rest of the PEP should be sufficient explanation. I hope :) The PEP isn't intended as a tutorial on the use of augmented assignment. > Suppose x is a 5-element sequence. After executing > y = x > x = x + x[:3] > len(y) == 5. But after instead executing the seemingly equivalent: > y = x > x += x[:3] > len(y) is unknown! Even though those statements use only operators > that are defined for sequence objects, the result still depends on > the specific type that the sequence happens to be. For tuples, > strings, and UserLists, len(y) will come out to be 5; but for lists, > len(y) will be 8. Yes. This is already the case. Consider y = x do_something(x) What did 'do_something' do ? Is 'x' mutable ? Did it alter 'x' ? Did 'y' alter along with 'x' ? What if this is the global namespace, and 'do_something' could modify both 'y' and 'x' separately !? > This is a major breakdown in the abstract objects layer. Instead > of being able to think of an object as a "sequence object", users > will be forced to make assumptions about the object's behavior > regarding in-place modification. As they already are regarding behaviour in the case of normal binary operators. > So someone might write a function that takes a sequence object as > an argument (i.e., it does not use any methods that are specific > to lists, or any other specific type), but test it only using > lists. If someone comes along and passes a tuple, or a custom > sequence type, there's a possibility that the function will not > work right. Worse yet, it may not even raise an exception; it > may just produce bogus results! This posibility is not specific to augmented assignment. It already applies, though I have to admit I've never seen it happen. > This will end up limiting users' abilities to mix and match > high-level objects, certainly one of Python's greatest features. I agree that the abstraction is one of Python's greatest features, but I doubt it will be limited by augmented assignment. If you do not know what augmented assignment is going to do to your object, *don't use it*. There are no plans to remove normal binary operators, yet. > By trying to pour in augmented assignment, mutation operators > (to replace e.g. list.extend), and in-place modification all at > once, PEP 203 succeeds only in making Python's abstract objects > layer into a confused soup. It is either this, or ending up with augmented assignment that is *only* syntactic sugar for normal assignment. And the decision has to be made now, before adding it. After adding it, it cannot be changed (except perhaps by the mythical Py3k.) Making augmented assignment not fall back to the normal binary operations is not an option, in my opinion, since it would make augmented assignment practically useless if you do not know what type you are talking about. Making _sane_ use of augmented assignment and the hooks behind it is up to the programmers. I do not see more room for confusion than with, say, normal binary operands, which *could* make Python classes do the weirdest things. I've never seen a piece of Python code that did not choose the most 'obvious' use for those operators, so why would people do unexpected things with inplace operators ? -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From none at none Mon Aug 7 22:47:55 2000 From: none at none (Eric Jacobs) Date: Mon, 07 Aug 2000 21:47:55 -0500 Subject: PyGres???? References: Message-ID: In article , kc5tja at garnet.armored.net (Samuel A. Falvo II) wrote: > I've managed to get ahold of PyGres, a module that allows Python > applications to access Postgre databases. However, there isn't a *word* > of documentation *anywhere* on how to use this thing, not with it, nor > on the Internet, based on my Google and python.org searches. See the file README. It's in a prominent location in the source distribution. > I'm having two issues. First, I can't seem to connect to a database > without typing the name of the database *precisely*. That is, it's not > case insensitive. For example, basics.DB("testDB") might work, while > basics.DB("testdb") will likely NOT work. A minor issue, and one which > I can work around. But it really is very annoying. See the system catalog pg_database. You can query it using the ~* operator to figure the exact capitalization of the name. Alternatively, Python has nice string.lower and string.upper functions (now methods too) that you can wrap around when you create and access the database. > Second, and far more important, is how the heck do I access individual > records piecemeal? In other words, suppose I have: > > >>> import basics # from /usr/share/doc/python-pygres/tutorial > >>> db = basics.DB("testDB") > >>> db.query("Select * from weather;"); > > the db.query() function call above will return a *string* containing the > PostgreSQL table information. This formatting is thoroughly > unacceptable for my needs. Is there any way to get that DB object > return something more suitable for automated processing, such as a list > of lists: > > ColumnA | ColumnB > --------+-------- > 45 | 90 > 22.5 | 50 > > would be returned as: > > [[45,22.5],[90,50]] db.query(...).getresult() BTW, query does not return a string. PyGres uses a custom print method to let you easily view the query in interactive mode. (Try it with a large query -- it will spawn a pager.) There is also a DB-API interface available. (import pgdb) From jclevieux at sud2000.com Tue Aug 8 16:48:11 2000 From: jclevieux at sud2000.com (Jean-Claude Levieux) Date: Tue, 08 Aug 2000 20:48:11 GMT Subject: Python 1.6b1 Mysql Message-ID: Hi, I am a newby. I installed python 1.6b1 without problem. But I can't install MySQLdb-0.2.1 Could you help me PLEASE Thanks in advance Here are the error messages : gcc -D_HAVE_BSDI -fpic -I/usr/home/sud2000/mysql/include/mysql -g -O2 - I/usr/home/sud2000/python/include/python1.6 -I/usr/home/sud2000/python/inc lude/python1.6 -DHAVE_CONFIG_H -c ./_mysqlmodule.c gcc -shared _mysqlmodule.o -L/usr/home/sud2000/mysql/lib/mysql -lmysqlclient -o _mysqlmodule.so /usr/home/sud2000/python/bin/python: can't resolve symbol 'mysql_field_count' /usr/home/sud2000/python/bin/python: can't resolve symbol 'mysql_affected_rows' /usr/home/sud2000/python/bin/python: can't resolve symbol 'mysql_insert_id' /usr/home/sud2000/python/bin/python: can't resolve symbol 'mysql_fetch_fields' /usr/home/sud2000/python/bin/python: can't resolve symbol 'mysql_thread_id' /usr/home/sud2000/python/bin/python: can't resolve symbol 'mysql_row_tell' /usr/home/sud2000/python/bin/python: can't resolve symbol 'mysql_change_user' /usr/home/sud2000/python/bin/python: can't resolve symbol 'mysql_num_rows' /usr/home/sud2000/python/bin/python: can't resolve symbol 'mysql_errno' /usr/home/sud2000/python/bin/python: can't resolve symbol 'mysql_error' /usr/home/sud2000/python/bin/python: can't resolve symbol 'mysql_num_fields' /usr/home/sud2000/python/bin/python: can't resolve symbol 'mysql_info' Whoa, couldn't import _mysql: Unable to resolve symbol From pduffin at hursley.ibm.com Fri Aug 25 11:21:13 2000 From: pduffin at hursley.ibm.com (Paul Duffin) Date: Fri, 25 Aug 2000 16:21:13 +0100 Subject: print statement and multithreading References: <8num2r0ogb@news2.newsguy.com> <39A3A280.62DB98C4@hursley.ibm.com> <8o0elg0151u@news1.newsguy.com> <39A50324.1C0006FC@hursley.ibm.com> <8o3cah0ius@news1.newsguy.com> <39A551D5.BAEC2D87@hursley.ibm.com> <8o45tf12aa9@news2.newsguy.com> <39A6557A.890B7541@hursley.ibm.com> <8o5nk70sup@news2.newsguy.com> Message-ID: <39A68EE9.21148649@hursley.ibm.com> Alex Martelli wrote: > > "Paul Duffin" wrote in message > news:39A6557A.890B7541 at hursley.ibm.com... > [snip] > > When you say that Python will support "The C Standard" you > > need to have an exact definition (URL) of the standard, > > "ANSI C" is not sufficient because otherwise everybody will > > URL?! The International Standards Institute does not > recognize URL's as valid (normative) concept, I believe. > An ISO standard is defined by its ISO code and date, not > by the content of any URL whatsoever. > > "ISO/IEC 9899:1990" is as close as it gets. The previous > (ANSI) standard was ANS X3.159-1989, but it was replaced > by the ISO standard, world-wide, including the United States. > > > have a different idea of what constitutes "ANSI C". This can > > The Standard is fully defined by the above-mentioned documents > (obviously as amended by the ISO working committees: currently, > Technical Corrigendum 1 [1994] and Normative Addendum 1 [?date?], > at least, are law [part of the current definition of ISO 9899, > and implicitly *and normatively* referenced when that standard > is specified). > > > either be a complete standard (preferable), or just the parts > > that Python uses. > > I'm not sure about what you have in mind, but, in case it's > that, you cannot just publish copies of an ISO Standard: ISO > retains copyright, and you need to license it from them (such > licensing fees are used by ISO as a revenue source). > This is so STUPID and short sighted. Surely the whole point of a standard is that it is everywhere and charging people for reading it will surely negatively affect the spread of the standard. Could this possibly be why there are so many non-standard compilers around ? > I understand it would be different were it strictly a United > States matter (governmental bodies cannot, by law, own any > copyright in the US, isn't it so?), but it isn't. > So how do you propose to explain to people what exactly is meant when Python says that it is "Standard ANSI C" ? The number is meaningless, you can't freely read the standard, so what do I as an individual do when I want to ensure that my Python extension (not that I have one ;-)) is "Standard ANSI C". > > Also, are you going to enforce this by checking when > > configuring Python that the compiler is 'Standard', passing > > the correct options to the compiler to make it so if it> > doesn't default to it or will you rely on the user 'knowing' > > enough to do thinks like > > CC="cc -ansi-magic-blah" ./configure .... > > At this point I'm not sure I understand what you mean by > "you" in this context. _I_, as an individual, am most likely > not going to either enforce, or fail to enforce, anything > whatsoever. As for "checking", there are no conformance > suites officially blessed by ISO (that I know of), and I do > not understand what, pragmatically, that would add. > > A configuration/setup file normally suggests/defaults-to > certain switches/options for whateve compiler targets, of > course; e.g., "-lm" is a popular option to ensure the math > library gets included at link-time. On a supported platform, > those switches are part of the way the build is pre-configured; > on an unknown platform, determining the appropriate switches > is part of the porting process. You seem to be implying that > there is something deeply different from doing this for the > purpose of "ensuring ISO 9899 is supported at some level" > rather than the purpose of "ensuring the math libraries are > included in the link step" -- or, indeed, finding out WHAT > the name of the C compiler *IS* on some unknown platform > (surely you don't believe it's "cc" everywhere, right...?-). > > So, what point[s], exactly, are you trying to make, or else > to ascertain...? > The point I am trying to make is that all sorts of questions arise when you say "CPython source is Standard ANSI C". Answering those questions will take some effort, and the reworking of the source will take a massive effort and for what benefit ? I don't think that you will significantly reduce the complexity of the code, or improve it in terms of readability because there will always be one compiler which isn't quite ANSI due to a bug, or a different interpretation of the standard. So the code / configure will be tweaked to make it work and the same will be done for the next one, ... before you know it you are back to square one. As an example just recently someone reported a bug in I think a quite new version of the HP compiler which meant that "\x12" sequences weren't handled properly so along came a little patch to the Tcl core..... Currently the compilers you support are exactly those compilers which can compile Python as is which may include some conditional code as determined by autoconf/configure. From peter_white at pjwc.compulink.co.uk Tue Aug 15 05:29:00 2000 From: peter_white at pjwc.compulink.co.uk (Peter J White) Date: Tue, 15 Aug 2000 10:29:00 +0100 Subject: Newbie question re: decompiling python Message-ID: <8nb2kk$e22$1@plutonium.compulink.co.uk> Hi How can I decompile a python PYC file to see the source? TIA Pete From Kevin.Digweed at dial.pipex.com Wed Aug 9 04:15:06 2000 From: Kevin.Digweed at dial.pipex.com (Kevin Digweed) Date: Wed, 09 Aug 2000 09:15:06 +0100 Subject: Can I do this faster? References: <3990FBCE.ED3458D8@proceryon.at> Message-ID: <3991130A.A8A17326@dial.pipex.com> Hi Horst! If you really want to speed this up, then your best bet is to keep the data shadowed in a structure for which the row is the key (assuming it's an immutable value). For example (uncompiled and untested, but double-checked): class foo: # (This is the class of 's', in your example) def generate_quick_lookup(self): self.quick = {} for key, value in self.__rowDict.items(): self.quick[value['data']] = key def __GetRowID(s, row): try: return s.quick[row] except KeyError: pass # Drop thru to return None. Of course, it defeats the object if you need to call s.generate_quick_lookup() each time before you call __GetRowID(), so this approach only helps if you can keep the 'quick' dict up-to-date as the row information upon which it's based is changed without having to process the whole thing each time. And even then, the actual benefit will depend on the ratio of lookups to modifications (I'm assuming that the ratio is high in this case - and therefore it's a reasonable thing to attempt - as you say the lookup code in question 'is executed very often'). If you know that the 'row' values are all numeric, know the maximum row value and know it's not too large to preclude having a list of that size lying around, I suspect the following will be even faster doing the actual lookup (same disclaimer re: testing as above): class foo: # (This is the class of 's', in your example) def generate_quick_lookup(self): self.quick = [None] * MAX_ROW for key, value in self.__rowDict.items(): self.quick[value['data']] = key def __GetRowID(s, row): return s.quick[row] # Might want to try/except, but that would hide out-of-range row errors. Horst Gassner wrote: > > Hello! > > The following code is executed very often in my program and I would be > happy if someone could help me to speed this up. > > def __GetRowID (s, row): > for key in s.__rowDict.keys(): > if s.__rowDict[key]['data'] == row: > return key > > Thanx in advance > Horst From alex at magenta.com Mon Aug 28 03:39:53 2000 From: alex at magenta.com (Alex Martelli) Date: Mon, 28 Aug 2000 09:39:53 +0200 Subject: gratuitous new features in 2.0 References: <7ba5.39a2ccf0.27c0b@yetix.sz-sb.de> <8o026t0rdi@news1.newsguy.com> <3dg0nuspxp.fsf@kronos.cnri.reston.va.us> <8o4e4o$mat$1@slb3.atl.mindspring.net> <39A78701.720CCEA4@seebelow.org> <8o8qi302ls5@news1.newsguy.com> <39A9638D.CAE7308A@seebelow.org> Message-ID: <8od58h0rdo@news1.newsguy.com> "Grant Griffin" wrote in message news:39A9638D.CAE7308A at seebelow.org... [snip] > It sounds to me like we primarily disagree on how grievous the issue of > adding new keywords is. Personally, I don't think it's the worst thing > in the world. <"Practicality beats purity"; "readability counts"> So Practicality dictates not breaking good working code. Python has managed to avoid new keywords for 6+ years; do you think that Python source code is unreadable because of that?! Breaking this excellent track record, particularly for the sake of a minor, debatable readability improvement to an absolutely marginal feature, would be a design decision of such abysmal quality as to defy belief; if it did happen, I would have to opine that meddlesome aliens have kidnapped our BDFL into their flying saucers, and substituted him with one of their minions, shaped to his superficial likeness. I'd MUCH rather the 'marginal feature' in question be placed in a function (or method), but if it absolutely HAS to be exposed as an extra feature of the print statement, then the "print>>" blotch is still heads and shoulders above the option of breaking good code. Alex From donn at u.washington.edu Wed Aug 2 16:33:09 2000 From: donn at u.washington.edu (Donn Cave) Date: 2 Aug 2000 20:33:09 GMT Subject: Bug in os.stat-module?? References: Message-ID: <8ma0i5$3r2c$1@nntp6.u.washington.edu> Quoth "THOMAS WEHOLT" : | I try to get the different date-variables from a file on a cd-rom using the | os.stat-method. It returns the same integer for all three, atime, ctime and | mtime. Doing the exact same on a plain file anywhere else on the filesystem | other than cd-rom will return, three, or at least two different integers. | But on the cd-rom all the files have the same integer-value returned from | the os.stat-call. Why? | | Anybody with the same experience and a possible workaround or fix? I find the same on FreeBSD 4.0. I don't think there is any workaround or fix. If you think about it, I think you'll agree that it's the only way it could work, when the filesystem resides on a readonly medium. Donn Cave, donn at u.washington.edu From fbochicchio at galactica.it Tue Aug 1 03:03:59 2000 From: fbochicchio at galactica.it (Francesco Bochicchio) Date: Tue, 01 Aug 2000 00:03:59 -0700 Subject: I have some problem about IDLE, help me... References: Message-ID: <3986765F.8CF31E4A@galactica.it> Pi wrote: > > I install Python by Debian Pakage... > python excute well... > but IDLE does not... > if I type "idle" > I got below message... > > Traceback (innermost last): > File "/usr/bin/idle", line 3, in ? > PyShell.main() > File "/usr/lib/idle/PyShell.py", line 612, in main > fixwordbreaks(root) > File "/usr/lib/idle/editorWindow.py", line 606, in fixwordbreaks > tk.call('tcl_wordBreakAfter', 'a b', 0) # make sure word.tcl is loaded > TclError: extra characters after close-quote > Not sure about that, but probably it is a matter of version of Tcl/Tk. I have debian potato (2.2 or 'frozen-going-to-stable'), Tcl8.0, TK 8.0, python 1.5, python-tk 1.5.2 packages and idle (1.5.2) works fine. If this does not help, take your problem to user-debian at lists.debian.org. They usually are quite helpful. Tip: have you considered Emacs + python_mode ? I find it more useful than idle ( at least for now ). Just my 2 lire, anyway. -- FB From m.faassen at vet.uu.nl Thu Aug 3 13:09:42 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 3 Aug 2000 17:09:42 GMT Subject: Python not that wierd References: <31575A892FF6D1118F5800600846864D4C713A@intrepid> <8mc579$5ui$1@nntp9.atl.mindspring.net> Message-ID: <8mc90m$po6$1@newshost.accu.uu.nl> Aahz Maruch wrote: > In article <31575A892FF6D1118F5800600846864D4C713A at intrepid>, > Simon Brunning wrote: >>> >Er, what, me an obsessive RPGer? Nooooooooo. >>> >>> Nah. ;) >>> >> I think that we need an RPG SIG! > Roll 3d6 to see if it happens. (Yes, I'm fundamentally a D&D type, why > do you ask?) I officially run a GURPS campaign, but it's very low-rule and low-dice; it's mostly freeform. Oh, and I also co-manage a mud. Should-organize-a-game-at-the-next-conference-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From SBrunning at trisystems.co.uk Fri Aug 4 03:57:37 2000 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Fri, 4 Aug 2000 08:57:37 +0100 Subject: Newsgroup Archieves ??? Message-ID: <31575A892FF6D1118F5800600846864D4C7157@intrepid> > Go to www.deja.com if you want to search news archieves. > Deja dropped the older archives recently. They only have a year or so's worth now. Real shame. Anywhere else? Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From g2 at seebelow.org Wed Aug 30 14:53:48 2000 From: g2 at seebelow.org (Grant Griffin) Date: Wed, 30 Aug 2000 19:53:48 +0100 Subject: Python questions from C/Perl/Java programmer References: <397C6F49.7BEBB207@alabanza.net> <397CC80C.43F5D8@alabanza.net> <397CE009.69835D49@yale.edu> <39AAA429.3053E515@erols.com> <39AC1FB0.315A8AC@seebelow.org> <1eg77vp.1sz1vup1j23i6dN@paris11-nas8-21-214.dial.proxad.net> Message-ID: <39AD583C.6BF298DE@seebelow.org> Fran?ois Granger wrote: > > Grant Griffin wrote: > > > (BTW, I > > never figured out why bright guys like that can't understand that > > newbies don't know how to "grep a FAQ" <>) > > BTW, I don't have anything called "grep" on my Macintosh. And I have > both Python and Perl installed ;-) Don't worry, it's just a silly Unix thing. ;-) You Mac folks probably either don't need it, or else maybe you've got something that does about the same thing, but's a whole lot easier to use. That said, I grep almost daily on my Windows machine. I have a DOS version of grep that came with Borland Pascal about 10 years ago. It still works great. (Microsoft is nothing if not backward compatible. ;-) But it wasn't until I learned Perl that I found out what this nebulous thing called a "regular expression" really was; since REs were my grep's default mode, I had endless trouble whenever I tried to grep on about anything but characters and numbers--because those things constituted a regular expression I didn't intend. one-man's-feature-is-another-man's-bug--ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From tim_one at email.msn.com Tue Aug 1 15:47:13 2000 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 1 Aug 2000 15:47:13 -0400 Subject: Debugging strategy? In-Reply-To: <8m78ee$dds$1@news7.svr.pol.co.uk> Message-ID: If you use try/except, make very sure you're not suppressing any errors you didn't intend to suppress. If the algorithm was using ints instead of longs by accident somewhere, and you're not using try/except, Python would have screamed at you (by raising OverflowError) if ints weren't "big enough" to hold your results. There are no known bugs in Python's long int routines, and indeed they haven't been changed in years. "trillions" is actually small compared to what people usually use Python's longs for. As a general clue, when errors pop in "big" problems that didn't show up in "short" ones, it's often simply the case that the "big" problem caused an unusual path through the code to be taken, and there's a bug on that path. You *should* have a collection of small test cases that guarantees to exercise every possible path through your code. In general, the more "if"s in the code, the less effective "random" small tests will be. All in all, sounds like you're in for a lot of pain . > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of Duncan Smith > Sent: Tuesday, August 01, 2000 3:28 PM > To: python-list at python.org > Subject: Debugging strategy? > > > I have a directed tree structure (possibly a forest). A weight (long > integer) is associated with each vertex. I can permute the structure > locally and calculate the new (local) weight and thus the overall > weight of > the tree. The goal is to minimise the overall weight. The vertex weights > can be very large (trillions). I am currently using simulated annealing, > which works fine for most trees. But occasionally, for larger trees, > something goes awry and I find that either the tree has not been permuted > correctly, or the weight has not been calculated correctly (I suspect the > former). There is no apparent reason why this should be more likely to > occur for larger trees and I'm pretty confident my scheme is O.K. > on paper. > I've tried reproducing the fault on small trees without any luck. > > The problem is that I don't know how to go about debugging my > code when the > problem arises so infrequently; possibly on the 20,000th iteration of an > algorithm. Has anyone any idea how I might tackle this problem? Does it > sound characteristic of a particular type of coding error (bearing in mind > I'm no computer scientist)? Might I be running into problems with using > such large integers (I've checked that they remain long integers > throughout > the permutation scheme)? I'm not expecting anyone to find the bug for me > because following my code would require a much more detailed > explanation of > the permutation scheme and/or the full 50+K of code. But I would > appreciate > any advice. Thanks in advance. > > Duncan Smith > > > -- > http://www.python.org/mailman/listinfo/python-list From Bill.Scherer at VerizonWireless.com Wed Aug 2 07:42:17 2000 From: Bill.Scherer at VerizonWireless.com (Bill Scherer) Date: Wed, 02 Aug 2000 07:42:17 -0400 Subject: python implemenation of rotor? Message-ID: <39880919.3F3CEC45@VerizonWireless.com> Hello, Does anyone know of a 'Pure Python' implementation of the rotor module? I would like to use rotor with JPython. Thanks! -- William K. Scherer Sr. Member of Applications Staff - Verizon Wireless Bill.Scherer_at_VerizonWireless.com From donn at u.washington.edu Tue Aug 8 12:39:28 2000 From: donn at u.washington.edu (Donn Cave) Date: 8 Aug 2000 16:39:28 GMT Subject: PyObject *data - access to raw data? References: <398FEE6B.9EE7645A@ix.netcom.com> <398F5D4A.9284D9F3@ix.netcom.com> <398F1A49.45D11EBC@ix.netcom.com> <8mneq3$4hb4$1@nntp6.u.washington.edu> <8mo5es$o80$0@216.39.151.169> Message-ID: <8mpd40$89ei$1@nntp6.u.washington.edu> Quoth Thomas Gagne : ... | It would seem the pack and unpack methods are great for creating a structure a | once, but not so great at accessing members of a structure for purposes of | manipulation. I've decided to create a class that uses a dictionary to mainta | values for the members. It uses a method called asBytes() to return the strin | by struct.pack(). I should probably call it asString() since I'll document th | arguments to send and recv and string arguments. That looks good. You could also call it __str__, though there is some difference of opinion on this. __str__ supports the str() function. For some people, this should be a ``friendly'' text representation, i.e. I guess readable. For me, it's the object qua string, and if that's readable, fine. (This is particularly in contrast to __repr__, which I think everyone agrees should be text.) Anyway, I guess the most likely advantage of calling it __str__ is that it would be invoked automatically in %s formatting. | Of course, right not its all buried inside my IsdHeader class, but I'm thinkin | create a more general class called CStructure that defines all the methods for | things, then subclassing it to create IsdHeader. Well, it sounds like you're having fun. From a practical point of view it sounds like we're approaching overkill, but that's a judgement call. Speaking of overkill, I think you are probably finding that your read/write accessor overloading isn't working. Unlike C++, Python doesn't support different functions with the same name but different signature. You can simulate it with a kind of varargs feature (try a parameter declared with a leading "*"), or with default arguments, but it's not commonly done and for me it isn't idiomatic Python. Might as well say getstatus()/setstatus(). Now, for a really intrusive accessor feature that is occasionally used in Python code (I think usually to the sorrow of everyone concerned, but others might disagree), consider this: class T: def __init__(self): self.__dict__ = {'x': 0, 'y': 0} def __getattr__(self, name): print 'getattr', repr(name) if name == 'xy': return self.x * self.y else: raise AttributeError, name def __setattr__(self, name, value): print 'setattr', repr(name), repr(value) if self.__dict__.has_key(name): self.__dict__[name] = value else: raise AttributeError, name t = T() print t.x print t.xy t.x = 5 t.y = 2 print t.x print t.xy print dir(t) I think the most useful thing about this is that since you know it's there in case you need it, you can relax and just code direct access to class instance attributes and avoid the probably pointless hassle of a pair of accessor functions dedicated to each attribute. Then if changes to the class mean you need to calculate a value on access, you can use these functions to do it -- in this extremely unlikely case, and 99 out of 100 classes you write will never need any such thing. Note that __getattr__ is called for only those attributes that don't already appear in the instance's __dict__. Donn Cave, donn at u.washington.edu From gregor at hoffleit.de Sat Aug 5 09:20:12 2000 From: gregor at hoffleit.de (Gregor Hoffleit) Date: Sat, 5 Aug 2000 15:20:12 +0200 Subject: Python 1.5.2 illegal ? Message-ID: <20000805152012.A16409@53b.hoffleit.de> Pardon me. Just a request for clarification. Does CNRI consider the use and distribution of Python 1.5.2 illegal ? It looks like CNRI is currently owner of the Python sources, and therefore they can change the license under which they distribute these sources at their free will. They choose to come up with a new license for their next, last Python release, 1.6. That's fine. Still, I got Python 1.5.2 under the terms of the old Python license. Suppose it happens that I like the old license much better. According to the terms of the (BSD like) Python 1.5.2 license, nobody could stop me from forking a new Python development tree, forked from the 1.5.2 sources. That's what happened to SSH 1.x, and now we have OpenSSH (and everybody is using that ;-). We could even call it FreePython and release it under the GPL. The old Python 1.5.2 license would allow that! Now earlier statements in this discussion made it look like CNRI would deny that we had this right to fork and relicense. Is that impression correct ? Then it sounds like CNRI is telling us that the 1.5.2 (and earlier) release was illegal to use and distribute, since its license was invalid. Similarly, I think PythonLabs had the option to fork Python 2.0 either from the to-be-released Python 1.6 under the CNRI license, or from the old Python 1.5.2 tree under the old Python license. I understand that much work has been done from 1.5.2 until 1.6b1, but if the CNRI license really would do the wrong thing (which is not yet sure), that would be an option, right ? I haven't researched that in depth, but I have the impression that there are quite a few Linux apps that might become illegal to use with Python 1.6 if the CNRI license wasn't GPL compatible. Things that come to mind are PyGtk and PyGnome, Sketch 0.7.x, Gimp-Python, Gnumeric's Python plugin etc. pp. Also, it would make linking Python into the to-be-released StarOffice 6.x impossible, AFAICS. If that happened, forking from Python 1.5.2 might become a necessity. Gregor On Mon, Jul 31, 2000 at 05:35:06PM -0400, Andrew Kuchling wrote: > CNRI's corporate counsel, for good or ill, does not believe the GPL > will ultimately stand up in court. I think this is incorrect -- Next > backed down and obeyed the GPL's terms in their use of GCC, and both > IBM and Sun, two entities not noted for disregarding legal niceties, > consider the GPL binding enough to use for releases of some of their > own code -- but my opinion is of little weight. From stuart.dallas at rcp.co.uk Wed Aug 9 04:13:01 2000 From: stuart.dallas at rcp.co.uk (Stuart Dallas) Date: 9 Aug 2000 08:13:01 GMT Subject: VC++ extension References: <8mp96k$3jm$1@nnrp1.deja.com> <3990C4AF.8C72A366@san.rr.com> Message-ID: <8F8B59E42stuartdallasrcpcouk@194.238.50.13> jkraska1 at san.rr.com (Courageous) wrote in <3990C4AF.8C72A366 at san.rr.com>: >Stuart Dallas wrote: >> >> I am developing an extension for Python in Visual C++ 6. I have created >> a Win32 DLL project and exported the initx function. When I try to >> import the extension into Python it responds with the following message: >> >> ImportError: dynamic module does not define init function >> >> I have checked the DLL with QuickView and the init function is being >> exported. >> >> Help! > >One: if you are not actually using classes or other C++ features, >rename your file from .cpp to .c. The designers of Visual C++, >in Their Infinite Wisdom (tm), decided that this would be the >way you'd tell their compiler you want ANSI-C compatability. Thanks. Changing the file extension to .c worked. -- Stuart Dallas RCP Consultants Ltd http://www.rcp.co.uk From kpmurphy at my-deja.com Wed Aug 9 17:33:01 2000 From: kpmurphy at my-deja.com (Keith Murphy) Date: Wed, 09 Aug 2000 21:33:01 GMT Subject: python: bug or feature? Message-ID: <8msimd$bia$1@nnrp1.deja.com> the first one works, but the second one always returns a 0. ( (e%4 == 0) & (self.current == e-1) ) ( e%4 == 0 & self.current == e-1 ) is there some reason the ordering in python can't accept the second one? thanks, -->keith Sent via Deja.com http://www.deja.com/ Before you buy. From uma at webde-ag.de.oz Wed Aug 30 03:50:34 2000 From: uma at webde-ag.de.oz (Uwe Maurer) Date: 30 Aug 2000 07:50:34 GMT Subject: How to create instances of classes in extension module? Message-ID: <8FA062305umawebdeagde@195.226.96.130> Hi, How can I create an instance of a python class in an extension module? More in detail: I have a class written in python and an extension module written in C. The extension module exports a function that should return an instance of the class. But how do I create an instance of that class in my C-code? Any hints? Thanks in advance. Uwe Maurer From hniksic at iskon.hr Tue Aug 8 16:15:21 2000 From: hniksic at iskon.hr (Hrvoje Niksic) Date: 08 Aug 2000 22:15:21 +0200 Subject: Creating Python "executables" on Windows? References: <8mp4at$e38$1@news1.wdf.sap-ag.de> <8mpaa302uoi@news2.newsguy.com> Message-ID: "Alex Martelli" writes: > "Hrvoje Niksic" wrote in message > news:wkr97zhkkc.fsf at iskon.hr... > > "Daniel Dittmar" writes: > > > > > - if you're using the DOS prompt, you can set the environment variable > > > PATHEXT to include .py. > > > > How do I do that? When I try `echo %PATHEXT%', I only get "ECHO is on". > > Are you on NT? Nope; that's Windows 98. Second edition, if it makes a difference. > > That would be very cool. I've installed Python using the > > installer provided on www.python.org (py152.exe). I'm not sure > > how I missed the assoc thing. > > It should do it automatically. (...) I now believe it's right, because the Python files have the snake icons in the explorer. From nowonder at nowonder.de Tue Aug 29 04:15:42 2000 From: nowonder at nowonder.de (Peter Schneider-Kamp) Date: Tue, 29 Aug 2000 08:15:42 +0000 Subject: Python 1.6 The balanced language References: Message-ID: <39AB712E.805ACB4B@nowonder.de> Suchandra Thapa wrote: > > Manuel Gutierrez Algaba wrote: > > > > What will happen in Python 3000 ? > > Well, that balance will be broken and python won't make sense > > any more. Sure, it'll be the same language : python. But, people > > will experience __always__ some kind unrest, because advanced > > features of some of the families will pop up, and nobody > > belongs to all the families. So Java-C++ guys will have hard > > times with functional, Functional-guys will have hard times > > with hard types... > > I disagree with you there. Pulling in strict or static typing > would be useful for large projects and wouldn't confuse anyone with > with c, c++, or functional language exposure (okay, polymorphic types > and parametric types would confuse c and c++ people a bit). The functional > extensions to python seem to mainly consist of a few additions and refinements > to the current features. I don't see any calls for adding the more "advanced" > features such as lazy evaluation or monads. Lazy evaluation? Guido seems to be less reluctant to add this some time in the future, if I channel him correctly (what, of course, only Tim can do right). There has always been a lot of people proposing/ advocating lazy evaluation. Monads? It took me almost two weeks to understand the concept. Anyone seriously proposing to add monads to Python should have to implement a Python compiler with Haskell monads first. Note that I had to implement a compiler for a Pascal subset using *a lot* of monads. > >Sometimes there are even technical drawbacks: if you use Stackless > >python (corrutines), you can use Jpython compatibility ! It is not impossible to implement coroutines for JPython. It's just hard (or impossible) to implement them efficiently without changing the VM beneath. > I don't anyone including Guido wants to have python become an > amalgam of Eiffel, Haskell, and Java since their paradigms don't mesh. I'm > not even sure how you would implement a pure functional object oriented There are stranger things under this sky. E.g. a functional language without lambda (http://www.eleves.ens.fr:8080/home/madore/programs/unlambda/). > language. Although, I think our BDFL would lean more towards a > Modula3+Haskell mixture =). Which only shows his good taste. pure-functional-programming-in-Modula3-is-a-pain-though-ly y'rs Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From kuchler at ajubasolutions.com Thu Aug 3 18:02:38 2000 From: kuchler at ajubasolutions.com (Dan Kuchler) Date: Thu, 03 Aug 2000 15:02:38 -0700 Subject: GTK/Gnome or TKinker? References: Message-ID: <3989EBFE.3EAD7BAB@ajubasolutions.com> Steve Lamb wrote: > > I've decided to embark on a project that I want to be fairly portable > across Unix and Windows. It will use a GUI and I am having trouble deciding > on which toolkit to use. I've looked into GTK/GNome and the fact that there > doesn't appear to be a fairly active port to Windows does exactly fill me with > confidence in its continued support > > OTOH is TKinker. Now, from what I hear TKinker isn't as well developed as > GTK/Gnome so while it appears to have a stable port to Windows taking up > TKinker might mean overall difficulties. > > Does anyone who has practical experience with these toolkits have any > advice? I am a tcl/tk programmer, not a python/tk programmer, but I am familiar with tk's development. Tk has been around for a long time, and as a result is pretty bug free (it comes with ~6000 tests I believe, and has been used in a fair number of commercial applications). The Tkinter releases seem to follow the Tk releases pretty closely. The next release of Tk (Tk 8.4) has several new widgets scheduled for it, which should be nice because widgets haven't been added to Tk itself for a few releases. There is a good set of features in the current toolkit, but 8.4 should have some really nice things in it. It is actively developed and bugs (especially serious ones) are fixed quickly. It is also open source (with pretty easy to read source) so if necessary you can debug Tk if you find a problem in it. I can't really speak about GTk/Gnome because I haven't written much code in it. Since it is fairly new, I have heard that some of the versions were pretty buggy and didn't have much documentation -- this all may be much better now, I really don't know. For more information on Tk and its development you can go to http://www.scriptics.com/ I hope this helps some.. --Dan From frr at mindless.com Thu Aug 31 15:03:03 2000 From: frr at mindless.com (Fernando Rodriguez) Date: Thu, 31 Aug 2000 19:03:03 GMT Subject: Access control in classes Message-ID: Hi! How can I implement some access control in my classes (equivalent to C++'s private, public, protected, etc...)? O:-) TIA From pinard at iro.umontreal.ca Tue Aug 15 10:25:05 2000 From: pinard at iro.umontreal.ca (=?ISO-8859-1?Q?Fran=E7ois_Pinard?=) Date: 15 Aug 2000 10:25:05 -0400 Subject: PYTHON IS CRAP In-Reply-To: Haniff Din's message of "Tue, 15 Aug 2000 13:22:50 +0100" References: <39986005.3A742278@nowonder.de> <461650299.20000815132250@virgin.net> Message-ID: (Also replying to the list.) [Haniff Din] > I think you've missed the whole point of the post. Indeed, I thought you were looking for a random fight, and did not understand you were serious. > Why do we need another language like "tcl" "perl" etc..? Looks like to > me people just trying to get Phds, and making like for everyone difficult. Honestly, if TCL and Perl were really satisfactory, this is quite unlikely that newer languages like Python would receive any acceptance. (For the record, Python is not _that_ new, it may be around, maybe ten years.) Python has _really_ made my life much easier. I used to program amounts of code of Perl and C[1] before. I do not use Perl anymore, and lost a good part of my interest for C. I never had the courage to study TCL or Java, or ASP or PHP, or VB, despite I often heard these are rather popular. In a word, new successful languages do address real needs, which in the free world, were deficiencies in other languages. This is a difficult undertaking to design a really good language. And most Phds are plainly forgotten :-). > I don't have the brain the size of a planet like you, able to absorb > and understand languages in seconds. Don't misjudge me. Every language I learned required a lot of work overall. Even Python. Maybe you can get the overall feeling of a language in one day, and the all essential details in one week, it still takes months to develop something that resembles a style, and becoming able to segregate between good and wrong habits. To really get the beginnings of a deeper culture, you should count a few years, for _any_ language. This is why I consider so important to select and learn at least one language well, than a lot of languages superficially. Such investments also explain why people make religions of languages, it is not easy to take a few years of life, and work and sweat, and throw these overboard. > I need fast reliable info to get started and fully understand Python in > under an hour. You can get started with Python in a few hours, I found it exceptionally easy. But there is no totally free meal. I'm working with Python with some intensity, for many months now, and even if I feel I begin to have an idea of it, I'm far from understanding it fully. It is completely unrealistic, in my opinion, to expect mastering a language under an hour. Unless the language is totally uninteresting, of course... > How am I supposed to keep up with all this web development stuff and > inform management when they say to me, why aren't using Python isn't > Perl out of date now? To keep up with everything with moves on, even superficially, is nearly impossible. Some of the current complexity looks gratuitous for me, it sometimes comes from ignorance, but this kind does not survive for very long usually. It more often comes from commercial concerns, where Microsoft (for example) introduces incompatibilities to kill competition, and difficulties to give some original value to Microsoft certification :-). Unless you want to know nothing about everything, you have to choose and specialise. Doing this while keeping an eye opened on the rest is a difficult art. Let me say that Python is one of my happiest bet, so far. ---------- [1] Before C and Perl and Scheme, I did a lot of Pascal and LISP, and before that, FORTRAN and COMPASS (both CPU and PPU), and Balm, and Snobol, Cobol, Algol, APL, and surely a few others that do not pop to my mind (I keep forgetting what I do). To some extent, I lost an incredible amount of time. I sometimes wish I found something like Python when I was younger :-). -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From hei at adtranzsig.de Thu Aug 10 06:27:30 2000 From: hei at adtranzsig.de (Dirk-Ulrich Heise) Date: Thu, 10 Aug 2000 12:27:30 +0200 Subject: Dumb wxPython install question Message-ID: <8mu06q$quc$1@desig-bs01-s04.adtranzsig.de> Hi! I'm happily using Boa constructor and wxPython on my machine at work, with Python1.5.2. (Windows NT) When trying the same at home with a Python 1.6a2, it fails to import wxPython. (it's a Win95 box) On both machines, wxPython is a subdirectory of the Python main directory. I suspected it's because wxPython is an extension so i looked for *.lib and *.dll, but i can find none on both machines. Question: Is wxPython an extension module and what *.lib or *.dlls should be there? Or do they carry a different file extension? And, is it even possible to use the same wxPython installer for Py1.5.2 and Py1.6a2? -- Dipl.Inform. Dirk-Ulrich Heise hei at adtranzsig.de dheise at debitel.net From robin at jessikat.fsnet.co.uk Fri Aug 18 15:48:54 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 18 Aug 2000 20:48:54 +0100 Subject: Creating Python "executables" on Windows? References: <8ng7080ss0@news1.newsguy.com> <8F948DDCFgmcmhypernetcom@199.171.54.155> Message-ID: In article <8F948DDCFgmcmhypernetcom at 199.171.54.155>, Gordon McMillan writes >[posted and mailed] > >Robin Becker wrote: > ... this bug is caused by the builder creating .pycs with lowercase names if they don't already exist with the right names. The installer doesn't really know which ones actually get used so it brings into existence (or tries to) badly named .pycs which it then complains about. -- Robin Becker From tgagne at ix.netcom.com Tue Aug 22 10:28:47 2000 From: tgagne at ix.netcom.com (Thomas Gagne) Date: Tue, 22 Aug 2000 10:28:47 -0400 Subject: import rfc822 # email headers and such References: <39999AED.F412E930@ix.netcom.com> <200008160718.JAA01207@kazul.rwth-aachen.de> Message-ID: <39A28E1F.647FB64B@ix.netcom.com> That would be a great idea, but I'm afraid I'm a little too new at this to volunteer, yet. From * at spam.ruud.org Tue Aug 8 11:39:54 2000 From: * at spam.ruud.org (Ruud de Rooij) Date: 8 Aug 2000 17:39:54 +0200 Subject: copying a list References: <39904406.9DCD282@yahoo.com> Message-ID: <8766pb92yd.fsf@hobbes.home.ruud.org> Gert-Jan Hovinga writes: > is there an easy way to get a copy of a list instead of a reference? > > for example, the following code prints [[1]] : > > a = [1, 2] > b = [] > b.append(a) > a.pop() > print b > > but i want it to print [[1, 2]] > > any easy solutions? or do i have to write a copy function myself? Use b.append(a[:]) instead. - Ruud de Rooij. -- ruud de rooij | *@spam.ruud.org | http://ruud.org From gpepice1 at nycap.rr.com Fri Aug 4 23:19:26 2000 From: gpepice1 at nycap.rr.com (gbp) Date: Sat, 05 Aug 2000 03:19:26 GMT Subject: are there any tutorials that someone completly new to programming can understand? References: <8l4klm$2kl$1@slb6.atl.mindspring.net> Message-ID: <398B88C0.C9F68EA1@nycap.rr.com> There are a lack of books on Python in general so there's a really big lack of books on niche things. All the books on python are for people who basically know how to program already. Python really is a good teaching langauge because its both 'correct' and fairly complete. You can write a lot of cool programs in python fairly easily compared to C. I think that college professors and high school teachers should teach Python insted of BASIC. BASIC is often taught to lower level programming classes because its accessable. However, basic is a pretty bad langauge. For higher level classes C (now C++, or even Java) is taught. C is great if you have 4 years and are highly motivated to learn about computers. When your learning on your own the quality of the book can be as if not more important than the langauge. Python is a great language but... People have learned with all different kinds of langauges. There is no right way to learn. Real programmers usually know 2-5 langauges fairly well. Since the demand for programmers is so high theres a whole new bred of paid visual basic programmers who barely know anything about programming langauges-- a similar thing is true for network administrators. Some people who have gone through school or have a lot of work experience may have been exposed to ten or even twenty. Langauge nuts may 'know' even more. I'm only 25 and iv'e written programs in basic(many flavors), logo, pascal, C/C++, lisp(weird), Perl(very weird), bash(sucks), SQL, and javascript(not that good), a little java, and now python (yeah!). Different langauges are good at different things, so there is never going to be a best langauge. People may argue about what the best langauge is in a particular niche. Since the major obstical is going to be motivation you should pick a language that you think is cool. After that try to lacate decent teaching materials. If you can't find them move on. If you have an interest in a particular field try a langauge that you know is used in that field. My advice to you is that the best books for learning programming come out of the acedemic world. Try to get a book that is meant for a first and second semester course in Computer science and is written by a professor or other acedemic. Try writing some toy programs. This is my short list of ones to check out: **** Logo: A fun little langauge that has a built in graphics engine. This is often used to teach kids but unlike basic it is actually a good langauge. *** C: Not for the faint of heart but if you want to know the internals of how computers actually work this may interest you. Note I said C not C++. *** Pascal: This is actually designed as a teaching langauge. (I think Logo was too) Not bad but it may be hard to write something cool in it. Lots a lanagues like Delpi and modula-2 are pascal-like. *** Java: The OOP is kinda tough but this language is solid. Good book essential. IDE recommended. *** Linux: Not a programming language :) Good way to learn about computers and operating systems. Also includes about 10-20 free langauges. SUSE Linux has the most stuff. ** 1/2 Visual Basic: Easy to actually build things with. Just don't let it go to your head. Your not a real programmer until you know TWO langauges :) *** HTML: Not exactly a langauge either but may be interesting. You combine this with other stuff to make web sites. *** SQL/Databases: Kindof a career thing. Databases are kindof interesting in there own right. SQL is a special lanaguage to manipulate databases. Access programmers are kindof like the Visual basic programmers. (Your not a real DBA until you know a 'real' database like Oracle, DB2, or Sybase :) Dan^ wrote: > > well..im 17 and thought that i should start with a programming language, and > after checking with some of my friends, they pointed me to python > > but, all the tutorials seem to be for those that have spent years in > programming (mabey im just looking in the wrong places) but id really like > to try my hand at this > > anywho, thx in advance > -Dan From m.faassen at vet.uu.nl Thu Aug 3 18:55:03 2000 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 3 Aug 2000 22:55:03 GMT Subject: Still no new license -- but draft text available References: Message-ID: <8mct87$fkm$2@newshost.accu.uu.nl> Tim Peters wrote: [Gordon appears to be quoted:] >> "Click first, read later" - Gen. Westmoreland >> "I click, therefore I am" - Renee Descartes >> "I am, therefore I click" - Martijn Faassen > "Click cluck, I'm a duck" - Gordon Is something wrong with the web-mail gateway? I seem to be missing out on messages, or at least to see replies before the originals come in. "Ick, it's a clam!"-ly yours, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From rumjuggler at cryptarchy.org Fri Aug 18 16:26:09 2000 From: rumjuggler at cryptarchy.org (Ben Wolfson) Date: Fri, 18 Aug 2000 20:26:09 GMT Subject: ANN: unlambda.py References: Message-ID: On Fri, 18 Aug 2000 20:08:47 GMT, Ben Wolfson wrote: >def pipe_fun(arg): > global curchar > if curchar: > return arg( dot_func(curchar) ) > return arg(v_func) This should be called "pipe_func". Damn. -- Barnabas T. Rumjuggler's page of dumbth: members.home.net/rumjuggler Remember, there's a difference between lesbians and tomboys. Tomboys have a square Walkman. Lesbians have a rectangular Walkman. -- Kibo From jh at web.de Sat Aug 26 22:57:00 2000 From: jh at web.de (Jürgen Hermann) Date: Sun, 27 Aug 2000 04:57:00 +0200 Subject: ANN: MoinMoin 0.2 Message-ID: <8oa01t$ojs$1@news.online.de> A WikiWikiWeb is a collaborative hypertext environment, with an emphasis on easy access to and modification of information. MoinMoin is a Python WikiClone, requires only a working webserver and Python 1.5.2 installation (might work on 1.6 though), and uses plain files to store all information. Release Name: 0.2 This release features major improvements over the first beta release, including: * detection of conflicting edits * versioning and diffs * Latin1 WikiNames * InterWiki support * print preview * inline images * numbered lists * and finally, some bug fixes. ---------------------------------------------------------------------------- ---- New features: * When saving, a datestamp saved in the form and that of the file are compared now; so, accidently saving over changes of other people is not possible anymore (saving still needs file locking though, for race conditions) * if the directory "backup" exists in the data dir, pages are saved there before a new version is written to disk * Removed the "Reset" button from EditPage * Added "Reduce editor size" link * Added Latin-1 WikiNames (J?rgenHermann ;) * Speeded up RecentChanges by looking up hostnames ONCE while saving * Show at most 14 (distinct) days in RecentChanges * Added icons for common functions, at the top of the page * Added a printing preview (no icons, etc.) * Added bracketed (external) URLs * Added support for quoted URLs ("http://...") * Added styles for :visited links to CSS * Embed image if an URL ends in .gif/.jpg/.png * No markup detection in code sections * Grey background for code sections * Added handling for numbered lists * the edit textarea now grows in width with the browser window (thanks to Sebastian Dau? for that idea) * Added page info (revision history) and viewing of old revisions * Added page diff, and diff links on page info * Added InterWiki support (use "wiki:WikiServer/theirlocalname"; the list of WikiServers is read from "data/intermap.txt") * Added "normal" InterWiki links * Added "action=raw" to send the raw wiki markup as text/plain (e.g. for backup purposes via wget) Bugfixes: * Removed an exception when saving empty pages * Fixed bold nested into emphasis ('''''Bold''' Italic'') From seefelds at magellan.umontreal.ca Mon Aug 21 15:21:02 2000 From: seefelds at magellan.umontreal.ca (Stefan Seefeld) Date: Mon, 21 Aug 2000 19:21:02 GMT Subject: trouble with the C API References: <39A1561D.DB9442FF@magellan.umontreal.ca> Message-ID: <39A18286.24034F8C@magellan.umontreal.ca> Bernhard Herzog wrote: > The PyDict functions only work with dictionary objects. The PyMapping > funtions are more general and work with all objects that support the > mapping protocol at the C-level. uhm, it appears I don't understand the python object model. How is the type of an object determined if not by inspection of the supported protocols (i.e. the existence of certain attributes, methods etc.) ? Well, looking at the (C) sources I get part of the answer: Each object has a type object associated with it. Let's rephrase the question then: doesn't each object have two types, one static type, determined by the type object it refers to and one dynamic type, given through the presence (at a given point in time !) of a particular method or attribute ? Why this ambiguity ? (please excuse my lack of understanding. I'm deeply trained by the C++ object model so I may have difficulties to adopt to other forms of life ;) Regards, Stefan _______________________________________________________ Stefan Seefeld Departement de Physique Universite de Montreal email: seefelds at magellan.umontreal.ca _______________________________________________________ ...ich hab' noch einen Koffer in Berlin... From nowonder at nowonder.de Tue Aug 8 04:17:51 2000 From: nowonder at nowonder.de (Peter Schneider-Kamp) Date: Tue, 08 Aug 2000 08:17:51 +0000 Subject: Waiting awhile References: <8mmvlh$ep6$1@nnrp1.deja.com> Message-ID: <398FC22F.6D139327@nowonder.de> Mike Olson wrote: > > How do I make a function delay for a second or two? Is there a way Does this work for you?: import time time.sleep(1.5) # sleeps for 1.5 seconds Peter -- Peter Schneider-Kamp ++47-7388-7331 Herman Krags veg 51-11 mailto:peter at schneider-kamp.de N-7050 Trondheim http://schneider-kamp.de From neilh at scintilla.org Mon Aug 14 03:45:20 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Mon, 14 Aug 2000 07:45:20 GMT Subject: micro-Python? References: <39979DEA.731494CF@mevis.de> Message-ID: > I am looking for a nice little interpreter for my micro-controller. > (well its not so mico..it has ram and a 'fast' 32b-cpu) > > Is there some plain-c programmed Python interpreter where I could easily > put > some system-dependend stuff inside? Deeply embedded Python http://www.abo.fi/~iporres/python/ Neil From NOSPAM at pacificnet.net Thu Aug 24 11:29:53 2000 From: NOSPAM at pacificnet.net (Ian Lipsky) Date: Thu, 24 Aug 2000 15:29:53 GMT Subject: converting an html table to a tree References: <8o2lok0160q@news2.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:8o2lok0160q at news2.newsguy.com... > [posted AND mailed] > > "Ian Lipsky" wrote in message > news:to2p5.444$3Q6.18123 at newsread2.prod.itd.earthlink.net... > > hi all, > > > > I'm completely new to python...just started reading learning python. I've > > got 5 days to figure out how to write a script to take an html table and > > convert it to a tree....basically a nested array (that's my guess on how > it > > would be done anyhow). Oh yeah...and I also have to drive 3000 miles in > > those 5 days ;)p > > Despite Python's ease, coding Python while actually driving is > a practice to be discouraged. Your Python code will probably > come out all right, but your car might crash in the meantime. > > > > I was hoping someone could give me a push in the right direction. What > > functions or whatever should I look at to get this done? I saw that in the > > book it mentions pythons ability to grab html and parse it, as one if the > > pluses of the language ('internet utility modules' is what the book called > > it/them). > > Standard modules htmllib and sgmllib will indeed help you. > > > > And I just found I don't have to actually go out and grab the page off a > > webserver. It'll be a file residing on the machine where the script will > be > > run. I assume that'll make it a little easier for me :) > > Not by much, since getting data off an arbitrary URL is so easy with > Python, but, yes, you can reduce your 'main program' to two lines: > > parser.feed(open('myfile.html').read()) > parser.close() > > once you have properly instantiated the 'parser' instance you need. > > Basically, you want to derive your class from htmllib.HTMLParser, and > add methods to handle the tags you're specifically interested in -- for > the problem you stated, table-related tags. > > For any tag-name FOO, you need to define in your class, either one method: > def do_foo(self, attributes): > # do whatever > if the tag does not require a corresponding close-tag (e.g.,
); or, > more commonly, two methods: > def start_foo(self, attributes): > # opening stuff > def end_foo(self): > # closing stuff > if both an opening and a closing tag will be there ( ...
, > and similar cases). > > The 'attributes' argument is a (possibly empty) list of (name,value) pairs. > > Further, you'll want to define a method in your class: > def handle_data(self, data): > # whatever > that will receive all textual data. Of course, you'll have flags > you maintain on start/end methods telling you whether the data must > simply be discarded, or how it is to be processed if relevant. > > > Now to your specific case. The tags you may want to handle are: > > TABLE, CAPTION, COL, COLGROUP, TBODY, TD, TFOOT, TH, THEAD, TR. > > (have I missed any...?). COL, I believe, is the only one that > does not require a closing-tag (although I think COLGROUP has an > _optional_ closing-tag if COL elements are not nested in it, but > I'm not sure). Which of these tags carry significant information > for your purposes...? > > The general structure might be: > TABLE > CAPTION > THEAD > TBODY > TFOOT > CAPTION is optional. So is each of THEAD, TBODY, TFOOT: if none > is explicitly specified, TBODY is implied. Each of THEAD, TBODY, > TFOOT has contents: > THEAD|TBODY|TFOOT: > TR > TH > TD > Zero or more TH and TD within each TR, zero or more TR's. > > I'm skipping COL, COLGROUP, and the attributes, as I think they > are basically presentational only, and you seem interested in > content-structuring instead. > > > Now, we need more precise specs: what kinds of tables do you > need to parse, and how do you want to structure (and output?) > the data they contain, depending on caption/thead/tbody/tfoot > and tr/th/td issues...? > > Let's take a very simple case to make things more definite. > > We process TABLE elements where only TBODY is interesting -- > THEAD and TFOOT, we skip silently. Similarly, we skip TH > and its contents too: we're only interested in: > TABLE > TBODY (may be implied) > TR (zero or more) > TD (zero or more) > data contents of TD tags only > As a result, we return a list (Python's normal data structure > for sequences; 'array' is very specialized in Python) where > each element corresponds to one row (TR); each element in > the list is another, nested, list, where each element > corresponds to the data in a TD, in sequence. > > Our class will expect to be 'fed' a document fragment > containing exactly one TABLE (the TABLE tag will have > to be explicit), and will ignore anything outside of > that tag as well as any redundant or nested TABLE tags > that may also be present. This is basically for simplicity; > you will have to think deep about what you want to do > in each of these cases! And add good error diagnosis... > > We'll also basically assume decent nesting rather than > go out of our way to accept peculiarly structured tables; > this, too, will need in-depth review! > > > import htmllib > import formatter > import string > import pprint > > class TableParser(htmllib.HTMLParser): > def __init__(self): > self.active=0 > self.finished=0 > self.skipping=0 > self.result=[] > self.current_row=[] > self.current_data=[] > htmllib.HTMLParser.__init__( > self, formatter.NullFormatter()) > def start_table(self,attributes): > if not self.finished: > self.active=1 > def end_table(self): > self.active=0 > self.finished=1 > def start_tbody(self,attributes): > self.skipping=0 > def end_tbody(self): > self.skipping=1 > def start_thead(self,attributes): > self.skipping=1 > def end_thead(self): > self.skipping=0 > def start_tfoot(self,attributes): > self.skipping=1 > def end_tfoot(self): > self.skipping=0 > def start_caption(self,attributes): > self.skipping=1 > def end_caption(self): > self.skipping=0 > def start_th(self,attributes): > self.skipping=self.skipping+1 > def end_th(self): > self.skipping=self.skipping-1 > def start_tr(self,attributes): > if self.active and not self.skipping: > self.current_row = [] > def end_tr(self): > if self.active and not self.skipping: > self.result.append(self.current_row) > def start_td(self,attributes): > if self.active and not self.skipping: > self.current_data = [] > def end_td(self): > if self.active and not self.skipping: > self.current_row.append( > string.join(self.current_data)) > def handle_data(self, data): > if self.active and not self.skipping: > self.current_data.append(data) > > def process(filename): > parser=TableParser() > parser.feed(open(filename).read()) > parser.close() > return parser.result > > def showparse(filename): > pprint.pprint(process(filename)) > > def _test(): > return showparse('c:/atable.htm') > > if __name__=='__main__': > _test() > > > With c:/atable.htm contents being, for example: > > > > > > > > > > > > > > > > > > > >
Heading 1Heading 2
Row 1, Column 1 text.Row 1, Column 2 text.
Row 2, Column 1 text.Row 2, Column 2 text.
> > > running the _test function will emit: > > >>> tableparse._test() > [['Row 1, Column 1 text.', 'Row 1, Column 2 text.'], > ['Row 2, Column 1 text.', 'Row 2, Column 2 text.']] > >>> > > > I hope this gives you a somewhat usable start on > your problem. > > > Alex WOW....where were you when i wanted someone to do my math homework for me? :) Thanks!! I found a post a few days back that also at least pointed me at some of the things i'd want to look at (urlib and htmllib). You actually gave me more info then i wanted :) i dont need to worry about the contents of each table cell. So unless i am overlooking something, i'll really only need to worry about the TABLE, TR and TD tags. I think i have to do this as though there could be an unspecified number of tables, which shouldnt be much more complicated then doing it if it were a specified number. Anyhow, i'm going to give this a try later tonight hopefully. But it looks like time is going to kill me on this one. Oh...and i wasnt planning on driving AND coding at the same time....mainy cuz i dont have a laptop and my desktop machine just wont fit on the front seat with the monitor too :)p Thanks for the help!!! From alex at magenta.com Tue Aug 1 17:51:49 2000 From: alex at magenta.com (Alex Martelli) Date: Tue, 1 Aug 2000 23:51:49 +0200 Subject: Python equivalent of C++'s virtual destructors? References: <3985CAB9.4928BDDE@alcyone.com> <8m6v04$2q1$1@nnrp1.deja.com> Message-ID: <8m7gui1q0f@news1.newsguy.com> wrote in message news:8m6v04$2q1$1 at nnrp1.deja.com... [snip] > "Note that it is possible (though not recommended!) for the > __del__ method to postpone destruction of the instance by > creating a new reference to it. It may then be called at a > later time when this new reference is deleted. It is not > guaranteed that __del__ methods are called for objects > that still exist when the interpreter exits." > > The last sentence is news to me - it's not clear to me > what a person _is_ supposed to do to guarantee things > get cleaned up when the interpreter exits. Calling delete on all global variables should do it, if it's so crucial, unless of course there are cycles... Personally, I rely on the operating system cleaning up after me as soon as my process is over. Lazy, but... Alex From kcazabon at home.com Mon Aug 28 00:56:26 2000 From: kcazabon at home.com (Kevin Cazabon) Date: Mon, 28 Aug 2000 04:56:26 GMT Subject: Win32gui... file dialogs? References: <8o592h0cuo@news2.newsguy.com> <8o80gd02091@news1.newsguy.com> <8o87t7026gu@news1.newsguy.com> <8o8du302bja@news1.newsguy.com> <8ob6b3112il@news2.newsguy.com> Message-ID: <_hmq5.216462$8u4.2197679@news1.rdc1.bc.home.com> Hey Alex; Can the forSave flag be set to some other value for selecting a directory instead of a file? I can't seem to find any documentation on Mark's win32gui module to find out what the function would be... | if forSave == 0: isok=win32gui.GetSaveFileName(ofn) | elif forSave == 1: isok=win32gui.GetOpenFileName(ofn) | elif forSave == 2: isok = win32gui.GetOpenDirName(ofn) # or whatever... The version of Win32 that I'm running doesn't have GetSaveFileName in it yet... I'm still using build 128. I am going to upgrade to the last 1.5.2 version, but have some rework to do before I can migrate to 1.6 (I'm waiting for a final release first too). What's the function name for select directory, if there is one, in the current win32gui? Thanks, Kevin. "Alex Martelli" wrote in message news:8ob6b3112il at news2.newsguy.com... | "Kevin Cazabon" wrote in message | news:l1Zp5.210819$8u4.2129533 at news1.rdc1.bc.home.com... | [snip] | > -how would you set initial directory and file? | > -how would you set filters (multiple types, or a single selected type with | > multiple extensions) | | The current version (see later) lets you do all of these (and a bit more). | Still a small fraction of the common-file-dialog's actual flexibility, but | more of it can be added if need be. | | > It'd be nice if we could come up with a dummy-proof Python script that | > allowed you to interface with the dialog through standard Python args... | > I'm sure there's more than one person out there that would appreciate it | as | > much as I... | | No doubt, which is why I've proceeded with the development. | | > Can I convince you to help me one step further? q:] | | Sure, here comes the newest version of ofn.py...: | | | import win32gui, struct, array, string | """ofn.py: Win32 functions to get 1 or more filenames for Open or Save, | via user interaction with the file-select Common Dialog. | """ | # A. Martelli, 2000-08-27; placed in the public domain. | | OFN_ALLOWMULTISELECT=0x00000200 | OFN_EXPLORER=0x00080000 | | def arrayToStrings(resultArray): | """return list-of-strings corresponding to a char array, | where each string is terminated by \000, and the whole | list by two adjacent \000 bytes | """ | astr=resultArray.tostring() | manyStrings=[] | # perhaps a loop of string.split would be faster... | while len(astr) and astr[0]!='\000': | i=astr.index('\000') | manyStrings.append(astr[:i]) | astr=astr[i+1:] | return manyStrings | | def szFrom(anarray): | """return the string-pointer (sz) corresponding to a char | array, 0 (null pointer) if no array | """ | if anarray: return anarray.buffer_info()[0] | else: return 0 | | def arrayFrom(astring,additional=0): | """return a char array built from a string, plus 0 | or more \000 bytes as filler | """ | if not astring: astring='' | return array.array('c',astring+additional*'\000') | | def arrayMulti(stringlist): | """return a char array built from many strings, each | separated by a \000 byte, and two \000's at the end | """ | return arrayFrom(string.join(stringlist,'\000'),2) | | def buildOfn(resultarray,filters=None,initdir=None,title=None, | multisel=1,oldlook=0): | """build an OPENFILENAME struct as a string, with several | options and a given result-array for the string[s] that | will result from the GetOpenFileName call | """ | flags=OFN_EXPLORER | if multisel: flags=flags|OFN_ALLOWMULTISELECT | if oldlook: flags=flags&~OFN_EXPLORER | szfile,maxfile=resultarray.buffer_info() | szfilter=szFrom(filters) | szinitdir=szFrom(initdir) | sztitle=szFrom(title) | return struct.pack( | "3i2P2iPiPi2PI2hPi2P", | 76, 0, 0, # size, owner-hwnd, hinstance | szfilter, 0, 0, 0, # filter, custom-filter, max-cust-filter, | filter-index | szfile, maxfile, # file, max-file | 0, 0, # file-title, max-file-title | szinitdir, sztitle, # initial-dir, dialog-title | flags, 0, 0, # flags, file-offset, file-extension | 0, # def-ext | 0, 0, 0) # cust-data, func-hook, template-name | | def openNames(forsave=0,filters=None,initdir=None,title=None, | initfile=None,multisel=1,oldlook=0): | """return a list of filenames for open or save, given | interactively by the user through a common-dialog; if | more than 1 string is returned, the first is the directory, | followed by the filenames. | """ | resultBuffer=arrayFrom(initfile,8192) | title=arrayFrom(title) | initdir=arrayFrom(initdir) | filters=arrayMulti(filters) | ofn=buildOfn(resultBuffer,filters,initdir,title,multisel,oldlook) | if forSave: isok=win32gui.GetSaveFileName(ofn) | else: isok=win32gui.GetOpenFileName(ofn) | if not isok: return [] | return arrayToStrings(resultBuffer) | | def _test(): | return openNames( | filters=('Texts and scripts','*.txt;*.py','Py stuff','*.py*') | ) | | if __name__=='__main__': | print _test() | | | This ofn.openNames() offers only a subset of the flexibility of the | underlying GetOpenFileName/GetSaveFileName calls, but I've | tried to make it a reasonable subset! The filters argument is | a list of strings, alternatively the string that's displayed for that | filter in the dialog's combobox, and the corresponding mask | (one or more wildcard-containing expressions separated by | semicolons). initdir, title (dialog's title) and initfile, if present, | are each just a Python string. forsave, multisel and oldlook are | just boolean values (multisel defaults to true, the others to | false). The return value is a list of: | - 0 strings, if the user has clicked Cancel on the dialog, | - 1 string, the full pathname, if 1 file was selected and OK'd | - n+1 strings, if n files were selected and OK'd: first the | directory in which the files reside, then the n files themselves | (for each, just the filename.ext; path is not repeated). | | Anything important still missing...? | | Testing has been spotty -- let me know of any problems and I'll | try to reproduce and solve them. | | | Alex | | | | From jeremy at alum.mit.edu Mon Aug 28 09:41:40 2000 From: jeremy at alum.mit.edu (Jeremy Hylton) Date: Mon, 28 Aug 2000 13:41:40 GMT Subject: Python recursive function question References: <20000828072829.A957771@vislab.epa.gov> Message-ID: <8odq6f$4ju$1@nnrp1.deja.com> In article <20000828072829.A957771 at vislab.epa.gov>, Randall Hopper wrote: > "Python does not have arbitrarily nested scopes" doesn't invoke enough data > structures for me to understand what's really going on in the interpreter. > How is interpreter compilation of InsertionSort() fundamentally different > than compilation of Insert(). > The scopes refer to namespaces in which names are resolved. To resolve the name "Insert," Python looks in the current namespaces, the global namespace, and the builtin namespace. If your recursive function is defined at what you called file level, it is part of the module's global namespace. When the recursive call occurs inside the function, Python first looks in the local namespace (and does not find it). Then it looks in the global namespace and finds it. When you define a recursive function in another scope, e.g. inside another function or method, it does not create an entry in the global namespace. Thus, Python can not find a binding for the name and raises a NameError. -- -- Jeremy Hylton, Sent via Deja.com http://www.deja.com/ Before you buy. From sami.hangaslammi.spam.trap at yomimedia.fi Fri Aug 18 06:44:57 2000 From: sami.hangaslammi.spam.trap at yomimedia.fi (Sami Hangaslammi) Date: Fri, 18 Aug 2000 13:44:57 +0300 Subject: map strangeness Message-ID: <8nj45m$83gf$1@learnet.freenet.hut.fi> Is there any specific reason why the build-in function "map" needs to have __len__ defined for instances that emulate sequences? It doesn't seem to use the value at all, for example the following works: | |class Fib: | def __init__(self, max=None): | self.max = max | self.current = 1 | self.prev = 0 | | def __getitem__(self, i): | if (max is not None) and self.current > self.max: | raise IndexError | x = self.current | self.current, self.prev = x + self.prev, x | return x | | def __len__(self): | return 0 | >> map(lambda x: x*2, Fib(10)) [2, 2, 4, 6, 10, 16] But without the "dummy" __len__ function you get: AttributeError: 'Fib' instance has no attribute '__len__' The same holds true also for 'filter', but 'reduce' seems to work without __len__. Using Python 1.6b1 From sami.hangaslammi.spam.trap at yomimedia.fi Mon Aug 21 01:53:40 2000 From: sami.hangaslammi.spam.trap at yomimedia.fi (Sami Hangaslammi) Date: Mon, 21 Aug 2000 08:53:40 +0300 Subject: basic question, sorry References: <8nqfao$c1l$1@nnrp1.deja.com> Message-ID: <8nqg77$e9pb$1@learnet.freenet.hut.fi> wrote in message news:8nqfao$c1l$1 at nnrp1.deja.com... > How can I check that dict[n] exists or not already? > > I tried: > 1) if not dict[n] > 2) if dict[n] == None if not dict.has_key(n) From g2 at seebelow.org Wed Aug 9 17:04:34 2000 From: g2 at seebelow.org (Grant Griffin) Date: Wed, 09 Aug 2000 22:04:34 +0100 Subject: Still no new license -- but draft text available References: Message-ID: <3991C762.1E8C@seebelow.org> Piet van Oostrum wrote: > > Many people do m\not like GPL but if python had originally been released > under GPL, CNRI wouldn't have been able to change that, and all this fuss > wouldn't have been necessary. But without its generous CWI license, many of the commercial uses of Python (which have undoubtedly contributed to its success) would not have been possible. So it seems to be a tradeoff. I personally dislike the GPL because it has repeatedly left me unable to use technically-meritorious and free (!) software. So I then have to buy something, or, more often, have to write my own. That just seems wasteful. It amazes me that people who want to give away their work would want to place restrictions on its use. If one has a "gift" mentality, the gift means more if given without strings. Alternatively, if one has a "paternal" mentality, one would want to see one's software child be as widely adopted and loved as possible. So go figure. But that being said, the *empirical* evidence seems to indicate that the open/free aspect of software is much more important than whether (or not) it is copylefted. If you consider the success of Python (with its generous CWI license), Perl (with its generous Artistic License--and the Grinchly GPL available as an alternative), and the Linux Sysem (not "GNU/Linux System"--na-nya-nana-nay Mr. Stallman! ;-) available only in GPL, it all seems to add up to this: the presence or absence of copyleft probably just doesn't matter. As evidence of the merit of the GPL, we hear the example of Next having to contribute Objective C so they could use the rest of the gcc compiler. This example is notable for its singularity: I haven't heard others. Also, notice that Objective C never really caught on. And Next itself is dead (I think). So at best, there seems to be very little empirical evidence that copyleft thing actually accomplishes its goal of making otherwise closed/commercial software become open/free. If Open Source has intrinsic economic value, the copyleft concept isn't needed; if it doesn't, copyleft won't be enough to make Open Source a force. In other words, you don't need to require people to make their improvements to software open/free if the openness and freeness of those improvements is truly economically beneficial to them--they'll do that without being forced; likewise, if you _try_ to force them but they find no advanatage in it, it probably won't work; they'll just go elsewhere, as I have done many times. Likewise, one can find no obvious correlation between the copyleftness of a license and the amount of contributions a given package receive. Python is a good example of Open Source software that receives considerable contributions without a copylefted license. Ditto Perl. Personally, I think of the whole copyleft thing as being primarily a clever marketing gimmick (whether or not Richard Stallman realizes it.) It definitely has a strong appeal to a certain segment of the population--especially young people. But then again, it turns off another segment. So, from strictly a marketing point of view, it's a tradeoff. Notice, though, that copyleft seems to thrive primarily in cases where somebody is *re-implementing* an existing system--most noticably the GNU/Linux System (OK, it's probably about time I threw His Royal Root of All Square Meanness a bone ;-). Specifically, the appeal of a re-implemented free system is primarily that it is _free_. (Or, as Linus Torvalds has said, the problem with UNIX was that it was "so expensive".) But if you're trying to popularize a _new_ system (as Guido and Larry Wall once were--and still are to an extent), it makes a lot more sense not to limit the ecologies that your system can live in (by putting in license terms that discourage commercial uses); broad usage terms give it a better chance of thriving and prospering. Put another way, packages which have a copyleft license restriction are at a competitive disadvantage compared to those who don't. (Even within the world of free/open software, competition is the rule.) But I think that the success of a re-implemented system like GNU/Linux can be entirely explained by the fact that it is free, open, and very high quality--in other words, by the merits of the product itself. The fact that it is copylefted is incidental--except that perhaps Richard Stallman would never have applied his considerable drive and technical talents to helping create it if he wasn't able to create a legal mechanism to enforce his strange obsession with making it difficult for people to make money on the work he "gives" away. (which-reminds-me:-i-bet-that-red-hat-ipo-thing-last-year-must-have -really-burned-his-butt-)-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From neilh at scintilla.org Tue Aug 8 03:59:47 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Tue, 08 Aug 2000 07:59:47 GMT Subject: Advice - Learning Python as 1st Programming Language References: Message-ID: > - Would it be better from learning perspective than, say, Java or > Javascript? Python is less ad-hoc than Javascript especially the object oriented features. They are both quite easy to learn. > - Is there any useful yet simple IDE available for Windows 98?] PythonWin or IDLE. > - Any way to embed Python in web pages, like JavaScript? Or would he have to > learn 2 languages? The Win32 extensions enable you to use Python as a client side scripting language with Internet Explorer but each client has to download and install the extensions. I think there was an add-in for Netscape Navigator but haven't heard much about it. Javascript is a much better choice for client side scripting as it is available in most browsers on most operating systems. > - Any good libraries for web CGI-like calls to Python (don't really care at > this point if it uses CGI-like mechanisms or something more efficient)? There are several. I only use cgi.py which is quite simple but has been adequate so far. > - Any good libraries for building things like page template (e.g. ASP, JSP, > ...) The Win32 extensions also work for server side ASP scripts. There are others I haven't used. > If you email to me, in addition to the group, would be great. Your email address appears horribly mangled - I don't think this will reach you by email. Neil From pduffin at hursley.ibm.com Wed Aug 30 06:02:54 2000 From: pduffin at hursley.ibm.com (Paul Duffin) Date: Wed, 30 Aug 2000 11:02:54 +0100 Subject: print statement and multithreading References: Message-ID: <39ACDBCE.35536F7@hursley.ibm.com> Tim Peters wrote: > > >>>> An excellent free overview can be found at: > >>>> > >>>> http://www-ccs.ucsd.edu/c/ > > As to all the rest of this, I've really lost track of what you're trying to > accomplish. If you're concerned about writing portable C, start by > *FOLLOWING THE LINK* above (was that subtle enough?). Also read the C FAQ. > This is a Python newsgroup. > Thanks for the pointer, again ..... ;-) Is that the rereference that you used when modifying Python to make it ANSI C ? If so then it would probably be a good idea to make it explicit, e.g. add a line like this to a help file, README, HOWTO, ... including any extra suggestions over and above what is contained there. "This source code is written in Standard C as defined by http://www-ccs.ucsd.edu/c/. Any deviations from this definition should be considered as bugs and reported to ...." I was just concerned that I (and others) know what you mean when you say that Python is written in "Standard C", or "ANSI C" and have a freely available reference. The above certainly looks as though it could fill that gap. From nobody at phony.org Tue Aug 8 19:38:14 2000 From: nobody at phony.org (Gary Momarison) Date: 08 Aug 2000 16:38:14 -0700 Subject: Cease and Desist from Watchfire References: Message-ID: ahopkins at ahopkins.dynacare.com (marduk) writes: > Hey guys, > > As most of you know, I have not worked on linbot in quite a while. > The latest snapshop release was October '99. I have been pretty > busy and had put the project on hold. marduk - This is not legal advice. Consult a licensed lawyer for that. There are also lots of web sites about copyright and trademark law. I've used linbot a few times (with mixed results) on a rather big site and was glad for it. Even as a Python babe, I could easily find and hack out one show-stopper and was glad you chose to use Python. You seemed to imply that the LinkButts only wanted you to change the name, so that's what I'm commenting on. If they are talking about Look-and-Feel or other issues, please say so. 1) Most people in your situation soon descover that they are dealing with Bullies who will push you farther than you can afford to risk going. One can sometimes go down the legal path (even at low cost) far enough that they will find something more rewarding to do, but if you go too far you risk big losses. You almost surely should Cry Uncle ASAP, though some people would first try to get them to pay for their nastiness by keeping their legal people busy. Like waiting for the next step, then saying OK, then renaming linbot to LinkRobot, repeat., etc. But it takes effort and entails risk. You'd want to consult a cheap lawyer about how far to go. You can get more thoughts on this by consulting related old article comments at slashdot.com, etc. 2) Whether you're using the GPL, something else, or nothing is irrelevant as that is a copyright issue and they are worrying about a trademark issue. Whether Linbot and Linkbot are too close or whether your non-commercial use is a problem hardly matters either, practically. But note that people (including you) needn't change "linbot" to anything for most purposes. Just where it's being used out there in the big bad world of commerce (eg, the Internet). 3) If you want linbot to belong to the People, the copyright holders (only you?) have to transfer all copyrights (and maybe patent rights) to the People with words like this: I, Full Name, hereby transfer all rights in the linbot program all associated files (as distributed in the containing tar file) to the Public Domain. Full Date, (& preferably) Full Address/ID Since IANAL, consult a lawyer for legal console on this. While your post implies the above, it wouldn't be explicit enough for most people. You want users to be able to prove (sort of) that they aren't infringing on some jerk that might claim to hold the linbot copyright. 4) Your post exemplifies the reason for one of my continual rants about the GPL. Too many people that don't care about licensing use it without knowing the implications because the propagandists makes it sound like it is something it is not. From bellamy at freesurf.fr Wed Aug 23 05:53:52 2000 From: bellamy at freesurf.fr (Bellamy Bruno) Date: Wed, 23 Aug 2000 11:53:52 +0200 Subject: type(x) syntax in a test Message-ID: <967024838.2137696526@news.club-internet.fr> Hi there... I guess my mistake is a typical beginner's one, sorry... But I just can't find the right syntax to make a test on a type. For instance: a = 'hello world' if type(a) == 'string': print 'glad to meet you' doesn't work... I surely missed something, but so far I can't find out what... From alex at magenta.com Fri Aug 25 12:35:49 2000 From: alex at magenta.com (Alex Martelli) Date: Fri, 25 Aug 2000 18:35:49 +0200 Subject: print statement and multithreading References: <8num2r0ogb@news2.newsguy.com> <39A3A280.62DB98C4@hursley.ibm.com> <8o0elg0151u@news1.newsguy.com> <39A50324.1C0006FC@hursley.ibm.com> <8o3cah0ius@news1.newsguy.com> <39A551D5.BAEC2D87@hursley.ibm.com> <8o45tf12aa9@news2.newsguy.com> <39A6557A.890B7541@hursley.ibm.com> <8o5nk70sup@news2.newsguy.com> <39A68EE9.21148649@hursley.ibm.com> Message-ID: <8o67hv07vs@news1.newsguy.com> "Paul Duffin" wrote in message news:39A68EE9.21148649 at hursley.ibm.com... [snip] > > I'm not sure about what you have in mind, but, in case it's > > that, you cannot just publish copies of an ISO Standard: ISO > > retains copyright, and you need to license it from them (such > > licensing fees are used by ISO as a revenue source). > > This is so STUPID and short sighted. They've been going at it for a long time, though, and their standards are widely implemented and used in specifications; on what time-frame do you believe their 'short-sightedness' will display itself? Centuries? Because surely it hasn't shown up in mere decades. > Surely the whole point of > a standard is that it is everywhere and charging people for > reading it will surely negatively affect the spread of the > standard. Could this possibly be why there are so many > non-standard compilers around ? Are there? I find far more implementations of, say, Scheme, that are at variance on some minor points with the (freely available) R5R, than I've met C compilers at variance with the ISO standard. Oh, I don't have a compliance suite for either, to be sure, but many years ago we decided to upgrade the sources of our application to standard C, and that was when we were actively supporting over a dozen platforms. The only "side effect" I recall was on some braindead SCO platform, where the SCO-supplied compiler ("Green Hills" branded, if I recall correctly) was seriously broken; switching to gcc made all peace and light again. > So how do you propose to explain to people what exactly is meant > when Python says that it is "Standard ANSI C" ? The number is > meaningless, you can't freely read the standard, so what do I as I'm not going to be the one documenting this (and if I were, be assured I would *NOT* call it 'ANSI' C, but rather *ISO* C). Far from being 'meaningless', the standard number is crucial: it's what get specified in contracts. > an individual do when I want to ensure that my Python extension > (not that I have one ;-)) is "Standard ANSI C". You presumably rely on your compiler supplier. What do you as an individual do, when you want to ensure that your wrench is in fact a metric wrench by ISO standard so-and-so, since IKEA (or whomever else you bought your to-be-self-assembled furniture from) requires such a wrench to assemble it? Answer: you rely on your wrench supplier. You *definitely* don't want to study the ISO standards on mechanical engineering, and set up your own conformance-testing shop -- a *very* costly endeavour, and the price of the standard is of course the least of it. And conformance-testing of software as complex as a compiler is not any cheaper... > > So, what point[s], exactly, are you trying to make, or else > > to ascertain...? > > The point I am trying to make is that all sorts of questions > arise when you say "CPython source is Standard ANSI C". They don't arise in my mind, and I don't think they arise in the mind of anybody who's not being deliberately non-cooperative about it. > Answering those questions will take some effort, and the > reworking of the source will take a massive effort and for I think the reworking is complete, so the correct tense is the past, not the future. > what benefit ? I don't think that you will significantly > reduce the complexity of the code, or improve it in terms > of readability because there will always be one compiler > which isn't quite ANSI due to a bug, or a different I think standard C has huge advantages over the chaotic pre-standard situation. I'm not alone in this belief; I think you might be near-alone in your contrary one. > Currently the compilers you support are exactly those compilers > which can compile Python as is which may include some conditional > code as determined by autoconf/configure. In practice, this will not change: Python will not run a compliance-suite and refuse to continue building if that blows up. So, if some compiler is not ANSI standard, due to a bug that makes it erroneously blow up if over than 17 unary pluses are applied, the Python build process will not notice, nor particularly care. But if the compiler pukes on int x(int y) { return 23; } because it's never heard of function prototypes, I seriously doubt the Python team will now make any effort whatsoever to build under *that* compiler. And THIS I see as progress. Alex From R.Brodie at rl.ac.uk Mon Aug 14 04:51:05 2000 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Mon, 14 Aug 2000 09:51:05 +0100 Subject: while row = c.fetchone(): # syntax error??? References: <399370FD.F883EFCE@ix.netcom.com> <8n0d1t0kao@news2.newsguy.com> Message-ID: <8n8btt$1dmu@newton.cc.rl.ac.uk> "Alex Martelli" wrote in message news:8n0d1t0kao at news2.newsguy.com... > Right. Assignment is not an expression in Python. One benefit is that > you avoid such errors as coding "while x=y:" where you meant to code > "while x==y:". But it does mean that certain C idioms aren't Python idioms. > > The workaround most often used is to change what one'd like to code as: > > while row=c.fetchone(): # nope -- Python doesn't like this! > doit(row) > > into the equivalent Python idiom: > > while 1: > row=c.fetchone() > if not row: break > doit(row) The real problem is the underlying class has a 'C' like API. Returning magic numbers like 0 isn't really Python's style. The natural way to do it in Python (given a more suitable underlying class) is: for row in c.fetchrows(): doit(row) As noted, you can always wrap the class. But it's not really Python's fault that it was broken in the first place. From richard_chamberlain at ntlworld.com Tue Aug 22 02:47:04 2000 From: richard_chamberlain at ntlworld.com (Richard Chamberlain) Date: Tue, 22 Aug 2000 07:47:04 +0100 Subject: Unanswered Questions in python.faqts.com References: <39A1C444.9C4C6274@sitegnome.com> Message-ID: <39A221E7.2D25CC71@ntlworld.com> Hi Fiona, > From within a function, is there a way to determine what the parent of a > calling widget is? from Tkinter import * root=Tk() frame=Frame(root) button=Button(frame,text='Click Me') button.pack() frame.pack(fill=BOTH,expand=1) def clicker(event): event.widget.master.configure(bg='blue') button.bind('