From peevee78 at yahoo.com Tue Jan 1 00:01:50 2002 From: peevee78 at yahoo.com (peevee78) Date: Mon, 31 Dec 2001 23:01:50 -0000 Subject: rtf reader\writer Message-ID: Hi I was wondering if there is a python module for reading and writing rtf files. I am currently planning a project that would generate an rtf file from text entered in a GUI. Thanks. peevee78. From lull at acm.org Tue Jan 1 00:29:15 2002 From: lull at acm.org (John Lull) Date: 31 Dec 2001 17:29:15 -0600 Subject: Basic threading questions References: Message-ID: aahz at panix.com (Aahz Maruch) wrote (with possible deletions): > Doesn't really answer your questions directly, but take a look at > http://starship.python.net/crew/aahz/ Care to expound about your comment on p. 74? >> Some common extensions: >> NumPy - no Thanks. Regards, John From aahz at panix.com Fri Jan 4 05:20:18 2002 From: aahz at panix.com (Aahz Maruch) Date: 3 Jan 2002 20:20:18 -0800 Subject: Basic threading questions References: Message-ID: In article , John Lull wrote: >aahz at panix.com (Aahz Maruch) wrote (with possible deletions): >> >> Doesn't really answer your questions directly, but take a look at >> http://starship.python.net/crew/aahz/ > >Care to expound about your comment on p. 74? >>> Some common extensions: >>> NumPy - no What's to expound? NumPy doesn't release the GIL. That's all there is to say about it. -- --- Aahz <*> (Copyright 2002 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista Pretty soon, cell phones will be so small we won't know who's crazy. From logiplexsoftware at earthlink.net Tue Jan 1 00:35:14 2002 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Mon, 31 Dec 2001 15:35:14 -0800 Subject: wxBitmapFromImage function in wxPython? In-Reply-To: <3C30290F.C20213B0@cti.ecp.fr> References: <3C2F7BB3.577D3712@cti.ecp.fr> <3$--$$_----__-$-$$@news.noc.cabal.int> <3C30290F.C20213B0@cti.ecp.fr> Message-ID: <20011231153514.123b7e03.logiplexsoftware@earthlink.net> On Mon, 31 Dec 2001 09:59:59 +0100 Stephane SOPPERA wrote: > Yes that's it. > I'v only the version 2.2.7, not the last one. IIRC, older versions had this as a method of wxBitmap and wxImage (ConvertToImage and ConvertToBitmap, respectively - you'll need to check the source to be sure). -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From david.abrahams at rcn.com Tue Jan 1 01:43:06 2002 From: david.abrahams at rcn.com (David Abrahams) Date: Mon, 31 Dec 2001 19:43:06 -0500 Subject: does python support overloaded methods?(py newbie) References: Message-ID: "Michael Kelly" wrote in message news:o2p13us48lu0r1o1m5e069maqfra1oluv3 at 4ax.com... > >wanted to confirm this. Overloading method names(with parameters > >belonging to different types) is possible in python??. Not exactly. The Boost.Python library for creating extension modules in C++ supports overloading by linking all the overloads into a chain under the control of a single callable object. Each overload in the chain is tried until one succeeds. You could do something similar in pure Python, but for it to work smoothly you'd need to have some way to distinguish argument errors at the "outer level". In other words, if * f1() has overloads a, b, and c * overload b calls some function f2() * f2's argument list doesn't match you don't want to go on to try overload c, thinking that overload b's argument list failed to match. > Hmmmm, seems like this is a bigger deal in compiled > languages since it's usually more hassle to deal with > an indefinite number of arguments. Scripting languages > often have some catch-all syntax to get all the rest of > the args. It really has nothing to do with compiled vs. non-compiled languages. Overloading gives us a mechanism to non-intrusively extend the semantics of a construct, and it's the only clean way to deal with the problem of multi-methods. You /might/ say that it's a bigger deal in statically-typed languages, but I think that's not even the case. Consider the trouble that Python has handling coercions and binary operators cleanly. -Dave From mkelly2002NOSPAM at earthlink.net Tue Jan 1 02:27:33 2002 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Tue, 01 Jan 2002 01:27:33 GMT Subject: does python support overloaded methods?(py newbie) References: Message-ID: On Mon, 31 Dec 2001 19:43:06 -0500, "David Abrahams" wrote: >It really has nothing to do with compiled vs. non-compiled languages. >Overloading gives us a mechanism to non-intrusively extend the semantics of >a construct, and it's the only clean way to deal with the problem of >multi-methods. I have a funny feelin' you get into that stuff about proving algebraically that a function cannot fail. :) 'sides, I'm not sure if you're answering my post or the previous guy. I have no desire to non-intrusively extend a construct, just use the language features I find most appealing. :) Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From jason at jorendorff.com Tue Jan 1 05:03:16 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Mon, 31 Dec 2001 22:03:16 -0600 Subject: does python support overloaded methods?(py newbie) In-Reply-To: Message-ID: > You /might/ say that it's a bigger deal in statically-typed > languages, but I think that's not even the case. Consider the > trouble that Python has handling coercions and binary > operators cleanly. Difficulty with type conversion rules and binary operators is not unique to Python. Languages with operator overloading have these problems, Python no more so than C++ or Ruby. ## Jason Orendorff http://www.jorendorff.com/ From hungjunglu at yahoo.com Tue Jan 1 08:58:45 2002 From: hungjunglu at yahoo.com (Hung Jung Lu) Date: 31 Dec 2001 23:58:45 -0800 Subject: does python support overloaded methods?(py newbie) References: Message-ID: <8ef9bea6.0112312358.7633783@posting.google.com> Hi, There are many ways of achieving the things you want to do. But method overloading itself is a non-Pythonic concept, since Python is a dynamicly-typed language: you don't know, nor do you care about, the type of an object until the moment you use it. One possibility is to use the 'exec' command. #---------------------------------------------------- class Currency: pass class Dollar(Currency): pass class Euro(Currency): pass class CalculateRupeeEquivalent: def calculate(self, currency): exec 'result = self.calculate_%s(currency)' % currency.__class__.__name__ return result def calculate_Dollar(self, currency): return 48.2400 * currency.amount def calculate_Euro(self, currency): return 42.9110 * currency.amount if __name__ == '__main__': dollarPortfolio = Dollar() euroPortfolio = Euro() calculator = CalculateRupeeEquivalent() dollarPortfolio.amount = 100.00 euroPortfolio.amount = 10.00 print 'Dollar portfolio in Rupees =', calculator.calculate(dollarPortfolio) print 'Euro portfolio in Rupees =', calculator.calculate(euroPortfolio) #---------------------------------------------------- output: Dollar portfolio in Rupees = 4824.0 Euro portfolio in Rupees = 429.11 #---------------------------------------------------- Of course, your example is really just to show a point... for real currency calculations no one would use subclasses for currency instances... currency instances are, naturally, instances of the currency class! :) No subclasses needed. Depending on how automated and how optimized you want the code to be, there are many other possible solutions in Python. Python just has too many dynamic features, which are far more powerful than method overloading of staticly-typed languages. Sorry for not showing more implementations, the possibilities are nearly endless in Python. Truly, if you are trying to emulate method overloading, you are not thinking in the right Pythonic way. :) A more Pythonic implementation would be: #---------------------------------------------------- class Currency: fx_rate = None pass class Dollar(Currency): fx_rate = 1.00000 class Euro(Currency): fx_rate = 1.12423 def warning(self): print '(Euro should only be used after January 1, 2002!)' class CalculateRupeeEquivalent: fx_rate = 48.2399 def calculate(self, currency): result = currency.amount / currency.fx_rate * self.fx_rate if hasattr(currency, 'warning'): currency.warning() return result if __name__ == '__main__': dollarPortfolio = Dollar() euroPortfolio = Euro() calculator = CalculateRupeeEquivalent() dollarPortfolio.amount = 100.00 euroPortfolio.amount = 10.00 rupee_amount = calculator.calculate(dollarPortfolio) print 'Dollar portfolio in Rupees =', rupee_amount rupee_amount = calculator.calculate(euroPortfolio) print 'Euro portfolio in Rupees =', rupee_amount #---------------------------------------------------- output: Dollar portfolio in Rupees = 4823.99 (Euro should only be used after January 1, 2002!) Euro portfolio in Rupees = 429.092801295 #---------------------------------------------------- Anyway, you get the idea. You are able to check the class features in runtime, which allows you: (1) a larger body of shared code, and yet (2) still be able to perform class-specific actions. After you learn all the dynamic features of Python, you will see that many of the claimed C++ or Java features are, actually, limitations of those languages. :) regards, Hung Jung From mkelly2002NOSPAM at earthlink.net Tue Jan 1 20:48:55 2002 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Tue, 01 Jan 2002 19:48:55 GMT Subject: does python support overloaded methods?(py newbie) References: <8ef9bea6.0112312358.7633783@posting.google.com> Message-ID: On 31 Dec 2001 23:58:45 -0800, hungjunglu at yahoo.com (Hung Jung Lu) wrote: >There are many ways of achieving the things you want to do. But method >overloading itself is a non-Pythonic concept, since Python is a >dynamicly-typed language: you don't know, nor do you care about, the >type of an object until the moment you use it. Yes, I see no *point* to have a preprocessor turning BOOL Draw(point x, point y) BOOL Draw(point a, point b, point c, point d) into BOOL Draw_pt_pt and BOOL Draw_pt_pt_pt_pt when in a dynamic language you'd just do Draw(points) and draw according to the number of points passed in. :) Overloading gives you a conceptual aid in a statically typed compiled language like C++ that's already built in to dynamically typed languages like Python Rexx, Ruby, whatever. Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From mcfletch at rogers.com Tue Jan 1 02:11:44 2002 From: mcfletch at rogers.com (Mike C. Fletcher) Date: Mon, 31 Dec 2001 20:11:44 -0500 Subject: Properties fun with 2.2 References: Message-ID: <3C310CD0.3080805@rogers.com> The problem with that is, what if I want properties 'a' and '_a'? That is, if superclass X stores the value of "a" as "_a" in the object's slots, (if I understand correctly), then any assignment to _a (in a sub-class or not) will overwrite the value of a. When you store the data in the dict under the same name (a), then you only have the 1 name taken up in the namespace, there's no surprises, just a documented property accessed as if it were a regular attribute. That becomes a significant question when you're using "automagic" properties like those with which I started the thread (ones that don't know what their property names are until instantiated (and don't know the final conditions of the class), and which manage all of the data storage automagically). Simple and clean is the reason properties exist in my little version of the universe :) . Enjoy, Mike Martin von Loewis wrote: ... > Delegating to a different attribute might be appropriate: > > class X(object): > __slots__ = ['_a'] > def set_a(self, val): > self._a = val > def get_a(self): > return self._a > a = property(get_a, set_a) > > Regards, > Martin _______________________________________ Mike C. Fletcher http://members.rogers.com/mcfletch/ From gkang at earthlink.net Tue Jan 1 02:36:34 2002 From: gkang at earthlink.net (GK) Date: 31 Dec 2001 17:36:34 -0800 Subject: 'pstruct' structure parser and python Message-ID: <8a5557a9.0112311736.77f2b048@posting.google.com> Has anyone developed a tool in PYTHON that is similar to PERL's 'pstruct' ? 'pstruct' is a basically a C structure parser that outputs offset information about structure members in an ascii file. Thanks! From debl2nonspammywhammy at bellatlantic.net Tue Jan 1 02:48:41 2002 From: debl2nonspammywhammy at bellatlantic.net (David Lees) Date: Tue, 01 Jan 2002 01:48:41 GMT Subject: Cancel messages References: <6e43133.0112310938.6f93f585@posting.google.com> Message-ID: <3C311584.3E97D48D@bellatlantic.net> For those of us who never hear of HipCrime before, is there anything I should be setting in my browswer when posting to prevent this sort of cancelation attack? David Lees Rob Mitchell wrote: > > Gerhard H?ring wrote in message news:... > > Le 28/12/01 ? 07:18, Syver Enstad ?crivit: > > > [...] > > > ========= WAS CANCELLED BY =======: > > > Path: news.sol.net!spool1-nwblwi.newsops.execpc.com!newsfeeds.sol.net!newspump.sol.net!newsfeed.direct.ca!look.ca!newshub2.rdc1.sfba.home.com!news.home.com!sjc1.nntp.concentric.net!newsfeed.concentric.net!newsfeed.ozemail.com.au!ozemail.com.au!not-for-mail > > > Message-ID: > > > Control: cancel > > > Subject: cmsg cancel > > > From: Syver Enstad > > > Newsgroups: comp.lang.python > > > X-No-Archive: yes > > > Lines: 2 > > > NNTP-Posting-Host: wonenara.ozemail.com.au > > > X-Trace: ozemail.com.au 1009643103 203.108.164.177 (Sun, 30 Dec 2001 03:25:03 EST) > > > NNTP-Posting-Date: Sun, 30 Dec 2001 03:25:03 EST > > > Organization: OzEmail Ltd, Australia > > > Distribution: world > > > Date: Sat, 29 Dec 2001 13:32:11 GMT > > > > > > This message was cancelled from within Mozilla. > > > > Just curious. > > > > What's going on here? A mailman bug from the mail <-> news gateway, or > > somebody coverage-testing their Mozilla?! > > It's HipCrime, who does this sort of thing all the time. Google has > archived thousands of these rogue cancels all originating from > 203.108.164.177 on December 13, 14, 15, 16, 17, 18, 20, 21, 29, 30, & > 31: > > http://groups.google.com/groups?q=203.108.164.177&num=100&hl=en&scoring=d > > I would first try complaining to abuse at ozemail.com.au , & then if the > rogue cancels continue after that date, to the newsfeeds propagating > the rogue cancel forgery floods to the rest of Usenet, as shown on the > Path line. For example, for the header above, one would complain to > concentric.net, home.com, look.ca, etc. If the abuse still continues > after that, these newsfeeds should be asked to block Ozemail entirely > until it demonstrates itself to be a responsible ISP. > > Rob From max at alcyone.com Tue Jan 1 02:56:03 2002 From: max at alcyone.com (Erik Max Francis) Date: Mon, 31 Dec 2001 17:56:03 -0800 Subject: Cancel messages References: <6e43133.0112310938.6f93f585@posting.google.com> <3C311584.3E97D48D@bellatlantic.net> Message-ID: <3C311733.EFE74714@alcyone.com> David Lees wrote: > For those of us who never hear of HipCrime before, is there anything I > should be setting in my browswer when posting to prevent this sort of > cancelation attack? No. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From dcook at radhet.com Wed Jan 2 20:13:05 2002 From: dcook at radhet.com (David M. Cook) Date: 2 Jan 2002 19:13:05 GMT Subject: Cancel messages References: <6e43133.0112310938.6f93f585@posting.google.com> Message-ID: On 31 Dec 2001 09:38:11 -0800, Rob Mitchell wrote: >It's HipCrime, who does this sort of thing all the time. Should have changed his name to DoofusCrime long ago. Dave Cook From howardk at cts.com Tue Jan 1 04:01:25 2002 From: howardk at cts.com (Howard Knight) Date: 01 Jan 2002 03:01:25 GMT Subject: Cancel messages References: <3c3097c7$0$79590$e2e8da3@nntp.cts.com> Message-ID: <3c312684$0$79590$e2e8da3@nntp.cts.com> Aahz Maruch (aahz at panix.com) wrote: > In article <3c3097c7$0$79590$e2e8da3 at nntp.cts.com>, > Howard Knight wrote: > >Aahz Maruch (aahz at panix.com) wrote: > >> > >> I don't think that cancels affect python-list, but the admins should > >> probably set up a filter to ignore the REPOST: articles based on the > >> X-Reposted-By: header. > > > >Actually, a better filter would be the "resurrector" pseudo site in the > >Path line. That way, if anyone else besides Guido resurrects posts, it > >will filter those out too. Here's a sample of one of Guido's Path > >lines: > > > > Path: ...!news.noc.cabal.int!resurrector!guidorepost!not-for-mail > > Possibly; what I meant, though, was filtering on the *existence* of > X-Reposted-By:, not the value of the header. That ought be more > efficent and just as accurate. For the mailing list, either one should work fine. For filtering on a news server itself, using the Path site filter is generally easier. So, if any of you are using a news server that does not honor cancels and you are still seeing the reposts, you should ask your news admin to drop all the reposts by filtering on the "resurrector" pseudo site. Howard From eldiener at earthlink.net Tue Jan 1 04:30:38 2002 From: eldiener at earthlink.net (Edward Diener) Date: Tue, 01 Jan 2002 03:30:38 GMT Subject: Server side scripting with PSP Message-ID: <3C312D01.3020102@earthlink.net> I want to do my server side scripting with Python. Probably Python Server Pages. Is there an implementation of this around without using an application server or is Zope or Webware the way to go ? What think ye all. From dkuhlman at rexx.com Wed Jan 2 00:14:45 2002 From: dkuhlman at rexx.com (Dave Kuhlman) Date: 1 Jan 2002 17:14:45 -0600 Subject: Server side scripting with PSP References: <3C312D01.3020102@earthlink.net> Message-ID: <1009927654.776407@rexx.com> If you want only the low-level, template processing part, take a look at: http://webware.sourceforge.net/Papers/Templates/ It describles a number of template/replacement mechanisms for Python. - Dave Edward Diener wrote: > > I want to do my server side scripting with Python. Probably Python > Server Pages. Is there an implementation of this around without using an > application server or is Zope or Webware the way to go ? What think ye all. > -- Dave Kuhlman dkuhlman at rexx.com -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From eldiener at earthlink.net Wed Jan 2 03:05:42 2002 From: eldiener at earthlink.net (Edward Diener) Date: Wed, 02 Jan 2002 02:05:42 GMT Subject: Server side scripting with PSP References: <3C312D01.3020102@earthlink.net> <1009927654.776407@rexx.com> Message-ID: <3C326A97.1010900@earthlink.net> I will look at it but I am willing to go the full route and have a higher level solution. I read about PSP some time ago but i could not find any good mention of it except with Webware. I am looking for a server side scripting solution that uses Python to generate dynamic web pages, based of course on user input. of course connection to a server database is a must but other than that I am fairly open to good solutions. Dave Kuhlman wrote: > If you want only the low-level, template processing part, take a > look at: > > http://webware.sourceforge.net/Papers/Templates/ > > It describles a number of template/replacement mechanisms for > Python. > > - Dave > > > Edward Diener wrote: > >>I want to do my server side scripting with Python. Probably Python >>Server Pages. Is there an implementation of this around without using an >>application server or is Zope or Webware the way to go ? What think ye all. >> >> > From tchur at optushome.com.au Wed Jan 2 08:13:34 2002 From: tchur at optushome.com.au (Tim Churches) Date: Wed, 02 Jan 2002 18:13:34 +1100 Subject: Have a look at Albatross (was Re: Server side scripting with PSP) References: <3C312D01.3020102@earthlink.net> <1009927654.776407@rexx.com> <3C326A97.1010900@earthlink.net> Message-ID: <3C32B31E.7448D8E0@optushome.com.au> Edward Diener wrote: > > I will look at it but I am willing to go the full route and have a > higher level solution. I read about PSP some time ago but i could not > find any good mention of it except with Webware. I am looking for a > server side scripting solution that uses Python to generate dynamic web > pages, based of course on user input. of course connection to a server > database is a must but other than that I am fairly open to good solutions. Edward, Have a look at Albatross by Object Craft in Melbourne, Australia - it sounds like it might be just what you are looking for. It was released on Christmas Day, and is still undergoing development, but already it appears (to me at least) to be the most elegant of the many Python Web app frameworks. And it is well documented. See http://www.object-craft.com.au Disclaimer: I have been working with the Object Craft guys over the last 8 months or so on a Web-based epidemiological application, which I hope will be ready for release in a few months. It used Albatross' predecessor, and now Albatross, to implement its front end with a remarkably small amount of code. The back-end is python-based as well, of course. Thus, I might be biased, but Albatross looks like seriously high quality work to me. Tim C Sydney, Australia From syring at email.com Wed Jan 2 12:21:57 2002 From: syring at email.com (Karl M. Syring) Date: Wed, 2 Jan 2002 12:21:57 +0100 Subject: Have a look at Albatross (was Re: Server side scripting with PSP) References: <3C312D01.3020102@earthlink.net> <1009927654.776407@rexx.com> <3C326A97.1010900@earthlink.net> Message-ID: "Tim Churches" schrieb > Have a look at Albatross by Object Craft in Melbourne, Australia - it > sounds like it might be just what you are looking for. It was released > on Christmas Day, and is still undergoing development, but already it > appears (to me at least) to be the most elegant of the many Python Web > app frameworks. And it is well documented. See > http://www.object-craft.com.au > > Disclaimer: I have been working with the Object Craft guys over the last > 8 months or so on a Web-based epidemiological application, which I hope > will be ready for release in a few months. It used Albatross' > predecessor, and now Albatross, to implement its front end with a > remarkably small amount of code. The back-end is python-based as well, > of course. Thus, I might be biased, but Albatross looks like seriously > high quality work to me. Albatross looks nice as does Webware, but I think both require application servers. This makes them unsuitable for many uses, as your web site hoster may not allow permanent processes. Karl M. Syring From djc at object-craft.com.au Wed Jan 2 13:55:01 2002 From: djc at object-craft.com.au (Dave Cole) Date: 02 Jan 2002 23:55:01 +1100 Subject: Have a look at Albatross (was Re: Server side scripting with PSP) References: <3C312D01.3020102@earthlink.net> <1009927654.776407@rexx.com> <3C326A97.1010900@earthlink.net> Message-ID: >>>>> "Karl" == Karl M Syring writes: Karl> Albatross looks nice as does Webware, but I think both require Karl> application servers. This makes them unsuitable for many uses, Karl> as your web site hoster may not allow permanent processes. Albatross does not use an application server. For server-side session support it does currently require you to run the session server. With a little bit of programming you could slot in a replacement for the SessionServerAppMixin class which used the local file system to store session files. It has a very simple interface: http://www.object-craft.com.au/projects/albatross/albatross/mixin-app-sess.html Then all you need to do is clone a server-side session based application class and make it inherit from your new mixin instead of the SessionServerAppMixin class. http://www.object-craft.com.au/projects/albatross/albatross/pack-modularsessapp.html At some point I should probably come up with a SessionFileAppMixin class which does what is required. I suppose with a bit of fiddling around you could come up with some mixin classes which makes Albatross work on top of an application server... At the moment I am working on improving the documentation for the code currently implemented. - Dave -- http://www.object-craft.com.au From marklists at mceahern.com Wed Jan 2 18:03:30 2002 From: marklists at mceahern.com (Mark McEahern) Date: Wed, 2 Jan 2002 09:03:30 -0800 Subject: Have a look at Albatross (was Re: Server side scripting with PSP) In-Reply-To: Message-ID: Dave Cole: > At the moment I am working on improving the documentation for the code > currently implemented. I'd be curious to see any analysis you did of Zope, Webware, and other Python web app servers that led you to ignore them in favor of developing your own framework. Cheers, // mark From djc at object-craft.com.au Thu Jan 3 02:45:11 2002 From: djc at object-craft.com.au (Dave Cole) Date: 03 Jan 2002 12:45:11 +1100 Subject: Have a look at Albatross (was Re: Server side scripting with PSP) In-Reply-To: References: Message-ID: >>>>> "Mark" == Mark McEahern writes: Mark> Dave Cole: >> At the moment I am working on improving the documentation for the >> code currently implemented. Mark> I'd be curious to see any analysis you did of Zope, Webware, and Mark> other Python web app servers that led you to ignore them in Mark> favor of developing your own framework. There is a fairly long story behind Albatross. I will try to summarise. The original toolkit (not Albatross) came out of a consulting job that we performed. The customer needed an easy to understand toolkit for building an public access web application. We looked at Zope and came to the conclusion that it was beyond the capabilities of the developers who were going to have to use it at the customer site. They even expressed quite a bit of resistance to Python in general (they did not want to have to learn a new language). Albatross is a 3rd generation version of the toolkit that we developed for the customer. They had some fairly narrow financial system requirements which were not something we wanted to build into a more general purpose toolkit. - Dave -- http://www.object-craft.com.au From eldiener at earthlink.net Wed Jan 2 23:16:01 2002 From: eldiener at earthlink.net (Edward Diener) Date: Wed, 02 Jan 2002 22:16:01 GMT Subject: Have a look at Albatross (was Re: Server side scripting with PSP) References: <3C312D01.3020102@earthlink.net> <1009927654.776407@rexx.com> <3C326A97.1010900@earthlink.net> Message-ID: <3C338659.1050502@earthlink.net> Tim Churches wrote: > Edward Diener wrote: > >>I will look at it but I am willing to go the full route and have a >>higher level solution. I read about PSP some time ago but i could not >>find any good mention of it except with Webware. I am looking for a >>server side scripting solution that uses Python to generate dynamic web >>pages, based of course on user input. of course connection to a server >>database is a must but other than that I am fairly open to good solutions. >> > > Edward, > > Have a look at Albatross by Object Craft in Melbourne, Australia - it > sounds like it might be just what you are looking for. It was released > on Christmas Day, and is still undergoing development, but already it > appears (to me at least) to be the most elegant of the many Python Web > app frameworks. And it is well documented. See > http://www.object-craft.com.au Thanks. They have begun to win me over by quoting Chaucer and I haven't even looked at the technology yet . From guido at python.org Tue Jan 1 06:12:10 2002 From: guido at python.org (Guido van Rossum) Date: Tue, 01 Jan 2002 05:12:10 GMT Subject: Python VS PHP References: Message-ID: "Cosmic_NTT" writes: > Hi everybody and..... good 2K+2. > OK, OK...Python & php cannot be used together : pcre linking > > It seems that python cannot be used in conjunction > with PHP : the Make with both resulted in : > > ########################## > /usr/lib/python1.5/config/libpython1.5.a(pypcre.o): In function > `pcre_study': > /usr/src/bs/BUILD/Python-1.5.2/Modules/./pypcre.c:514: multiple definition > of `pcre_malloc' > modules/php4/libphp4.a(pcre.o):/tmp/php-4.1.0/ext/pcre/pcrelib/pcre.c:309: > first defined here > /usr/lib/python1.5/config/libpython1.5.a(pypcre.o): In function > `pcre_study': > /usr/src/bs/BUILD/Python-1.5.2/Modules/./pypcre.c:516: multiple definition > of `pcre_free' > modules/php4/libphp4.a(pcre.o):/tmp/php-4.1.0/ext/pcre/pcrelib/pcre.c:309: > first defined here > collect2: ld returned 1 exit status > make[2]: *** [target_static] Error 1 > make[1]: *** [build-std] Error 2 > make: *** [build] Error 2 > ############################# > > But how to solve the problem? Try Python 2.0 or (preferably) later, they have a new regular expression library (SRE) so you don't need pcre (it is still available, but you can turn it off in the configuration easily). --Guido van Rossum (home page: http://www.python.org/~guido/) From woodsplitter at rocketmail.com Tue Jan 1 06:41:32 2002 From: woodsplitter at rocketmail.com (stalin) Date: 31 Dec 2001 21:41:32 -0800 Subject: Client-side web scripting in Python? References: <8abfe95a.0112311037.35fb4c2@posting.google.com> Message-ID: <7876a8ea.0112312141.72142df@posting.google.com> rolffreimuth at hotmail.com (Rolf) wrote: > I am considering writing a simple application in Python. I am > evaluating the possibility of writing the GUI for the app as a static > HTML page that uses client-side script. I agree with Paul that this is a bad idea if the general Internet user is your target audience, but I suspect you know that. You're probably developing an intranet application or a 'classic desktop application' with a DHTML interface. > Python does not seem to know about the document object which is > accessible from Javascript. It seems necessary to be able to > use that document object in order to modify the contents of the > page. You're absolutely right that it's necessary to access the document object in order to dynamically modify page contents. Javascript establishes various aliases for the purpose of convenience ('document' is actually 'window.document', 'alert' is actually 'window.alert', etc.). If I recall correctly, older version of the Win32 bindings for Python did not establish these shortcuts; the programmer had to refer to objects by their fully qualified names. An easy way to circumvent this is to establish the aliases yourself as global variables at the beginning of the first
Even when I'm doing an IE-specific project, I try to stick to the W3C standard rather using Microsoft-specific methods/properties. E.g.: document.getElementById('coolSiteList') rather than document.all.coolSiteList . This soothes my conscience and makes the code more portable to other browsers if future support for them is desirable. Even so, I wouldn't put anything IE-specific on the Internet; only on intranets or client-side apps with a DHTML interface.
From rolffreimuth at hotmail.com Tue Jan 1 20:04:07 2002 From: rolffreimuth at hotmail.com (Rolf) Date: 1 Jan 2002 11:04:07 -0800 Subject: Client-side web scripting in Python? References: <8abfe95a.0112311037.35fb4c2@posting.google.com> <7x3d1r2paa.fsf@ruckus.brouhaha.com> Message-ID: <8abfe95a.0201011104.2905994f@posting.google.com> Paul Rubin wrote in message news:<7x3d1r2paa.fsf at ruckus.brouhaha.com>... > rolffreimuth at hotmail.com (Rolf) writes: > > Is there any way to do *pure* python client-side scripting? Are there > > any good resources with examples of how to do it? > > If you mean for publishing web pages on the internet, it doesn't sound > like such a great idea. I've stopped paying attention to Windoze but > I believe there's a Python version (ActiveState?) that's callable as a > COM object. So you'd have to download the huge interpreter to the > client, and then you could call it from Javascript. You should be > able to pass it the document object as an argument. From there, the > python script can use the regular COM automation methods to navigate > inside the document object, or it can call javascript code to > manipulate the document. I've forgotten most of this stuff but > basically once you get hold of the IWebBrowser2 interface you can > make the browser do most anything you want. I dont mean for it to be a web application. I am just considering it as a possibility for a simple GUI. To run the app, a user would need Python installed, plus MSIE, plus a few other python libs. It is primarily for my own use and education. To launch the app, the user would just click on an HTML file on the local hard drive. Having the GUI in a browser is an advantage for this application. The app basically scans a directory tree for large digital photos (~2MB each) then it uses PIL to create thumbnails and and some more reasonably sized "large" images for publishing on the web. I also was considering writing some code to manage the FTP of the "processed" images up to my website. Rolf From altis at semi-retired.com Wed Jan 2 00:40:05 2002 From: altis at semi-retired.com (Kevin Altis) Date: Tue, 1 Jan 2002 15:40:05 -0800 Subject: Client-side web scripting in Python? References: <8abfe95a.0112311037.35fb4c2@posting.google.com> <7x3d1r2paa.fsf@ruckus.brouhaha.com> <8abfe95a.0201011104.2905994f@posting.google.com> Message-ID: Rolf, based on your description I don't see the advantage of having the GUI in the browser. If you need a simple GUI tool, you might want to look at PythonCard. http://pythoncard.sourceforge.net/ There is a simple layout editor (the resourceEditor sample) in the latest version. There is also support for converting to and from PIL image format and drawing PIL images into PythonCard buffered bitmaps for use in the GUI. You shouldn't have to change any of your existing PIL code. You can create a Windows binary of your application using py2exe and then end-users won't have to have Python, wxPython, PIL, or PythonCard, or any other libraries installed. You can post questions to the PythonCard mailing list http://lists.sourceforge.net/lists/listinfo/pythoncard-users or ask them here on comp.lang.python as long as you put PythonCard in the subject line so it is easy to spot. ka "Rolf" wrote in message news:8abfe95a.0201011104.2905994f at posting.google.com... > Paul Rubin wrote in message news:<7x3d1r2paa.fsf at ruckus.brouhaha.com>... > > rolffreimuth at hotmail.com (Rolf) writes: > > > Is there any way to do *pure* python client-side scripting? Are there > > > any good resources with examples of how to do it? > > > > If you mean for publishing web pages on the internet, it doesn't sound > > like such a great idea. I've stopped paying attention to Windoze but > > I believe there's a Python version (ActiveState?) that's callable as a > > COM object. So you'd have to download the huge interpreter to the > > client, and then you could call it from Javascript. You should be > > able to pass it the document object as an argument. From there, the > > python script can use the regular COM automation methods to navigate > > inside the document object, or it can call javascript code to > > manipulate the document. I've forgotten most of this stuff but > > basically once you get hold of the IWebBrowser2 interface you can > > make the browser do most anything you want. > > > I dont mean for it to be a web application. I am just considering it > as a possibility for a simple GUI. To run the app, a user would need > Python installed, plus MSIE, plus a few other python libs. It is > primarily for my own use and education. To launch the app, the user > would just click on an HTML file on the local hard drive. > > Having the GUI in a browser is an advantage for this application. The > app basically scans a directory tree for large digital photos (~2MB > each) then it uses PIL to create thumbnails and and some more > reasonably sized "large" images for publishing on the web. I also was > considering writing some code to manage the FTP of the "processed" > images up to my website. > > Rolf From paul at zope.com Fri Jan 4 16:27:42 2002 From: paul at zope.com (Paul Everitt) Date: Fri, 04 Jan 2002 10:27:42 -0500 Subject: Client-side web scripting in Python? References: <8abfe95a.0112311037.35fb4c2@posting.google.com> <7x3d1r2paa.fsf@ruckus.brouhaha.com> <8abfe95a.0201011104.2905994f@posting.google.com> Message-ID: <3C35C9EE.5000701@zope.com> Hi Rolf. I'm tinkering around with something similar. That is, using IE5.5 as the GUI for a data model in XML and logic in Python (via win32all's support for ActiveScripting). I've made a bit of progress, so if you'd like to send me an email on the subject, go right ahead. Note that you'll probably want to approach this as an "HTA" (HTML Application), an IE5.5+ approach that lets you lower the security system in IE and function with all the privileges a regular, full-blown Python app would provide. A number of posts in this thread have questioned the approach of using web-oriented technologies as a GUI. I think it's worth considering. On the upside, if you know HTML/CSS/DOM/XML/XSLT etc., then you'll get to leverage a LOT of knowledge. For example, here's a series of articles on GUI design using client-side XML and XSLT: http://www.15seconds.com/Issue/010921.htm http://www.15seconds.com/issue/010927.htm http://www.15seconds.com/issue/011113.htm http://www.15seconds.com/issue/011129.htm http://www.15seconds.com/issue/011212.htm These tutorials show how to build an expandible tree with event handlers, context menus, insert/delete/update, drag-and-drop, and a progress indicator. For my project I'm using Python's COM support to put a DOM-like view on Outlook data, which I can then "persist" either to a local XML file or to/from a remote Zope site. The GUI for the app is an IE5.5 HTA, with XML as the model, XSLT and CSS as the view, a combination of JavaScript and Python as the logic, and the XmlHttpRequest component for networking over HTTP. --Paul Rolf wrote: > Paul Rubin wrote in message news:<7x3d1r2paa.fsf at ruckus.brouhaha.com>... > >>rolffreimuth at hotmail.com (Rolf) writes: >> >>>Is there any way to do *pure* python client-side scripting? Are there >>>any good resources with examples of how to do it? >>> >>If you mean for publishing web pages on the internet, it doesn't sound >>like such a great idea. I've stopped paying attention to Windoze but >>I believe there's a Python version (ActiveState?) that's callable as a >>COM object. So you'd have to download the huge interpreter to the >>client, and then you could call it from Javascript. You should be >>able to pass it the document object as an argument. From there, the >>python script can use the regular COM automation methods to navigate >>inside the document object, or it can call javascript code to >>manipulate the document. I've forgotten most of this stuff but >>basically once you get hold of the IWebBrowser2 interface you can >>make the browser do most anything you want. >> > > > I dont mean for it to be a web application. I am just considering it > as a possibility for a simple GUI. To run the app, a user would need > Python installed, plus MSIE, plus a few other python libs. It is > primarily for my own use and education. To launch the app, the user > would just click on an HTML file on the local hard drive. > > Having the GUI in a browser is an advantage for this application. The > app basically scans a directory tree for large digital photos (~2MB > each) then it uses PIL to create thumbnails and and some more > reasonably sized "large" images for publishing on the web. I also was > considering writing some code to manage the FTP of the "processed" > images up to my website. > > Rolf > From altis at semi-retired.com Fri Jan 4 19:28:52 2002 From: altis at semi-retired.com (Kevin Altis) Date: Fri, 4 Jan 2002 10:28:52 -0800 Subject: Client-side web scripting in Python? References: <8abfe95a.0112311037.35fb4c2@posting.google.com> <7x3d1r2paa.fsf@ruckus.brouhaha.com> <8abfe95a.0201011104.2905994f@posting.google.com> Message-ID: <4vmZ7.9443$75.892134@news.uswest.net> Paul, it sounds like you got much further than I ever did. You might be interested to know that you can design your own folder views under Windows. Look for the 'Web' folder in C:\WINNT or C:\WINDOWS and the .htt files inside. Those control the folder views and the files are just JavaScript and HTML. I tried doing some myself using PythonScript, but Python namespaces make accessing the DOM more complicated than the flat JavaScript namespace. I can send some MSDN links... if anyone wants to dig in further. Also, Neil Hodgson did some simple test files earlier this year that display PythonCard resource files in the IE DOM. The files are at Pyker.hta and PykerLaunch.hta: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/pythoncard/PythonCardPrototyp e/ These files are part of the most recent PythonCard release as well. They are just a test. The idea was that we might be able to share layout and code between desktop apps and a web app, but the idea wasn't pursued beyond Neil's initial tests. ka "Paul Everitt" wrote in message news:mailman.1010158089.28339.python-list at python.org... > > Hi Rolf. I'm tinkering around with something similar. That is, using > IE5.5 as the GUI for a data model in XML and logic in Python (via > win32all's support for ActiveScripting). I've made a bit of progress, > so if you'd like to send me an email on the subject, go right ahead. > > Note that you'll probably want to approach this as an "HTA" (HTML > Application), an IE5.5+ approach that lets you lower the security system > in IE and function with all the privileges a regular, full-blown Python > app would provide. > > A number of posts in this thread have questioned the approach of using > web-oriented technologies as a GUI. I think it's worth considering. On > the upside, if you know HTML/CSS/DOM/XML/XSLT etc., then you'll get to > leverage a LOT of knowledge. > > For example, here's a series of articles on GUI design using client-side > XML and XSLT: > > http://www.15seconds.com/Issue/010921.htm > http://www.15seconds.com/issue/010927.htm > http://www.15seconds.com/issue/011113.htm > http://www.15seconds.com/issue/011129.htm > http://www.15seconds.com/issue/011212.htm > > These tutorials show how to build an expandible tree with event > handlers, context menus, insert/delete/update, drag-and-drop, and a > progress indicator. > > For my project I'm using Python's COM support to put a DOM-like view on > Outlook data, which I can then "persist" either to a local XML file or > to/from a remote Zope site. The GUI for the app is an IE5.5 HTA, with > XML as the model, XSLT and CSS as the view, a combination of JavaScript > and Python as the logic, and the XmlHttpRequest component for networking > over HTTP. > > --Paul > > Rolf wrote: > > > Paul Rubin wrote in message news:<7x3d1r2paa.fsf at ruckus.brouhaha.com>... > > > >>rolffreimuth at hotmail.com (Rolf) writes: > >> > >>>Is there any way to do *pure* python client-side scripting? Are there > >>>any good resources with examples of how to do it? > >>> > >>If you mean for publishing web pages on the internet, it doesn't sound > >>like such a great idea. I've stopped paying attention to Windoze but > >>I believe there's a Python version (ActiveState?) that's callable as a > >>COM object. So you'd have to download the huge interpreter to the > >>client, and then you could call it from Javascript. You should be > >>able to pass it the document object as an argument. From there, the > >>python script can use the regular COM automation methods to navigate > >>inside the document object, or it can call javascript code to > >>manipulate the document. I've forgotten most of this stuff but > >>basically once you get hold of the IWebBrowser2 interface you can > >>make the browser do most anything you want. > >> > > > > > > I dont mean for it to be a web application. I am just considering it > > as a possibility for a simple GUI. To run the app, a user would need > > Python installed, plus MSIE, plus a few other python libs. It is > > primarily for my own use and education. To launch the app, the user > > would just click on an HTML file on the local hard drive. > > > > Having the GUI in a browser is an advantage for this application. The > > app basically scans a directory tree for large digital photos (~2MB > > each) then it uses PIL to create thumbnails and and some more > > reasonably sized "large" images for publishing on the web. I also was > > considering writing some code to manage the FTP of the "processed" > > images up to my website. > > > > Rolf > > > > > > From bkc at Murkworks.com Fri Jan 4 22:34:27 2002 From: bkc at Murkworks.com (Brad Clements) Date: Fri, 4 Jan 2002 16:34:27 -0500 Subject: Client-side web scripting in Python? References: <8abfe95a.0112311037.35fb4c2@posting.google.com> <7x3d1r2paa.fsf@ruckus.brouhaha.com> <8abfe95a.0201011104.2905994f@posting.google.com> Message-ID: <3c362081$1_11@news.newsgroups.com> Have I already suggested taking a look at IBM's SASH? http://sash.alphaworks.ibm.com Don't be put off by "Javascript runtime" on the front page. I've gotten them to make up an example or two showing how to embed Python into Sash weblications, just like using IE. Some things that put Sash ahead of the curve (in concept, if not in actual practice) 1. Sash weblications are self-packaging CABS, the runtime includes it's own security engine so you can distribute self-installing weblications from a web page, yet when they run they *can* (but don't have to), have .hta like access to the system. In particular, you can partition the access into categories and levels. 2. Sash has built-in support for XML-RPC and Soap (and yes, the xml-rpc works with Zope) .. Haven't tried SOAP yet still waiting for Brian's stuff. 3. Weblications can be "hosted" in other web pages, in various parts of the Windows desktop such as toolbar, system tray, search/find, etc. Not just an .hta style window. 4. There's a group working on a Linux implementation Now, if I could convince them to drop javascript and substitute Python as the native code engine I'd be thrilled. "Paul Everitt" wrote in message news:mailman.1010158089.28339.python-list at python.org... > > Hi Rolf. I'm tinkering around with something similar. That is, using > IE5.5 as the GUI for a data model in XML and logic in Python (via > win32all's support for ActiveScripting). I've made a bit of progress, > so if you'd like to send me an email on the subject, go right ahead. I'm currently doing a bit of XML-RPC from Zope to IE (6) sending xml_pickle's to IE for XSLT processing. Dreaming of having TAL in xsl. Paul, I'm interested in seeing what you've done too. -- Brad Clements, DevNet Sysop 5 Developer Network Sysop Team -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! Check out our new Unlimited Server. No Download or Time Limits! -----== Over 80,000 Newsgroups - 19 Different Servers! ==----- From nhodgson at bigpond.net.au Fri Jan 4 23:56:03 2002 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Fri, 04 Jan 2002 22:56:03 GMT Subject: Client-side web scripting in Python? References: <8abfe95a.0112311037.35fb4c2@posting.google.com> Message-ID: <7qqZ7.34127$wD1.200861@news-server.bigpond.net.au> [It appears this hasn't propagated, possibly due to the attachment, so the demo code is now on a web site] Rolf: > I installed ActiveState's Python 2.1 and I can successfully write > Python code on both the server and client sides, but I am having > trouble doing a few things. Python does not seem to know about the > document object which is accessible from Javascript. It seems > necessary to be able to use that document object in order to modify > the contents of the page. Some of my code is quite happy accessing the document object. A simple image gallery HTA that uses document is attached to this message. The code works with IE 6 but may have problems with other versions. I'd really like to write a decent HTA demonstration in Python but haven't been able to think up something that is small and useful. This demo would be much better if it performed the search and load of image files in the background. http://scintilla.sourceforge.net/Gallery.hta Also explore the win32comext\axscript\demos\client\ie directory for some more examples. Neil From tim.one at home.com Tue Jan 1 07:03:05 2002 From: tim.one at home.com (Tim Peters) Date: Tue, 1 Jan 2002 01:03:05 -0500 Subject: stackless python In-Reply-To: <3C309327.60407@tismer.com> Message-ID: [Paul Rubin] > The limitations of "simple generators" also seem kind of artificial-- > maybe Stackless for 2.2 can support calling a generator from multiple > places. [Christian Tismer] > Sure, Stackless generators are not limited. They are first class > objects which can be used everywhere. So are 2.2's Simple Generators. Paul is confused if he thinks a Python generator can't be called from multiple places (although that's not typical use). Since they're just objects that implement the 2.2 iterator protocol, we *can't* stop them from getting called from multiple places . > Just think of ICON's co-expressions. Python's generators are between Icon's generators and Icon's co-expressions: like an Icon coexp, they can be resumed at will independent of control context (although it's more usual to let "for" loops drive them by magic), but like an Icon generator they always return control to their resumer. A subtle advantage of the latter is that semantics in case of unhandled exception are very clear: an active instance of a Python generator "came from" an obvious place, and that's the obvious place to pass on an unhandled exception. BTW, Neil Schemenauer had no trouble rewriting all "the usual" coroutine examples to use Simple Generators instead. It remains debatable whether coexps are actually more powerful; in general, a Python-level dispatch loop can keep around any number of Simple Generators suspended in midstream (including chains of generators, recursive or otherwise), and coexp-like transfer can then be faked by yielding back to the dispatch loop with an indication of which generator you want to see resumed next. Neil didn't need all that machinery to handle the examples he tried, though. I expect that if someone bothered to flesh this all out, the rub would be that resuming a generator chain N deep (ditto yielding back from one) requires time proportional to N. if-you-don't-avoid-the-c-stack-you-have-to-rebuild-it-each-time-ly y'rs - tim From donn at drizzle.com Tue Jan 1 19:41:32 2002 From: donn at drizzle.com (Donn Cave) Date: Tue, 01 Jan 2002 18:41:32 -0000 Subject: stackless python References: None <9vpjds$due$1@usc.edu> <1008824522.772261@yabetcha.sttl.drizzle.com> Message-ID: Quoth Christian Tismer : ... | Continuations can do even more, they are able to create new | control structures for your language. And exactly that it the point | which makes them insuitable for Python: They are too powerful. | Python has its own control structures, and we don't need a construct | with the power to build some. This is oversized, and very oversized | construct turns out to be a drawback at some future. | What Python needs is a secure mechanism to switch frame changes | at certain times. This is not continuations, but microthreads with | explicit or implicit switching. | | I will implement this for Python 2.2, probably with some help | of volunteers. Could Gordon McMillan's "asyncore turned right-side out" select dispatcher have been written with the microthread facility you have in mind? I am sure there's some way to present that capability in terms of a pre-defined control structure, instead of raw continuations, but it's a pity if it has to be given up because it's too powerful. Donn Cave, donn at drizzle.com From tismer at tismer.com Tue Jan 1 23:13:40 2002 From: tismer at tismer.com (Christian Tismer) Date: Tue, 01 Jan 2002 23:13:40 +0100 Subject: stackless python References: None <9vpjds$due$1@usc.edu> <1008824522.772261@yabetcha.sttl.drizzle.com> Message-ID: <3C323494.3030206@tismer.com> Donn Cave wrote: > Quoth Christian Tismer : > ... > | Continuations can do even more, they are able to create new > | control structures for your language. And exactly that it the point > | which makes them insuitable for Python: They are too powerful. > | Python has its own control structures, and we don't need a construct > | with the power to build some. This is oversized, and very oversized > | construct turns out to be a drawback at some future. > | What Python needs is a secure mechanism to switch frame changes > | at certain times. This is not continuations, but microthreads with > | explicit or implicit switching. > | > | I will implement this for Python 2.2, probably with some help > | of volunteers. > > Could Gordon McMillan's "asyncore turned right-side out" select > dispatcher have been written with the microthread facility you > have in mind? Yes, I'm pretty sure. > I am sure there's some way to present that capability in terms of > a pre-defined control structure, instead of raw continuations, but > it's a pity if it has to be given up because it's too powerful. No, I no longer think so. It has to be shrunk down to the capabilities needed. Having continuations where one-shot continuations (aka frames with state) are sufficient is not healthy. I've been thinking of this since a year now, and finally Guido convinced me. ciao - chris -- Christian Tismer :^) Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net/ 14163 Berlin : PGP key -> http://wwwkeys.pgp.net/ PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com/ From jkraska at san.rr.com Wed Jan 2 01:05:44 2002 From: jkraska at san.rr.com (Courageous) Date: Wed, 02 Jan 2002 00:05:44 GMT Subject: stackless python References: <9vpjds$due$1@usc.edu> <1008824522.772261@yabetcha.sttl.drizzle.com> Message-ID: >No, I no longer think so. >It has to be shrunk down to the capabilities needed. >Having continuations where one-shot continuations (aka frames with >state) are sufficient is not healthy. >I've been thinking of this since a year now, and finally Guido >convinced me. It'll be misfortunate if all access to continuations goes away. Will your library at least allow the ability ot manipulate them through C extension functions? I would highly suggest that you offer this. It leaves continuation code to the experts and is highly dissuasive to the casual user, which would mean in practice very little of the labyrnthine code which use of continuations results in. C// From donn at drizzle.com Wed Jan 2 04:07:25 2002 From: donn at drizzle.com (Donn Cave) Date: Wed, 02 Jan 2002 03:07:25 -0000 Subject: stackless python References: <9vpjds$due$1@usc.edu> <1008824522.772261@yabetcha.sttl.drizzle.com> Message-ID: Quoth Courageous : (quoting Christian Tismer) |> No, I no longer think so. |> It has to be shrunk down to the capabilities needed. |> Having continuations where one-shot continuations (aka frames with |> state) are sufficient is not healthy. |> I've been thinking of this since a year now, and finally Guido |> convinced me. | | It'll be misfortunate if all access to continuations goes away. | Will your library at least allow the ability ot manipulate them | through C extension functions? I would highly suggest that you | offer this. It leaves continuation code to the experts and is | highly dissuasive to the casual user, which would mean in practice | very little of the labyrnthine code which use of continuations | results in. Eww, that sounds like the worst of both worlds to me. Not only do I lack your confidence in C coders, I find C modules quite a bit more inscrutable. I'm inclined to agree with him on as far as quoted above, though I'm sure he has a more comprehensive sense of what "unhealthy" means. The trick is defining what's really useful, and shrinking it to that. If the result will work for nearly every practical use of continuations, then it's a good deal, and of course by that standard there wouldn't be any apparent reason to support more from C. Donn Cave, donn at drizzle.com From tismer at tismer.com Wed Jan 2 10:37:21 2002 From: tismer at tismer.com (Christian Tismer) Date: Wed, 02 Jan 2002 10:37:21 +0100 Subject: stackless python References: <9vpjds$due$1@usc.edu> <1008824522.772261@yabetcha.sttl.drizzle.com> Message-ID: <3C32D4D1.70609@tismer.com> Courageous wrote: >>No, I no longer think so. >>It has to be shrunk down to the capabilities needed. >>Having continuations where one-shot continuations (aka frames with >>state) are sufficient is not healthy. >>I've been thinking of this since a year now, and finally Guido >>convinced me. >> > > It'll be misfortunate if all access to continuations goes away. > Will your library at least allow the ability ot manipulate them > through C extension functions? I would highly suggest that you > offer this. It leaves continuation code to the experts and is > highly dissuasive to the casual user, which would mean in practice > very little of the labyrnthine code which use of continuations > results in. If I'm heading towards integration into the mainstream, I cannot introduce a backdoor to continuations. They do add a considerable amount of complexity to the kernel code. I might add a branch for this later on. For now, I need to go with one-shot continuations. That is: After the continuation is run, its state is changed and it cannot be run again, resp. it is no longer the same continuation. As a compromize, I can provide an explicit clone operation to save a continuation for re-use. Today, this happens automagically, although it isn't needed in most cases. Happy new year - chris -- Christian Tismer :^) Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net/ 14163 Berlin : PGP key -> http://wwwkeys.pgp.net/ PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com/ From maxm at mxm.dk Wed Jan 2 11:15:14 2002 From: maxm at mxm.dk (maxm) Date: Wed, 2 Jan 2002 11:15:14 +0100 Subject: stackless python References: <9vpjds$due$1@usc.edu> <1008824522.772261@yabetcha.sttl.drizzle.com> Message-ID: <_4BY7.7129$aS.1110024@news010.worldonline.dk> "Christian Tismer" wrote in message news:mailman.1009964282.4849.python-list at python.org... > If I'm heading towards integration into the mainstream, I cannot > introduce a backdoor to continuations. They do add a considerable > amount of complexity to the kernel code. Anyhoo ... I look forward to trying out the microthreads. They sound like something really worthwile. I do hope that something like it gets into the standard distribution. regards Max M From mwh at python.net Tue Jan 1 20:22:12 2002 From: mwh at python.net (Michael Hudson) Date: Tue, 1 Jan 2002 19:22:12 GMT Subject: stackless python References: <9vpjds$due$1@usc.edu> <1008824522.772261@yabetcha.sttl.drizzle.com> <7x3d1r1k9j.fsf@ruckus.brouhaha.com> Message-ID: Paul Rubin writes: > The thing I don't fully understand is that several Scheme > implementations are both smaller and faster than Python. Less dynamism, I think. I'm not sure what the standard says about things like (define (func x y) (+ x y)) (set! + -) (display (func 2 3)) but I'd bet at least some implementations would print "5". Certainly in CL the compiler can know for certain if the + will refer to cl:+ or not, and rebinding cl:+ is not allowed. > I've been wondering for a while whether it's time to graft a Python > parser onto a Scheme compiler/evaluator. Would be an interesting project, but I'd guess that either you wouldn't get a significant speed up, or the language you'd end up implementing would have subtle differences from Python as we know it. Cheers, M> From justin at iago.org Wed Jan 2 19:52:47 2002 From: justin at iago.org (Justin Sheehy) Date: Wed, 02 Jan 2002 13:52:47 -0500 Subject: stackless python In-Reply-To: (Michael Hudson's message of "Tue, 1 Jan 2002 19:22:12 GMT") References: <9vpjds$due$1@usc.edu> <1008824522.772261@yabetcha.sttl.drizzle.com> <7x3d1r1k9j.fsf@ruckus.brouhaha.com> Message-ID: Michael Hudson writes: >> The thing I don't fully understand is that several Scheme >> implementations are both smaller and faster than Python. > > Less dynamism, I think. I'm not sure what the standard says about > things like > > (define (func x y) (+ x y)) > (set! + -) > (display (func 2 3)) > > but I'd bet at least some implementations would print "5". It's hard to show that _none_ of them do that, but on the ones I have handy: ---- Chez Scheme Version 6.1 Copyright (c) 1998 Cadence Research Systems > (define (func x y) (+ x y)) > (set! + -) > (display (func 2 3)) -1 ---- Welcome to MzScheme version 103, Copyright (c) 1995-2000 PLT (Matthew Flatt) > (define (func x y) (+ x y)) > (set! + -) > (display (func 2 3)) -1 ---- $ elk > (define (func x y) (+ x y)) func > (set! + -) #[primitive +] > (display (func 2 3)) -1 ---- (mit scheme) 1 ]=> (define (func x y) (+ x y)) ;Value: func 1 ]=> (set! + -) ;Value 1: #[arity-dispatched-procedure 1] 1 ]=> (display (func 2 3)) -1 ;Unspecified return value ---- guile> (define (func x y) (+ x y)) guile> (set! + -) guile> (display (func 2 3)) -1 ---- At least a good portion of Scheme implementations support this level of dynamism. At least a couple of those are pretty darn efficient compared to CPython. So I'd venture that while there may be "less dynamism" in some real sense, it isn't as simple a difference as you imply. -Justin p.s. - I suspect that scheme48 might not let you assign to "+", from what I remember of it. From bokr at accessone.com Wed Jan 2 23:41:59 2002 From: bokr at accessone.com (Bengt Richter) Date: Wed, 02 Jan 2002 22:41:59 GMT Subject: stackless python References: <9vpjds$due$1@usc.edu> <1008824522.772261@yabetcha.sttl.drizzle.com> <7x3d1r1k9j.fsf@ruckus.brouhaha.com> Message-ID: <3c3387a2.99732617@wa.news.verio.net> On Wed, 02 Jan 2002 13:52:47 -0500, Justin Sheehy wrote: >Michael Hudson writes: > >>> The thing I don't fully understand is that several Scheme >>> implementations are both smaller and faster than Python. >> >> Less dynamism, I think. I'm not sure what the standard says about >> things like >> >> (define (func x y) (+ x y)) >> (set! + -) >> (display (func 2 3)) >> >> but I'd bet at least some implementations would print "5". > FWIW, here's an oldie (came on 5 1/4" floppy in "PC Scheme Trade Edition" book from MIT press 1990, by Texas Instruments) Note the difference in results at [3] and [4]: _________________________________________ PC Scheme Student Edition 3.0 (C) Copyright 1987 by Texas Instruments All Rights Reserved. [PCS-DEBUG-MODE is OFF] [1] (define (func x y) (+ x y)) FUNC [2] (set! + -) [WARNING: modifying an `integrable' variable: +] # [3] (display (func 2 3)) 5 [4] (+ 2 3) -1 [5] _________________________________________ >It's hard to show that _none_ of them do that, but on the ones I have handy: > >---- >Chez Scheme Version 6.1 >Copyright (c) 1998 Cadence Research Systems > >> (define (func x y) (+ x y)) >> (set! + -) >> (display (func 2 3)) >-1 >---- >Welcome to MzScheme version 103, Copyright (c) 1995-2000 PLT (Matthew Flatt) >> (define (func x y) (+ x y)) >> (set! + -) >> (display (func 2 3)) >-1 >---- >$ elk >> (define (func x y) (+ x y)) >func >> (set! + -) >#[primitive +] >> (display (func 2 3)) >-1 >---- >(mit scheme) >1 ]=> (define (func x y) (+ x y)) > >;Value: func > >1 ]=> (set! + -) > >;Value 1: #[arity-dispatched-procedure 1] > >1 ]=> (display (func 2 3)) >-1 >;Unspecified return value >---- >guile> (define (func x y) (+ x y)) >guile> (set! + -) >guile> (display (func 2 3)) >-1 >---- > >At least a good portion of Scheme implementations support this level >of dynamism. At least a couple of those are pretty darn efficient >compared to CPython. So I'd venture that while there may be "less >dynamism" in some real sense, it isn't as simple a difference as you imply. > >-Justin > > >p.s. - I suspect that scheme48 might not let you assign to "+", from > what I remember of it. > > > From mwh at python.net Thu Jan 3 11:24:23 2002 From: mwh at python.net (Michael Hudson) Date: Thu, 3 Jan 2002 10:24:23 GMT Subject: stackless python References: <9vpjds$due$1@usc.edu> <1008824522.772261@yabetcha.sttl.drizzle.com> <7x3d1r1k9j.fsf@ruckus.brouhaha.com> <3c3387a2.99732617@wa.news.verio.net> Message-ID: bokr at accessone.com (Bengt Richter) writes: > On Wed, 02 Jan 2002 13:52:47 -0500, Justin Sheehy wrote: > > >Michael Hudson writes: > > > >>> The thing I don't fully understand is that several Scheme > >>> implementations are both smaller and faster than Python. > >> > >> Less dynamism, I think. I'm not sure what the standard says about > >> things like > >> > >> (define (func x y) (+ x y)) > >> (set! + -) > >> (display (func 2 3)) > >> > >> but I'd bet at least some implementations would print "5". > > > FWIW, here's an oldie (came on 5 1/4" floppy in "PC Scheme Trade > Edition" book from MIT press 1990, by Texas Instruments) > > Note the difference in results at [3] and [4]: That was what I was expecting, at least some of the time. [...] > >It's hard to show that _none_ of them do that, but on the ones I > >have handy: [lots of -1's] > >At least a good portion of Scheme implementations support this level > >of dynamism. At least a couple of those are pretty darn efficient > >compared to CPython. Were any of those compiling the code? > >So I'd venture that while there may be "less > >dynamism" in some real sense, it isn't as simple a difference as > >you imply. I wouldn't want anyone to think I claimed it was simple; it was just an example. It may be almost a social thing; the sort of code one writes in scheme may be easier to compile efficiently than the sort of code one writes in Python. This is getting into meaningless wibble territory anyway, so I'm going to stop. Cheers, M. From justin at iago.org Thu Jan 3 17:08:18 2002 From: justin at iago.org (Justin Sheehy) Date: Thu, 03 Jan 2002 11:08:18 -0500 Subject: stackless python In-Reply-To: (Michael Hudson's message of "Thu, 3 Jan 2002 10:24:23 GMT") References: <9vpjds$due$1@usc.edu> <1008824522.772261@yabetcha.sttl.drizzle.com> <7x3d1r1k9j.fsf@ruckus.brouhaha.com> <3c3387a2.99732617@wa.news.verio.net> Message-ID: Michael Hudson writes: >> >At least a good portion of Scheme implementations support this level >> >of dynamism. At least a couple of those are pretty darn efficient >> >compared to CPython. > > Were any of those compiling the code? Yes, Chez Scheme performs incremental compilation. > It may be almost a social thing; the sort of code one writes in scheme > may be easier to compile efficiently than the sort of code one writes > in Python. Could be. My personal suspicion is that the main reasons for the fact that Scheme implementations tend to be so much more optimized than Python are: 1 - Hundreds of graduate students attacking the problem. 2 - Less concern with issues like maintainability and vast portability of a single core implementation. I really don't believe the "Python is harder to optimize" argument[1], either for language definition or social reasons. Other similarly dynamic languages have successfully produced well-optimized implementations. I think that it just hasn't been a very high priority among the relatively small group of people that actually work on the CPython core. -Justin [1] - qualification: There are a few things that Python doesn't have that do make it harder to optimize than it would be if they were present, such as type declarations. My point is that other languages that are also missing these features have not found them to be insurmountable obstacles. From jkraska at san.rr.com Thu Jan 3 18:24:41 2002 From: jkraska at san.rr.com (Courageous) Date: Thu, 03 Jan 2002 17:24:41 GMT Subject: stackless python References: <9vpjds$due$1@usc.edu> <1008824522.772261@yabetcha.sttl.drizzle.com> <7x3d1r1k9j.fsf@ruckus.brouhaha.com> <3c3387a2.99732617@wa.news.verio.net> Message-ID: >[1] - qualification: There are a few things that Python doesn't have > that do make it harder to optimize than it would be if they were > present, such as type declarations. My point is that other > languages that are also missing these features have not found > them to be insurmountable obstacles. And in any case, actually only a small part of the performance problem -- or at least for the performance problem within the order of magnitude currently faced by Python. C// From lull at acm.org Tue Jan 1 07:52:06 2002 From: lull at acm.org (John Lull) Date: 1 Jan 2002 00:52:06 -0600 Subject: Multiple active locales, AKA class-based API for the locale module. References: Message-ID: <4sm23u8q1j729ehiolvfm7i9qn7ell498r@4ax.com> I wrote: > At first glance, this looks like a fairly straight-forward bit of work. Neglecting, of course, the really tough bits -- strcoll(), strxfrm(), and all the process-wide side-effects of setlocale(). Regards, John From syver-en+usenet at online.no Tue Jan 1 09:42:22 2002 From: syver-en+usenet at online.no (Syver Enstad) Date: 01 Jan 2002 09:42:22 +0100 Subject: Fix for problem importing modules in packages in Pymacs.py (0.12) Message-ID: The point being recursing to the "lowest" level to get the actual module. This fixes the problem I was having with importing modules like Emacs.extensions. >From pymacs.py, first is new code, second is original 0.12 version *************** *** 168,183 **** try: if directory: sys.path.insert(0, directory) ! # if the module_name is of the form package.module ! # then the return value of __import__ is the package not the module ! def my_import(name): # fix copied from the python library documentation ! mod = __import__(name) ! components = '.'.split(name) ! for comp in components[1:]: ! mod = getattr(mod, comp) # get the next package or module ! return mod ! object = my_import(module_name) ! finally: if directory: del sys.path[0] --- 168,174 ---- try: if directory: sys.path.insert(0, directory) ! object = __import__(module_name) finally: if directory: del sys.path[0] -- Vennlig hilsen Syver Enstad From pinard at iro.umontreal.ca Thu Jan 3 22:31:42 2002 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 03 Jan 2002 16:31:42 -0500 Subject: Fix for problem importing modules in packages in Pymacs.py (0.12) References: Message-ID: [Syver Enstad] > This fixes the problem I was having with importing modules like > Emacs.extensions. Wow! Thanks a lot. > >From pymacs.py, first is new code, second is original 0.12 version I implemented your very solution, yet it a bit differently. Unless you tell me there is a blunt below, I'll put out Pymacs 0.13 soon. --- pymacs.py~ Thu Jan 3 16:23:32 2002 +++ pymacs.py Thu Jan 3 16:23:09 2002 @@ -172,6 +172,10 @@ finally: if directory: del sys.path[0] + # Whenever MODULE_NAME is of the form [PACKAGE.]...MODULE, + # __import__ returns the outer PACKAGE, not the module. + for component in string.split(module_name, '.')[1:]: + object = getattr(object, component) except ImportError: return None interactions = object.__dict__.get('interactions', {}) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From henrik at moskau.hmotakef.homeip.net Tue Jan 1 10:24:27 2002 From: henrik at moskau.hmotakef.homeip.net (Henrik Motakef) Date: 01 Jan 2002 09:24:27 +0000 Subject: Python Script References: Message-ID: <87y9jictkk.fsf@moskau.hmotakef.homeip.net> "john duncan" writes: > I use OpenBSD 3.0, which of these > packages do I need to install to get it to run. The > header line is #!/usr/bin/env python2 Which one of the "python-2.1.1-XXX-tgz"s you install doesn't matter much, try "man ports" and look for "flavors". All include the complete Python distribution, and optionally thread and Tk (a GUI package) support. If you have X installed, use the one with threads and tk (which is, AFAIK, the default when you build it from /usr/ports/lang/python). However, in OpenBSD the python interpreter is installed as /usr/local/bin/python2.1, symlinked to /usr/local/bin/python. So you have to either change the script's first line, or, probably better, create another symlink to "python2" somewhere in you path ("ln -s /usr/local/bin/python2.1 /usr/local/bin/python2" should help). hth Henrik From aleax at aleax.it Tue Jan 1 10:28:11 2002 From: aleax at aleax.it (Alex Martelli) Date: Tue, 01 Jan 2002 09:28:11 GMT Subject: REPOST: Re: Python and Ruby: a comparison References: <3C2B9A61.EE1618DB@earthlink.net> <2WpX7.1145$0s5.714029@news20> <3C2E6876.4CBF45D4@geneva-link.ch> <465v2u4lv3illoviq19nhdf1r2vcknbakn@4ax.com> <7$--$$-$$$$_$-$__$@news.noc.cabal.int> Message-ID: Edward Diener wrote: > CLR is a lowest common denominator for language ideas which MS supports. > What happens when a language has good ideas which are more advanced than > what CLR supports. It is left out of CLR, or included into it with those > ideas stripped from the language to accomodate CLR. Sometimes the Holy Your assertions are seriously counterfactual. Check the list at, e.g., http://www.dotnet-fr.org/links.php3?op=viewslink&sid=15. Consider, say, the Gasgow Haskell Compiler for .NET. Obviously, Haskell 98 has quite a few "good ideas which are more advanced" than anything in .NET, such as lazy evaluation, typeclasses, immutable data, monads... So, was Haskell "left out of CLR"? Not at all, Glasgow Haskell supports CLR. Were the advanced ideas that are 99% of Haskell "stripped from the language"? Again, not at all, obviously. Pretty evidently, instead, what happened (and the same can be said for Mercury, Oberon, APL, and so on) is that a distinction is drawn between a language and its "foreign function interface" (traditional lisp/fp terminology for: how a language interfaces to "foreign" pieces of code, those written in other languages; sometimes more generally called a "foreign language interface"). It's pretty obvious, isn't it? The CLR dictates a certain MINIMAL set of functionality that a language must support to fully integrate with it. In no way does it constrain any _extra_ functionality the language may wish to add. Such extras will not be seamlessly made available via the CLR sanctioned "view" of any component written in the language, of course (eh yes, it IS pretty obvious: if no other language has ever yet invented the sublime concept of superinfermollification that my new Aretinus language will introduce tomorrow, how could my components expose and offer superinfermollification to other components coded in other inferior languages?!). But that doesn't, by any stretch of the imagination, imply either that the language is "left out of the CLR", nor of course that the language is stripped of its original ideas. I'll still use (e.g.) Mercury backtracking, Haskell typeclasses, or Oberon active-objects, even if "lesser" languages will obviously not "see" them at the interface! Alex From eldiener at earthlink.net Tue Jan 1 22:18:37 2002 From: eldiener at earthlink.net (Edward Diener) Date: Tue, 01 Jan 2002 21:18:37 GMT Subject: REPOST: Re: Python and Ruby: a comparison References: <3C2B9A61.EE1618DB@earthlink.net> <2WpX7.1145$0s5.714029@news20> <3C2E6876.4CBF45D4@geneva-link.ch> <465v2u4lv3illoviq19nhdf1r2vcknbakn@4ax.com> <7$--$$-$$$$_$-$__$@news.noc.cabal.int> Message-ID: <3C322751.9070404@earthlink.net> Alex Martelli wrote: > Edward Diener wrote: > > >>CLR is a lowest common denominator for language ideas which MS supports. >>What happens when a language has good ideas which are more advanced than >>what CLR supports. It is left out of CLR, or included into it with those >>ideas stripped from the language to accomodate CLR. Sometimes the Holy >> > > Your assertions are seriously counterfactual. > > Check the list at, e.g., > http://www.dotnet-fr.org/links.php3?op=viewslink&sid=15. > > Consider, say, the Gasgow Haskell Compiler for .NET. Obviously, Haskell 98 > has quite a few "good ideas which are more advanced" than anything in .NET, > such as lazy evaluation, typeclasses, immutable data, monads... So, was > Haskell "left out of CLR"? Not at all, Glasgow Haskell supports CLR. Were > the advanced ideas that are 99% of Haskell "stripped from the language"? > > Again, not at all, obviously. Pretty evidently, instead, what happened > (and the same can be said for Mercury, Oberon, APL, and so on) is that a > distinction is drawn between a language and its "foreign function > interface" (traditional lisp/fp terminology for: how a language interfaces > to "foreign" pieces of code, those written in other languages; sometimes > more generally called a "foreign language interface"). > > It's pretty obvious, isn't it? The CLR dictates a certain MINIMAL set of > functionality that a language must support to fully integrate with it. In > no way does it constrain any _extra_ functionality the language may wish to > add. Such extras will not be seamlessly made available via the CLR > sanctioned "view" of any component written in the language, of course (eh > yes, it IS pretty obvious: if no other language has ever yet invented the > sublime concept of superinfermollification that my new Aretinus language > will introduce tomorrow, how could my components expose and offer > superinfermollification to other components coded in other inferior > languages?!). But that doesn't, by any stretch of the imagination, imply > either that the language is "left out of the CLR", nor of course that the > language is stripped of its original ideas. I'll still use (e.g.) Mercury > backtracking, Haskell typeclasses, or Oberon active-objects, even if > "lesser" languages will obviously not "see" them at the interface! I stand corrected. Yes you can use .NET versions of languages and as long as you don't use the features of the language in managed code which CLR supports, it is possible to use all the features of the language internally. However if a .NET language version does not implement key portions of CLR, mainly garbage collection, the basic necessary data types, and single inheritance OOP, it is a poor candidate to be inetgrated with .NET. I still feel this leads to language subsets and people who learn a computer language and only use, and know, a portion of that language. It has already happened before .NET was even created with VC++, where a great many programmers who know only MS's subset of C++ and even some of its incorrect syntax, assume they are using C++ effectively and correctly and often they are not. Managed C++ in .NET is also an abortion of C++ which only a computer programming masochist could love. I anticipate this happening with most .NET versions of languages and that many programmers of these languages will only know and use the .NET subset and not the full language. Eddie From aleax at aleax.it Wed Jan 2 11:36:18 2002 From: aleax at aleax.it (Alex Martelli) Date: Wed, 2 Jan 2002 11:36:18 +0100 Subject: REPOST: Re: Python and Ruby: a comparison References: <3C2B9A61.EE1618DB@earthlink.net> <2WpX7.1145$0s5.714029@news20> <3C2E6876.4CBF45D4@geneva-link.ch> <465v2u4lv3illoviq19nhdf1r2vcknbakn@4ax.com> <7$--$$-$$$$_$-$__$@news.noc.cabal.int> <3C322751.9070404@earthlink.net> Message-ID: "Edward Diener" wrote in message news:3C322751.9070404 at earthlink.net... ... > > languages?!). But that doesn't, by any stretch of the imagination, imply > > either that the language is "left out of the CLR", nor of course that the > > language is stripped of its original ideas. I'll still use (e.g.) Mercury > > backtracking, Haskell typeclasses, or Oberon active-objects, even if > > "lesser" languages will obviously not "see" them at the interface! ... > Yes you can use .NET versions of languages and as long as you don't use > the features of the language in managed code which CLR supports, it is > possible to use all the features of the language internally. However if Right. > a .NET language version does not implement key portions of CLR, mainly > garbage collection, the basic necessary data types, and single > inheritance OOP, it is a poor candidate to be inetgrated with .NET. Yes, there are indeed certain minimal functional requirements that a language must support if it is to be meaningfully integrated into the .NET Platform. For example, VB6 was lacking in some of these reqs (e.g., it had no implementation-inheritance); thus, VB7 (aka VB.NET) "had" to be enriched to include such functionality in some way or other, and it was. (Nothing forced MS to enrich VB in the specifc way they chose -- making it a substantially better language but with a serious loss of backwards compatibility -- that wasn't mandated by CLR reqs, but rather a strategic choice by MS, who no doubt took a kind of political/strategical advantage of "having to change anyway" to shoehorn some language changes that they otherwise desired). > I still feel this leads to language subsets and people who learn a > computer language and only use, and know, a portion of that language. It I think your feelings are misleading you on this subject. Language subsets &c are inevitably caused by languages being "larger" than what is needed by some substantial group of people, and happen for every language with reasonably-long history and wide use. Some languages just accept that: they AIM to be big and cover a lot of bases, thus subsetting is taken in stride. C++, Perl, O'CAML, Common Lisp: nobody has 100% of them in their everyday "active vocabulary", and very few users indeed reach 100% even in "passive vocabulary" (portion of the language that is understood if met in code being read, even though not normally used in code produced by the person). But even languages which aim to be small, unless they are highly restricted, end up subsetted anyway. Few Haskell users routinely write their own monads: much can be done in Haskell without the very substantial conceptual jump needed to fully grasp monads and author your own, thus, enter subsetting. Very few Python users routinely write their own metaclasses: ditto ditto. It's anything but rare even for a highly productive and competent Python coder to have problems grasping metaclasses even in "passive vocabulary" terms. And, why not? The average Pythonista does not need them, they're a hard step up on the conceptual ladder, so WHY bemoan their lack from either active or passive vocabularies of Pythonistas? Subsetting becomes even more prevalent as soon as you accept some "standard library" features as part of a language. If you never do (e.g.) CGI web programming, why should you care about that subset of a language, or its libraries, that exists strictly for the benefit of CGI authors? Yet the language (cum libraries) is better for having those modules too, widening its usability and applicability (and similarly for monads, metaclasses, etc etc). It's certainly mistaken to think that a totally new phenomenon (the introduction of .NET Framework and its CLR) "leads to" an old, existing, and inevitable one. Post hoc does not necessarily mean propter hoc, but the reverse implication IS indeed necessary (as long as time's arrows don't start flipping around randomly, causes MUST come before effects). > has already happened before .NET was even created with VC++, where a > great many programmers who know only MS's subset of C++ and even some of > its incorrect syntax, assume they are using C++ effectively and > correctly and often they are not. Extremely similar phenomena prevailed even before Mr Gates knew how to tell a bit from a byte: most scientists I met in the '70s, who thought they knew and were using Fortran effectively and correctly, were just as sadly mistaken -- they actually knew and used (and at times with far from optimal efficiency) some specific dialect of the Fortran language as supplied by, e.g., Digital Equipment, or IBM, or some other purveyor yet (or rather, almost invariably, some specific SUBSET of that specific dialect; few people who learned Fortran on boxes where you could write, e.g., a literal constant as 'CIAO', ever knew that the standard way of writing it was 4HCIAO, or could easily recognize the latter form; just as one example...). > Managed C++ in .NET is also an > abortion of C++ which only a computer programming masochist could love. The ability to play havoc with pointers and memory management in C++, while inevitably and inextricably part of that language, is hardly a plus for a vast majority of the application uses to which C++ is (maybe inappropriately) put on a daily basis. Doing away with that is the single highest factor in productivity enhancement when moving, e.g., to Java. Yet the loss of templates (generic programming) hurts productivity most grievously (when imposed upon programmers who have learned to make good use of templates, of course). I believe that, today still, "Managed C++" is the only .NET language that lets you use templates (as the architects of .NET seem to share with those of Java a horrible blind spot regarding generic programming -- I keep hearing that Java is due to gain Generic Programming features any day now, but I still can't see them in Javasoft's released SDKs). Much as I might prefer "C# with templates" or whatever, therefore, I'm quite liable to choose "Managed C++" today if tasked to develop some largish subsystem in and for .NET (given that no "Python .NET" is at hand: Python programming, as it hinges on signature based polymorphism, just like templates, gives similar productivity advantages to templates in even smoother and more general ways, of course). > I anticipate this happening with most .NET versions of languages and > that many programmers of these languages will only know and use the .NET > subset and not the full language. If most programmers will indeed start eschewing "unmanaged" memory access for application-level programming, this will no doubt reduce bugs and increase productivity. But giving up on extremely low-level features (unsuitable for application programming needs) is something that basically only touches on C++ and similar system-level languages, since application oriented languages don't offer those anyway (not the sensible ones!-). Apart from "unmanaged memory access" issues, I totally disagree with your thesis. If a given programmer or programming shop wants the semantics of C#/VB.NET, they will mostly be using C# or VB.NET depending on syntax sugar tastes. When somebody goes to the trouble of using the .NET versions of, say, APL, or Haskell, or Mercury, it definitely will NOT be just in order to get peculiar syntax sugar on the same semantics: rather, it will be because SOME supplementary features of those respective languages are of interest (may be arry operations, typeclasses, backtracking respectively). It will therefore be an EXTREMELY RARE phenomenon for programmers to be using "strange" (non C#/VB.NET) languages in the .NET versions and "only know and use the .NET subset", assuming that, by the latter, you mean the semantics supported "at the interface between separate components" by CLR. Alex From bmcyitz at freebox.com Wed Jan 2 18:01:02 2002 From: bmcyitz at freebox.com (Yitz) Date: 2 Jan 2002 09:01:02 -0800 Subject: REPOST: Re: Python and Ruby: a comparison References: <3C2B9A61.EE1618DB@earthlink.net> <2WpX7.1145$0s5.714029@news20> <3C2E6876.4CBF45D4@geneva-link.ch> <465v2u4lv3illoviq19nhdf1r2vcknbakn@4ax.com> <7$--$$-$$$$_$-$__$@news.noc.cabal.int> <3C322751.9070404@earthlink.net> Message-ID: "Alex Martelli" wrote in message news:... > Much as I might prefer "C# with templates" or whatever, therefore, I'm > quite liable to choose "Managed C++" today if tasked to develop some > largish subsystem in and for .NET (given that no "Python .NET" is at > hand: Python programming, as it hinges on signature based polymorphism, > just like templates, gives similar productivity advantages to templates > in even smoother and more general ways, of course). See http://www.activestate.com/Initiatives/NET/Research.html for a preliminary "Python .NET" - it already exists. Yitz From aleax at aleax.it Thu Jan 3 15:31:10 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 3 Jan 2002 15:31:10 +0100 Subject: REPOST: Re: Python and Ruby: a comparison References: <3C2B9A61.EE1618DB@earthlink.net> <2WpX7.1145$0s5.714029@news20> <3C2E6876.4CBF45D4@geneva-link.ch> <465v2u4lv3illoviq19nhdf1r2vcknbakn@4ax.com> <7$--$$-$$$$_$-$__$@news.noc.cabal.int> <3C322751.9070404@earthlink.net> Message-ID: "Yitz" wrote in message news:a239f0c0.0201020901.43ee3213 at posting.google.com... > "Alex Martelli" wrote in message news:... > > > Much as I might prefer "C# with templates" or whatever, therefore, I'm > > quite liable to choose "Managed C++" today if tasked to develop some > > largish subsystem in and for .NET (given that no "Python .NET" is at > > hand: Python programming, as it hinges on signature based polymorphism, > > just like templates, gives similar productivity advantages to templates > > in even smoother and more general ways, of course). > > See http://www.activestate.com/Initiatives/NET/Research.html for > a preliminary "Python .NET" - it already exists. It is a finished experimental project, not something anybody would choose "to develop some largish subsystem in and for .NET". Alex From eldiener at earthlink.net Wed Jan 2 23:12:21 2002 From: eldiener at earthlink.net (Edward Diener) Date: Wed, 02 Jan 2002 22:12:21 GMT Subject: REPOST: Re: Python and Ruby: a comparison References: <3C2B9A61.EE1618DB@earthlink.net> <2WpX7.1145$0s5.714029@news20> <3C2E6876.4CBF45D4@geneva-link.ch> <465v2u4lv3illoviq19nhdf1r2vcknbakn@4ax.com> <7$--$$-$$$$_$-$__$@news.noc.cabal.int> <3C322751.9070404@earthlink.net> Message-ID: <3C33856F.3050809@earthlink.net> Alex Martelli wrote: > "Edward Diener" wrote in message > news:3C322751.9070404 at earthlink.net... >>I still feel this leads to language subsets and people who learn a >>computer language and only use, and know, a portion of that language. It >> > > I think your feelings are misleading you on this subject. Language > subsets &c are inevitably caused by languages being "larger" than what > is needed by some substantial group of people, and happen for every > language with reasonably-long history and wide use. > > Some languages just accept that: they AIM to be big and cover a lot > of bases, thus subsetting is taken in stride. C++, Perl, O'CAML, Common > Lisp: nobody has 100% of them in their everyday "active vocabulary", > and very few users indeed reach 100% even in "passive vocabulary" > (portion of the language that is understood if met in code being > read, even though not normally used in code produced by the person). > > But even languages which aim to be small, unless they are highly > restricted, end up subsetted anyway. Few Haskell users routinely > write their own monads: much can be done in Haskell without the > very substantial conceptual jump needed to fully grasp monads and > author your own, thus, enter subsetting. Very few Python users > routinely write their own metaclasses: ditto ditto. It's anything > but rare even for a highly productive and competent Python coder > to have problems grasping metaclasses even in "passive vocabulary" > terms. And, why not? The average Pythonista does not need them, > they're a hard step up on the conceptual ladder, so WHY bemoan their > lack from either active or passive vocabularies of Pythonistas? You make a cogent argument and I generally agree that many programmers do not use a large part of their respective programming languages. > > Subsetting becomes even more prevalent as soon as you accept some > "standard library" features as part of a language. If you never > do (e.g.) CGI web programming, why should you care about that > subset of a language, or its libraries, that exists strictly for > the benefit of CGI authors? Yet the language (cum libraries) is > better for having those modules too, widening its usability and > applicability (and similarly for monads, metaclasses, etc etc). I make the distinction between libraries and language features. There is a totally different mindset to not using libraries than to not using features, even though both "not using" parts may be a logical result of the programmer's project(s) and are certainly valid in many given situations. > > It's certainly mistaken to think that a totally new phenomenon > (the introduction of .NET Framework and its CLR) "leads to" an > old, existing, and inevitable one. Post hoc does not necessarily > mean propter hoc, but the reverse implication IS indeed necessary > (as long as time's arrows don't start flipping around randomly, > causes MUST come before effects). The scenario I have experienced most goes like this: Programmer A, let's say that is me, uses some feature of a language which has been added to the language to make it easier and more elegant to use. The language still supports earlier constructs which may support the same functionality but in a more contorted way which in general impedes good design and ease of coding somewhat ( however one may define good design ). Programmer B has been nurtured on some subset of the same language which does not support the added feature or, if it does so, deprecates it in favor of other, more homogenized goals. Programmer A works with Programmer B and has to design and implement with Programmer B. When Programmer A sees the way Programmer B uses some element of the language and tries to point out a more advanced way of doing something, Programmer B says either 1) That construct is not a part of the language , or 2) I have seen that but Software Corporation X doesn't implement that feature in their subset so I certainly don't have any time or inclination to learn to use it, or 3) Yes, I know all about it but I have always done things this way because very few implementations support this new feature so I haven't bothered to learn it. > > >>has already happened before .NET was even created with VC++, where a >>great many programmers who know only MS's subset of C++ and even some of >>its incorrect syntax, assume they are using C++ effectively and >>correctly and often they are not. >> > > Extremely similar phenomena prevailed even before Mr Gates knew how > to tell a bit from a byte: most scientists I met in the '70s, who > thought they knew and were using Fortran effectively and correctly, > were just as sadly mistaken -- they actually knew and used (and at > times with far from optimal efficiency) some specific dialect of the > Fortran language as supplied by, e.g., Digital Equipment, or IBM, or > some other purveyor yet (or rather, almost invariably, some specific > SUBSET of that specific dialect; few people who learned Fortran on > boxes where you could write, e.g., a literal constant as 'CIAO', ever > knew that the standard way of writing it was 4HCIAO, or could easily > recognize the latter form; just as one example...). I am not blaming MS personally for this but huge and successful companies carry much weight and very often do not have the technical merit of software ideas in mind when they promote their solutions to programming problems. > > > >>Managed C++ in .NET is also an >>abortion of C++ which only a computer programming masochist could love. >> > > The ability to play havoc with pointers and memory management in C++, > while inevitably and inextricably part of that language, is hardly a > plus for a vast majority of the application uses to which C++ is (maybe > inappropriately) put on a daily basis. Doing away with that is the > single highest factor in productivity enhancement when moving, e.g., to > Java. The language which you ( and so many others ) identify as C++, with its ability to "play havoc with pointers and memory management" has been superceded in the past 7 years by a language whose modern constructs make it nearly impossible to have these problems. The fact that many so-called C++ programmers do not want to use these very simple and elegant constructs, in favor of more error-prone techniques still supported by the lnaguage for backward compatibility, is not proof of these problems still existing for practiced programmers in the language. Java's doing away with those problems is a red herring, since these problems no longer exist for professional C++ programmers. Nor am I sold on productivity enhancement when moving to Java simply because you claim it. And I am a Java programmer also. Productivity is not just the spewing forth of the maximum lines of code in the minimum time. But I am sure you know that. > > Yet the loss of templates (generic programming) hurts productivity most > grievously (when imposed upon programmers who have learned to make good > use of templates, of course). I believe that, today still, "Managed > C++" is the only .NET language that lets you use templates (as the > architects of .NET seem to share with those of Java a horrible blind spot > regarding generic programming -- I keep hearing that Java is due to gain > Generic Programming features any day now, but I still can't see them in > Javasoft's released SDKs). I am guessing that the "generic programming" of Java and C# will be created to allow flexibly specified algorithms to operate against any "collection" or parts of a "collection" of objects. > > Much as I might prefer "C# with templates" or whatever, therefore, I'm > quite liable to choose "Managed C++" today if tasked to develop some > largish subsystem in and for .NET (given that no "Python .NET" is at > hand: Python programming, as it hinges on signature based polymorphism, > just like templates, gives similar productivity advantages to templates > in even smoother and more general ways, of course). Save me ! No, I will be using C# ( aka Microsoft's version of Java ) if I do .NET and not some managed abortion. > > >>I anticipate this happening with most .NET versions of languages and >>that many programmers of these languages will only know and use the .NET >>subset and not the full language. >> > > If most programmers will indeed start eschewing "unmanaged" memory access > for application-level programming, this will no doubt reduce bugs and > increase productivity. But giving up on extremely low-level features > (unsuitable for application programming needs) is something that basically > only touches on C++ and similar system-level languages, since application > oriented languages don't offer those anyway (not the sensible ones!-). Being "sensible" in programming is not my inclination. I prefer creativity at its expense. That is why I heavily prefer Python over sensible and pragmatic Perl or safe and limited Javascript ( or VBScript ). > > Apart from "unmanaged memory access" issues, I totally disagree with your > thesis. If a given programmer or programming shop wants the semantics > of C#/VB.NET, they will mostly be using C# or VB.NET depending on syntax > sugar tastes. When somebody goes to the trouble of using the .NET versions > of, say, APL, or Haskell, or Mercury, it definitely will NOT be just in > order to get peculiar syntax sugar on the same semantics: rather, it will > be because SOME supplementary features of those respective languages are > of interest (may be arry operations, typeclasses, backtracking > respectively). > > It will therefore be an EXTREMELY RARE phenomenon for programmers to be > using "strange" (non C#/VB.NET) languages in the .NET versions and "only > know and use the .NET subset", assuming that, by the latter, you mean the > semantics supported "at the interface between separate components" by CLR. I hope you are right, but I anticipate too many full-blooded languages becoming watered down and weak by bathing in the .NET stream. Have I not already seen posts on this NG about Python .NET ? Eddie From aleax at aleax.it Thu Jan 3 11:01:44 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 3 Jan 2002 11:01:44 +0100 Subject: subsetting and .NET (was Re: Python and Ruby: a comparison) References: <3C2B9A61.EE1618DB@earthlink.net> <2WpX7.1145$0s5.714029@news20> <3C2E6876.4CBF45D4@geneva-link.ch> <465v2u4lv3illoviq19nhdf1r2vcknbakn@4ax.com> <7$--$$-$$$$_$-$__$@news.noc.cabal.int> <3C322751.9070404@earthlink.net> <3C33856F.3050809@earthlink.net> Message-ID: "Edward Diener" wrote in message news:3C33856F.3050809 at earthlink.net... ... > > Subsetting becomes even more prevalent as soon as you accept some > > "standard library" features as part of a language. If you never ... > I make the distinction between libraries and language features. There is > a totally different mindset to not using libraries than to not using > features, even though both "not using" parts may be a logical result of But, not using *PART* of a module or package, or not using a subset of some object's methods, is very similar, mindset-wise, to not using part of a language's features. E.g., consider: A) "I don't ever write 'x+=23' -- I grew up with 'x = x + 23' and that's good enough for me" B) "I don't ever write 'd.setdefault(key, def)' -- I grew up with 'if not d.has_key(key): d[key] = def' and that's good enough for me" C) "I don't ever write '[x for x in l if isok(x)]' -- I grew up with 'filter(isok, l)' and that's good enough for me" (and so on, and so forth). Some of these uses and not-uses affect stuff that is documented in Python's Library manual, others don't (affecting only stuff that's documented in the Language manual), but there's really very little "mindset difference" between them. > inclination to learn to use it, or 3) Yes, I know all about it but I > have always done things this way because very few implementations > support this new feature so I haven't bothered to learn it. A very good pragmatical reason to eschew "this new feature", if true and if you do need to worry about several implementations. Among the applications I maintained, it was 1994 before I could feel confident of going for ISO-C function prototypes throughout the codebase (and even then, it was only possible because at that point in time I felt I could, worst case, rely on gcc being available in all cases of need). The Python codebase only took the same step in version 2.0, i.e., in the year 2000, having to worry about a wider porting-targets range. This doesn't really affect the .NET situation, of course. E.g., the "new features" in Haskell for .NET are the .NET-specific parts (equivalent to a traditional "foreign function interface" part). Worrying that "Haskell for .NET" users won't use "Haskell specific" parts (such as lazy evaluation or typeclasses) is IMHO misplaced: it would be a terrible chore to carefully avoid them (just try to avoid lazy evaluation systematically in Haskell...!!!), and people with no liking or need for them would presumably choose a language of wider availability such as, say, C#. All in all, I consider your worries that .NET-compatible versions of such languages will worsen the issue of subsetting for the languages in question to be unfounded. > The language which you ( and so many others ) identify as C++, with its > ability to "play havoc with pointers and memory management" has been > superceded in the past 7 years by a language whose modern constructs > make it nearly impossible to have these problems. The fact that many I *beg* your pardon: I'm a Brainbench MVP for C++, "C++ Guru" is one of the main roles for which my current employer pays my not inconsiderable salary (side by side with similar guruhood for other technologies such as COM, network protocols, and Win32 APIs), and I'm perfectly aware of ISO C++ strengths (and weaknesses -- mostly, subtlety and complication). It's simply untrue that ISO C++'s "modern constructs" ``make it nearly impossible to have [memory management] problems'', because those constructs need to keep working within an overall conceptual framework where memory management is among an application programmer's responsibilities and "object ownership" is the fundamental conceptual tool for it. And it's just not an appropriate tool for most application needs (garbage collection IS). > so-called C++ programmers do not want to use these very simple and > elegant constructs, in favor of more error-prone techniques still > supported by the lnaguage for backward compatibility, is not proof of > these problems still existing for practiced programmers in the language. If somebody's doing "greenfield development" in C++, they're lucky (if, in my well-informed opinion, misguided in their language choice). Most commonly, there are legacy subsystems and legacy interfaces to be kept, and those won't give you the freedom to use currently-optimal approaches (typically template-based ones) everywhere. > Java's doing away with those problems is a red herring, since these > problems no longer exist for professional C++ programmers. I play the guru and language advisor for almost 200 professional C++ programmers at my current employer, and I maintain your assertion is totally false. > Nor am I sold on productivity enhancement when moving to Java simply > because you claim it. And I am a Java programmer also. Productivity is I'm not "a Java programmer". I just conducted pilot projects back when Java was launched, to help my employer make strategic technology choices on the basis of something better than sheer hype (technology trailblazing being among my job responsibilities). I measured things carefully and noticed a productivity increase of between 10% and 20% for such tasks as coding in Java a number of existing proprietary net protocols, compared to coding them in ISO C++ -- this was with substantial C++ experience vs no substantial Java experience yet (but some features of ISO C++ were then new enough that the experience with them was still a bit thin, albeit richer than that with Java). The gain came mostly from automatic memory management, offset, however, by the huge productivity loss due to the lack of templates (generics) -- a short while later I tried a Java dialect called "Pizza", which DID offer generics, but it was deemed an experimental project, not suitable for production use (pity). On the basis of these and other measurements, my employer decided that the costs and risks of technology migration were not warranted; Java was used only for certain well-defined projects where customers demanded it, and otherwise we stuck with C++. I still strongly believe that going to a higher-level language (such as Python) for most of our development would be a huge productivity win, but I concur that languages such as Java or C#, with their maybe-20% gains, are not worth the costs and risks (particularly for migrations; greenfield projects may be different) -- when generics are in, things may get better, but for example .NET generics at this time are *not* scheduled to cover one of the most productive patterns, Coplien's "Pattern Without a Name" (class C: public T {...}); not sure if "Generic Java" does accept Coplien's PWAN. > not just the spewing forth of the maximum lines of code in the minimum > time. But I am sure you know that. "Spewing forth" *working* code (that passes a thorough test suite and thus demonstrably delivers a given functionality F, measured, say, in function points), is indeed the key measure in coding productivity. The ease of future code modification and refactoring is of course also important, but, if the test suites are really good and thorough, the correlation with ease of initially passing the test suites is high. > I am guessing that the "generic programming" of Java and C# will be > created to allow flexibly specified algorithms to operate against any > "collection" or parts of a "collection" of objects. Collections are important, but far from exhaustive in terms of generics' usefulness. E.g., Coplien's PWAN has little to do with collections, yet it's highly pervasive in well-designed generics code. > > Much as I might prefer "C# with templates" or whatever, therefore, I'm > > quite liable to choose "Managed C++" today if tasked to develop some ... > Save me ! No, I will be using C# ( aka Microsoft's version of Java ) if > I do .NET and not some managed abortion. I wonder if you do fully appreciate the power of signature based polymorphism (generics). Many don't. > Being "sensible" in programming is not my inclination. I prefer > creativity at its expense. That is why I heavily prefer Python over > sensible and pragmatic Perl or safe and limited Javascript ( or BScript ). I find Python highly sensible and highly pragmatic, as (allegedly) befits the Dutch national character. But then, I'm not a highly creative person (much like Carver Mead, according to his interview to the Economist last September -- "He says he has never had an original idea in his life", and I feel quite similarly -- cfr http://www.economist.com/displayStory.cfm?Story_ID=779543). > I hope you are right, but I anticipate too many full-blooded languages > becoming watered down and weak by bathing in the .NET stream. Have I not > already seen posts on this NG about Python .NET ? Yes, and? Where's the "watered down and weak" effect? Alex From eldiener at earthlink.net Thu Jan 3 16:45:34 2002 From: eldiener at earthlink.net (Edward Diener) Date: Thu, 03 Jan 2002 15:45:34 GMT Subject: subsetting and .NET (was Re: Python and Ruby: a comparison) References: <3C2B9A61.EE1618DB@earthlink.net> <2WpX7.1145$0s5.714029@news20> <3C2E6876.4CBF45D4@geneva-link.ch> <465v2u4lv3illoviq19nhdf1r2vcknbakn@4ax.com> <7$--$$-$$$$_$-$__$@news.noc.cabal.int> <3C322751.9070404@earthlink.net> <3C33856F.3050809@earthlink.net> Message-ID: <3C347C47.6000802@earthlink.net> Alex Martelli wrote: > "Edward Diener" wrote in message > news:3C33856F.3050809 at earthlink.net... >>The language which you ( and so many others ) identify as C++, with its >>ability to "play havoc with pointers and memory management" has been >>superceded in the past 7 years by a language whose modern constructs >>make it nearly impossible to have these problems. The fact that many >> > > I *beg* your pardon: I'm a Brainbench MVP for C++, "C++ Guru" is one > of the main roles for which my current employer pays my not inconsiderable > salary (side by side with similar guruhood for other technologies such > as COM, network protocols, and Win32 APIs), and I'm perfectly aware of > ISO C++ strengths (and weaknesses -- mostly, subtlety and complication). Good for you ! > > It's simply untrue that ISO C++'s "modern constructs" ``make it nearly > impossible to have [memory management] problems'', because those constructs > need to keep working within an overall conceptual framework where > memory management is among an application programmer's responsibilities > and "object ownership" is the fundamental conceptual tool for it. And > it's just not an appropriate tool for most application needs (garbage > collection IS). The constructs will keep working whatever the conceptual framework is since they are now part of the C++ standard library and can be used interoperably in any context. And of course your last sentence is just your opinion and certainly not mine. GC languages do not seem to consider it important to ever control the order of the destruction of objects but there is a class of types and situations for which this is necessary and the usual solution for implementing this important idiom in GC languages ranges from poor to non-existent, although of course it need not be. A large part of this "GC necessity" debate has really to do with the design of a language and how much control the programmer should have over memory allocation and the construction and destruction of objects, what you rightly call "object ownership". Making a blanket statement that "object ownership" is "just not an appropriate tool for most application needs (garbage collection IS)" doesn't mean anything to me since every application, and indeed every module, can be different based on its design. > > >>so-called C++ programmers do not want to use these very simple and >>elegant constructs, in favor of more error-prone techniques still >>supported by the lnaguage for backward compatibility, is not proof of >>these problems still existing for practiced programmers in the language. >> > > If somebody's doing "greenfield development" in C++, they're lucky (if, > in my well-informed opinion, misguided in their language choice). Most > commonly, there are legacy subsystems and legacy interfaces to be kept, > and those won't give you the freedom to use currently-optimal approaches > (typically template-based ones) everywhere. A noble argument for supporting subsets of languages as pragmatic necessities ! > > >>Java's doing away with those problems is a red herring, since these >>problems no longer exist for professional C++ programmers. >> > > I play the guru and language advisor for almost 200 professional C++ > programmers at my current employer, and I maintain your assertion is > totally false. I personally don't care if you are the advisor to god himself on matters of C++ or if you are Bjarne Stroustrup in disguise. You are talking to someone here who is not the least impressed by all of this "I am an important authority" stuff. And on that note, I will bid this discussion good=bye and seriously wish you the best of luck in your programming endeavors. From sholden at holdenweb.com Thu Jan 3 17:01:36 2002 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 3 Jan 2002 11:01:36 -0500 Subject: subsetting and .NET (was Re: Python and Ruby: a comparison) References: <3C2B9A61.EE1618DB@earthlink.net> <2WpX7.1145$0s5.714029@news20> <3C2E6876.4CBF45D4@geneva-link.ch> <465v2u4lv3illoviq19nhdf1r2vcknbakn@4ax.com> <7$--$$-$$$$_$-$__$@news.noc.cabal.int> <3C322751.9070404@earthlink.net> <3C33856F.3050809@earthlink.net> <3C347C47.6000802@earthlink.net> Message-ID: "Edward Diener" wrote in message news:3C347C47.6000802 at earthlink.net... > Alex Martelli wrote: [ ... ] > > I play the guru and language advisor for almost 200 professional C++ > > programmers at my current employer, and I maintain your assertion is > > totally false. > > > I personally don't care if you are the advisor to god himself on matters > of C++ No, Alex doesn't advise me about C++, but he has been invaluable as a technical editor. And that's "God" to you, by the way. > or if you are Bjarne Stroustrup in disguise. You are talking to > someone here who is not the least impressed by all of this "I am an > important authority" stuff. > I am not at all impressed that you are not impressed. Alex has proved over the years that he knows of which he writes when it comes to programming, coffee, European history and a few other subjects besides. I suspect he was citing his authority to try to help you understand that you were talking rubbish, but channelling the Martellibot is usually unnecessary given the volume of his output. > And on that note, I will bid this discussion good=bye and seriously wish > you the best of luck in your programming endeavors. > Aha, rational argument having failed to win your point you proceed to take your bat home. Fortunately c.l.py has more balls than just yours, so the game will continue without you :-) Thank you for your contribution, and good luck. regards Steve -- http://www.holdenweb.com/ From aleax at aleax.it Thu Jan 3 17:09:43 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 3 Jan 2002 17:09:43 +0100 Subject: subsetting and .NET (was Re: Python and Ruby: a comparison) References: <3C2B9A61.EE1618DB@earthlink.net> <2WpX7.1145$0s5.714029@news20> <3C2E6876.4CBF45D4@geneva-link.ch> <465v2u4lv3illoviq19nhdf1r2vcknbakn@4ax.com> <7$--$$-$$$$_$-$__$@news.noc.cabal.int> <3C322751.9070404@earthlink.net> <3C33856F.3050809@earthlink.net> <3C347C47.6000802@earthlink.net> Message-ID: "Edward Diener" wrote in message news:3C347C47.6000802 at earthlink.net... ... > your opinion and certainly not mine. GC languages do not seem to > consider it important to ever control the order of the destruction of > objects but there is a class of types and situations for which this is > necessary and the usual solution for implementing this important idiom > in GC languages ranges from poor to non-existent, although of course it If you need to ensure that A is never destroyed before B, you just add to B a (strong) reference to A. That's all there is to it (in Python, and other sensible "GC languages"), and I'd like to understand how this is "poor" or "non-existent" -- it covers application needs. It's also very obvious, so, why haven't you even addressed it above? > A large part of this "GC necessity" debate has really to do with the > design of a language and how much control the programmer should have > over memory allocation and the construction and destruction of objects, > what you rightly call "object ownership". Making a blanket statement > that "object ownership" is "just not an appropriate tool for most > application needs (garbage collection IS)" doesn't mean anything to me On the other hand, it means a lot to zillions of application programmers who waste their time debugging such low-level issues rather than adding value to application program products. Having to control object destruction and memory allocation is about as sensible in an application's development as having to develop the silicon production process for the CPU chips the application will run on. And if that "doesn't mean anything to you", let me shorten this: it's a ridiculous waste of energy on inappropriately-low-level concerns. > >>problems no longer exist for professional C++ programmers. > > > > I play the guru and language advisor for almost 200 professional C++ > > programmers at my current employer, and I maintain your assertion is > > totally false. > > I personally don't care if you are the advisor to god himself on matters In other words, you know you made a deliberately false assertion and lack the guts to try to keep lying to defend it. You have offended an uncounted number of professional C++ programmers -- all those for whom memory-management issues DO still exist as problems (sadly, most of them), by denying their professionality, and lack the common decency to apologize as publically as you offended once your accusation is challenged. Great. Just great. Alex From skip at pobox.com Thu Jan 3 17:02:03 2002 From: skip at pobox.com (Skip Montanaro) Date: Thu, 3 Jan 2002 10:02:03 -0600 Subject: subsetting and .NET (was Re: Python and Ruby: a comparison) In-Reply-To: References: <3C2B9A61.EE1618DB@earthlink.net> <2WpX7.1145$0s5.714029@news20> <3C2E6876.4CBF45D4@geneva-link.ch> <465v2u4lv3illoviq19nhdf1r2vcknbakn@4ax.com> <7$--$$-$$$$_$-$__$@news.noc.cabal.int> <3C322751.9070404@earthlink.net> <3C33856F.3050809@earthlink.net> Message-ID: <15412.32891.249222.760733@12-248-41-177.client.attbi.com> Alex> E.g., consider: Alex> A) "I don't ever write 'x+=23' -- I grew up with 'x = x + 23' and that's Alex> good enough for me" Alex> B) "I don't ever write 'd.setdefault(key, def)' -- I grew up with Alex> 'if not d.has_key(key): d[key] = def' and that's good enough for me" Alex> C) "I don't ever write '[x for x in l if isok(x)]' -- I grew up with Alex> 'filter(isok, l)' and that's good enough for me" Alex> (and so on, and so forth). You forgot: D) "I don't ever write 'print >> sys.stderr, "divide by zero!"' -- I grew up with 'sys.stderr.write("divide by zero!\n")' and that's good enough for me". ;-) -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From aleax at aleax.it Thu Jan 3 17:11:27 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 3 Jan 2002 17:11:27 +0100 Subject: subsetting and .NET (was Re: Python and Ruby: a comparison) References: <3C2B9A61.EE1618DB@earthlink.net> <2WpX7.1145$0s5.714029@news20> <3C2E6876.4CBF45D4@geneva-link.ch> <465v2u4lv3illoviq19nhdf1r2vcknbakn@4ax.com> <7$--$$-$$$$_$-$__$@news.noc.cabal.int> <3C322751.9070404@earthlink.net> <3C33856F.3050809@earthlink.net> Message-ID: "Skip Montanaro" wrote in message news:mailman.1010073787.6869.python-list at python.org... > > Alex> E.g., consider: > > Alex> A) "I don't ever write 'x+=23' -- I grew up with 'x = x + 23' and that's > Alex> good enough for me" > > Alex> B) "I don't ever write 'd.setdefault(key, def)' -- I grew up with > Alex> 'if not d.has_key(key): d[key] = def' and that's good enough for me" > > Alex> C) "I don't ever write '[x for x in l if isok(x)]' -- I grew up with > Alex> 'filter(isok, l)' and that's good enough for me" > > Alex> (and so on, and so forth). > > You forgot: > > D) "I don't ever write 'print >> sys.stderr, "divide by zero!"' -- I > grew up with 'sys.stderr.write("divide by zero!\n")' and that's good > enough for me". Yep, you CAN change the latter part of each of these assertions into "because this specific newfangled addition is an abomination in the eye of all right-thinking people":-). Personally, I'd only do it for [D], of course. Alex From zapr at icon.co.za Tue Jan 1 10:59:57 2002 From: zapr at icon.co.za (Robert Laing) Date: Tue, 01 Jan 2002 11:59:57 +0200 Subject: Glade tut Message-ID: I've put the start of a tut on using Glade on the web at http://www.icon.co.za/~zapr I wrote it out of frustration at not finding anything similar already available. The tut goes as far as creating a text reader with a few lines of code. A problem I've got is that I simply can't figure out how to get fundamental things like buttons on "child" dialog windows to work. If anyone knows how, please let me know so that the tut can gradually grow into a cookbock with recipes on how to use most of the widgets available in Glade Regards Robert From mickey at tm.informatik.uni-frankfurt.de Tue Jan 8 14:05:01 2002 From: mickey at tm.informatik.uni-frankfurt.de (Michael 'Mickey' Lauer) Date: 8 Jan 2002 15:05:01 +0200 Subject: Glade tut References: Message-ID: <3c3afc8d@nntp.server.uni-frankfurt.de> Robert Laing wrote: > I've put the start of a tut on using Glade on the web at > http://www.icon.co.za/~zapr Nice. You have some broken image links though (widget_tree.png, gless.png are pointing to your /home/projects/Project1/... instead of /) Cheers, :M: From newsweek21 at orgio.net Tue Jan 1 12:17:42 2002 From: newsweek21 at orgio.net (Áß¾ÓÅ׸¶À̺¥Æ®) Date: Tue, 1 Jan 2002 20:17:42 +0900 Subject: **ÃàÇÏÇÕ´Ï´Ù** Æú¶ó·ÎÀ̵å Ä«¸Þ¶ó³ª ·Î¸¸¼Õ °í±Þ Ä¿Çüոñ½Ã°è¸¦ »çÀºÇ°À¸·Î µå¸³´Ï´Ù.[È« º¸] Message-ID: An HTML attachment was scrubbed... URL: From aleax at aleax.it Tue Jan 1 12:25:02 2002 From: aleax at aleax.it (Alex Martelli) Date: Tue, 01 Jan 2002 11:25:02 GMT Subject: tkicon (was Re: Icons and Tkinter!....From PRJoshi) References: <1$--$$_----__-$_%$@news.noc.cabal.int> Message-ID: Laura Creighton wrote: > 1. Put this bookmark in your web browser. > http://groups.google.com/advanced_group_search?as_ugroup=comp.lang.python > > 2. Go there. Search for something useful. I tried 'change tk icon' > in the 'all of the words' box. > > You will get many hits. The first one I think will interest you. Excellent advice! Unfortunately, the tkIcon downloadable doesn't seem to exist on the SecretLabs site any more. Googling for "tkicon python" also fails to reveal any obvious downloadables. Anybody knows where tkicon sources suitable for current releases of Python and Tk might hide...? Alex From fredrik at pythonware.com Tue Jan 1 14:20:11 2002 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 01 Jan 2002 13:20:11 GMT Subject: tkicon (was Re: Icons and Tkinter!....From PRJoshi) References: <1$--$$_----__-$_%$@news.noc.cabal.int> Message-ID: Alex Martelli wrote: > Anybody knows where tkicon sources suitable for current > releases of Python and Tk might hide...? http://effbot.org/downloads/ From maxm at mxm.dk Tue Jan 1 12:34:16 2002 From: maxm at mxm.dk (maxm) Date: Tue, 1 Jan 2002 12:34:16 +0100 Subject: Optimization help needed: Search and Replace using dictionary of parameters References: <3C309E64.6A7E37DD@vip.fi> Message-ID: <59hY7.9751$Zm5.898082@news000.worldonline.dk> "Pekka Niiranen" wrote in message news:3C309E64.6A7E37DD at vip.fi... > How can I do this most efficiently: > > I have filenames and parameters in a sparse matrix that is a > dictionary: > I dont remember who posted this snippet on c.l.py a long time ago, but it works like a charm, so I havn't bothered changing it. Actually it ought to be a standard method on the string object, or at least avaliable in the standard distribution somehow as it get's asked regularly on the group. But here it is again. Using this it should be easy to just itereate over the files you want changed and then use the class on it. regards Max M ################################################### import re, string class MultiReplace: def __init__(self, repl_dict): # "compile" replacement dictionary # assume char to char mapping charmap = map(chr, range(256)) for k, v in repl_dict.items(): if len(k) != 1 or len(v) != 1: self.charmap = None break charmap[ord(k)] = v else: self.charmap = string.join(charmap, "") return # string to string mapping; use a regular expression keys = repl_dict.keys() keys.sort() # lexical order pattern = string.join(map(re.escape, keys), "|") self.pattern = re.compile(pattern) self.dict = repl_dict def replace(self, str): # apply replacement dictionary to string if self.charmap: return string.translate(str, self.charmap) def repl(match, get=self.dict.get): item = match.group(0) return get(item, item) return self.pattern.sub(repl, str) if __name__ == '__main__': r = MultiReplace({"spam": "eggs", "spam": "eggs"}) print r.replace("spam&eggs") ## eggs&spam r = MultiReplace({"a": "b", "b": "a"}) print r.replace("keaba") ## kebab From jlh at home.com Tue Jan 1 21:10:52 2002 From: jlh at home.com (Jeff Hinrichs) Date: Tue, 1 Jan 2002 14:10:52 -0600 Subject: Optimization help needed: Search and Replace using dictionary of parameters References: <3C309E64.6A7E37DD@vip.fi> <59hY7.9751$Zm5.898082@news000.worldonline.dk> Message-ID: <078101c19300$69b383e0$6702a8c0@gato> > I dont remember who posted this snippet on c.l.py a long time ago, but it > works like a charm, so I havn't bothered changing it. ... > if __name__ == '__main__': > > r = MultiReplace({"spam": "eggs", "spam": "eggs"}) > print r.replace("spam&eggs") > ## eggs&spam This actually outputs eggs&eggs, to get the desired output of spam&eggs the dictionary needs to be modified to:{"spam": "eggs", "eggs": "spam"} From maxm at mxm.dk Wed Jan 2 13:49:52 2002 From: maxm at mxm.dk (maxm) Date: Wed, 2 Jan 2002 13:49:52 +0100 Subject: Optimization help needed: Search and Replace using dictionary of parameters References: <3C309E64.6A7E37DD@vip.fi> <59hY7.9751$Zm5.898082@news000.worldonline.dk> Message-ID: "maxm" wrote ... Well to do a followup to my own post ;-) I sort of needed the search and replace functionality myself and so wrote a small script. here goes... ########################################################### # recursivley replaces ALL ocurrences of a string in files # and optionally in the filenames too. import re, string class MultiReplace: def __init__(self, repl_dict): # "compile" replacement dictionary # assume char to char mapping charmap = map(chr, range(256)) for k, v in repl_dict.items(): if len(k) != 1 or len(v) != 1: self.charmap = None break charmap[ord(k)] = v else: self.charmap = string.join(charmap, "") return # string to string mapping; use a regular expression keys = repl_dict.keys() keys.sort() # lexical order pattern = string.join(map(re.escape, keys), "|") self.pattern = re.compile(pattern) self.dict = repl_dict def replace(self, str): # apply replacement dictionary to string if self.charmap: return string.translate(str, self.charmap) def repl(match, get=self.dict.get): item = match.group(0) return get(item, item) return self.pattern.sub(repl, str) from os.path import walk, isdir, join, split from os import rename def getAllFiles(startDir): def visit(result, dirname, names): for file in names: result.append(join(dirname, file)) result = [] walk(startDir, visit, result) return result def replace(startDir, mrDict, changeFileNames=0): # replaces ALL ocurrences of a string in both files and filenames mr = MultiReplace(mrDict) # search and replace in file content files = getAllFiles(startDir) for file in files: # Replace in files if not isdir(file): f = open(file, 'r+w') content = f.read() newContent = mr.replace(content) f.seek(0) f.write(newContent) f.truncate() f.close() # if changeFileNames == 1: # Rename filenames head, tail = split(file) newTail = mr.replace(tail) rename(file, join(head, newTail)) if __name__ == '__main__': startDir = 'C:/zope/zope243/lib/python/Products/ots_User/' replace(startDir, {'ots_emne_003':'ots_User'}, changeFileNames=1) From ahimsa at inext.co.za Tue Jan 1 13:28:21 2002 From: ahimsa at inext.co.za (Ahimsa Consulting) Date: Tue, 1 Jan 2002 14:28:21 +0200 Subject: Help on a summative formula References: Message-ID: <000901c192bf$ee29a500$0100000a@aeon2k> Hi all Need newbie level assistance on putting together a formula. I am trying to work out the phrasing for reading user input and adding each input to the previous input until the total is >= 150. I thought for a while the Fibonacci series might help since that passes the value of one element and adds it to a previous value, so it worked fine for the first two inputs but then went off at a tangent. Any thoughts please. Thanks Andrew From debl2nonospammywhamm at bellatlantic.net Tue Jan 1 18:28:37 2002 From: debl2nonospammywhamm at bellatlantic.net (David Lees) Date: Tue, 01 Jan 2002 17:28:37 GMT Subject: Help on a summative formula References: Message-ID: <3C31F1C1.F7A09A92@bellatlantic.net> Your language is ambiguous, but it sounds like you are simply trying to sum all inputs until the total reaches 150. You post no sample code, so assume your input is in a list, X. def total(X): sum = 0 for i in range(len(X)): sum += X[i] if sum >= 150: return sum If what you intended to ask for was "how do I scan through input until I have 2 successive inputs that total >= 150" then it is: def prev2(X): for i in range(1,len(X)): if X[i-1]+X[i] >= 150: return X[i-1]+X[i] Note this is sloppy code because there is no error condition checking. David Lees Ahimsa Consulting wrote: > > Hi all > Need newbie level assistance on putting together a formula. I am trying to > work out the phrasing for reading user input and adding each input to the > previous input until the total is >= 150. I thought for a while the > Fibonacci series might help since that passes the value of one element and > adds it to a previous value, so it worked fine for the first two inputs but > then went off at a tangent. > Any thoughts please. > Thanks > Andrew From emile at fenx.com Tue Jan 1 18:55:58 2002 From: emile at fenx.com (Emile van Sebille) Date: Tue, 1 Jan 2002 09:55:58 -0800 Subject: Help on a summative formula References: Message-ID: "Ahimsa Consulting" wrote in message news:mailman.1009888201.18587.python-list at python.org... > Hi all > Need newbie level assistance on putting together a formula. I am trying to > work out the phrasing for reading user input and adding each input to the > previous input until the total is >= 150. I thought for a while the > Fibonacci series might help since that passes the value of one element and > adds it to a previous value, so it worked fine for the first two inputs but > then went off at a tangent. > Any thoughts please. > Thanks > Andrew > > total = 0 while total < 150: total += raw_input("Enter a number: ") HTH, -- Emile van Sebille emile at fenx.com --------- From emile at fenx.com Tue Jan 1 19:00:04 2002 From: emile at fenx.com (Emile van Sebille) Date: Tue, 1 Jan 2002 10:00:04 -0800 Subject: Help on a summative formula References: Message-ID: "Emile van Sebille" wrote in message news:a0stl1$mvbot$1 at ID-11957.news.dfncis.de... > > "Ahimsa Consulting" wrote in message > news:mailman.1009888201.18587.python-list at python.org... > > Hi all > > Need newbie level assistance on putting together a formula. I am trying to > > work out the phrasing for reading user input and adding each input to the > > previous input until the total is >= 150. I thought for a while the > > Fibonacci series might help since that passes the value of one element and > > adds it to a previous value, so it worked fine for the first two inputs > but > > then went off at a tangent. > > Any thoughts please. > > Thanks > > Andrew > > > > > > total = 0 > while total < 150: > total += raw_input("Enter a number: ") > Ooops, forgot to paste in the tested version: >>> while total < 150: ... total += int(raw_input("Enter a number: ")) From ahimsa at inext.co.za Tue Jan 1 21:47:13 2002 From: ahimsa at inext.co.za (Ahimsa) Date: Tue, 1 Jan 2002 22:47:13 +0200 Subject: Help on a summative formula References: Message-ID: <002501c19305$a28306a0$0100000a@aeon2k> Thanks for the input folks. I found a way to make it work. With a bit of tweaking I may be able to get it to cut off an input that would exceed 100. But what the heck: this is my very first code that does something more than say 'Hello, World!'. Thanks for indulging me in this birth ;-)> For comments (constructive please) this is it. Thanks Andrew ______________________ # Running total of user inputs until the sum exceeds or is equal to 100. a = 1 s = 0 print 'Enter a number to add till you reach 100.' print 'If you wanna quit, just enter 0.' while a != 0: print 'Current sum is ',s a = input('Number? ') s = s + a if s >= 100: print 'Thank you.' print 'Total Sum was ',s print 'Bye.' break else: print 'And again ...?' print 'Have a nice day now!' __________________________ From debl2nonospammywhamm at bellatlantic.net Wed Jan 2 00:40:08 2002 From: debl2nonospammywhamm at bellatlantic.net (David Lees) Date: Tue, 01 Jan 2002 23:40:08 GMT Subject: Help on a summative formula References: Message-ID: <3C3248DA.FD46673@bellatlantic.net> Your language is ambiguous, but it sounds like you are simply trying to sum all inputs until the total reaches 150. You post no sample code, so assume your input is in a list, X. def total(X): sum = 0 for i in range(len(X)): sum += X[i] if sum >= 150: return sum If what you intended to ask for was "how do I scan through input until I have 2 successive inputs that total >= 150" then it is: def prev2(X): for i in range(1,len(X)): if X[i-1]+X[i] >= 150: return X[i-1]+X[i] Note this is sloppy code because there is no error condition checking. David Lees Ahimsa Consulting wrote: > > Hi all > Need newbie level assistance on putting together a formula. I am trying to > work out the phrasing for reading user input and adding each input to the > previous input until the total is >= 150. I thought for a while the > Fibonacci series might help since that passes the value of one element and > adds it to a previous value, so it worked fine for the first two inputs but > then went off at a tangent. > Any thoughts please. > Thanks > Andrew From fperez528 at yahoo.com Tue Jan 1 13:34:21 2002 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Wed, 02 Jan 2002 12:02:21 +2328 Subject: swig/sip/boost.python/cxx advice? Message-ID: Hi all, I've done lightweight/easy things with C/python using swig, but in the near future I may need to write some more complex extensions, possibly in C++. So I'd like to hear from anyone with experience with the various tools out there on their pros, cons, comparisons, etc. To my knowledge, we have Swig, Sip, Cxx and Boost.python. If there are others, feel free to include them in the discussion. I'm aware of some of their differences and I've read their various documentations in more or less detail, but I have so little experience with them that I don't feel qualified to make an intelligent decision. I'm deliberately not giving my specific needs because I'd like to hear general comments on all aspects of these tools, including those not relevant to the project I have in mind right now (both because I may need them later for different things and for the benefit of others). Thanks to all, Fernando. From rasmussn at lanl.gov Thu Jan 3 16:23:11 2002 From: rasmussn at lanl.gov (rasmussn at lanl.gov) Date: Thu, 3 Jan 2002 08:23:11 -0700 Subject: swig/sip/boost.python/cxx advice? In-Reply-To: Message-ID: On Wednesday, January 2, 2002, at 12:02 PM, Fernando P?rez wrote: > > To my knowledge, we have Swig, Sip, Cxx and Boost.python. If there are > others, feel free to include them in the discussion. > Check out http://www.acl.lanl.gov/siloon/ Siloon uses the EDG compiler front end so it is able to support many complex C++ features. Look for a new release in February. Craig From Henning at 3s-hanusa.de Tue Jan 1 16:58:48 2002 From: Henning at 3s-hanusa.de (Henning Hanusa) Date: Tue, 1 Jan 2002 16:58:48 +0100 Subject: TEST Message-ID: just a test - please ignore Henning From zooko at zooko.com Tue Jan 1 18:08:21 2002 From: zooko at zooko.com (Zooko) Date: Tue, 01 Jan 2002 09:08:21 -0800 Subject: quick n' dirty measurement of compression and byte-compilation Message-ID: [Please Cc: zooko at zooko.com in replies. Thank you!] Dear Pythonismos and Pythonoreans: I noticed that the PyXML build script byte-compiles its .py files. It seems like this potentially introduces incompatibility if the version of Python used to build differs from the version used to run the resulting package. Python seems to have broken forward- and backward-compatibility for bytecode in almost every release from 1.5 to 2.2. I wondered about the savings in space and in load time that we get by byte- compiling files before packaging them, so I collected all of the .py files in my Mojo Nation[1] directory and byte-compiled and compressed them in various ways. There were 3.5 MB worth of .py files. This includes complete copies of PyXML v0.6.6 and pybsddb v3.3.0 and some source code borrowed from Zope as well as the Mojo Nation source code. It took 14 seconds to byte-compile all of them, in either -OO mode (optimized, no docstrings) or in normal mode (non-optimized, including docstrings), on my Pentium III 450 MHz laptop. Therefore I estimate that it takes approximately 4 milliseconds per KB of source code to do byte-compilation on such a PC. Here are the sizes of the resulting files: Key: py. == not byte-compiled pyc. == byte-compiled in normal mode pyo. == byte-compiled in -OO mode .tar == uncompressed .tar.gz3 == compressed with `gzip -3' (normal gzip compression) .tar.gz9 == compressed with `gzip -9' .tar.bz2 == compressed with `bzip2 -9' files sorted by type: 3512320 Jan 1 07:46 py.tar 4003840 Jan 1 07:46 pyc.tar 3317760 Jan 1 07:46 pyo.tar 739409 Jan 1 07:43 py.tar.gz3 1122935 Jan 1 07:43 pyc.tar.gz3 808596 Jan 1 07:43 pyo.tar.gz3 732414 Jan 1 07:43 py.tar.gz9 1115887 Jan 1 07:43 pyc.tar.gz9 799386 Jan 1 07:43 pyo.tar.gz9 601511 Jan 1 07:44 py.tar.bz2 846736 Jan 1 07:44 pyc.tar.bz2 608945 Jan 1 07:44 pyo.tar.bz2 files sorted by size: 601511 Jan 1 07:44 py.tar.bz2 608945 Jan 1 07:44 pyo.tar.bz2 732414 Jan 1 07:43 py.tar.gz 739409 Jan 1 07:43 py.tgz 799386 Jan 1 07:43 pyo.tar.gz 808596 Jan 1 07:43 pyo.tgz 846736 Jan 1 07:44 pyc.tar.bz2 1115887 Jan 1 07:43 pyc.tar.gz 1122935 Jan 1 07:43 pyc.tgz 3317760 Jan 1 07:46 pyo.tar 3512320 Jan 1 07:46 py.tar 4003840 Jan 1 07:46 pyc.tar The surprising fact is that for these source files the original .py's compress better than the .pyo's! My suggestions are: 1. For compatibility and small packages, distribute plain .py's, not byte- compiled files. 2. If you want even smaller packages, use bzip2. 3. If you want faster start-up time, make sure that the byte-compiled files get persistently cached on the end-user's computer (that is, by making the directory that contains the .py's writable by the user, or by byte-compiling upon installation). 4. If #3 is difficult, check whether the actual difference in start-up times is sufficiently important to you. It appears to be negligible for many purposes. Regards, Zooko http://zooko.com/ Security and Distributed Systems Engineering [1] http://mojonation.net/ From mwh at python.net Tue Jan 1 20:29:34 2002 From: mwh at python.net (Michael Hudson) Date: Tue, 1 Jan 2002 19:29:34 GMT Subject: quick n' dirty measurement of compression and byte-compilation References: Message-ID: Zooko writes: > [Please Cc: zooko at zooko.com in replies. Thank you!] Oh, do I have to? > Dear Pythonismos and Pythonoreans: > > I noticed that the PyXML build script byte-compiles its .py files. > It seems like this potentially introduces incompatibility if the > version of Python used to build differs from the version used to run > the resulting package. Depends where you install the files. By default don't they end up in $(prefix)/lib/python$(VERSION)/site-packages ^^^^^^^ ? Anyway, if you try to import the files into the "wrong" version of Python, they'll be recompiled (if you can write to that directory). > Python seems to have broken forward- and backward-compatibility for > bytecode in almost every release from 1.5 to 2.2. Yep. Not sure about 1.6->2.0. Except saying "broken" implies there was ever a hint of compatibility... Cheers, M. From tjreedy at home.com Tue Jan 1 21:32:31 2002 From: tjreedy at home.com (Terry Reedy) Date: Tue, 01 Jan 2002 20:32:31 GMT Subject: quick n' dirty measurement of compression and byte-compilation References: Message-ID: "Michael Hudson" wrote in message news:lkofkddg4i.fsf at elios.maths.bris.ac.uk... > Zooko writes: > > Python seems to have broken forward- and backward-compatibility for > > bytecode in almost every release from 1.5 to 2.2. > > Yep. Not sure about 1.6->2.0. Except saying "broken" implies there > was ever a hint of compatibility... To amplify: bytecodes are explicitly not part of the language definition but are a version-and interpreter-specific caching optimization. CPython bytecodes are not Python, and are pretty useless for someone with the Jython interpreter. Terry J. Reedy From zooko at zooko.com Tue Jan 1 22:23:23 2002 From: zooko at zooko.com (Zooko) Date: Tue, 01 Jan 2002 13:23:23 -0800 Subject: quick n' dirty measurement of compression and byte-compilation In-Reply-To: Message from Michael Hudson of "01 Jan 2002 19:29:33 GMT." References: Message-ID: [Please Cc: zooko at zooko.com in replies. Thank you!] Michael Hudson wrote: > > Zooko writes: > > > I noticed that the PyXML build script byte-compiles its .py files. > > It seems like this potentially introduces incompatibility if the > > version of Python used to build differs from the version used to run > > the resulting package. > > Depends where you install the files. By default don't they end up in > > $(prefix)/lib/python$(VERSION)/site-packages Mojo Nation currently gets distributed [1] either as a self-installing Windows package or as an "untar me and run in place" Unix tarball. Even if we *did* install into `$(prefix)/lib/python$(VERSION)/site-packages', that wouldn't solve the problem of delivering only byte-compiled .pyo's for a version of Python that the user doesn't have. I didn't include a measurement of including both .py's and .pyo's in my earlier post. Here it is, appended. The difference in package size can be substantial. For Mojo Nation, if we were to transmit both .pyo's and .py's, using standard `gzip' compression, the resulting package would be 1,548,451 bytes. If we were to transmit only .py's, using `bzip2 -9', the resulting package would be 601,511 bytes. I'd like to repeat my suggestion to developers: transmit straight .py files and do byte-compilation on the end-user's computer, either in the installation script or simply at runtime. (Also: use bzip2.) Regards, Zooko http://zooko.com/ Security and Distributed Systems Engineering [1] http://mojonation.net/download Key: py. == not byte-compiled pyc. == byte-compiled in normal mode pyo. == byte-compiled in -OO mode pyb. == both .py's *and* .pyo's .tar == uncompressed .tar.gz3 == compressed with `gzip -3' (normal gzip compression) .tar.gz9 == compressed with `gzip -9' .tar.bz2 == compressed with `bzip2 -9' files sorted by type: 3512320 Jan 1 07:46 py.tar 4003840 Jan 1 07:46 pyc.tar 3317760 Jan 1 07:46 pyo.tar 6819840 Jan 1 13:05 pyb.tar 739409 Jan 1 07:43 py.tar.gz3 1122935 Jan 1 07:43 pyc.tar.gz3 808596 Jan 1 07:43 pyo.tar.gz3 1548451 Jan 1 13:04 pyb.tar.gz3 732414 Jan 1 07:43 py.tar.gz9 1115887 Jan 1 07:43 pyc.tar.gz9 799386 Jan 1 07:43 pyo.tar.gz9 1531782 Jan 1 13:04 pyb.tar.gz9 601511 Jan 1 07:44 py.tar.bz2 846736 Jan 1 07:44 pyc.tar.bz2 608945 Jan 1 07:44 pyo.tar.bz2 1214033 Jan 1 13:05 pyb.tar.bz2 files sorted by size: 601511 Jan 1 07:44 py.tar.bz2 608945 Jan 1 07:44 pyo.tar.bz2 732414 Jan 1 07:43 py.tar.gz 739409 Jan 1 07:43 py.tgz 799386 Jan 1 07:43 pyo.tar.gz 808596 Jan 1 07:43 pyo.tgz 846736 Jan 1 07:44 pyc.tar.bz2 1115887 Jan 1 07:43 pyc.tar.gz 1122935 Jan 1 07:43 pyc.tgz 1214033 Jan 1 13:05 pyb.tar.bz2 1531782 Jan 1 13:04 pyb.tar.gz9 1548451 Jan 1 13:04 pyb.tar.gz3 3317760 Jan 1 07:46 pyo.tar 3512320 Jan 1 07:46 py.tar 4003840 Jan 1 07:46 pyc.tar 6819840 Jan 1 13:05 pyb.tar From richardjones at optushome.com.au Tue Jan 1 23:16:37 2002 From: richardjones at optushome.com.au (Richard Jones) Date: Wed, 2 Jan 2002 09:16:37 +1100 Subject: quick n' dirty measurement of compression and byte-compilation In-Reply-To: References: Message-ID: <200201012216.g01MGc222196@mail008.syd.optusnet.com.au> On Wed, 2 Jan 2002 08:23, Zooko wrote: > ... delivering only byte-compiled .pyo's ... Don't forget that distributing .pyo only means that python _must_ be run in -OO mode for every application that wants to use the modules. This is, in some cases (eg. Zope) a pain. > I'd like to repeat my suggestion to developers: transmit straight .py files > and do byte-compilation on the end-user's computer, either in the > installation script or simply at runtime. Absolutely - this is what distutils does! Use distutils! > (Also: use bzip2.) Does winzip understand bzip2? It's the defacto standard unzipper on windows, isn't it? Does Mac OS X come with bzip2? Richard From skip at pobox.com Wed Jan 2 01:02:32 2002 From: skip at pobox.com (Skip Montanaro) Date: Tue, 1 Jan 2002 18:02:32 -0600 Subject: quick n' dirty measurement of compression and byte-compilation In-Reply-To: References: Message-ID: <15410.19992.947909.576142@12-248-41-177.client.attbi.com> zooko> I'd like to repeat my suggestion to developers: transmit straight zooko> .py files and do byte-compilation on the end-user's computer, zooko> either in the installation script or simply at runtime. (Also: zooko> use bzip2.) As others have reported you shouldn't distribute .py[co] files. They have never been part of the defined public interface. Even if distributing .py[co] files made your distribution substantially smaller than distributing .py files you'd still be asking for trouble. Network bandwidth is clearly a secondary issue in this case. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From mwh at python.net Wed Jan 2 10:40:57 2002 From: mwh at python.net (Michael Hudson) Date: Wed, 2 Jan 2002 09:40:57 GMT Subject: quick n' dirty measurement of compression and byte-compilation References: Message-ID: Zooko writes: > [Please Cc: zooko at zooko.com in replies. Thank you!] > > Michael Hudson wrote: > > > > Zooko writes: > > > > > I noticed that the PyXML build script byte-compiles its .py files. > > > It seems like this potentially introduces incompatibility if the > > > version of Python used to build differs from the version used to run > > > the resulting package. > > > > Depends where you install the files. By default don't they end up in > > > > $(prefix)/lib/python$(VERSION)/site-packages > > Mojo Nation currently gets distributed [1] either as a > self-installing Windows package or as an "untar me and run in place" > Unix tarball. Yeah, I see that it's different for "applications" as opposed to "libraries". OTOH, I thought "best practice" for apps was to bundle up a copy of Python too, using py2exe or installer. Obviously this depends on distribution method and the size of your application... > Even if we *did* install into > `$(prefix)/lib/python$(VERSION)/site-packages', that wouldn't solve > the problem of delivering only byte-compiled .pyo's for a version of > Python that the user doesn't have. Perhaps I should have read more than the first paragraph of your post... [...] > I'd like to repeat my suggestion to developers: transmit straight > .py files and > do byte-compilation on the end-user's computer, > either in the installation > script or simply at runtime. (Also: > use bzip2.) .. 'cause then I'd have read this, which I agree with. Cheers, M. From mlh at vier.idi.ntnu.no Tue Jan 1 18:22:22 2002 From: mlh at vier.idi.ntnu.no (Magnus Lie Hetland) Date: Tue, 1 Jan 2002 17:22:22 +0000 (UTC) Subject: ANN: Anygui 0.1b1 released Message-ID: Greetings! Anygui 0.1b1 has been released, and may be dowloaded from the Anygui project page (http://sourceforge.net/projects/anygui). Anygui is a generic GUI package which allows you to write programs that will work with several backends, such as Tkinter, wxPython, PythonWin and Java Swing. The name is inspired by the standard library package anydbm, because the behaviour is similar: You write your program using the Anygui API, and Anygui figures out which back-end to use. One of the additions in this new release is the support for curses and plain text, giving you full GUI functionality using only the print statement! For more information, please visit the Anygui web site at http://www.anygui.org Magnus Lie Hetland, Anygui admin -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.org From jdhunter at nitace.bsd.uchicago.edu Tue Jan 1 19:14:55 2002 From: jdhunter at nitace.bsd.uchicago.edu (John Hunter) Date: Tue, 01 Jan 2002 12:14:55 -0600 Subject: More flexible parameter passing in C++ References: <8ef9bea6.0112311125.559ff28d@posting.google.com> Message-ID: >>>>> "Hung" == Hung Jung Lu writes: Hung> Is there some object-oriented way of making parameter Hung> passing more flexible in C++? I mean, the goal is avoid Hung> modifying the header declaration of methods... especially in Hung> situations where you have subclasses and sub-subclasses. What if you passed a struct such as Params, which has all the params as fields? Then you could pass each method the Params object. If you need to add a new parameter, for a certain method, you would only need to change the Param struct. All of the calling semantics would be unchanged. Or you could create the new param class by subclassing it. struct ParamsBase { string name; size_t N; float dt; }; struct MyParams : ParamsBase { Foo foo; }; //will accept either a ParamsBase* or a MyParams* void some_method( ParamsBase* pars); From laurent.pointal at laposte.net Tue Jan 1 19:14:59 2002 From: laurent.pointal at laposte.net (Laurent Pointal) Date: 01 Jan 2002 18:14:59 GMT Subject: More flexible parameter passing in C++ References: <8ef9bea6.0112311125.559ff28d@posting.google.com> Message-ID: [posted and mailed] hungjunglu at yahoo.com (Hung Jung Lu) wrote in news:8ef9bea6.0112311125.559ff28d at posting.google.com: > Hi, > > This is a question on C++. I guess I am too spoiled with Python > features. Now it's hard for me to do things in C++. :) > > Consider the case of hook methods. You have parent classes that > declare hooks. Well, a parent class may not do much with a hook, but > the child class may do something with it. That's what hooks are for. > > Now, the parent class does not know nor does it care what's on the > parameter list. Python can handle all this well: the parameter list > can be quite dynamic in Python. There are many ways to handle dynamic > parameter lists. > > But I am having hard time with C++, now. > > One way out is to use hashmaps (equivalent to Python dictionaries), > but this is bad for performance. > > Is there some object-oriented way of making parameter passing more > flexible in C++? I mean, the goal is avoid modifying the header > declaration of methods... especially in situations where you have > subclasses and sub-subclasses. You may have posted to comp.lang.c++ (or comp.lang.c++.moderated)... I set followup-to to this newsgroup. But as I'm replying... First solution: =============== You can do it a la printf, see variable number of arguments in your C++ documentation (the ellipsis at the end of functions prototype) and look for va_list, va_start, va_arg, va_end. But: -Its far from type safe. -Its far from object oriented. -I dont think we can call it a pattern. Second solution: ================ In C++, you can have multiple methods with same name but with different argument types (ex. multiple constructors with different parameters). So you can have a base foo method, with the arguments known by your base class, and a foo method in your subclass, with your own arguments - you can call base class foo by giving right arguments. Its type safe, its true C++. But: -Its not a variable number of arguments. -The compiler must know what method to call, so you may have to coerce arguments from time to time to correspond to the method stamp you want to call. -The programmer can call your parent foo method simply by giving the right arguments, and there may be risks he does this without knowing that he dont call your foo method. -There is no direct relation from your sublass' foo and the parent class' foo. Conclusion: Mapping Python code to C++ code is not immediate :-) > Hung Jung A+ Laurent. From mwh at python.net Tue Jan 1 20:13:15 2002 From: mwh at python.net (Michael Hudson) Date: Tue, 1 Jan 2002 19:13:15 GMT Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: Christian Tismer writes: > Well, it is a little late to answer this, but... Hey, I don't care, I'm just glad to see you're still paying attention :) > Michael Hudson wrote: [...] > >> * Just to implement map, 150 lines of builtin_map had to be > >> rewritten into 350 lines (builtin_map, make_stub_code, > >> make_map_frame, builtin_map_nr, builtin_map_loop). The author > >> indicates that the same procedure still needs to be done for > >> apply and filter. Just what is the "same procedure"? Isn't there > >> some better way? > >> > > > > This is where implementing stackless in C really, really hurts. > > > [great explanation of stackless techniques skipped.] > > I agree this is not easy to undrstand and to implement. > I always was thinking of a framework which makes this > easier, but I didn'tcome up with something suitable. I've had similar thoughts, but likewise fell short. I think you could probably do things with m4 that took something readable and spat out stack-neutral C, but it would be a Major Project. > >>- The code adds PREPARE macros into each branch of ceval. Why? > >>- It adds a long list of explicitly not-supported opcodes into > >> the ceval switch, instead of using 'default:'. No explanation > >> for that change is given, other than 'unused opcodes go here'. > >> Is it necessary to separately maintain them? Why? > >> > > > > This was an optimization Chris used to try and get back some of the > > performance lost during the stackless changes. IIRC, he handles > > exceptions and return values as "pseudo-opcodes" rather than using the > > WHY_foo constants the current ceval.c uses. I never really understood > > this part. > > > This is really just an optimization. > The PREPARE macros were used to limit code increase, and to > gove me some more options to play with. > Finally, the PREPARE macros do an optimized opcode prefetch > which turns out to be a drastical speedup for the interpreter loop. > Standard Python does an increment for every byte code and then > one for the optional argument, and the argument is picked bytewise. > What I do is a single add to the program counter, dependent of the > opcode/argument size which is computed in the PREPARE macro. > Then, on intel machines, I use a short word access to the argument > which gives a considerable savings. (Although this wouldn't be > necessary if the compilers weren't that dumb). This could/should be split off from stackless, right? > >>It may be that some of these questions can be answered giving a good > >>reason for the change, but I doubt that this code can be incorporated > >>as-is, just saying "you need all of this for Stackless Python". I > >>don't believe you do, but I cannot work it out myself, either. > >> > > > > I think integrating stackless into the core is a fairly huge amount of > > work. I'd like to think I could do it, given several months of > > full-time effort (which isn't going to happen). About the only likely > > way I see for it to get in is for it to become important to Zope > > Corp. for some reason, and them paying Tim or Guido (or Chris) to do > > it. > > > I'm at a redesign for Stackless 2.2. I hope to make it simpler, > split apart Stackless and optimization, Ah :) > and continuations are no longer my primary target, but built-in > microthreads. Fair enough. Glad to hear you've found some time for your baby! Cheers, M. From tismer at tismer.com Tue Jan 1 23:21:12 2002 From: tismer at tismer.com (Christian Tismer) Date: Tue, 01 Jan 2002 23:21:12 +0100 Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: <3C323658.7040608@tismer.com> Michael Hudson wrote: > Christian Tismer writes: >>Well, it is a little late to answer this, but... > Hey, I don't care, I'm just glad to see you're still paying attention > :) Hmmtja, late but yes. >>Michael Hudson wrote: >> > [...] > >> >> * Just to implement map, 150 lines of builtin_map had to be >> >> rewritten into 350 lines (builtin_map, make_stub_code, >> >> make_map_frame, builtin_map_nr, builtin_map_loop). The author >> >> indicates that the same procedure still needs to be done for >> >> apply and filter. Just what is the "same procedure"? Isn't there >> >> some better way? >> >> >> > >> > This is where implementing stackless in C really, really hurts. >> >> >>[great explanation of stackless techniques skipped.] >> >>I agree this is not easy to understand and to implement. >>I always was thinking of a framework which makes this >>easier, but I didn'tcome up with something suitable. >> > I've had similar thoughts, but likewise fell short. I think you could > probably do things with m4 that took something readable and spat out > stack-neutral C, but it would be a Major Project. There must be a simple path. The scheme is always the same. See the split of functions in stackless map. I hope to find a macro set that can create this mess from a couple of fragments. [understanding prepare macroes} >>This is really just an optimization. >>The PREPARE macros were used to limit code increase, and to >>gove me some more options to play with. >>Finally, the PREPARE macros do an optimized opcode prefetch >>which turns out to be a drastical speedup for the interpreter loop. >>Standard Python does an increment for every byte code and then >>one for the optional argument, and the argument is picked bytewise. >>What I do is a single add to the program counter, dependent of the >>opcode/argument size which is computed in the PREPARE macro. >>Then, on intel machines, I use a short word access to the argument >>which gives a considerable savings. (Although this wouldn't be >>necessary if the compilers weren't that dumb). >> > > This could/should be split off from stackless, right? Yes. And if you have a look in the last (dusty) release, you see that it already is. There is a python script that applies all these optimizations automagically. [integration rumor again] >>I'm at a redesign for Stackless 2.2. I hope to make it simpler, >>split apart Stackless and optimization, >> > > Ah :) Jaah :) >>and continuations are no longer my primary target, but built-in >>microthreads. >> > > Fair enough. Glad to hear you've found some time for your baby! Well, thanks. I had a lot of trouble with my living babies, now after that, the virtual ones get their attention again. ciao - chris -- Christian Tismer :^) Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net/ 14163 Berlin : PGP key -> http://wwwkeys.pgp.net/ PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com/ From mwh at python.net Thu Jan 3 12:20:29 2002 From: mwh at python.net (Michael Hudson) Date: Thu, 3 Jan 2002 11:20:29 GMT Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: Christian Tismer writes: > >>I agree this is not easy to understand and to implement. > >>I always was thinking of a framework which makes this > >>easier, but I didn'tcome up with something suitable. > >> > > I've had similar thoughts, but likewise fell short. I think you could > > probably do things with m4 that took something readable and spat out > > stack-neutral C, but it would be a Major Project. > > > There must be a simple path. The scheme is always the same. Yes. > See the split of functions in stackless map. I hope to find > a macro set that can create this mess from a couple of fragments. But C is ****so**** unexpressive on this level. #define STACKLESS_CALL(FUNC, ARGTUPLE) \ { PyFrameObject* f = PyFrame_New(); f.next = FUNC; \ f.nextargs = ARGTUPLE; f.return_to = ???; return; } You could probably do it in Lisp. Cheers, M. -- ... so the notion that it is meaningful to pass pointers to memory objects into which any random function may write random values without having a clue where they point, has _not_ been debunked as the sheer idiocy it really is. -- Erik Naggum, comp.lang.lisp From tismer at tismer.com Thu Jan 3 13:16:19 2002 From: tismer at tismer.com (Christian Tismer) Date: Thu, 03 Jan 2002 13:16:19 +0100 Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: <3C344B93.6090705@tismer.com> Michael Hudson wrote: > Christian Tismer writes: ... >>There must be a simple path. The scheme is always the same. >> > > Yes. > > >>See the split of functions in stackless map. I hope to find >>a macro set that can create this mess from a couple of fragments. >> > > But C is ****so**** unexpressive on this level. > > #define STACKLESS_CALL(FUNC, ARGTUPLE) \ > { PyFrameObject* f = PyFrame_New(); f.next = FUNC; \ > f.nextargs = ARGTUPLE; f.return_to = ???; return; } > > You could probably do it in Lisp. Haah! Got it! I could probably do it in Python. Why do we have this wonderful language. I can put some comments into the source which can be understood by a Python script. This script is then run over the source and spits out the necessary C code. Gr?bel, Denk -- chris -- Christian Tismer :^) Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net/ 14163 Berlin : PGP key -> http://wwwkeys.pgp.net/ PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com/ From tismer at tismer.com Tue Jan 15 20:12:06 2002 From: tismer at tismer.com (Christian Tismer) Date: Tue, 15 Jan 2002 20:12:06 +0100 Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: <3C447F06.5010103@tismer.com> Martin von Loewis wrote: > Michael Hudson writes: > > >>>- it adds 17 new members to the frame object, doubling the number >>> of members. Usage of some of these members isn't obvious to me. >>> >>See below about map & friends. >> > > If they are all just for the variables in map etc., a better solution > must be found - don't think it is desirable to have them in every > frame, if they are just used inside map. They were also heavily used in the continuation code. I wanted to add a number of registers, which are used in the manner an extension needed it, without doing a redesign of frames (which breaks compatibility). > However, from inspecting the patch, I doubt this is the case. Some of > them are general-purpose, but I couldn't easily figure out what, for > example, this first-instruction business is good for. Some fields are not necessary, after all. This is evolution in flux ... :-) >>So when map wants to call the Python function, it needs to stuff all >>the local data it cares about into a frame object (see above), push >>this frame object onto the (Python) stack, *return* to the interpreter >>in such a way that the mapping function is called next and then every >>time(!) that returns have the interpreter call back into map again. >> > > Why couldn't map behave as if it was a plain Python function, > implemented as > > def map(fun,args): > res = [] > for a in args: > res.append(fun(a)) It does so. > [I know that map is implemented in a more-involved way; it should > still be possible to find its Python equivalent, then think how > stackless would execute this equivalent] > > For the additions to frame_state, that would mean that map should > reserve a number of localsplus variables, instead of outright adding > to frame_state on the C level. I wanted map to be as efficient as before, so I needed some integer registers, not Python objects. No, I would propose to extend frames to also support memory which doesn't need to hold Python objects. That makes them general-purpose. >>>- The code adds PREPARE macros into each branch of ceval. Why? >>>- It adds a long list of explicitly not-supported opcodes into >>> the ceval switch, instead of using 'default:'. No explanation >>> for that change is given, other than 'unused opcodes go here'. >>> Is it necessary to separately maintain them? Why? >>> >>This was an optimization Chris used to try and get back some of the >>performance lost during the stackless changes. IIRC, he handles >>exceptions and return values as "pseudo-opcodes" rather than using the >>WHY_foo constants the current ceval.c uses. I never really understood >>this part. >> > > If it is an optimization, I think we should take a step back and first > try to understand what it tries to optimize, and how it does > that. Perhaps we find that it isn't needed at all, and that the > problem could be solved in a different way. If you don't understand > it, it can't go into Python. Please, these optimizations should be kept out of Stackless discussion. As you might have noticed by looking into the source tree, there is a file named ceval_pre.c which does not have these optimizations. You can compile it instead of ceval.c and get the same (slower) functionality. I always work with this file when I change Stackless. As a part of the build step, I run the script cevalpatch.py, which scans the source and applies the optimization patches. So why care. >>I think integrating stackless into the core is a fairly huge amount of >>work. I'd like to think I could do it, given several months of >>full-time effort (which isn't going to happen). About the only likely >>way I see for it to get in is for it to become important to Zope >>Corp. for some reason, and them paying Tim or Guido (or Chris) to do >>it. >> > > I don't think these are the options. I don't volunteer to support this > code myself, either, but if somebody would step forward and claim that > she understands it all, and is willing to present it to Guido in a way > that he understands it also, and if all the hackish parts of it would > be replaced by understandable code, I think it could go into Python. > It just needs a determined volunteer to work on it. Turns out that I will have to try it. ciao - chris -- Christian Tismer :^) Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net/ 14163 Berlin : PGP key -> http://wwwkeys.pgp.net/ PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com/ From tismer at tismer.com Tue Jan 15 19:48:28 2002 From: tismer at tismer.com (Christian Tismer) Date: Tue, 15 Jan 2002 19:48:28 +0100 Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> Message-ID: <3C44797C.8030202@tismer.com> John S. Yates, Jr. wrote: > On 5 Nov 2001 13:53:28 GMT, amk at localhost.debian.org (A.M. Kuchling) wrote: > > >>Not at all. Stackless would have ramifications not just for a few >>files in the core, but also for all the extension modules that come >>with Python and for all the authors of third-party extension modules. >> > > Is this because those extension modules would break? Or because they > would be sub-optimal until they took advantage of continuations? The extension modules do not break. But unless they support the stackless way of calling back into an interpreter, they will block things like microthreads. In order to allow a C function to cooperate with Stackless, it needs to free the C stack completely while it calls other python functions. Everyting must be saved and restored from the frame chain. There are cases where this is trivial, and other cases where they are nearly impossible (aka rewrite the whole extension). But there is no problem for C extensions which don't call back into Python or if they do this only for short time, and you can live with not switching coroutines/microthreads during this call. ciao - chris -- Christian Tismer :^) Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net/ 14163 Berlin : PGP key -> http://wwwkeys.pgp.net/ PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com/ From tismer at tismer.com Tue Jan 15 19:59:34 2002 From: tismer at tismer.com (Christian Tismer) Date: Tue, 15 Jan 2002 19:59:34 +0100 Subject: C callbacks ? Re: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> Message-ID: <3C447C16.3060006@tismer.com> Frederic Giacometti wrote: > "Gordon McMillan" wrote in message > news:Xns91515922BE028gmcmhypernetcom at 199.171.54.214... > >>John S. Yates, Jr. wrote: >> >> >>>On 5 Nov 2001 13:53:28 GMT, amk at localhost.debian.org (A.M. Kuchling) >>>wrote: >>> >>But making Python *truly* stackless means getting rid of all recursions, >>and that is an enormous task. If you don't do that, you've got a >>language feature that doesn't work in some apparently random >>set of circumstances. >> > > But how do you process callbacks to Python from C code (extensions or > embeded python)? Either you do it as before. Then you get the known behavior of Python. You cannot restart uthreads from your C extension nested Python code, unless it starts its own scheduling and terminates this until returning to the C code. Or: You rewrite your C extension in a way that it vanishes from the C stack while it is executing Python code. This is not trivial. A good example is stackless' map, which does eactly this. > One has to return to C after executing the Python code, and than C has to > return to Python after executing the remainer of its code... Exactly. The C code has to put all its state info into a frame and play the frame chain game, as Python functions do. If it adheres to that rule, everything works seamlessly. In a way, your C code becomes "the interpreter" for this frame. A frame structure with better support for this has to be developed. Currently, there are just a few extra fields which I used for my specific stuff, like stackless map and full continuation support. In the long term, I wish to have more general frames which can be adjusted to the extension's needs. ciao - chris -- Christian Tismer :^) Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net/ 14163 Berlin : PGP key -> http://wwwkeys.pgp.net/ PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com/ From phr-n2002a at nightsong.com Tue Jan 15 20:15:12 2002 From: phr-n2002a at nightsong.com (Paul Rubin) Date: 15 Jan 2002 11:15:12 -0800 Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> Message-ID: <7xy9iz8lz3.fsf@ruckus.brouhaha.com> Christian Tismer writes: > In order to allow a C function to cooperate with Stackless, it needs > to free the C stack completely while it calls other python functions. > Everyting must be saved and restored from the frame chain. Do you think stuff can be added to SWIG to support this? From tismer at tismer.com Wed Jan 16 16:24:41 2002 From: tismer at tismer.com (Christian Tismer) Date: Wed, 16 Jan 2002 16:24:41 +0100 Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <7xy9iz8lz3.fsf@ruckus.brouhaha.com> Message-ID: <3C459B39.9050003@tismer.com> Paul Rubin wrote: > Christian Tismer writes: > >>In order to allow a C function to cooperate with Stackless, it needs >>to free the C stack completely while it calls other python functions. >>Everyting must be saved and restored from the frame chain. >> > > Do you think stuff can be added to SWIG to support this? I believe this is a *very* good idea! ciao - chris -- Christian Tismer :^) Mission Impossible 5oftware : Have a break! Take a ride on Python's Kaunstr. 26 : *Starship* http://starship.python.net/ 14163 Berlin : PGP key -> http://wwwkeys.pgp.net/ PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF where do you want to jump today? http://www.stackless.com/ From jkraska at san.rr.com Tue Jan 15 23:51:58 2002 From: jkraska at san.rr.com (Courageous) Date: Tue, 15 Jan 2002 22:51:58 GMT Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> Message-ID: >But there is no problem for C extensions which don't call back >into Python or if they do this only for short time, and you can >live with not switching coroutines/microthreads during this call. In fact, there are whole classes of problems where this isn't an issue at all. Speaking to the general audience, I'd like to point out that microthreads are hardly the only use for continuations. A step-wise cooperative scheduler can make use of these, and since every python step completes a C extension call, there's no overlap and therefor no blocking. While this is certainly obscure, I'll note that it has pragmatic use in a simulation environment (which is exactly where I use it). C// From peter.milliken at gtech.com Tue Jan 1 20:52:52 2002 From: peter.milliken at gtech.com (Peter Milliken) Date: Wed, 2 Jan 2002 06:52:52 +1100 Subject: waterfall (was Re: REPOST: Re: Book "python programming patterns". anybody read this??) References: <2$--$$_----___%_$$@news.noc.cabal.int> Message-ID: Thanks Gordon :-) Yes, what is described is "waterfall" - I object violently (:-)) to the concept that it "didn't work" though. Seems to me that there is a lot of "well it didn't work for all situations so there must be something wrong with it" thinking around the place - waterfall works very well in many situations - but not all, there is *no* definitive model (to my knowledge :-)) that works well in *every* situation. In fact, waterfall has worked very successfully on some extremely large projects - waterfall was the "standard" for many years in defence contracts - sure there were some absolute disasters but there were also many resounding successes - in fact, I would suggest that analsise of the disasters would many times show that the waterfall model wasn't adhered to i.e. I worked on one project that went for 7.5 years and was cancelled by the customer - they were still changing the SRS when the contract was cancelled - doesn't matter what model you use, it is very hard to hit a moving target. So there are "many decades" of industry experience that show it did work extremely well. The limitations of the model are well know though and hence the rise of other models such as spiral etc. I won't bother to go into the why's and wherefores these are all adequately covered in software development textbooks. I would just caution both of you to be a little less dismissive of waterfall (sorry Gordon, I don't think you are being dismissive of it but the "background" of waterfall that you give is wrong - in my experience :-)) - the concepts are still sound. As far as I am concerned the other models are purely modifications of the concepts found in waterfall (get each step right before proceeding to the next) and whether you use waterfall, spiral or whatever is purely a question of judgement or trade-off for the situation you are developing for. AFAIK, waterfall is perfectly appropriate if you can get your mind around the problem in one go and the customers requirements are definitive - use one of the other models otherwise :-) Peter "Gordon McMillan" wrote in message news:Xns9188626EA5C2gmcmhypernetcom at 199.171.54.213... > Alex Martelli wrote: > > [snip] > > > This is also known as the "waterfall model" of software development. > > > > It just doesn't work, as many decades of industry experience have amply > > shown. > > > The "waterfall" model comes from the days when most development was > mainframe batch systems. It "worked" (to some limited degree) in that > environment because of the following conditions: > > - there were only a half-dozen or so basic building blocks in mainframe > batch systems (sort, merge, select, extract...) > - the scope of the projects (successfully managed through "waterfall") was > generally tiny compared to the scope of the system in which they fit > - there were senior people on the project who could balance the "top down" > with some "bottom up", but keep it secret > > Violate any one of those (too many technical choices; too big a system; or > people who aren't very familiar with the system's context) and the resultant > system was iteration 1 of an iterative prototype too expensive to complete. > > More generally, you could describe a successful "waterfall" project as an > iterative prototype that worked the first time through. > > What Peter had right was that *thinking* about the problem is always > necessary, even in an iterative prototype :-). > > -- Gordon > http://www.mcmillan-inc.com/ From aleax at aleax.it Wed Jan 2 11:59:41 2002 From: aleax at aleax.it (Alex Martelli) Date: Wed, 2 Jan 2002 11:59:41 +0100 Subject: waterfall (was Re: REPOST: Re: Book "python programming patterns". anybody read this??) References: <2$--$$_----___%_$$@news.noc.cabal.int> Message-ID: "Peter Milliken" wrote in message news:a0t49r$e861 at news1.gtech.com... ... > the concepts are still sound. As far as I am concerned the other models are > purely modifications of the concepts found in waterfall (get each step right > before proceeding to the next) and whether you use waterfall, spiral or The key concept in any form of modern software development methodology is to acknowledge that you *CANNOT* confidently "get a step right before proceeding to the next": feedback and iteration are not optionals. It makes about as much sense to describe this as "purely modification of" waterfall, as to describe communism as purely modification of the concepts found in liberalism (let each citizen pursue his personal advantage freely within the laws): sure, just change the laws so you can only do what the Central Committee tells you to do, and there you are. > AFAIK, waterfall is perfectly appropriate if you can get your mind around > the problem in one go and the customers requirements are definitive - use > one of the other models otherwise :-) How do you KNOW that "the customer's requirements are definitive"? Let's say: use waterfall when you are ABSOLUTELY certain that the customer's requirements are definitive and you have understood them correctly and completely at once. To make "absolutely certain" more concrete, let's say that you will undertake to disembowel yourself ritually if it turns out you were wrong -- that the requirements were NOT quite as clear, well-communicated, well-understood, definitive and/or nailed-down as you thought. If you're not willing to commit to this, then you're not ABSOLUTELY certain, and you shouldn't use waterfall. Now THIS seems a workable operating definition to me. Besides, the few developers self-assured enough to operate this way will soon be out of the gene pool, enhancing the breed. A win-win proposition. The only real defect of waterfall as applied over the last few decades is the lack of a precise definition of "absolutely certain", and by the hara-kiri clause I think we remedy that quite effectively. Alex From marklists at mceahern.com Wed Jan 2 17:58:35 2002 From: marklists at mceahern.com (Mark McEahern) Date: Wed, 2 Jan 2002 08:58:35 -0800 Subject: waterfall In-Reply-To: Message-ID: > How do you KNOW that "the customer's requirements are definitive"? To which I would add so as to emphasize the inevitability of change: "How do you KNOW that the customer's requirements however definitive they might be NOW, will not change before you're done?" // mark From peter.milliken at gtech.com Wed Jan 2 22:55:16 2002 From: peter.milliken at gtech.com (Peter Milliken) Date: Thu, 3 Jan 2002 08:55:16 +1100 Subject: waterfall (was Re: REPOST: Re: Book "python programming patterns". anybody read this??) References: <2$--$$_----___%_$$@news.noc.cabal.int> Message-ID: "Alex Martelli" wrote in message news:a0up6s$eef$1 at serv1.iunet.it... > "Peter Milliken" wrote in message > news:a0t49r$e861 at news1.gtech.com... > ... > > the concepts are still sound. As far as I am concerned the other models > are > > purely modifications of the concepts found in waterfall (get each step > right > > before proceeding to the next) and whether you use waterfall, spiral or > > The key concept in any form of modern software development methodology is to > acknowledge that you *CANNOT* confidently "get a step right before > proceeding > to the next": feedback and iteration are not optionals. > Agreed, depends on your definition of getting it right - that is why feedback and iteration will always be with us. > It makes about as much sense to describe this as "purely modification of" > waterfall, as to describe communism as purely modification of the concepts > found in liberalism (let each citizen pursue his personal advantage freely > within the laws): sure, just change the laws so you can only do what the > Central Committee tells you to do, and there you are. > Well, I think "looser" on this one than you do :-) Software development is a stepwise process of determining requirements, producing a design, coding to that design, testing the code and delivery to a customer - the ultimate model :-). How you break that up or organise that for the particular project is what spawns the so called "models". I don't know of any model that doesn't have this basic process embedded in it. > > AFAIK, waterfall is perfectly appropriate if you can get your mind around > > the problem in one go and the customers requirements are definitive - use > > one of the other models otherwise :-) > > How do you KNOW that "the customer's requirements are definitive"? How can you BUILD something if you don't know what it is? If you are a software house then you have to get an agreed contractual basis as to what you deliver - otherwise you are always changing what you deliver - which is fine if you are paid on a time and materials basis but not many customers want to enter into that kind of open ended arrangement. So, just like hiring a plumber to do a job, you ask for a quote, he asked you what the job is and then advises the quote based on what you tell him - same thing has to happen in software otherwise you go out of business backwards. Of course, if you have the "luxury" of developing for an inhouse part of the company then you (the supplier) and the customer can screw around to your hearts content until one day a manager somewhere notices the dollars disappearing into a blackhole and cans the entire thing (or makes the pair of you stop screwing around! :-)). So nailing down the requirements is always the first step - agreement means that (at least at that moment :-)) when the customer signs on the dotted line everyone believes that to the best of their knowledge the requirements are definitive enough to proceed to build the product. The majority of failures that I have seen and read about have one underlying common thread - the requirements were still being changed at the time the project was cancelled. > > Let's say: use waterfall when you are ABSOLUTELY certain that the > customer's requirements are definitive and you have understood them > correctly and completely at once. To make "absolutely certain" more > concrete, let's say that you will undertake to disembowel yourself > ritually if it turns out you were wrong -- that the requirements were > NOT quite as clear, well-communicated, well-understood, definitive and/or > nailed-down as you thought. If you're not willing to commit to this, > then you're not ABSOLUTELY certain, and you shouldn't use waterfall. > I think you are getting too rigid here - all software models are based upon the fundamental steps of requirements analyise, design, code and test. Even models based upon rapid protyping follow the same basic steps (the requirements are very loose obviously, the aim of protyping is to refine them) - the protype is built to a set of understood requirements, the protype has some form of design, there is coding and there is testing. ABSOLUTE has to be applied if you want to stay in business - if the requirements change (as they will) as the project progresses then the customer can ask for a modification and project management deal with it i.e. estimate cost and schedule impact, determine in conjunction with the customer where and how the change will be slotted in i.e. it might be agreed that the change can be progressed AFTER the current system has been finished and "sold off" or the decision might be to fit the changed requirements in ASAP. So I am getting confused by your responses - all you seem to do is blast waterfall - I haven't seen any attempt at some constructive response here, a proposal for some other model because it fits better into your concepts of software development or personal situations. All I have said is that waterfall can and has worked in the past and shouldn't be dismissed upon the argument that "it hasn't worked in the past, so therefore lets not consider it" (my interpretation of your responses). This seems a nonsense argument at best. > Now THIS seems a workable operating definition to me. Besides, the > few developers self-assured enough to operate this way will soon be > out of the gene pool, enhancing the breed. A win-win proposition. > The only real defect of waterfall as applied over the last few decades > is the lack of a precise definition of "absolutely certain", and by > the hara-kiri clause I think we remedy that quite effectively. > To me, the gene pool just seems to swirl and swirl with no signs of reaching any superior state. It appears more to me that the new genes entering the pool from colleges every year think they are the next Leonardo Da Vinci of software development, that they can ignore the lessons of the past and just stride out there with supreme confidence that they know what is right - hence people like me (who have been here for several decades now) see the same mistakes being made time and time again. I am sure that you are just as confident as I am that you "know what is right". I have seen what works and what doesn't, I don't pretend that I know it all, but what I do know is correct for the circumstances I have experienced :-). So waterfall can and does work in the right context. So do the other models - there is no single model that will work best for all circumstances. So, unless you are "absolutely certain" then I hope you are on a time and materials contract, otherwise there will be a win-win situation and the gene pool will have one less participant :-) Peter From gmcm at hypernet.com Thu Jan 3 01:54:22 2002 From: gmcm at hypernet.com (Gordon McMillan) Date: 03 Jan 2002 00:54:22 GMT Subject: waterfall (was Re: REPOST: Re: Book "python programming patterns". anybody read this??) References: <2$--$$_----___%_$$@news.noc.cabal.int> Message-ID: Peter Milliken wrote (among a whole lot of other stuff): > How can you BUILD something if you don't know what it is? If you are a > software house then you have to get an agreed contractual basis as to > what you deliver - otherwise you are always changing what you deliver - > which is fine if you are paid on a time and materials basis but not > many customers want to enter into that kind of open ended arrangement. Probably true for big software houses, but as a very small (one person) shop, I find almost no one is interested in a fixed-price bid. That way they can change their minds without disturbing the budget. -- Gordon http://www.mcmillan-inc.com/ From aleax at aleax.it Thu Jan 3 23:07:23 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 3 Jan 2002 23:07:23 +0100 Subject: waterfall (was Re: REPOST: Re: Book "python programming patterns". anybody read this??) Message-ID: <050f01c19472$3e505840$102b2bc1@cadlab.it> "Peter Milliken" wrote in message news:a0vvrj$e862 at news1.gtech.com... ... > > How do you KNOW that "the customer's requirements are definitive"? > > How can you BUILD something if you don't know what it is? If you are a By *finding out* what it is. The process of "building", in the widest sense of the word, is the process of finding out what is being built. > software house then you have to get an agreed contractual basis as to what > you deliver - otherwise you are always changing what you deliver - which is Remember that well over 90% of software development is in-house, so that the specific business models you may have in mind are quite marginal in the world of software development as a whole. Further, a good slice of what is NOT "in house" is development of software to be sold (or rented, subscribed to, included as novelty gift in potato chip packs, etc) "off the shelf", so there is absolutely no "agreed contractual basis" with your customers until AFTER you have the software ready for sale (rent, subscription, etc). > in software otherwise you go out of business backwards. Of course, if you > have the "luxury" of developing for an inhouse part of the company then you > (the supplier) and the customer can screw around to your hearts content Except that this is not the customer's interest: they want SOLUTIONS to their problems, the latter often being rather ill-defined ones. So, it's in their best interest to work with you to help find out exactly what they need, and with what priority in terms of what needs to work first, what can come later, what would "be nice to have" but not vital, and so on. Further, YOUR interests are also to similarly develop successful, useful, usable, software systems -- systems that get used and deliver results. That's assuming you're an engineer at heart, rather than a bureaucrat whose key goals are following established procedure and always having somebody else to blame when things go wrong, of course. > So nailing down the requirements is always the first step - agreement means It almost never is. Use velcro or masking tape, not nails. The requirements are going to be refined, prioritized, changed in scope, refactored, reprioritized, etc, throughout the life of a successful software system. Those nails would get bent out of shape and rust far too soon to be any real use. > failures that I have seen and read about have one underlying common thread - > the requirements were still being changed at the time the project was > cancelled. I.e., the customer was in the process of finding out what they actually needed -- a perfectly normal interactive discovery process -- and somewhere in some decision-making positions were people who did NOT realize this and were not prepared for it. Most likely because they harbored [expletive deleted] notions about "nailing down the requirements is always the first step". BTW, you may not read about them as failures, but examples also abound of software that WAS painstakingly specified in minute detail before any step towards building it was taken, then later delivered -- and never used, being totally irrelevant to the business needs. In my (indirect) experience, this tends to happen in public procurement, where laws and regulations may indeed mandate such an absurd process. It also happens in development for "off-the-shelf" sale (etc), in which case it tends to be more visible since the end product, despite fulfilling its "nailed down" specs perfectly, doesn't sell. It may not be something you will read about as a failure, but, both as a taxpayer AND as an engineer, I consider these disasters, which are far from unheard of, every bit as bad as other development disasters. > > Let's say: use waterfall when you are ABSOLUTELY certain that the > > customer's requirements are definitive and you have understood them > > correctly and completely at once. To make "absolutely certain" more > > concrete, let's say that you will undertake to disembowel yourself > > ritually if it turns out you were wrong -- that the requirements were > > NOT quite as clear, well-communicated, well-understood, definitive and/or > > nailed-down as you thought. If you're not willing to commit to this, > > then you're not ABSOLUTELY certain, and you shouldn't use waterfall. > > I think you are getting too rigid here - all software models are based upon > the fundamental steps of requirements analyise, design, code and test. Even You may call then "steps" if you wish, and you have missed quite a few crucial ones (such as "deploy", "document and/or train", "tune", ...), but that doesn't make them anywhere as separate and/or sequential as all that. > models based upon rapid protyping follow the same basic steps (the > requirements are very loose obviously, the aim of protyping is to refine > them) - the protype is built to a set of understood requirements, the > protype has some form of design, there is coding and there is testing. "There is" understanding, design, coding, testing, and other things yet "there are". But the optimal sequencing, interleaving, merging and splitting of the various activities are not optimally rigid -- YOU tell ME "I am getting too rigid", I, on the other hand, claim Agile Development processes are the very antithesis of rigidity and Waterfall IS rigidity in software development -- an inappropriate, inferior and unsuitable methodology. > So I am getting confused by your responses - all you seem to do is blast > waterfall - I haven't seen any attempt at some constructive response here, a All I want to do in this thread is make sure waterfall is and stay blasted, since benighted discussors are trying to revive the zombie. Excellent textbooks, articles, courses etc, abound, on many superior alternatives, such as Rational Unified Process, Extreme Programming, and so forth. > proposal for some other model because it fits better into your concepts of > software development or personal situations. Read anything published in the field in the last few years and you'll find nothing but. Meanwhile, the monster of Waterfall needs to be spiked through the heart each and every time it threatens to revive, which is basicall what I'm doing here. > All I have said is that waterfall can and has worked in the past and It can't and hasn't, in any relevant case (see below). > shouldn't be dismissed upon the argument that "it hasn't worked in the past, > so therefore lets not consider it" (my interpretation of your responses). > This seems a nonsense argument at best. It has never worked, it can never work, it's an absurdity based on a total misconception of the nature of programming, of engineering, of the human mind, of human society, and of the universe. There, good enough for you? You're of course driving me to rather extreme assertions, just as I would be if (e.g.) debating some other similar absurdity which every historical experience and common sense show can't work, yet upon which altar blood (true or metaphorical) has been shed aplenty in the past and threatens to be shed again until and unless the nightmare is driven forever from the sublunar world. There ARE trivial 'projects' (not worth the name of 'projects') which basically consist in doing for the hundredth time much the same thing as you've done the last 99 times. Boring, but true; in this case the amount of "interleaving" needed may diminish, potentially down to a lower bound of zero. This is much like saying that "communism" can work within a small, close-knit family where everybody trust and love each other: in such a scenario there is no need to account for "whose money it is", who's earning and who's spending, and so on. But it *JUST DOESN'T SCALE* -- it's no basis for economics, which has to deal with the vast majority of interesting cases, where people, far from loving each other, may barely _stand_ each other. Idealizing and extrapolating the tiny "loving family" scenario leads to horrors that range from endless queues outside of empty shops all the way to rivers of blood down the streets. Wrong-headed software development approaches so far have less potential for utter disaster -- but, deaths HAVE resulted from "waterfall" development (specifically its hubris-like lack of check-backs and continuous verification), as any reader of the Risks column will know. Waterfall proponents traditionally wanted to dismiss such occurrences as (paraphrasing) "operator error". That's a good symptom of a system that's not fit for use by human beings, and the rationalization attempts for the system. Sure, there's nothing wrong with communism per se, only when you apply it to human beings do problems appear (for all I know, Martians may be quite happy with it). Perfect beings might be able to apply Waterfall -- I don't really care about them (being perfect, they'll surely be good at picking their methodologies anyway): "Know then thyself, presume not God to scan; The proper study of Mankind is Man". Man is fallible, and has evolved in an environment of trial-and-error, continuous feedback, continuous adjustment. The worst failures come when one's pride rears up and proclaims that one HAS fully grasped the issues, so no more tentative, feedback, adjustments, etc, are possible -- when one denies the fallibility, or fails to accept the indispensable "checks and balances" that compensate for it and make it bearable. "Pride comes before a fall". On the subject of "operator error", see Perrow, "Normal Accidents"; and to some extent Norman, "Design of Everyday Things". On inflexibility (resulting from excessive pride from past successes) as the key aspect in the (economic) fall of every Empire, Carlo Cipolla has an excellent short article in his delightful, highly mixed book "Le Tre Rivoluzioni" (there's probably an English version somewhere too, given that Cipolla has written and taught in English even more than in Italian -- I can look for it, if you want to try and read it). Kennedy's "Rise and Fall of the Great Powers" is, to some extent, a look at the same issue with wider scope. Waterfall is highly reminiscent of each of these general issues. > any superior state. It appears more to me that the new genes entering the > pool from colleges every year think they are the next Leonardo Da Vinci of A failure, as an engineer, of course -- he applied "waterfall", rather than iteratively testing and checking that he knew what he was doing. So, none of his machines ever really worked well, and some of his incredible works of art (artists can afford far more pride than engineers can) were not as lasting as those of his contemporaries (who, more humbly, tried things in small increments and kept double-checking with customers...). > software development, that they can ignore the lessons of the past and I.e., human fallibility? If new graduates are so full of misplaced pride that they think they can use Waterfall, rather than solid, interactive mingled-steps development, I entirely blame their teachers. > stride out there with supreme confidence that they know what is right - > hence people like me (who have been here for several decades now) see the > same mistakes being made time and time again. I am sure that you are just Yes, I do see Waterfall being praised -- but more likely by people my contemporaries, such as you, rather than by young brilliant graduates (who are more likely, at least, to have read recent relevant literature). > confident as I am that you "know what is right". I have seen what works It's exactly because *I know that I don't know* (and that others don't know either), that I consider it a horror to praise and defend a methodology that could only work for perfect (and mind-reading) developers who are developing for idealized customers who DO know exactly what they need. > what doesn't, I don't pretend that I know it all, but what I do know is > correct for the circumstances I have experienced :-). So waterfall can and > does work in the right context. So do the other models - there is no single > model that will work best for all circumstances. No, but, as I don't care about what works or doesn't for hypothetical Martians, I do know there's a model that will work horribly in all interesting circumstances: it's called Waterfall. > So, unless you are "absolutely certain" then I hope you are on a time and > materials contract, otherwise there will be a win-win situation and the That I am absolutely certain that Waterfall doesn't work for human beings doesn't mean I already know what does work best for any given situation, since there are so many other possibilities; it means I, and the rest of the team, _including the customer_, can *find out*, and interactively as well as iteratively develop and refine solutions and methods that "work well enough" to deliver significant business value, reliably and repeatably. Alex From peter.milliken at gtech.com Fri Jan 4 01:28:50 2002 From: peter.milliken at gtech.com (Peter Milliken) Date: Fri, 4 Jan 2002 11:28:50 +1100 Subject: waterfall (was Re: REPOST: Re: Book "python programming patterns". anybody read this??) References: Message-ID: "Alex Martelli" wrote in message news:mailman.1010095689.2965.python-list at python.org... > "Peter Milliken" wrote in message > news:a0vvrj$e862 at news1.gtech.com... > ... > > > How do you KNOW that "the customer's requirements are definitive"? > > > > How can you BUILD something if you don't know what it is? If you are a > > By *finding out* what it is. The process of "building", in the widest > sense of the word, is the process of finding out what is being built. > And you don't call "finding out" requirements analysise? :-) I'll drop the rest of the email now...... > > software house then you have to get an agreed contractual basis as to what > > you deliver - otherwise you are always changing what you deliver - which > is > > Remember that well over 90% of software development is in-house, so that the > specific business models you may have in mind are quite marginal in the > world of software development as a whole. Further, a good slice of what is > NOT "in house" is development of software to be sold (or rented, subscribed > to, included as novelty gift in potato chip packs, etc) "off the shelf", so > there is absolutely no "agreed contractual basis" with your customers until > AFTER you have the software ready for sale (rent, subscription, etc). > > > > in software otherwise you go out of business backwards. Of course, if you > > have the "luxury" of developing for an inhouse part of the company then > you > > (the supplier) and the customer can screw around to your hearts content > > Except that this is not the customer's interest: they want SOLUTIONS to > their problems, the latter often being rather ill-defined ones. So, it's > in their best interest to work with you to help find out exactly what they > need, and with what priority in terms of what needs to work first, what can > come later, what would "be nice to have" but not vital, and so on. > > Further, YOUR interests are also to similarly develop successful, useful, > usable, software systems -- systems that get used and deliver results. > That's assuming you're an engineer at heart, rather than a bureaucrat whose > key goals are following established procedure and always having somebody > else to blame when things go wrong, of course. > > > So nailing down the requirements is always the first step - agreement > means > > It almost never is. Use velcro or masking tape, not nails. > > The requirements are going to be refined, prioritized, changed in scope, > refactored, reprioritized, etc, throughout the life of a successful > software system. Those nails would get bent out of shape and rust far too > soon to be any real use. > > > failures that I have seen and read about have one underlying common > thread - > > the requirements were still being changed at the time the project was > > cancelled. > > I.e., the customer was in the process of finding out what they actually > needed -- a perfectly normal interactive discovery process -- and somewhere > in some decision-making positions were people who did NOT realize this and > were not prepared for it. Most likely because they harbored [expletive > deleted] notions about "nailing down the requirements is always the first > step". > > BTW, you may not read about them as failures, but examples also abound > of software that WAS painstakingly specified in minute detail before any > step towards building it was taken, then later delivered -- and never > used, being totally irrelevant to the business needs. In my (indirect) > experience, this tends to happen in public procurement, where laws and > regulations may indeed mandate such an absurd process. It also happens > in development for "off-the-shelf" sale (etc), in which case it tends to > be more visible since the end product, despite fulfilling its "nailed down" > specs perfectly, doesn't sell. > > It may not be something you will read about as a failure, but, both as > a taxpayer AND as an engineer, I consider these disasters, which are far > from unheard of, every bit as bad as other development disasters. > > > > > Let's say: use waterfall when you are ABSOLUTELY certain that the > > > customer's requirements are definitive and you have understood them > > > correctly and completely at once. To make "absolutely certain" more > > > concrete, let's say that you will undertake to disembowel yourself > > > ritually if it turns out you were wrong -- that the requirements were > > > NOT quite as clear, well-communicated, well-understood, definitive > and/or > > > nailed-down as you thought. If you're not willing to commit to this, > > > then you're not ABSOLUTELY certain, and you shouldn't use waterfall. > > > > I think you are getting too rigid here - all software models are based > upon > > the fundamental steps of requirements analyise, design, code and test. > Even > > You may call then "steps" if you wish, and you have missed quite a few > crucial ones (such as "deploy", "document and/or train", "tune", ...), > but that doesn't make them anywhere as separate and/or sequential as all > that. > > > models based upon rapid protyping follow the same basic steps (the > > requirements are very loose obviously, the aim of protyping is to refine > > them) - the protype is built to a set of understood requirements, the > > protype has some form of design, there is coding and there is testing. > > "There is" understanding, design, coding, testing, and other things yet > "there are". But the optimal sequencing, interleaving, merging and > splitting of the various activities are not optimally rigid -- YOU tell > ME "I am getting too rigid", I, on the other hand, claim Agile Development > processes are the very antithesis of rigidity and Waterfall IS rigidity in > software development -- an inappropriate, inferior and unsuitable > methodology. > > > > So I am getting confused by your responses - all you seem to do is blast > > waterfall - I haven't seen any attempt at some constructive response here, > a > > All I want to do in this thread is make sure waterfall is and stay blasted, > since benighted discussors are trying to revive the zombie. Excellent > textbooks, articles, courses etc, abound, on many superior alternatives, > such as Rational Unified Process, Extreme Programming, and so forth. > > > proposal for some other model because it fits better into your concepts of > > software development or personal situations. > > Read anything published in the field in the last few years and you'll > find nothing but. Meanwhile, the monster of Waterfall needs to be > spiked through the heart each and every time it threatens to revive, which > is basicall what I'm doing here. > > > All I have said is that waterfall can and has worked in the past and > > It can't and hasn't, in any relevant case (see below). > > > shouldn't be dismissed upon the argument that "it hasn't worked in the > past, > > so therefore lets not consider it" (my interpretation of your responses). > > This seems a nonsense argument at best. > > It has never worked, it can never work, it's an absurdity based on a > total misconception of the nature of programming, of engineering, of > the human mind, of human society, and of the universe. There, good > enough for you? > > You're of course driving me to rather extreme assertions, just as I > would be if (e.g.) debating some other similar absurdity which every > historical experience and common sense show can't work, yet upon > which altar blood (true or metaphorical) has been shed aplenty in > the past and threatens to be shed again until and unless the nightmare > is driven forever from the sublunar world. > > There ARE trivial 'projects' (not worth the name of 'projects') which > basically consist in doing for the hundredth time much the same thing > as you've done the last 99 times. Boring, but true; in this case the > amount of "interleaving" needed may diminish, potentially down to a > lower bound of zero. This is much like saying that "communism" can > work within a small, close-knit family where everybody trust and love > each other: in such a scenario there is no need to account for "whose > money it is", who's earning and who's spending, and so on. But it > *JUST DOESN'T SCALE* -- it's no basis for economics, which has to deal > with the vast majority of interesting cases, where people, far from > loving each other, may barely _stand_ each other. Idealizing and > extrapolating the tiny "loving family" scenario leads to horrors that > range from endless queues outside of empty shops all the way to rivers > of blood down the streets. Wrong-headed software development approaches > so far have less potential for utter disaster -- but, deaths HAVE resulted > from "waterfall" development (specifically its hubris-like lack of > check-backs and continuous verification), as any reader of the Risks > column will know. > > Waterfall proponents traditionally wanted to dismiss such occurrences > as (paraphrasing) "operator error". That's a good symptom of a system > that's not fit for use by human beings, and the rationalization attempts > for the system. Sure, there's nothing wrong with communism per se, only > when you apply it to human beings do problems appear (for all I know, > Martians may be quite happy with it). Perfect beings might be able to > apply Waterfall -- I don't really care about them (being perfect, they'll > surely be good at picking their methodologies anyway): "Know then thyself, > presume not God to scan; The proper study of Mankind is Man". > > Man is fallible, and has evolved in an environment of trial-and-error, > continuous feedback, continuous adjustment. The worst failures come when > one's pride rears up and proclaims that one HAS fully grasped the issues, > so no more tentative, feedback, adjustments, etc, are possible -- when one > denies the fallibility, or fails to accept the indispensable "checks and > balances" that compensate for it and make it bearable. "Pride comes before > a fall". > > On the subject of "operator error", see Perrow, "Normal Accidents"; and to > some extent Norman, "Design of Everyday Things". On inflexibility > (resulting from excessive pride from past successes) as the key aspect in > the (economic) fall of every Empire, Carlo Cipolla has an excellent short > article in his delightful, highly mixed book "Le Tre Rivoluzioni" (there's > probably an English version somewhere too, given that Cipolla has written > and taught in English even more than in Italian -- I can look for it, if > you want to try and read it). Kennedy's "Rise and Fall of the Great > Powers" is, to some extent, a look at the same issue with wider scope. > > Waterfall is highly reminiscent of each of these general issues. > > > > any superior state. It appears more to me that the new genes entering the > > pool from colleges every year think they are the next Leonardo Da Vinci of > > A failure, as an engineer, of course -- he applied "waterfall", rather than > iteratively testing and checking that he knew what he was doing. So, none > of his machines ever really worked well, and some of his incredible works of > art (artists can afford far more pride than engineers can) were not as > lasting as those of his contemporaries (who, more humbly, tried things in > small increments and kept double-checking with customers...). > > > software development, that they can ignore the lessons of the past and > > I.e., human fallibility? If new graduates are so full of misplaced pride > that they think they can use Waterfall, rather than solid, interactive > mingled-steps development, I entirely blame their teachers. > > > stride out there with supreme confidence that they know what is right - > > hence people like me (who have been here for several decades now) see the > > same mistakes being made time and time again. I am sure that you are just > > Yes, I do see Waterfall being praised -- but more likely by people my > contemporaries, such as you, rather than by young brilliant graduates (who > are more likely, at least, to have read recent relevant literature). > > > > confident as I am that you "know what is right". I have seen what works > > It's exactly because *I know that I don't know* (and that others don't know > either), that I consider it a horror to praise and defend a methodology > that could only work for perfect (and mind-reading) developers who are > developing for idealized customers who DO know exactly what they need. > > > what doesn't, I don't pretend that I know it all, but what I do know is > > correct for the circumstances I have experienced :-). So waterfall can and > > does work in the right context. So do the other models - there is no > single > > model that will work best for all circumstances. > > No, but, as I don't care about what works or doesn't for hypothetical > Martians, I do know there's a model that will work horribly in all > interesting circumstances: it's called Waterfall. > > > > So, unless you are "absolutely certain" then I hope you are on a time and > > materials contract, otherwise there will be a win-win situation and the > > That I am absolutely certain that Waterfall doesn't work for human beings > doesn't mean I already know what does work best for any given situation, > since there are so many other possibilities; it means I, and the rest of > the team, _including the customer_, can *find out*, and interactively as > well as iteratively develop and refine solutions and methods that "work > well enough" to deliver significant business value, reliably and repeatably. > > > Alex > From aleax at aleax.it Fri Jan 4 13:59:47 2002 From: aleax at aleax.it (Alex Martelli) Date: Fri, 4 Jan 2002 13:59:47 +0100 Subject: waterfall (was Re: REPOST: Re: Book "python programming patterns". anybody read this??) References: Message-ID: "Peter Milliken" wrote in message news:a12t09$bai2 at news1.gtech.com... ... > > > How can you BUILD something if you don't know what it is? If you are a > > > > By *finding out* what it is. The process of "building", in the widest > > sense of the word, is the process of finding out what is being built. > > And you don't call "finding out" requirements analysise? :-) No, because, when the "finding out" process is finished, the end result is generally knowledge *embodied in a working product*. "Analysis" (even, I presume, in your alternate spelling thereof) normally carries connotations of omitting such equally crucial procedures as design, implementation, testing, deployment, documentation, training, tuning. And yet, you aren't sure you really know "what it is" until the various procedures converge and business value is delivered (and only the customer is really qualified to judge about this last and crucial point -- unless you manage to inveigle some customers as at least part-time members of the team, you'll only get indirect future indications of this, e.g. as filtered by marketing personnel who might well lack other aspects of understanding). For another potentially useful analogy on the subject, try reading George Soros' "The Alchemy of Finance: Reading the Mind of the Market". He doesn't write as well as he speculates (that would be a tall order indeed), but there is one aspect of his thinking, as here expressed, that makes the book relevant in this context. He frames his speculations as _experiments testing out specific financial theories_. Understanding is reached when a theory works (an investment makes money), and even more when a theory is disproved (an investment loses money) -- yes, Soros is an unabashed Popperian, and quite proud of it too. Some others may be better at verbalizing their theories, and rationalizing about them, but "the process of building is the finding out of what is being built" holds quite well here. For example, such "details" (ha!) as edging-strategies and fallback positions concretely embody the need to meta-understand: develop concrete and detailed models, not only of what a theory predicts, but of _how confidently_ it predicts it, and what follows from various degrees of theory-failure. Similarly, in software development, we may adopt different flavors and intensities of "defensive programming" and "flexibility-maintaining strategies/investments" that embody, not just our best current understanding of what we're building, but also meta- understanding about how confident we are of specs' stability and what happens when (...not "if"...:-) the specs to slide along various possible axes, or "fault lines", of variability. I posted a few hours ago on another thread a similar analogy with the works of Renaissance builder Biagio Rossetti (as opposed to ones who were both great architects AND superb theoreticians, such as Palladio or Alberti). Studying the _process_ by which all of these greats of the past reached their best results is somewhat enlightening, too, although we must not forget that they were dealing with technologies far older and more stable than Information Processing is today. Hint, anyway: if you think their masterpieces saw the light through a linear, "waterfall" process of specification, then blueprinting, then bricks and stones, then touching up... you are sadly mistaken here, too. I think (having never studied this in depth) that today, several further centuries later, most building is probably "technologically stable" enough to proceed this way, maybe -- most buildings being just about identical to previous, already-existing buildings, and technology making it prohibitively expensive to go for customization versus "one size fits all". But some very relevant buildings are still done the good old way, with lot of interaction and feedback between "stages" that are anything BUT separate. Read, for example, the interviews Renzo Piano gave back when his Kansai airport building was one of the few that proved able to withstand the Kobe earthquake of 1995 "without so much as a broken window". He credits the input he received from the construction workers (and took into account, iteratively revising design, etc) as a major contribution to the structure's amazing robustness... Alex From tjreedy at home.com Fri Jan 4 17:02:58 2002 From: tjreedy at home.com (Terry Reedy) Date: Fri, 04 Jan 2002 16:02:58 GMT Subject: waterfall (was Re: REPOST: Re: Book "python programming patterns". anybody read this??) References: Message-ID: Perhaps relevant to this discussion, from this morning's (Friday 2002 Jan 4) News Journal (Wilmington, Delaware, USA): "Gov. Ruth Ann Miner has scraped plans for a computerized accounting and purchasing system after four years of design costing $7.4 million." The article goes on to note that the system would have cost another $7 million to implement and $2 million a year to operate and would be obsolete from the day delivered because of already planned changes in the state's accounting procedures. It strikes me (and the Governor) as scandelous that so-called professionals would spend so much time endlessly designing and never produce anything that worked and was useful. Terry J. Reedy From johnroth at ameritech.net Sat Jan 5 00:28:20 2002 From: johnroth at ameritech.net (John Roth) Date: Fri, 4 Jan 2002 15:28:20 -0800 Subject: waterfall (was Re: REPOST: Re: Book "python programming patterns". anybody read this??) References: Message-ID: "Terry Reedy" wrote in message news:SmkZ7.353785$5A3.134640907 at news1.rdc2.pa.home.com... > Perhaps relevant to this discussion, from this morning's (Friday 2002 > Jan 4) News Journal (Wilmington, Delaware, USA): > > "Gov. Ruth Ann Miner has scraped plans for a computerized accounting > and purchasing system after four years of design costing $7.4 > million." The article goes on to note that the system would have cost > another $7 million to implement and $2 million a year to operate and > would be obsolete from the day delivered because of already planned > changes in the state's accounting procedures. > > It strikes me (and the Governor) as scandelous that so-called > professionals would spend so much time endlessly designing and never > produce anything that worked and was useful. > > Terry J. Reedy Unfortunately, that's the way Government projects work. Until someone convinces the people who control the purse strings (congress, legislators) that you can't get good, repeatable results without incremental delivery, the same messes will happen. When you put out a bid for a project to be delivered in one lump, 5 years down the road, it's going to fail. That's one of the more guaranteed statements in this universe. John Roth From kyle at kylecordes.com Sat Jan 5 06:13:47 2002 From: kyle at kylecordes.com (Kyle Cordes) Date: Fri, 4 Jan 2002 23:13:47 -0600 Subject: waterfall (was Re: REPOST: Re: Book "python programming patterns". anybody read this??) References: Message-ID: "John Roth" wrote in message news:u3cegesrf4f698 at news.supernews.com... > When you put out a bid for a project to be delivered in one > lump, 5 years down the road, it's going to fail. That's one of the > more guaranteed statements in this universe. Deeply ironic, isn't it... -- [ Kyle Cordes * kyle at kylecordes.com * http://kylecordes.com ] [ Consulting, Training, and Software development tips and ] [ techniques: Java, Delphi, ASTA, BDE Alternatives Guide, ] [ JB Open Tools, EJB, Web applications, methodologies, etc. ] From akuchlin at mems-exchange.org Mon Jan 7 21:51:10 2002 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 07 Jan 2002 15:51:10 -0500 Subject: waterfall (was Re: REPOST: Re: Book "python programming patterns". anybody read this??) References: Message-ID: <3dk7utdgw1.fsf@ute.mems-exchange.org> "John Roth" writes: > Unfortunately, that's the way Government projects work. Until Isn't that the way all projects, government or not, work? I remember horrifying numbers quoted in places such as Robert Glass's column in Comm. of the ACM to the effect that 50% (or maybe it was 60%, or 90%) of projects fail by either not producing a deliverable, or producing a deliverable that doesn't work, or by producing a working deliverable that doesn't solve the problem. --amk (www.amk.ca) Don't interrupt me when I'm eulogizing. -- Dr Judson/Fenric, in "The Curse of Fenric" From brueckd at tbye.com Mon Jan 7 21:51:05 2002 From: brueckd at tbye.com (brueckd at tbye.com) Date: Mon, 7 Jan 2002 12:51:05 -0800 (PST) Subject: waterfall (was Re: REPOST: Re: Book "python programming patterns". anybody read this??) In-Reply-To: <3dk7utdgw1.fsf@ute.mems-exchange.org> Message-ID: On 7 Jan 2002, Andrew Kuchling wrote: > "John Roth" writes: > > Unfortunately, that's the way Government projects work. Until > > Isn't that the way all projects, government or not, work? I remember > horrifying numbers quoted in places such as Robert Glass's column in > Comm. of the ACM to the effect that 50% (or maybe it was 60%, or 90%) > of projects fail by either not producing a deliverable, or producing > a deliverable that doesn't work, or by producing a working deliverable > that doesn't solve the problem. I don't know about all projects in general, but for "large" projects (ones that were planned to take a year or more to create) the number was much closer to 90% than 50%. Worse, the majority of both successes and failures tend to be way over budget too. -Dave From nhodgson at bigpond.net.au Sat Jan 5 00:38:00 2002 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Fri, 04 Jan 2002 23:38:00 GMT Subject: waterfall (was Re: REPOST: Re: Book "python programming patterns". anybody read this??) References: Message-ID: Terry Reedy: > It strikes me (and the Governor) as scandelous that so-called > professionals would spend so much time endlessly designing and never > produce anything that worked and was useful. Some problems are *really* hard. Diseconomies of scale doom some projects to failure. I bet the cause here was accomodation of legacy infrastructure. Neil From herveyw at dynamic-cast.com Tue Jan 1 21:16:12 2002 From: herveyw at dynamic-cast.com (Hervey Wilson) Date: Tue, 1 Jan 2002 12:16:12 -0800 Subject: "Safe" Embedded Python Message-ID: <3c32190d$1_2@news.nwlink.com> I am contemplating embedding Python in my application in order to support end-user scripting. Having done some initial investigation, I am happy with the functionality that I can expose but now I find myself concerned with safety / security, specifically I want to limit scripting activities to the core language features and the object model that my application exposes. Put another way, I don't want the scripts to be able to read / write to the hard-disk, open sockets and so on. Can anyone provide some tips / links on the viability of doing this and any implementation examples ? Thanks in advance, H. From gh_pythonlist at gmx.de Tue Jan 1 21:32:37 2002 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Tue, 1 Jan 2002 21:32:37 +0100 Subject: "Safe" Embedded Python In-Reply-To: <3c32190d$1_2@news.nwlink.com> References: <3c32190d$1_2@news.nwlink.com> Message-ID: <20020101203236.GA3112@lilith.hqd-internal> Le 01/01/02 ? 12:16, Hervey Wilson ?crivit: > I am contemplating embedding Python in my application in order to support end-user scripting. Having done some initial > investigation, I am happy with the functionality that I can expose but now I find myself concerned with safety / > security, specifically I want to limit scripting activities to the core language features and the object model that my > application exposes. Put another way, I don't want the scripts to be able to read / write to the hard-disk, open sockets > and so on. > > Can anyone provide some tips / links on the viability of doing this > and any implementation examples ? I've never done this myself, but I can give a few tips: The rexec module might offer most of what you need. You'll need to restrict the modules users can import and remove some builtins, like with: del __builtins__.__dict__['open'] The rexec module probably already offers this, I haven't checked. In the PostgreSQL source tree (http://www.postgresql.org/) you can find plpython, a module for implementing server-side Python procedures for the PostgreSQL database. I have seen it restricts the modules you can load. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From cliechti at gmx.net Wed Jan 2 01:45:52 2002 From: cliechti at gmx.net (Chris Liechti) Date: 2 Jan 2002 01:45:52 +0100 Subject: "Safe" Embedded Python References: <3c32190d$1_2@news.nwlink.com> Message-ID: Gerhard H?ring wrote in news:mailman.1009917181.18293.python-list at python.org: > Le 01/01/02 ? 12:16, Hervey Wilson ?crivit: >> I am contemplating embedding Python in my application in order to >> support end-user scripting. Having done some initial investigation, I >> am happy with the functionality that I can expose but now I find >> myself concerned with safety / security, specifically I want to limit >> scripting activities to the core language features and the object >> model that my application exposes. Put another way, I don't want the >> scripts to be able to read / write to the hard-disk, open sockets and >> so on. >> >> Can anyone provide some tips / links on the viability of doing this >> and any implementation examples ? > > I've never done this myself, but I can give a few tips: > > The rexec module might offer most of what you need. yes with rexec and bastion you can control what modules and classes are available to the client. you can write a open and import filter and let pass the files/modules you want and block on others. bastion protects your classes you want to expose to the client (e.g. real private attributes). > You'll need to restrict the modules users can import and remove some > builtins, like with: > > del __builtins__.__dict__['open'] there is only one __builtins__ and when you remove the open function not even the server can write files... better use rexec, its simpler and saver. > The rexec module probably already offers this, I haven't checked. > > In the PostgreSQL source tree (http://www.postgresql.org/) you can find > plpython, a module for implementing server-side Python procedures for > the PostgreSQL database. I have seen it restricts the modules you can > load. > > Gerhard -- Chris From matt at mondoinfo.com Tue Jan 1 22:00:20 2002 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Tue, 01 Jan 2002 21:00:20 GMT Subject: Beginner Tkinter Q.: how to re-pack a frame in place? References: <3C30CF3E.3020202@eschatek.com> Message-ID: On Mon, 31 Dec 2001 12:49:02 -0800, J B Bell wrote: Dear JB, >Hello all. Hello! >I'm new to Tkinter, but not Python. I've written a utility >dice-roller for an RPG and would like to GUIfy it. My main snag >right now is that I haven't been able to find docs on how one does a >re-draw in place. That is, at the simplest level, let's say I have a >frame with several text input widgets packed into it--I'd like to be >able to edit one of the input boxes, then hit a "re-sort" button and >have the fram they're in re-pack them in some kind of sorted order. >So if I had widgets saying, e.g., "1", "2", "3", and I changed the >"2" to a "5" and hit "Re-pack", the widget order would change, with >underlying variables preserved appropriately. Tkinter will let you unpack and repack widgets as much as you like. It's not completely clear from your description why that would be an advantage over moving the data around, but it's not too hard to do. I'll append a small example that does things both ways. Regards, Matt #!/usr/local/bin/python from Tkinter import * import random def labelsSortHelper(label1,label2): val1=int(label1.cget("text")) val2=int(label2.cget("text")) return cmp(val1,val2) class mainWin: def __init__(self,root): self.root=root random.seed() self.createWidgets() self.fillLabels() return None def createWidgets(self): self.labels1=[] f1=Frame(self.root) for count in range(3): l=Label(f1,width=5) l.pack(side=LEFT) self.labels1.append(l) f1.pack(side=TOP) self.labels2=[] f2=Frame(self.root) for count in range(3): l=Label(f2,width=5) l.pack(side=LEFT) self.labels2.append(l) f2.pack(side=TOP) b=Button(self.root,text="New values",command=self.fillLabels) b.pack(side=TOP) b=Button(self.root,text="Sort",command=self.sort) b.pack(side=TOP) return None def fillLabels(self): for l in self.labels1+self.labels2: l.configure(text=str(random.randrange(6))) return None def sort(self): valsList=[] for count in range(len(self.labels1)): valsList.append(int(self.labels1[count].cget("text"))) valsList.sort() for count in range(len(self.labels1)): self.labels1[count].configure(text=str(valsList[count])) tempLabels=[] for l in self.labels2: tempLabels.append(l) l.pack_forget() tempLabels.sort(labelsSortHelper) for l in tempLabels: l.pack(side=LEFT) self.labels2=tempLabels return None def main(): root=Tk() mainWin(root) root.mainloop() return None if __name__=="__main__": main() From nospam at mega-nerd.com Tue Jan 1 22:21:33 2002 From: nospam at mega-nerd.com (Erik de Castro Lopo) Date: Wed, 02 Jan 2002 08:21:33 +1100 Subject: Any colour ImageDraw examples? Message-ID: <3C32285D.6E6A9588@mega-nerd.com> Hi all, I'm trying to use ImageDraw to draw a colour image. Is this even possible? All the example code I find using http://groups.google.com seems to create monochrome images. TIA, Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam at mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "Don't hate the media. Become the media." - Jello Biafra From nospam at mega-nerd.com Tue Jan 1 22:39:51 2002 From: nospam at mega-nerd.com (Erik de Castro Lopo) Date: Wed, 02 Jan 2002 08:39:51 +1100 Subject: Any colour ImageDraw examples? References: <3C32285D.6E6A9588@mega-nerd.com> Message-ID: <3C322CA7.9B99270D@mega-nerd.com> Erik de Castro Lopo wrote: > > Hi all, > > I'm trying to use ImageDraw to draw a colour image. Is this even > possible? All the example code I find using http://groups.google.com > seems to create monochrome images. Typical. Soon as I post a question I find the answer: http://www.pythonware.com/products/pil/articles/creating-palette-images.htm Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam at mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "I contend that we are both atheists. I just believe in one fewer god than you do. When you understand why you dismiss all the other possible gods, you will understand why I dismiss yours." -- Stephen Roberts From chrisyeun at attbi.com Tue Jan 1 22:25:28 2002 From: chrisyeun at attbi.com (Chris Yeun) Date: 01 Jan 2002 13:25:28 -0800 Subject: Python2.1 ceval.c error...Please help. Message-ID: <1009920329.624.0.camel@bertha> Hello, I upgraded to the Debian Linux "Woody" versions of Squishdot 1.3.0-1, Zope 2.4.2-0.2, and Python 2.1.1-7. I'm receiving an error message when running Squishdot and trying to post a new article...the error on the server is is: python2.1: ../Python/ceval.c:687: eval_code2: Assertion `(stack_pointer - f->f_valuestack) <= f->f_stacksize' failed. The client receives a "Connection Refused" error from the web browser. Has anyone seen this error before? I'd like to submit a bug report and would appreciate which package I should submit the report to. Thanks, Chris. From skip at pobox.com Wed Jan 2 00:59:19 2002 From: skip at pobox.com (Skip Montanaro) Date: Tue, 1 Jan 2002 17:59:19 -0600 Subject: Python2.1 ceval.c error...Please help. In-Reply-To: <1009920329.624.0.camel@bertha> References: <1009920329.624.0.camel@bertha> Message-ID: <15410.19799.710243.916584@12-248-41-177.client.attbi.com> Chris> I upgraded to the Debian Linux "Woody" versions of Squishdot Chris> 1.3.0-1, Zope 2.4.2-0.2, and Python 2.1.1-7. I'm receiving an Chris> error message when running Squishdot and trying to post a new Chris> article...the error on the server is is: Chris> python2.1: ../Python/ceval.c:687: eval_code2: Assertion `(stack_pointer Chris> - f->f_valuestack) <= f->f_stacksize' failed. If you have access to a version of Python 2.1 compiled with -g, you can use this gdb user function to display the Python stack (stick it in your ~/.gdbinit file). It should help you narrow down the location of the problem. define ppystack while $pc < Py_Main || $pc > Py_GetArgcArgv if $pc > eval_frame && $pc < PyEval_EvalCodeEx set $__fn = PyString_AsString(co->co_filename) set $__n = PyString_AsString(co->co_name) printf "%s (%d): %s\n", $__fn, f->f_lineno, $__n end up-silently 1 end select-frame 0 end You will have to replace "eval_frame" with "eval_code2" and replace "PyEval_EvalCodeEx" with whatever function immediately follows eval_code2 in ceval.c (the above function names are correct for Python 2.2). -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From chrisyeun at attbi.com Tue Jan 1 22:27:02 2002 From: chrisyeun at attbi.com (chris) Date: Tue, 01 Jan 2002 21:27:02 GMT Subject: Python2.1. ceval.c error. Message-ID: Hello, I upgraded to the Debian Linux "Woody" versions of Squishdot 1.3.0-1, Zope 2.4.2-0.2, and Python 2.1.1-7. I'm receiving an error message when running Squishdot and trying to post a new article...the error on the server is is: python2.1: ../Python/ceval.c:687: eval_code2: Assertion `(stack_pointer - f->f_valuestack) <= f->f_stacksize' failed. The client receives a "Connection Refused" error from the web browser. Has anyone seen this error before? I'd like to submit a bug report and would appreciate which package I should submit the report to. Thanks, Chris. From fgranger at alussinan.org Tue Jan 1 22:37:53 2002 From: fgranger at alussinan.org (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Tue, 1 Jan 2002 22:37:53 +0100 Subject: REPOST: Re: A new forum is up! Q: what means nntp References: <40dbad98.0112262238.73fc14f9@posting.google.com> <3C2B941D.B1E45AA5@htp-tel.de> <1$--$$_----_---$_$@news.noc.cabal.int> Message-ID: <1f5cglh.1ykt7g31hhcijaN%fgranger@alussinan.org> Aahz Maruch wrote: > In article , > DeepBleu wrote: > > > >NNTP is an internet protocol like SMTP, POP3 and HTTP for > >communication. Also, it is the oldest one and it used to be the most > >instructive before AOL hit the scene along with the 'gold rush' :) > > Really? NNTP is older than SMTP? Mind telling me where you found that > little gem? Interresting to dig into the History... SMTP RFC 821 aug 82 NNTP RFC 977 feb 86 -- "Things should be made as simple as possible, but not simpler." Albert Einstein, apparently in his "Autobiographical notes" Cit? par Alex Martelli From sholden at holdenweb.com Tue Jan 1 23:30:39 2002 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 1 Jan 2002 17:30:39 -0500 Subject: Python Popularity: Questions and Comments References: Message-ID: wrote in message news:mailman.1009474351.12838.python-list at python.org... > On Thu, 27 Dec 2001, A. Keyton Weissinger wrote: > > > If it is as "X" as we all say/know/feel-in-our-hearts that it is, why is > > there so very little real commercial appeal? Why are there not industrial > > strength application servers being based on Python? Why are there not big > > public companies trying to sell products that improve upon Python in all its > > Python-ness? Why is company X not moving all their dreck VB/COBOL/PL/1/etc > > code onto Python instead of investing the huge amount of > > money/time/resources into moving it to Java? > > To me, the fact that so many people are moving to Java at all means that a > lot of times those decisions have little to do with technology and lots to > do with hype (more favorably termed "momentum"). IMO Python *is* going the > direction you hope, and it is getting there at the right pace. > [ ... ] Look at Unix, look at TCP/IP. Both fundamental technologies in supporting today's computing environment, both approximating thirty years old, both not really starting to achieve "market dominance" until they were twenty years down their development tracks. It simply takes a long time for a technology to mature to mass usability. ... and what do Microsoft have that's twenty years old and worth keeping? ... I personally think that Python will continue to rise in popularity, which is why I chose to spend most of last year's spare time writing a book about it. But we should also remember that no one language will ever edge all the others out, and Python's *real* strength is its ability to integrate smoothly into so many operating environments. Idealy it's cross-platform interoperability we should be aiming at if we want Python to continue to survive and grow. regards Steve -- http://www.holdenweb.com/ From phd at phd.pp.ru Tue Jan 1 23:49:25 2002 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 2 Jan 2002 01:49:25 +0300 Subject: The (superlow)quality of software (was Re: Python Popularity: Questions and Comments) In-Reply-To: ; from sholden@holdenweb.com on Tue, Jan 01, 2002 at 05:30:39PM -0500 References: Message-ID: <20020102014925.A8298@phd.pp.ru> On Tue, Jan 01, 2002 at 05:30:39PM -0500, Steve Holden wrote: > Look at Unix, look at TCP/IP. Both fundamental technologies in supporting > today's computing environment, both approximating thirty years old, both not > really starting to achieve "market dominance" until they were twenty years > down their development tracks. It simply takes a long time for a technology > to mature to mass usability. Neither UNIX nor TCP/IP are suitable for mass use. They are here by accident, not because they are mature. Just a few points. UNIX is old and outdated; there are many ideas that still does not appear in the UNIX world; UNIX has usability problems; UNIX lacks standard desktop and office suite. TCP/IP is vulnerable to many kinds of attacks; it lacks QoS (bandwidth-on-demand, e.g., or guaranteed connectivity). (I am playing a devil advocate here, of course.) > ... and what do Microsoft have that's twenty years old and worth > keeping? ... The most important thing - the name. (If you follow my posts you know I hate it, because I am afraid of its power. But it's still *the* name). Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From logiplexsoftware at earthlink.net Wed Jan 2 00:41:25 2002 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Tue, 1 Jan 2002 15:41:25 -0800 Subject: The (superlow)quality of software (was Re: Python Popularity: Questions and Comments) In-Reply-To: <20020102014925.A8298@phd.pp.ru> References: <20020102014925.A8298@phd.pp.ru> Message-ID: <20020101154125.10237cfe.logiplexsoftware@earthlink.net> On Wed, 2 Jan 2002 01:49:25 +0300 Oleg Broytmann wrote: > Neither UNIX nor TCP/IP are suitable for mass use. They are here by > accident, not because they are mature. > Just a few points. > UNIX is old and outdated; there are many ideas that still does not > appear in the UNIX world; UNIX has usability problems; UNIX lacks standard > desktop and office suite. There is a fundamental difference in the approaches of Unix and Windows that people seem to disregard: Unix was never meant as a personal computer OS. Windows was never meant to work in a network environment with multiple users. They are growing towards each other (and each is still superior in it's target environment) but there is still a long way to go before they can really be considered direct competitors. This is rapidly changing (Unix vendors adopting GNOME, MS adopting TCP/IP [and giving up on the idea of MSN replacing the Internet ;-) ] ), but at the moment, they each fill a different need. > TCP/IP is vulnerable to many kinds of attacks; it lacks QoS > (bandwidth-on-demand, e.g., or guaranteed connectivity). > (I am playing a devil advocate here, of course.) Is there a better alternative? NETBEUI, IPX, SNA... Appletalk? These show their shortcomings quickly on anything outside a LAN. Doesn't IPv6 support QoS? > > ... and what do Microsoft have that's twenty years old and worth > > keeping? ... > > The most important thing - the name. (If you follow my posts you know I > hate it, because I am afraid of its power. But it's still *the* name). Agreed. However, that name means two different things to two different groups of people: to Microsoft's target audience it means ease-of-use and features (and unfortunately, they have a larger target audience); to people who manage networks it means reliability issues and inflexibility. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From phd at phd.pp.ru Wed Jan 2 02:15:04 2002 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 2 Jan 2002 04:15:04 +0300 Subject: The (superlow)quality of software (was Re: Python Popularity: Questions and Comments) In-Reply-To: <20020101154125.10237cfe.logiplexsoftware@earthlink.net>; from logiplexsoftware@earthlink.net on Tue, Jan 01, 2002 at 03:41:25PM -0800 References: <20020102014925.A8298@phd.pp.ru> <20020101154125.10237cfe.logiplexsoftware@earthlink.net> Message-ID: <20020102041504.A9032@phd.pp.ru> On Tue, Jan 01, 2002 at 03:41:25PM -0800, Cliff Wells wrote: > > TCP/IP is vulnerable to many kinds of attacks; it lacks QoS > > (bandwidth-on-demand, e.g., or guaranteed connectivity). > > (I am playing a devil advocate here, of course.) > > Is there a better alternative? NETBEUI, IPX, SNA... Appletalk? That was exactly my point - TCP/IP was not mature.... but other alternatives was even worse. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From db3l at fitlinxx.com Wed Jan 2 03:56:41 2002 From: db3l at fitlinxx.com (David Bolen) Date: 01 Jan 2002 21:56:41 -0500 Subject: The (superlow)quality of software (was Re: Python Popularity: Questions and Comments) References: <20020102014925.A8298@phd.pp.ru> <20020101154125.10237cfe.logiplexsoftware@earthlink.net> Message-ID: Oleg Broytmann writes: > On Tue, Jan 01, 2002 at 03:41:25PM -0800, Cliff Wells wrote: > > > TCP/IP is vulnerable to many kinds of attacks; it lacks QoS > > > (bandwidth-on-demand, e.g., or guaranteed connectivity). > > > (I am playing a devil advocate here, of course.) > > > > Is there a better alternative? NETBEUI, IPX, SNA... Appletalk? > > That was exactly my point - TCP/IP was not mature.... but other > alternatives was even worse. I'd disagree that having an exposure or missing a feature would make a protocol "immature". TCP/IP as a protocol family has been stable and unchanging for a long time now, and I would argue meets its original goals. There are many very solid implementations, including support for specific implementation optimizations that are well known and commonly implemented. I think thats more than enough to consider a protocol stack could be considered "mature". Whether or not the protocol was designed to withstand the current state of the art for attacks, or whether it has all the modern desirable features is an orthogonal question - one of applicability and not of maturity. -- -- 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 phd at phd.pp.ru Wed Jan 2 15:46:58 2002 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 2 Jan 2002 17:46:58 +0300 Subject: The (superlow)quality of software (was Re: Python Popularity: Questions and Comments) In-Reply-To: ; from db3l@fitlinxx.com on Tue, Jan 01, 2002 at 09:56:41PM -0500 References: <20020102014925.A8298@phd.pp.ru> <20020101154125.10237cfe.logiplexsoftware@earthlink.net> Message-ID: <20020102174658.H12844@phd.pp.ru> On Tue, Jan 01, 2002 at 09:56:41PM -0500, David Bolen wrote: > > That was exactly my point - TCP/IP was not mature.... but other > > alternatives was even worse. > > I'd disagree that having an exposure or missing a feature would make a > protocol "immature". TCP/IP as a protocol family has been stable and > unchanging for a long time now, and I would argue meets its original > goals. There are many very solid implementations, including support > for specific implementation optimizations that are well known and > commonly implemented. I think thats more than enough to consider a > protocol stack could be considered "mature". > > Whether or not the protocol was designed to withstand the current > state of the art for attacks, or whether it has all the modern > desirable features is an orthogonal question - one of applicability > and not of maturity. I agree to change my wording: "applicability" instead of "maturity". My original point was that: UNIX and TCP/IP (and all that) are here not because of quality, but... I don't know why, really. Look, what is better: UNIX or (insert your OS here)? Pascal or C? x86 or 68000? Perl or Python? Still Perl is more popular than Python, x86 is more popular that any processor, and (insert that hateful OS) is more popular than UNIX. It seems that society and especially business choose not the best, but worst alternative. So if we want to make Python more popular we should make it worse (well, I am kidding... to some extent). Actually I personnaly don't want to increase Python and Zope popularity beyond some bounds (this time I am not kidding). Popularity is the hallmark of mediocrity. And what is worse, popularity will (actually, already's) draw windoze lamers with all their idiotic questions (who needs to read the FAQs and docs, really?), and the best newsgroup comp.lang.python starts looking more and more like comp.lang.p*.misc. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From mwh at python.net Thu Jan 3 11:36:13 2002 From: mwh at python.net (Michael Hudson) Date: Thu, 3 Jan 2002 10:36:13 GMT Subject: The (superlow)quality of software (was Re: Python Popularity: Questions and Comments) References: <20020102014925.A8298@phd.pp.ru> <20020101154125.10237cfe.logiplexsoftware@earthlink.net> Message-ID: Oleg Broytmann writes: > My original point was that: UNIX and TCP/IP (and all that) are here not > because of quality, but... I don't know why, really. Look, what is better: > UNIX or (insert your OS here)? Pascal or C? x86 or 68000? Perl or Python? > Still Perl is more popular than Python, x86 is more popular that any > processor, and (insert that hateful OS) is more popular than UNIX. > It seems that society and especially business choose not the best, but > worst alternative. So if we want to make Python more popular we should make > it worse (well, I am kidding... to some extent). > > Actually I personnaly don't want to increase Python and Zope popularity > beyond some bounds (this time I am not kidding). Popularity is the hallmark > of mediocrity. And what is worse, popularity will (actually, already's) > draw windoze lamers with all their idiotic questions (who needs to read the > FAQs and docs, really?), and the best newsgroup comp.lang.python starts > looking more and more like comp.lang.p*.misc. You have read Richard Gabriel's "Worse is Better" paper, haven't you? Cheers, M. From phd at phd.pp.ru Thu Jan 3 13:53:24 2002 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 3 Jan 2002 15:53:24 +0300 Subject: The (superlow)quality of software (was Re: Python Popularity: Questions and Comments) In-Reply-To: ; from mwh@python.net on Thu, Jan 03, 2002 at 10:36:13AM +0000 References: <20020102014925.A8298@phd.pp.ru> <20020101154125.10237cfe.logiplexsoftware@earthlink.net> Message-ID: <20020103155324.D20504@phd.pp.ru> On Thu, Jan 03, 2002 at 10:36:13AM +0000, Michael Hudson wrote: > You have read Richard Gabriel's "Worse is Better" paper, haven't you? Certainly. First time I read it many years ago, when I've just connected to the Net, my English was pretty bad at that time. Later I reread it few times to understand it better. The ideas are arguable, of course, but deniable. :) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From phd at phd.pp.ru Thu Jan 3 14:32:52 2002 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 3 Jan 2002 16:32:52 +0300 Subject: The (superlow)quality of software (was Re: Python Popularity: Questions and Comments) In-Reply-To: <20020103155324.D20504@phd.pp.ru>; from phd@phd.pp.ru on Thu, Jan 03, 2002 at 03:53:24PM +0300 References: <20020102014925.A8298@phd.pp.ru> <20020101154125.10237cfe.logiplexsoftware@earthlink.net> <20020103155324.D20504@phd.pp.ru> Message-ID: <20020103163252.B21186@phd.pp.ru> On Thu, Jan 03, 2002 at 03:53:24PM +0300, Oleg Broytmann wrote: > times to understand it better. The ideas are arguable, of course, but > deniable. :) ...but NOT deniable... of course :) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From aleax at aleax.it Thu Jan 3 14:13:12 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 3 Jan 2002 14:13:12 +0100 Subject: The (superlow)quality of software (was Re: Python Popularity: Questions and Comments) References: <20020102014925.A8298@phd.pp.ru> <20020101154125.10237cfe.logiplexsoftware@earthlink.net> Message-ID: "Oleg Broytmann" wrote in message news:mailman.1010062574.6509.python-list at python.org... > On Thu, Jan 03, 2002 at 10:36:13AM +0000, Michael Hudson wrote: > > You have read Richard Gabriel's "Worse is Better" paper, haven't you? > > Certainly. First time I read it many years ago, when I've just connected > to the Net, my English was pretty bad at that time. Later I reread it few > times to understand it better. The ideas are arguable, of course, but > deniable. :) Gabriel himself has done an excellent job of denying (and reaffirming, and redenying, and ...:-) those ideas. The only thing they aren't, is *ignorable* -0- you do have to wrestle with them, if you agree that "the unexamined life is not worth living" (Socrates). Alex From tjreedy at home.com Thu Jan 3 18:07:55 2002 From: tjreedy at home.com (Terry Reedy) Date: Thu, 03 Jan 2002 17:07:55 GMT Subject: The (superlow)quality of software (was Re: Python Popularity: Questions and Comments) References: <20020102014925.A8298@phd.pp.ru> <20020101154125.10237cfe.logiplexsoftware@earthlink.net> Message-ID: > You have read Richard Gabriel's "Worse is Better" paper, haven't you? This supposedly lives at www.dreamsongs.com/WorseIsBetter.html I did not get any response today but did get Google's cached version at http://www.google.com/search?q=cache:EIBVwH4VKlo:www.dreamsongs.com/Wo rseIsBetter.html+%22Richard+Gabriel%22+Better+Worse&hl=en From chrishbarker at attbi.com Fri Jan 4 23:21:51 2002 From: chrishbarker at attbi.com (Chris Barker) Date: Fri, 04 Jan 2002 14:21:51 -0800 Subject: The (superlow)quality of software (was Re: Python Popularity: Questions and Comments) References: <20020102014925.A8298@phd.pp.ru> Message-ID: <3C362AFF.52E1870D@attbi.com> Cliff Wells wrote: > Oleg Broytmann wrote: > UNIX has usability problems; UNIX lacks > standard > > desktop and office suite. There is a big distinction between technical merit, and marketing/market issues. There is no reason that *nix is not technically capable of being as (or more) usable thatn windows (Maybe Apple will do it!). The lack of a "standard" desktop or ofice suite is also about the market, and isn some ways it is a good thing. Having a "standard" be a propriatary product controlled by one company is not a good way to develop inovative new technology. > > hate it, because I am afraid of its power. But it's still *the* name). > > Agreed. However, that name means two different things to two different > groups of people: to Microsoft's target audience it means ease-of-use and > features (and unfortunately, they have a larger target audience); to people > who manage networks it means reliability issues and inflexibility. You forgot most people: It is what "everyone" uses. I doubt most Windows users even knew they had a choice, or at least not a viable one, except maybe the Macintosh. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at attbi.net --- --- --- ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From bbollenbach at home.com Wed Jan 2 04:45:51 2002 From: bbollenbach at home.com (Brad Bollenbach) Date: Wed, 02 Jan 2002 03:45:51 GMT Subject: Python Popularity: Questions and Comments References: Message-ID: "Steve Holden" wrote in message news:HOqY7.25744$a56.10288 at atlpnn01.usenetserver.com... > wrote in message > news:mailman.1009474351.12838.python-list at python.org... > > On Thu, 27 Dec 2001, A. Keyton Weissinger wrote: > > > > > If it is as "X" as we all say/know/feel-in-our-hearts that it is, why is > > > there so very little real commercial appeal? Why are there not > industrial > > > strength application servers being based on Python? Why are there not > big > > > public companies trying to sell products that improve upon Python in all > its > > > Python-ness? Why is company X not moving all their dreck > VB/COBOL/PL/1/etc > > > code onto Python instead of investing the huge amount of > > > money/time/resources into moving it to Java? > > > > To me, the fact that so many people are moving to Java at all means that a > > lot of times those decisions have little to do with technology and lots to > > do with hype (more favorably termed "momentum"). IMO Python *is* going the > > direction you hope, and it is getting there at the right pace. I think Steve is giving too much credit to those who make the decisions. It's not so much about "hype" as it is that (truly and sadly) the people that make the most important decisions about which tools will be used to construct a given piece of software in a company are often the ones that know the least about them (I come from a Powerbuilder shop, I know this very, very well). In short, they're pretty stupid. See http://www.dilbert.com for examples of that. If the decisions were put in the hands of people that knew how to make them, Python would be considerably more popular (I personally would use it in my day job if I were /allowed/, and I do for small make-my-life-easier types of programs), as would Perl, and Java would probably still just be thought of as a different kind of coffee. But, just because you don't use it at work, doesn't mean it can't make your life easier at home and for playing around. Use Python because it makes YOUR life easier, not because somebody told you it was supposed to. Popularity is of little concern when one desires to be lazy (who cares if everybody's using Java, if I know that I want to use Python because it's a lot easier for people with human-sized brains to use?). If you're concerned about popularity of a language, this suggests that you're also concerned about marketability. If this is true, then it goes without saying that you'll do much better to invest your time learning Java or Visual Basic. (Search www.dice.com for salaries being offered for programmers in these languages to see what I mean. There are a few orders of magnitude more positions available for a VB or Java programmer, than for a Python programmer.) Brad From sholden at holdenweb.com Wed Jan 2 11:23:10 2002 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 2 Jan 2002 05:23:10 -0500 Subject: Python Popularity: Questions and Comments References: Message-ID: "Brad Bollenbach" wrote in message news:PnvY7.18562$U67.2001222 at news3.calgary.shaw.ca... > "Steve Holden" wrote in message [ ... ] > I think Steve is giving too much credit to those who make the decisions. > It's not so much about "hype" as it is that (truly and sadly) the people > that make the most important decisions about which tools will be used to > construct a given piece of software in a company are often the ones that > know the least about them (I come from a Powerbuilder shop, I know this > very, very well). > Just to keep the record straight, nothing you quoted could be attributed to me! You seemed to be responding to the same postings as I did. Having struggled myself with PowerBuilder's "object-oriented" development environment, by the way, I have sympathy for your plight. > In short, they're pretty stupid. See http://www.dilbert.com for examples of > that. > > If the decisions were put in the hands of people that knew how to make them, > Python would be considerably more popular (I personally would use it in my > day job if I were /allowed/, and I do for small make-my-life-easier types of > programs), as would Perl, and Java would probably still just be thought of > as a different kind of coffee. > ...and if wishes were horses then beggars would ride. Sadly this does not change the fundamental nature of the world. Sun's product quality is somewhat better than Microsoft's, but they failed to persuade the world of the superiority of NeWS, for example. They messed up the Java playing field by screwing with the "standardization" process, successfully suing Microsoft (who have responded by removing Java support from XP, and bringing out C#) and turning the language into a huge API. > But, just because you don't use it at work, doesn't mean it can't make your > life easier at home and for playing around. Use Python because it makes YOUR > life easier, not because somebody told you it was supposed to. Popularity is > of little concern when one desires to be lazy (who cares if everybody's > using Java, if I know that I want to use Python because it's a lot easier > for people with human-sized brains to use?). > Yup. "Java is the COBOL of the object-oriented world" (tm). > If you're concerned about popularity of a language, this suggests that > you're also concerned about marketability. If this is true, then it goes > without saying that you'll do much better to invest your time learning Java > or Visual Basic. (Search www.dice.com for salaries being offered for > programmers in these languages to see what I mean. There are a few orders of > magnitude more positions available for a VB or Java programmer, than for a > Python programmer.) > I figure Python's popularity is due for a real rise over the next two years. This will be both a good and a bad thing, and *does* cause me some concern: I will be sorry when comp.lang.python stops being the low-noise group it has been to date, but I fear this may be inevitable. I have a feeling that most of Python's new users will start to use it to modify existing Python code which has been provided as a part of key applications environments (such as Red Hat's Anaconda, or Zope systems). But ultimately, as I said at the start, what you responded to wasn't what *I* said :-) regards Steve -- http://www.holdenweb.com/ From mats at laplaza.org Mon Jan 7 18:59:54 2002 From: mats at laplaza.org (Mats Wichmann) Date: Mon, 07 Jan 2002 17:59:54 GMT Subject: Python Popularity: Questions and Comments References: Message-ID: <3c39e1d1.1908324@news.laplaza.org> On Tue, 1 Jan 2002 17:30:39 -0500, "Steve Holden" wrote: :I personally think that Python will continue to rise in popularity, which is :why I chose to spend most of last year's spare time writing a book about it. You had spare time? :-) Mats Wichmann From madmax at express.ru Tue Jan 1 23:50:29 2002 From: madmax at express.ru (Maxes) Date: 1 Jan 2002 14:50:29 -0800 Subject: perl: ${$i) , python: ? Message-ID: Hi all. How to create variables with dynamic names ? simple example on perl: #! /usr/bin/perl @kl=qw(t1 t2); foreach $i (@kl) { ${$i}=3; } print "$t1 $t2\n"; #result would be "3 3" b.r. Kozin Maxim From wurmy at earthlink.net Wed Jan 2 00:09:11 2002 From: wurmy at earthlink.net (Hans Nowak) Date: Tue, 01 Jan 2002 23:09:11 GMT Subject: perl: ${$i) , python: ? References: Message-ID: <3C32404A.9F651388@earthlink.net> Maxes wrote: > > Hi all. > > How to create variables with dynamic names ? > simple example on perl: > #! /usr/bin/perl > @kl=qw(t1 t2); > foreach $i (@kl) { > ${$i}=3; > } > print "$t1 $t2\n"; > > #result would be "3 3" It's questionable whether this is good coding practice, but the Pythonic equivalent would be something like >>> kl = ["t1", "t2"] >>> for i in kl: exec "%s = 3" % (i) >>> print t1, t2 3 3 >>> Or you can mess with the locals() or globals() dictionaries, but this is not guaranteed to work. --Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA==\n') # decode for email address ;-) Site:: http://www.awaretek.com/nowak/ From tim at vegeta.ath.cx Wed Jan 2 21:06:47 2002 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 02 Jan 2002 20:06:47 GMT Subject: perl: ${$i) , python: ? References: <3C32404A.9F651388@earthlink.net> Message-ID: Hans Nowak graced us by uttering: > Maxes wrote: >> How to create variables with dynamic names ? [ snip Perl code using symbolic references ] > > It's questionable whether this is good coding practice, but > the Pythonic equivalent would be something like [ snip Python code using exec ] This is pretty much the reason symbolic references are so vehemently discouraged in the Perl community. symrefs date back to pre-ref perl that didn't support hardrefs like Perl5 does. exec in Python (like eval in both Python and Perl) are not to be taken lightly either. Both symrefs and the exec/eval pair are alleged to be valuable tools, but there is nearly always a solution that 1) doesn't need them and 2) are therefore much safer. I don't imagine the OP's case is any different. In any case, abuse (by programmer or end user) can lead to obscure bugs and/or security issues. They should all be used with caution. Tim Hammerquist -- The two surviving chocolate people copulate desperately, losing themselves in a melting frenzy of lust, spending the last of their brief, borrowed lives in a spasm of raspberry cream and fear. -- Narrator, The Sandman From richardjones at optushome.com.au Wed Jan 2 00:12:18 2002 From: richardjones at optushome.com.au (Richard Jones) Date: Wed, 2 Jan 2002 10:12:18 +1100 Subject: perl: ${$i) , python: ? In-Reply-To: References: Message-ID: <200201012312.g01NCIc18239@mail016.syd.optusnet.com.au> On Wed, 2 Jan 2002 09:50, Maxes wrote: > Hi all. > > How to create variables with dynamic names ? > simple example on perl: > #! /usr/bin/perl > @kl=qw(t1 t2); > foreach $i (@kl) { > ${$i}=3; > } > print "$t1 $t2\n"; > > #result would be "3 3" Is there a reason why you can't put the values in a storage mechanism like a dictionary, rather than stuffing them straight into the current variable scope? >>> d = {} >>> keys = "t1 t2".split() >>> for key in keys: ... d[key] = 3 ... >>> print "%(t1)s %(t2)s"%d 3 3 >>> If you _really_ want to do this, and in my opinion it's yecchy, you can. Use locals() to ge a handle on the local variables dictionary, and play with that... [... continuing on from before] >>> d = locals() >>> for key in keys: ... d[key] = 3 ... >>> print t1, t2 3 3 >>> Again, I don't recommend this approach because it's ugly, potentially dangerous, ... Richard From dalke at dalkescientific.com Wed Jan 2 19:32:24 2002 From: dalke at dalkescientific.com (Andrew Dalke) Date: Wed, 2 Jan 2002 11:32:24 -0700 Subject: perl: ${$i) , python: ? References: Message-ID: Richard Jones: >If you _really_ want to do this, and in my opinion it's yecchy, >you can. Use locals() to ge a handle on the local variables >dictionary, and play with that... The dictionary returned from locals() is not guaranteed to affect the local variables. http://www.python.org/doc/current/lib/built-in-funcs.html ] locals() ] Return a dictionary representing the current local symbol ] table. Warning: The contents of this dictionary should not ] be modified; changes may not affect the values of local ] variables used by the interpreter. Changing globals is allowed. Hans Nowak said to use 'exec' > exec "%s = 3" % (i) ... > Or you can mess with the locals() or globals() dictionaries, > but this is not guaranteed to work. It's exactly as guaranteed to work as exec: Andrew dalke at dalkescientific.com From amichail at cse.unsw.edu.au Wed Jan 2 00:41:39 2002 From: amichail at cse.unsw.edu.au (Amir Michail) Date: 1 Jan 2002 15:41:39 -0800 Subject: anydbm is slow Message-ID: <1010a26.0201011541.6405048f@posting.google.com> Hi, I'm trying to write out a large database file using anydbm. However, it's quite slow. Writing out a 200 meg file can take hours. In fact, I do most of the work using an internal map and write out that map at the end since I thought this would be faster. (I have lots of memory.) However, it's still very slow. Any hints? Amir From skip at pobox.com Wed Jan 2 01:10:17 2002 From: skip at pobox.com (Skip Montanaro) Date: Tue, 1 Jan 2002 18:10:17 -0600 Subject: anydbm is slow In-Reply-To: <1010a26.0201011541.6405048f@posting.google.com> References: <1010a26.0201011541.6405048f@posting.google.com> Message-ID: <15410.20457.238062.975835@12-248-41-177.client.attbi.com> Amir> I'm trying to write out a large database file using anydbm. Amir> However, it's quite slow. Writing out a 200 meg file can take Amir> hours. Amir> In fact, I do most of the work using an internal map and write out Amir> that map at the end since I thought this would be faster. (I have Amir> lots of memory.) However, it's still very slow. Amir> Any hints? What underlying db module does anydbm use? >>> import anydbm >>> anydbm._defaultmod If it returns the dumbdbm module, you'll have a good idea where the problem lies. On the other hand, writing out a 200meg file is going to take awhile. The underlying db package probably has to do quite a bit of shuffling. If you're accessing a relatively small number of entries in the db file, you'd probably be better off letting the underlying library cache things for you. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From amichail at cse.unsw.edu.au Wed Jan 2 01:19:24 2002 From: amichail at cse.unsw.edu.au (Amir Michail) Date: Wed, 2 Jan 2002 11:19:24 +1100 Subject: anydbm is slow In-Reply-To: <15410.20457.238062.975835@12-248-41-177.client.attbi.com> References: <1010a26.0201011541.6405048f@posting.google.com> <15410.20457.238062.975835@12-248-41-177.client.attbi.com> Message-ID: <1020102001924.30486@cse.unsw.edu.au> On Wed, 2 Jan 2002 11:10, Skip Montanaro wrote: > Amir> I'm trying to write out a large database file using anydbm. > Amir> However, it's quite slow. Writing out a 200 meg file can take > Amir> hours. > > Amir> In fact, I do most of the work using an internal map and write > out Amir> that map at the end since I thought this would be faster. (I > have Amir> lots of memory.) However, it's still very slow. > > Amir> Any hints? > > What underlying db module does anydbm use? > > >>> import anydbm > >>> anydbm._defaultmod > > Hi, It returns dbhash from '/usr/lib/python2.1/dbhash.pyc'. Perhaps I should use a different db package? The data consists of an enormous number of keys and relatively short data strings. Amir > > If it returns the dumbdbm module, you'll have a good idea where the problem > lies. On the other hand, writing out a 200meg file is going to take > awhile. The underlying db package probably has to do quite a bit of > shuffling. > > If you're accessing a relatively small number of entries in the db file, > you'd probably be better off letting the underlying library cache things > for you. From skip at pobox.com Wed Jan 2 04:12:29 2002 From: skip at pobox.com (Skip Montanaro) Date: Tue, 1 Jan 2002 21:12:29 -0600 Subject: anydbm is slow In-Reply-To: <1020102001924.30486@cse.unsw.edu.au> References: <1010a26.0201011541.6405048f@posting.google.com> <15410.20457.238062.975835@12-248-41-177.client.attbi.com> <1020102001924.30486@cse.unsw.edu.au> Message-ID: <15410.31389.618417.965618@12-248-41-177.client.attbi.com> >> What underlying db module does anydbm use? Amir> It returns dbhash from '/usr/lib/python2.1/dbhash.pyc'. Amir> Perhaps I should use a different db package? The data consists of Amir> an enormous number of keys and relatively short data strings. I doubt you'll find anything faster. I think you need to consider whether you should be writing the entire db at exit or not. What sort of data access pattern do you have? I still think you might find it better to simply access the data directly from the database. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From amichail at cse.unsw.edu.au Wed Jan 2 05:22:04 2002 From: amichail at cse.unsw.edu.au (Amir Michail) Date: Wed, 2 Jan 2002 15:22:04 +1100 Subject: anydbm is slow In-Reply-To: <15410.31389.618417.965618@12-248-41-177.client.attbi.com> References: <1010a26.0201011541.6405048f@posting.google.com> <1020102001924.30486@cse.unsw.edu.au> <15410.31389.618417.965618@12-248-41-177.client.attbi.com> Message-ID: <1020102042204.509@cse.unsw.edu.au> On Wed, 2 Jan 2002 14:12, Skip Montanaro wrote: > >> What underlying db module does anydbm use? > > Amir> It returns dbhash from '/usr/lib/python2.1/dbhash.pyc'. > > Amir> Perhaps I should use a different db package? The data consists > of Amir> an enormous number of keys and relatively short data strings. > > I doubt you'll find anything faster. I think you need to consider whether > you should be writing the entire db at exit or not. What sort of data > access pattern do you have? I still think you might find it better to > simply access the data directly from the database. Hi, The program, GUISearch, is not incremental in that way. It just analyzes source code and generates databases. The databases are not written to after that. Amir From jafo-pythonlist at tummy.com Thu Jan 3 16:07:45 2002 From: jafo-pythonlist at tummy.com (Sean Reifschneider) Date: Thu, 3 Jan 2002 08:07:45 -0700 Subject: anydbm is slow In-Reply-To: <1020102001924.30486@cse.unsw.edu.au>; from amichail@cse.unsw.edu.au on Wed, Jan 02, 2002 at 11:19:24AM +1100 References: <1010a26.0201011541.6405048f@posting.google.com> <15410.20457.238062.975835@12-248-41-177.client.attbi.com> <1020102001924.30486@cse.unsw.edu.au> Message-ID: <20020103080745.B22224@tummy.com> On Wed, Jan 02, 2002 at 11:19:24AM +1100, Amir Michail wrote: >It returns dbhash from '/usr/lib/python2.1/dbhash.pyc'. > >Perhaps I should use a different db package? The data consists >of an enormous number of keys and relatively short data strings. I used anydbm for radiusContext and in general it worked pretty well. I didn't consider it very slow, and it's not unusual for it to be dealing with several hundred megabytes to over 1GB of data. It stores a fair bit of payload for every key, though. One thing I did find was that letting anydbm pick the dbm module, which I eventually found would, after inserting a lot of elements, generate an exception on insertion. It, unfortunately, wasn't very reliable and I never ended up tracking it down. I did end up switching to gdbm, which solved the problem. You can see what I did by looking at the code for a recent radiusContext at ftp://ftp.tummy.com/pub/tummy/radiusContext/ Sean -- The day that Linux invades the desktop market is the day that I start believing in people again. Sean Reifschneider, Inimitably Superfluous tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python From skip at pobox.com Thu Jan 3 17:21:33 2002 From: skip at pobox.com (Skip Montanaro) Date: Thu, 3 Jan 2002 10:21:33 -0600 Subject: anydbm is slow In-Reply-To: <20020103080745.B22224@tummy.com> References: <1010a26.0201011541.6405048f@posting.google.com> <15410.20457.238062.975835@12-248-41-177.client.attbi.com> <1020102001924.30486@cse.unsw.edu.au> <20020103080745.B22224@tummy.com> Message-ID: <15412.34061.237517.594489@12-248-41-177.client.attbi.com> Sean> One thing I did find was that letting anydbm pick the dbm module, Sean> which I eventually found would, after inserting a lot of elements, Sean> generate an exception on insertion. It, unfortunately, wasn't Sean> very reliable and I never ended up tracking it down. I did end up Sean> switching to gdbm, which solved the problem. Could it have perhaps been choosing bsddb and you had Berkeley DB 1.x installed? It had serious bugs in the hash implementation. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From amichail at cse.unsw.edu.au Thu Jan 3 22:13:23 2002 From: amichail at cse.unsw.edu.au (Amir Michail) Date: Fri, 4 Jan 2002 08:13:23 +1100 Subject: anydbm is slow In-Reply-To: <20020103080745.B22224@tummy.com> References: <1010a26.0201011541.6405048f@posting.google.com> <1020102001924.30486@cse.unsw.edu.au> <20020103080745.B22224@tummy.com> Message-ID: <1020103211323.11384@cse.unsw.edu.au> Hi, After more careful examination of my code, the bottleneck turned out to be elsewhere. Sorry about the misleading statement on anydbm! Amir On Fri, 4 Jan 2002 02:07, Sean Reifschneider wrote: > On Wed, Jan 02, 2002 at 11:19:24AM +1100, Amir Michail wrote: > >It returns dbhash from '/usr/lib/python2.1/dbhash.pyc'. > > > >Perhaps I should use a different db package? The data consists > >of an enormous number of keys and relatively short data strings. > > I used anydbm for radiusContext and in general it worked pretty well. > I didn't consider it very slow, and it's not unusual for it to be dealing > with several hundred megabytes to over 1GB of data. It stores a fair bit > of payload for every key, though. > > One thing I did find was that letting anydbm pick the dbm module, which > I eventually found would, after inserting a lot of elements, generate an > exception on insertion. It, unfortunately, wasn't very reliable and I > never ended up tracking it down. I did end up switching to gdbm, which > solved the problem. > > You can see what I did by looking at the code for a recent radiusContext at > ftp://ftp.tummy.com/pub/tummy/radiusContext/ > > Sean From laurent.szyster at q-survey.be Wed Jan 2 15:42:15 2002 From: laurent.szyster at q-survey.be (Laurent Szyster) Date: Wed, 02 Jan 2002 15:42:15 +0100 Subject: anydbm is slow References: <1010a26.0201011541.6405048f@posting.google.com> Message-ID: <3C331C47.E4B3AC1D@q-survey.be> Amir Michail wrote: > > Hi, > > I'm trying to write out a large database file using anydbm. > However, it's quite slow. Writing out a 200 meg file can take > hours. > > In fact, I do most of the work using an internal map and write out > that map at the end since I thought this would be faster. (I have > lots of memory.) However, it's still very slow. > > Any hints? Have a look at cdb: http://cr.yp.to/cdb.html it's been designed to exactly do what you want: quickly write a large dbm-like database to disk. Unfortunately, I don't know of any Python binding for that library or any port of it for Windows or Mac. Laurent Szyster From phd at phd.pp.ru Wed Jan 2 15:49:15 2002 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 2 Jan 2002 17:49:15 +0300 Subject: anydbm is slow In-Reply-To: <3C331C47.E4B3AC1D@q-survey.be>; from laurent.szyster@q-survey.be on Wed, Jan 02, 2002 at 03:42:15PM +0100 References: <1010a26.0201011541.6405048f@posting.google.com> <3C331C47.E4B3AC1D@q-survey.be> Message-ID: <20020102174915.I12844@phd.pp.ru> On Wed, Jan 02, 2002 at 03:42:15PM +0100, Laurent Szyster wrote: > http://cr.yp.to/cdb.html > > it's been designed to exactly do what you want: quickly write > a large dbm-like database to disk. > > Unfortunately, I don't know of any Python binding for that library http://www.vex.net/parnassus/apyllo.py?find=cdb Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From laurent.szyster at q-survey.be Wed Jan 2 15:54:37 2002 From: laurent.szyster at q-survey.be (Laurent Szyster) Date: Wed, 02 Jan 2002 15:54:37 +0100 Subject: anydbm is slow References: <1010a26.0201011541.6405048f@posting.google.com> <3C331C47.E4B3AC1D@q-survey.be> Message-ID: <3C331F2D.5E7796A3@q-survey.be> Laurent Szyster wrote: > > Unfortunately, I don't know of any Python binding for that library > or any port of it for Windows or Mac. Well, looking at the bottom of page at http://cr.yp.to/cdb.html there are links to various scripting language bindings and ports of cdb. For Python, go to: http://pilcrow.madison.wi.us/ Good luck. Laurent From skip at pobox.com Wed Jan 2 16:31:29 2002 From: skip at pobox.com (Skip Montanaro) Date: Wed, 2 Jan 2002 09:31:29 -0600 Subject: anydbm is slow In-Reply-To: <3C331C47.E4B3AC1D@q-survey.be> References: <1010a26.0201011541.6405048f@posting.google.com> <3C331C47.E4B3AC1D@q-survey.be> Message-ID: <15411.10193.723041.663599@beluga.mojam.com> Laurent> Unfortunately, I don't know of any Python binding for that Laurent> library or any port of it for Windows or Mac. >From the cdb web page: http://pilcrow.madison.wi.us/ Cheers, -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From rdsteph at earthlink.net Wed Jan 2 00:57:02 2002 From: rdsteph at earthlink.net (Ron Stephens) Date: Tue, 01 Jan 2002 23:57:02 GMT Subject: Ruby folks focus on Parrot Message-ID: <3C324DEA.D25CB245@earthlink.net> Just copying this one note from comp.lang.ruby today, to show that Ruby folks are real serious about getting aRuby that runs on Parrot, the new runtime environment for Perl 6. This poster even asserts how important it could be to beat Python to the punch in this regards, so to speak. ;-))) The following is a copy of a post to comp.lang.ruby on the subject "Project Proposal: Cardinal: Ruby frontend for Parrot". >>>>We've had a couple of different threads flowing here the last few days about getting Ruby to work with Parrot. Dan Sugalski has suggested that we (the Ruby community) need to create a Ruby parser in Ruby that initially needs to emit Parrot bytecode and later we could pass on an AST. So..... I want to propose a new project called Cardinal (the name is open to discussion, I chose Cardinal because Parrots are birds, Rubys are red and Cardinals are red birds - is the name already taken? I don't see any Cardinal project on RAA). The goal of Cardinal is to create a Ruby frontend for Parrot. What's Parrot? Briefly, Parrot is Perl6's new virtual machine. But it's being designed in such a way as to allow different language frontend parsers to use the Parrot backend. So, in theory, this will allow you to write a program in Ruby that uses Perl or Python libraries. There is a Parrot FAQ at: http://www.panix.com/~ziggy/parrot.html which might answer more questions. Why? There are several reasons why it's a good idea for Ruby to be able to 'play' with Parrot... 1) As mentioned above, it would allow us to tap into the vast Perl CPAN libraries (and Python's too). This seems like a win for Ruby since our library of modules is much smaller right now. 2) It could allow Ruby to reach a wider audience. The likelyhood is that Perl6 will eventually be installed all over the place like Perl5 is now. There have been a few threads recently asking about Ruby friendly ISP's and web hosting companies, there aren't many yet, but if we could run Ruby via Perl6's Parrot backend we could eventually run Ruby just about anywhere. 3) The 'coolness' factor - especially if we can get Ruby playing with Parrot before Python (or even potentially before Perl, as Dan has suggested), that would be good publicity for Ruby and could possibly help expand our user base. 4) Performance? - I think that the Parrot folks are putting a lot of thought into improving performance, maybe it's possible that Ruby running on Parrot will be faster than the current implementation (but I'm speculating here). 5) The involvment of the Ruby community could help influence the development of Parrot (I think it already has to some extent - they are paying attention to some of Ruby's requirements, such as support for continuations) How? I'm not entirely sure yet, but I think a lot of the groundwork has been laid for the parser (RubyInRuby, Rockit). There has been work done on the AST representation (RubySchema, AST) - Cardinal should build on already existing work in these areas and concentrate on generating Parrot bytecode or assembly. Hopefully Cardinal can give a boost to those other projects so we can eventually see several other backends like Cardinal which can be plugged into the frontend parser/AST generator. Who? Who's interested? Ideas, Suggestions? Phil From skip at pobox.com Wed Jan 2 01:12:04 2002 From: skip at pobox.com (Skip Montanaro) Date: Tue, 1 Jan 2002 18:12:04 -0600 Subject: Ruby folks focus on Parrot In-Reply-To: <3C324DEA.D25CB245@earthlink.net> References: <3C324DEA.D25CB245@earthlink.net> Message-ID: <15410.20564.697845.371571@12-248-41-177.client.attbi.com> Ron> Just copying this one note from comp.lang.ruby today, to show that Ron> Ruby folks are real serious about getting aRuby that runs on Ron> Parrot, the new runtime environment for Perl 6. This poster even Ron> asserts how important it could be to beat Python to the punch in Ron> this regards, so to speak. ;-))) I posted a link to Simon Cozens' recent post to python-dev a couple days ago. I'm sure he wouldn't mind if you enhanced his pyasm-to-parrot translator. Dive right in. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From akuchlin at mems-exchange.org Wed Jan 2 03:01:40 2002 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 01 Jan 2002 21:01:40 -0500 Subject: Ruby folks focus on Parrot References: <3C324DEA.D25CB245@earthlink.net> Message-ID: <3dital7bp7.fsf@mozart.mems-exchange.org> Ron Stephens writes: > runtime environment for Perl 6. This poster even asserts how important > it could be to beat Python to the punch in this regards, so to speak. Hmmm... that's not really possible given that I've already checked nondist/sandbox/parrot into the Python CVS tree; it compiles a trivial Python subset to Parrot assembly source, as long as the only type you use is integer. Unfortunately Parrot 0.0.3 isn't really complete enough yet to support a really interesting subset of Python. The painful absence is that there's no working support for variables yet, so you can't really implement scopes properly, and getting code generation right requires writing register allocation code that would promptly become useless as soon as variable storage actually gets implemented. Another necessary task is to write PythonString and PythonInteger classes supporting Python's semantics for those types; Parrot already includes PerlString and PerlInteger implementations. Work on that could proceed now, but I have little motivation to work on that given the lack of variables. (If someone wants to work on that anyway, feel free to do so.) --amk From mlh at vier.idi.ntnu.no Wed Jan 2 17:39:10 2002 From: mlh at vier.idi.ntnu.no (Magnus Lie Hetland) Date: Wed, 2 Jan 2002 16:39:10 +0000 (UTC) Subject: Ruby folks focus on Parrot References: <3C324DEA.D25CB245@earthlink.net> Message-ID: In article <3C324DEA.D25CB245 at earthlink.net>, Ron Stephens wrote: >Just copying this one note from comp.lang.ruby today, to show that Ruby >folks are real serious about getting aRuby that runs on Parrot, the new >runtime environment for Perl 6. This poster even asserts how important >it could be to beat Python to the punch in this regards, so to speak. >;-))) Hm. This sounds cool, but then again, so does .NET... And JVM... I haven't looked at the specs, but I assume that Parrot is better suited as a backend to Python than the other VMs? I thought one of the ideas behind this "common VM" stuff was to have one platform where "everything" runs, but it seems that we're starting to see a proliferation of such VMs, just like with languages... Maintaining half a dozen equivalent Python implementations sounds scary (and error-prone) to me... Oh, well. I'm sure Parrot is very nice :) -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.org From jkraska at san.rr.com Wed Jan 2 01:09:20 2002 From: jkraska at san.rr.com (Courageous) Date: Wed, 02 Jan 2002 00:09:20 GMT Subject: Parrot<-->Python Message-ID: Sorry, Where is Parrot/Python being hosted? I presume that it is, yes? C// From rdsteph at earthlink.net Wed Jan 2 01:16:45 2002 From: rdsteph at earthlink.net (Ron Stephens) Date: Wed, 02 Jan 2002 00:16:45 GMT Subject: Parrot<-->Python References: Message-ID: <3C32528B.8FFBE3C9@earthlink.net> Slashdot posted an article today on Parrot which I think includes many Parrot links including a link to the hosting site. The Slashdot article can be found at http://slashdot.org/index.pl?section=developers From tuttledon at mailandnews.com Wed Jan 2 02:53:39 2002 From: tuttledon at mailandnews.com (Don Tuttle) Date: Wed, 02 Jan 2002 01:53:39 GMT Subject: Parrot<-->Python References: Message-ID: ??? Maybe this what you want? http://www.parrotcode.org/ Don "Courageous" wrote in message news:dlj43u8gv3cahe9kmco0v8r7t2ib4c42no at 4ax.com... > > Sorry, > > Where is Parrot/Python being hosted? I presume that it is, yes? > > C// > From jkraska at san.rr.com Wed Jan 2 04:08:41 2002 From: jkraska at san.rr.com (Courageous) Date: Wed, 02 Jan 2002 03:08:41 GMT Subject: Parrot<-->Python References: Message-ID: <15u43uk2smm6hc9qr4htv82ct1bnot5lnq@4ax.com> On Wed, 02 Jan 2002 01:53:39 GMT, "Don Tuttle" wrote: >??? Maybe this what you want? >http://www.parrotcode.org/ Not as far as I can tell. I'm talking about the part which turns Python into Parrot bytecode, not Parrot itself. I haven't downloaded their binaries, but it seems unlikely that such an entity would be in the initial Parrot virtual machine. C// From tim at vegeta.ath.cx Wed Jan 2 20:47:07 2002 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 02 Jan 2002 19:47:07 GMT Subject: Parrot<-->Python References: Message-ID: Courageous graced us by uttering: > Where is Parrot/Python being hosted? I presume that it is, yes? Parrot is the VM for Perl6 and is thus not due for official release for at least a year or so. Compiling Perl6 code to Parrot bytecode is an assumed project, but compiling Python to Parrot bytecode is, AFAIK, left as an exercise to the Python community. Heck, according to the site, they're still hacking out bugs in Parrot's internals. The code available at http://www.parrotcode.org/ is through CVS. They don't have any alpha or beta releases. Tim Hammerquist -- Must be a different Larry Wall. There are at least 137 of us in the U.S. -- Larry Wall in <199809300035.RAA12495 at wall.org> From mwh at python.net Thu Jan 3 11:38:54 2002 From: mwh at python.net (Michael Hudson) Date: Thu, 3 Jan 2002 10:38:54 GMT Subject: Parrot<-->Python References: Message-ID: Courageous writes: > Sorry, > > Where is Parrot/Python being hosted? I presume that it is, yes? Not quite sure what you mean, but you might be looking for http://cvs.sf.net/cgi-bin/viewcvs.cgi/python/python/nondist/sandbox/parrot/ I'm not aware of anything else. Cheers, M. From m.faassen at vet.uu.nl Fri Jan 4 18:09:10 2002 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Jan 2002 17:09:10 GMT Subject: Parrot<-->Python References: Message-ID: Courageous wrote: > Where is Parrot/Python being hosted? I presume that it is, yes? Andrew Kuchling was talking about doing something along those lines in another thread, and I've also seen a post by one of the parrot hackers to Python-dev about a small implementation. I believe that was very small though; didn't he post the code as well? I remember seeing something somewhere. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From rdsteph at earthlink.net Wed Jan 2 01:14:01 2002 From: rdsteph at earthlink.net (Ron Stephens) Date: Wed, 02 Jan 2002 00:14:01 GMT Subject: Mono and Python Message-ID: <3C3251E0.612B0401@earthlink.net> I continue to be intrigued by the progress of the Mono project, which is spear-headed by the controversial Miguel de Icaza. There was a long article by Miguel about Mono in the recent issue of Linux Journal, and the project seems to be moving forward nicely. It is interesting because it is an attempt to achieve cross language compatibility using a common language runtime and component system based on the ECMA specs created by Microsoft for the .Net project. Mono is essentially a partial recreation the .Net runtime environment on Unix and Linux. Controversial, yes, but interesting. Slashdot just posted an interview with Miguel de Icaza where they discuss the present status of Mono and it can be found at http://slashdot.org/index.pl?section=developers I am wondering/hoping/speculating whether Python can/will/should participate. Wouldn't it be nice to have an open source project to create a Mython version of Python, a completely compatible version of Python that would run on the Mono clr, just as Jython runs on the JVM? I know it would be a huge undertaking, but it would be nice. Maybe it would be even more important for Python to have a Mono compatible version than it would be for Python to have a .NET compatible version, but I don't know. Maybe both a .NET and a Mono compatible version of Python could be created by one and the same open source project, given the similarities between Mono and .Net? Mark Hammond has commented that creating a .Net version of Python is a really big job, with a lot of pitfalls along the way. (ActiveState has created a VisualPython.Net, but that is very different, it is a capability to use the Microsoft Visual Studio IDE to create Python programs, but not an ability for Python programs to run on the .Net common language runtime, or clr.) Does anyone have any thoughts or comments on any of this? The recent Miguel de Icaza interview with Slashdot can be found at http://slashdot.org/index.pl?section=developers Ron Stephens http://www.awaretek.com/plf.html From tuttledon at mailandnews.com Wed Jan 2 04:23:24 2002 From: tuttledon at mailandnews.com (Don Tuttle) Date: Wed, 02 Jan 2002 03:23:24 GMT Subject: Mono and Python References: <3C3251E0.612B0401@earthlink.net> Message-ID: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/Dndotnet/ht ml/deicazainterview.asp?frame=true Interesting interview. I'm also very interested in what Mark has to say about Python and .NET and Mono. His early progress report http://www.activestate.com/Initiatives/NET/Python_whitepaper.doc was not encouraging. And the fact that ActiveState has backed away from Python is even more ominous. It's clear that Miguel de Icaza believes .NET solves important development issues. ("We are doing this for selfish reasons: we want a better way of developing Linux and Unix applications ourselves and we see the CLI as such a thing.") That seems to be born out by the better than expected support the Mono project is receiving from developers outside his company. Sure would make me feel better to hear from the Python-dev community that Python can and will be a player in this new ball game. Because, quite frankly, the silence of the past few months as been deafening. Don "Ron Stephens" wrote in message news:3C3251E0.612B0401 at earthlink.net... > I continue to be intrigued by the progress of the Mono project, which is > spear-headed by the controversial Miguel de Icaza. There was a long > article by Miguel about Mono in the recent issue of Linux Journal, and > the project seems to be moving forward nicely. > > It is interesting because it is an attempt to achieve cross language > compatibility using a common language runtime and component system based > on the ECMA specs created by Microsoft for the .Net project. Mono is > essentially a partial recreation the .Net runtime environment on Unix > and Linux. Controversial, yes, but interesting. > > Slashdot just posted an interview with Miguel de Icaza where they > discuss the present status of Mono and it can be found at > http://slashdot.org/index.pl?section=developers > > I am wondering/hoping/speculating whether Python can/will/should > participate. Wouldn't it be nice to have an open source project to > create a Mython version of Python, a completely compatible version of > Python that would run on the Mono clr, just as Jython runs on the JVM? > > I know it would be a huge undertaking, but it would be nice. Maybe it > would be even more important for Python to have a Mono compatible > version than it would be for Python to have a .NET compatible version, > but I don't know. > > Maybe both a .NET and a Mono compatible version of Python could be > created by one and the same open source project, given the similarities > between Mono and .Net? > > Mark Hammond has commented that creating a .Net version of Python is a > really big job, with a lot of pitfalls along the way. (ActiveState has > created a VisualPython.Net, but that is very different, it is a > capability to use the Microsoft Visual Studio IDE to create Python > programs, but not an ability for Python programs to run on the .Net > common language runtime, or clr.) > > Does anyone have any thoughts or comments on any of this? > > The recent Miguel de Icaza interview with Slashdot can be found at > http://slashdot.org/index.pl?section=developers > > Ron Stephens > http://www.awaretek.com/plf.html > From tim.one at home.com Wed Jan 2 05:28:47 2002 From: tim.one at home.com (Tim Peters) Date: Tue, 1 Jan 2002 23:28:47 -0500 Subject: Mono and Python In-Reply-To: Message-ID: [Don Tuttle] > It's clear that Miguel de Icaza believes .NET solves important > development issues. > ... > That seems to be born out by the better than expected support the > Mono project is receiving from developers outside his company. > > Sure would make me feel better to hear from the Python-dev community > that Python can and will be a player in this new ball game. Sorry, I've heard nothing to that effect either. > Because, quite frankly, the silence of the past few months has been > deafening. Unsure what this means -- Python-Dev is as active as ever, but most cycles are consumed by dealing with bug reports and patch submissions. I don't think anyone in that crew has the bandwidth to take on a non-trivial new project, and I doubt PythonLabs could get a green light to work on Mono specifically. If I had spare cycles, I'd devote them to pushing Armin Rigo's Psyco along -- but I don't. Others would be more likely to give Parrot a hand -- but probably won't. Etc. Alas, AFAICT all of "the usual suspects" are overloaded already. Note that python-dev is a small group of people -- there are rarely more than 4 really active at any time. We have hundreds of contributors for small things, but big things rarely get tackled unless Guido personally drives them. The Unicode and SRE exceptions come to mind, and they were enabled by external funding; ditto, I assume, ActiveState's Itanium port and .NET work for Python. if-an-area-attracts-neither-volunteers-nor-cash-...-ly y'rs - tim From thomas at gatsoft.no Wed Jan 2 08:13:37 2002 From: thomas at gatsoft.no (Thomas Weholt) Date: Wed, 02 Jan 2002 07:13:37 GMT Subject: Mono and Python References: <3C3251E0.612B0401@earthlink.net> Message-ID: > encouraging. And the fact that ActiveState has backed away from Python is > even more ominous. What?! Why? Any links to statements etc. ? Grown very fond of their distro for the windows-platform, so it would suck alot if they gave it up. Thomas From pedronis at bluewin.ch Wed Jan 2 16:58:43 2002 From: pedronis at bluewin.ch (Samuele Pedroni) Date: Wed, 2 Jan 2002 16:58:43 +0100 Subject: Mono and Python References: <3C3251E0.612B0401@earthlink.net> Message-ID: <3c332edd_3@news.bluewin.ch> Hi, If I recall correctly, in some previous posts to the newsgroup on the topic, Mark Hammond suggested that a bridgining approach (*) more like JPE for java or the current win32com would be a simpler, better straregy for python and .net interoperability. I don't remember how much this was related to the bad performance experience of the Python.NET prototype. OTOH if someone longs for Python.NET it does not need to start from scratch , my impression with some skimming over the .net docs, is that you can more or less port the Jython Java codebase to C# and CLR/.net. After you have understood how to concretely exploit some apparent/inutive mappings, e.g. AppDomain=ClassLoader and worked around the possible differences, it is probably more grunt work than rocket science. If MS has not screwed up something badly performance-wise and there is no weight mismatch (I mean something relatively lightweight on Java that has a heavy weight counterpart) the initial result should be acceptable. And then you can only improve ;). Anyway both the JVM and the CLR as they are do not offer a perfect match for python very dynamic and very late binding semantics. No, definetely I'm not volunteering for doing this. regards. PS (some-conspiracy-theory-just-for-fun): the paranoid worst-case scenario with (*) is in case in the long run MS make "hard" for "non-selected parties" to deploy/ develop non-CLR/managed code (i.e. native code) for its OSes. It could even say that it is for security reasons. Then you *need* Python.NET. Don Tuttle wrote in message M2vY7.30030$mp3.18276900 at typhoon.southeast.rr.com... > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/Dndotnet/ht > ml/deicazainterview.asp?frame=true > > Interesting interview. I'm also very interested in what Mark has to say > about Python and .NET and Mono. His early progress report > http://www.activestate.com/Initiatives/NET/Python_whitepaper.doc was not > encouraging. And the fact that ActiveState has backed away from Python is > even more ominous. > > It's clear that Miguel de Icaza believes .NET solves important development > issues. ("We are doing this for selfish reasons: we want a better way of > developing Linux and Unix applications ourselves and we see the CLI as such > a thing.") That seems to be born out by the better than expected support the > Mono project is receiving from developers outside his company. > > Sure would make me feel better to hear from the Python-dev community that > Python can and will be a player in this new ball game. Because, quite > frankly, the silence of the past few months as been deafening. > > Don > > > "Ron Stephens" wrote in message > news:3C3251E0.612B0401 at earthlink.net... > > I continue to be intrigued by the progress of the Mono project, which is > > spear-headed by the controversial Miguel de Icaza. There was a long > > article by Miguel about Mono in the recent issue of Linux Journal, and > > the project seems to be moving forward nicely. > > > > It is interesting because it is an attempt to achieve cross language > > compatibility using a common language runtime and component system based > > on the ECMA specs created by Microsoft for the .Net project. Mono is > > essentially a partial recreation the .Net runtime environment on Unix > > and Linux. Controversial, yes, but interesting. > > > > Slashdot just posted an interview with Miguel de Icaza where they > > discuss the present status of Mono and it can be found at > > http://slashdot.org/index.pl?section=developers > > > > I am wondering/hoping/speculating whether Python can/will/should > > participate. Wouldn't it be nice to have an open source project to > > create a Mython version of Python, a completely compatible version of > > Python that would run on the Mono clr, just as Jython runs on the JVM? > > > > I know it would be a huge undertaking, but it would be nice. Maybe it > > would be even more important for Python to have a Mono compatible > > version than it would be for Python to have a .NET compatible version, > > but I don't know. > > > > Maybe both a .NET and a Mono compatible version of Python could be > > created by one and the same open source project, given the similarities > > between Mono and .Net? > > > > Mark Hammond has commented that creating a .Net version of Python is a > > really big job, with a lot of pitfalls along the way. (ActiveState has > > created a VisualPython.Net, but that is very different, it is a > > capability to use the Microsoft Visual Studio IDE to create Python > > programs, but not an ability for Python programs to run on the .Net > > common language runtime, or clr.) > > > > Does anyone have any thoughts or comments on any of this? > > > > The recent Miguel de Icaza interview with Slashdot can be found at > > http://slashdot.org/index.pl?section=developers > > > > Ron Stephens > > http://www.awaretek.com/plf.html > > > > From mwh at python.net Thu Jan 3 11:40:24 2002 From: mwh at python.net (Michael Hudson) Date: Thu, 3 Jan 2002 10:40:24 GMT Subject: Mono and Python References: <3C3251E0.612B0401@earthlink.net> Message-ID: "Don Tuttle" writes: > Sure would make me feel better to hear from the Python-dev community > that Python can and will be a player in this new ball game. > Because, quite frankly, the silence of the past few months as been > deafening. Eh? A new .X release is "deafening silence"? Cheers, M. From tuttledon at mailandnews.com Wed Jan 2 08:30:25 2002 From: tuttledon at mailandnews.com (Don Tuttle) Date: Wed, 02 Jan 2002 07:30:25 GMT Subject: Mono and Python References: Message-ID: >> [Don Tuttle] > > Because, quite frankly, the silence of the past few months has been > > deafening. > > [Tim Peters] > Unsure what this means -- In particular I was thinking about a post I made last month to the ActivePython list about the furture of Python and .NET that went unanswered. (Of course Mark's "Christmas present" would later explain the silence.) And in general I've seen very little discussion or enthusiasm about a C# implementation of Python like there was (is) for Jython. Perhaps this is simple because everyone assumed ActiveState was going to do it. But it now looks like VisualPython is their only active .NET project for Python and that worries me. I'd like to know if ActiveState's apparent abandonment of this project was because it proved to technically difficult (imposable?) or simply because they felt the ROI wasn't there. And truth be told, I'm scared CLI is going to be a multiplatform hit and Python isn't going to be invited to the party. Don From akuchlin at mems-exchange.org Wed Jan 2 16:42:50 2002 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 02 Jan 2002 10:42:50 -0500 Subject: Mono and Python References: Message-ID: <3dheq44v45.fsf@ute.mems-exchange.org> "Don Tuttle" writes: > And truth be told, I'm scared CLI is going to be a multiplatform hit and > Python isn't going to be invited to the party. I kind of doubt it. The whole supporting-multiple-language thing seems like a trick to fool purchasers who look for cross-platform support but don't look too closely, similar to Internet Explorer's multiplatform support. IE has been ported to Solaris and HP-UX, mostly so Microsoft can say "See, you don't have to standardize on Netscape inside your company, because IE runs on Unix." Only later, when the decision has been made, do you realize that it doesn't run on Linux or AIX or Tru64, and only then does it start to become less of a priority to release updated versions; the Unix versions are at 5.0 while 5.5 and 6.0 have subsequently been released. At that point you decide it's easier to just move everyone to Windows, and the goal of the port has been accomplished. Similarly, I think MS would like people to use the CLI/CLR and therefore entices them with the run-any-language-you-like carrot. But only C# and VB will run really quickly -- remember, the .net port of Python ran about 10 times slower than MS's anointed languages, because the CLR isn't well-suited to dynamic languages -- and oh sorry, version 2.0 will probably break all those other languages, and at that point you'll just give up and write C# and VB code. I think Parrot is much more promising as a future frontier, because it's being written by the same people who are actually going to implement languages on top of it, and it already supports some nice features such as stacklessness. The chief danger is that if no one else tries to build languages on top of Parrot, then Perl-specific biases will creep in. On a more general note (and not one aimed at Don or at anyone in particular), this whole "Python popularity" thread has been an example of Town Council planning in action (http://slashdot.org/features/98/10/13/1423253.shtml). There have been lots of opinions about what Python needs -- an optimizing compiler, better support for building standalone support for Parrot, support for .net -- but distressingly few people have actually gone ahead and started coding anything. (And I don't mean "designing", or "vaguely speculating"; I mean "coding".) I simply delete messages that pontificate about what Python needs, and I suspect I'm not the only person around who does this. If something is supposedly vital to Python's future, yet no one is willing to spend time on it, then it probably isn't so vital after all. If someone is willing to spend time on it, then it's probably worth considering, and the very attempt will teach us something. Talk is cheap; actual code can be worth more than rubies. And the initial job isn't even that hard. No one expects a complete finished product to spring up fully-formed like Athena from the head of Jupiter. Armin Rigo's Psyco isn't complete, yet it'll likely teach us more about JITs than a year's worth of comp.lang.python postings. My Python-to-Parrot translator does nothing non-trivial, yet I learnt quite a bit about Parrot in the process. Writing a rough cut at a C# Python implementation using .net or Mono might provide the fourth Python implementation, but it would certainly teach you about C# and Mono, and it would be real-world experience, not claims from MS or Ximian press releases. --amk (www.amk.ca) If my dream was true, then everything we know, everything we think we know is a lie. -- From Rose Walker's diary, in SANDMAN #16: "Lost Hearts" From robin at jessikat.fsnet.co.uk Wed Jan 2 18:15:24 2002 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 2 Jan 2002 17:15:24 +0000 Subject: Mono and Python References: <3dheq44v45.fsf@ute.mems-exchange.org> Message-ID: In article <3dheq44v45.fsf at ute.mems-exchange.org>, Andrew Kuchling writes >Similarly, I think MS would like people to use the CLI/CLR and >therefore entices them with the run-any-language-you-like carrot. But >only C# and VB will run really quickly -- remember, the .net port of >Python ran about 10 times slower than MS's anointed languages, because >the CLR isn't well-suited to dynamic languages -- and oh sorry, >version 2.0 will probably break all those other languages, and at that >point you'll just give up and write C# and VB code. Even though net VB is pure M$ they've had to eliminate things like default attributes and all calls now have to have parens. So even if you're a happy VB kiddie already, M$ has a way of making your skills redundant. A friend advises me that his net versions are 'sluggish' compared to what he's used to. -CLI used to mean command line interfaced-ly yrs- Robin Becker From rdsteph at earthlink.net Thu Jan 3 02:54:51 2002 From: rdsteph at earthlink.net (Ron Stephens) Date: Thu, 03 Jan 2002 01:54:51 GMT Subject: Mono and Python References: <3dheq44v45.fsf@ute.mems-exchange.org> Message-ID: <3C33BAF9.313B64E1@earthlink.net> I actually agree with you; and I've definitely been playing the town council type here on the newsgroup lately. Now that the holidays are over, I gotta go back to work anyway. But when I go into town council mode, everyone shoudl just feel free to yell "shut up" as loud as you can and I will hear you. I actually did try to bring up these bullshit topics between Xmas and New Years, when the newsgroup was extra slow. But for what its worth, before I go for now, my last thoughts on these alternate runtime environments: ...Well, I don't actually have any last thoughts, just go back and re-read what Andrew Kuchling said about them, I think he is 100% correct. If someone produces actual code for Python.net or Mono, like Andrew has done for Parrot, that's great. meanwhile, if someone can add to what Andrew has done for python -parrot, great---but even Parrot is not really ready to be ported to anyway. Those who can code, code. Those who can't, talk; and the coders *always* have the right to shoot the talkers. Meanwhile, talk is fun in moderation, at the right times. (at least if you don't get shot) And Python will continue to attract clueless newbies, some of whom will progress to clued in newbies. C'est la vie. But the more I think about it, even before I read the excellent Town Council piece, the more I think .Net, Mono, and Parrot might be poor diversions of precious coding skills time and energy. But only the actual coders can decide that. Meanwhile viva la Python... From akuchlin at mems-exchange.org Thu Jan 3 17:01:30 2002 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 03 Jan 2002 11:01:30 -0500 Subject: Mono and Python References: <3dheq44v45.fsf@ute.mems-exchange.org> <3C33BAF9.313B64E1@earthlink.net> Message-ID: <3dbsgb77ad.fsf@dust.mems-exchange.org> Ron Stephens writes: > Those who can code, code. Those who can't, talk; and the coders *always* have > the right to shoot the talkers. Meanwhile, talk is fun in moderation, at the > right times. (at least if you don't get shot) Yes, but coding *isn't that hard*. Really. My point is that rather than talking, it's better to actually fire up Emacs or whatever and actually try implementing an interesting idea. (Linus Torvalds once said in an interview that he was incredibly arrogant in 1992 when he aimed at implementing an OS; if he'd known how difficult the task actually was, he'd never have tried it. I wish we had more arrogant people in the Python community.) --amk From bkc at Murkworks.com Fri Jan 4 15:14:35 2002 From: bkc at Murkworks.com (Brad Clements) Date: Fri, 4 Jan 2002 09:14:35 -0500 Subject: Mono and Python References: <3dheq44v45.fsf@ute.mems-exchange.org> <3C33BAF9.313B64E1@earthlink.net> <3dbsgb77ad.fsf@dust.mems-exchange.org> Message-ID: <3c35b968$1_2@news.newsgroups.com> "Andrew Kuchling" wrote in message news:3dbsgb77ad.fsf at dust.mems-exchange.org... > Ron Stephens writes: > (Linus Torvalds once said in an interview that he was incredibly > arrogant in 1992 when he aimed at implementing an OS; if he'd known > how difficult the task actually was, he'd never have tried it. I wish > we had more arrogant people in the Python community.) > > --amk I wouldn't mind being arrogant, but I have to feed my family first. Who supported Linus during his bootstrap time? -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! Check out our new Unlimited Server. No Download or Time Limits! -----== Over 80,000 Newsgroups - 19 Different Servers! ==----- From rdeviasse at sympatico.ca Thu Jan 3 03:23:48 2002 From: rdeviasse at sympatico.ca (Robert N. Deviasse) Date: Wed, 2 Jan 2002 21:23:48 -0500 Subject: Mono and Python References: <3dheq44v45.fsf@ute.mems-exchange.org> Message-ID: "Andrew Kuchling" wrote in message news:3dheq44v45.fsf at ute.mems-exchange.org... > Similarly, I think MS would like people to use the CLI/CLR and > therefore entices them with the run-any-language-you-like carrot. But > only C# and VB will run really quickly -- remember, the .net port of > Python ran about 10 times slower than MS's anointed languages, That's a poor example. Take a look at their whitepaper: http://www.activestate.com/Initiatives/NET/Research.html It basically says: Compiler -------- The Python for .NET compiler is written using CPython. It compiles Python source code, and uses the .NET Reflection::Emit library to generate a .NET assembly. The COM Interoperability features of .NET are used to access the Reflection::Emit library. This particular strategy was chosen to minimize the implementation time. ... The primary drawback to this approach is the speed of the compiler. Much of the abstract syntax tree (AST) manipulation code is also written in Python code, and as this is one of the most CPU intensive areas of the compiler, we suffer a significant speed penalty. Further, the use of Reflection::Emit via COM is also causing us some performance problems. Some of these problems are due to the speed of the Python COM bindings, but Reflection::Emit itself and/or the COM interoperability layers are also costing us significant time. They basically chose the extremely slow approach in order to implement it quickly. COM itself is slow, but writing a CPU intensive part of the code in Python sure doesn't help performance. Later on, they say: The Python for .NET runtime defines a .NET interface (IPyType) that captures Python's semantics. The definition of this interface is almost identical to the existing CPython type object, which is the object primarily responsible for object semantics in CPython. ... The Python for .NET runtime also exposes an API for use by the compiler, working almost exclusively with the PyObject structures. The runtime also provides a function for creating a new PyObject at runtime, given nothing but an anonymous .NET object reference. The compiler will frequently generate calls to create these PyObject structures (often storing the result in a variable), and also pass these PyObject structures back into the runtime as needed. This isn't a bad approach, but why did they use non-portable COM to implement this? They should have been able to use PInvoke() to directly access the Python data structures. It would be far more portable and efficient. > because the CLR isn't well-suited to dynamic languages Could you elaborate what you mean? Some usages of types can be inferred, but for the general case, couldn't the following table-driven class take care of the problem? class FunctionDispatchTable { // ... delegate void MemberFunction(object[] arguments); object addFunction(string functionName, MemberFunction memberfunction); object dispatch(string functionName, params object[] arguments); }; > -- and oh sorry, > version 2.0 will probably break all those other languages, and at that > point you'll just give up and write C# and VB code. Could you elaborate? Looking at the template and functional additions to the CLR, I don't see any reason why this would be the case. http://research.microsoft.com/projects/clrgen/ http://research.microsoft.com/projects/ilx/ From nhodgson at bigpond.net.au Thu Jan 3 04:57:18 2002 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Thu, 03 Jan 2002 03:57:18 GMT Subject: Mono and Python References: <3dheq44v45.fsf@ute.mems-exchange.org> Message-ID: Robert N. Deviasse: [Talking about Python.NET] > They basically chose the extremely slow approach in order to > implement it quickly. COM itself is slow, but writing a CPU > intensive part of the code in Python sure doesn't help > performance. The slow compilation process for Python.NET is not that important if the compiled code is kept and there are some techniques, as you have pointed out for speeding up compilation. The problem is the slow execution of the resulting compiled code which can be easily experienced by compiling and running PyStone with Python.NET. Neil From tuttledon at mailandnews.com Thu Jan 3 07:45:28 2002 From: tuttledon at mailandnews.com (Don Tuttle) Date: Thu, 03 Jan 2002 06:45:28 GMT Subject: Mono and Python References: <3dheq44v45.fsf@ute.mems-exchange.org> Message-ID: > [Neil Hodgson] > [Talking about Python.NET] > > The slow compilation process for Python.NET is not that important if the > compiled code is kept and there are some techniques...The problem is the slow execution of the > resulting compiled code which can be easily experienced by compiling and > running PyStone with Python.NET. Any idea as to why ? Also, does anyone knows how this compares to Perl.NET? Don From brian at sweetapp.com Thu Jan 3 08:35:08 2002 From: brian at sweetapp.com (Brian Quinlan) Date: Wed, 2 Jan 2002 23:35:08 -0800 Subject: Mono and Python In-Reply-To: Message-ID: <000001c19429$2c2d70b0$445d4540@Dell2> Mark's Python .NET prototype actually compiles Python code down to IL for execution by the CLR (common language runtime). Perl .NET works in a completely different fashion - bridge code is generated but the usual Perl interpreter is still used at runtime. Don wrote: > > The slow compilation process for Python.NET is not that important if > > the compiled code is kept and there are some techniques...The problem is > > the slow execution of the resulting compiled code which can be easily > > experienced by compiling and > > running PyStone with Python.NET. > > Any idea as to why ? > Also, does anyone knows how this compares to Perl.NET? From nhodgson at bigpond.net.au Thu Jan 3 12:16:50 2002 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Thu, 03 Jan 2002 11:16:50 GMT Subject: Mono and Python References: <3dheq44v45.fsf@ute.mems-exchange.org> Message-ID: Don Tuttle: > > [Neil Hodgson] > >...The problem is the slow execution of the > > resulting compiled code which can be easily experienced by compiling and > > running PyStone with Python.NET. > > Any idea as to why ? I haven't looked into the code. The only hints I've seen are in the aforementioned word document that Microsoft's initial optimization efforts are aimed at more static languages such as C# because the main battle is C# versus Java. Neil From mhammond at skippinet.com.au Fri Jan 4 05:26:31 2002 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 04 Jan 2002 04:26:31 GMT Subject: Mono and Python References: <3dheq44v45.fsf@ute.mems-exchange.org> Message-ID: <3C352F00.40809@skippinet.com.au> Robert N. Deviasse wrote: > Later on, they say: > The Python for .NET runtime defines a .NET interface (IPyType) > that captures Python's semantics. The definition of this interface > is almost identical to the existing CPython type object, which is > the object primarily responsible for object semantics in CPython. > ... > The Python for .NET runtime also exposes an API for use by the > compiler, working almost exclusively with the PyObject structures. > The runtime also provides a function for creating a new PyObject > at runtime, given nothing but an anonymous .NET object reference. > The compiler will frequently generate calls to create these PyObject > structures (often storing the result in a variable), and also pass > these PyObject structures back into the runtime as needed. > > This isn't a bad approach, but why did they use non-portable COM > to implement this? They should have been able to use PInvoke() to > directly access the Python data structures. It would be far more portable > and efficient. I think you misunderstood. The IPyType is not an interface to a CPython PyTypeObject object. It is a .NET reimplementation of the PyTypeObject semantics (actually implemented in C#). Thus, there is nothing COM (or even MS specific I am aware of) in the runtime. As you quoted above (and I snipped) the compiler itself *does* use COM. For anyone looking at running Python on the CLR, I think an early decision needs to be made - do we try and go "native CLR", or build a "CPython interface". The project you refer to uses the "native CLR" approach, and I believe is basically what Jython does. There is no CPython runtime involved, and all C implemented modules need to be reimplemented somehow. The "CPython interface" approach would build bindings to the existing CPython. This would allow many existing modules to be used as is. This may however offer less then perfect integration, but Python 2.2 type-class unification efforts may make this more tenable. Mark. From paul at prescod.net Thu Jan 3 08:15:48 2002 From: paul at prescod.net (Paul Prescod) Date: Thu, 03 Jan 2002 02:15:48 -0500 Subject: Mono and Python References: Message-ID: <3C340524.AEF655F8@prescod.net> Don Tuttle wrote: > >.... > > I'd like to know if ActiveState's apparent abandonment of this project was > because it proved to technically difficult (imposable?) or simply because > they felt the ROI wasn't there. That's an easy question to answer. Whether or not the problem is difficult, ActiveState would go out of business if it didn't focus on ROI. My personal opinion is that it shouldn't be harder than Jython but then there are thousands of person-hours of work in Jython. Jython could not have been done by a business of ActiveState's size in the current economic climate. > And truth be told, I'm scared CLI is going to be a multiplatform hit and > Python isn't going to be invited to the party. Think of it the opposite way. The CLI hasn't proved its importance as a platform yet so the Python community is taking a wait and see approach. When it becomes a clearly important target some new enthusiast you have never heard of (to this point) will take it on as a means of carving out their corner of the noosphere. As far as Microsoft and future incarnations of .NET: Microsoft has always been very interested in having the scripting languages "run well" on their platforms. Until now their platform was win32. In the future it will be .NET. He is probably right that the first incarnation was in large part a marketing exercise but as Microsoft's core platform shifts from win32 to .NET, I suspect they will be more and more anxious to that the scripting languages interoperate with it. After all, this is an important part of their strategy to move developers from Linux to Windows. Of course, if Microsoft could get everybody to their languages, they would. But getting people onto their *platforms* is much, much more important than getting them to use their languages. Still, scripting languages are to Microsoft as hobbits are to wizards. I wouldn't expect them to offer much help or to go out of their way to make our lives harder. Paul Prescod From tuttledon at mailandnews.com Thu Jan 3 21:21:10 2002 From: tuttledon at mailandnews.com (Don Tuttle) Date: Thu, 03 Jan 2002 20:21:10 GMT Subject: Mono and Python References: Message-ID: > Don Tuttle wrote: > > I'd like to know if ActiveState's apparent abandonment of this project was > > because it proved to technically difficult (imposable?) or simply because > > they felt the ROI wasn't there. .> >[Paul Prescod] > That's an easy question to answer. Whether or not the problem is > difficult, ActiveState would go out of business if it didn't focus on > ROI. Hi Paul. Thanks for your response! > [Paul Prescod] > My personal opinion is that it shouldn't be harder than Jython but then > there are thousands of person-hours of work in Jython. Jython could not > have been done by a business of ActiveState's size in the current > economic climate. Economic conditions haven't been good for over a year. So you realize this just begs the question, "Then why did ActiveState ever start it? What did they hope to achieve?" > >[Don Tuttle] > > And truth be told, I'm scared CLI is going to be a multiplatform hit and > > Python isn't going to be invited to the party. > [Paul Prescod] > Think of it the opposite way. The CLI hasn't proved its importance as a > platform yet so the Python community is taking a wait and see approach. > When it becomes a clearly important target some new enthusiast you have > never heard of (to this point) will take it on as a means of carving out > their corner of the noosphere. As to the Mono project I agree with you. But does anyone doubt Microsoft's commitment to .NET? To Sun, Java is just a sideline. To Microsoft, .NET IS its future. And anyone the least bit familiar with Microsoft should know when its future is a stake Microsoft will do "whatever it takes" to succeed. As to why some young code slinger, eager to make a name for themselves, hasn't already taken on the Python.NET project-- Could it be...ahum...that it is because ActiveState said THEY would tackle the project, that said hero never tried? > [Paul Prescod] > As far as Microsoft and future incarnations of .NET: Microsoft has > always been very interested in having the scripting languages "run well" > on their platforms. Until now their platform was win32. In the future it > will be .NET. He is probably right that the first incarnation was in > large part a marketing exercise but as Microsoft's core platform shifts > from win32 to .NET, I suspect they will be more and more anxious to that > the scripting languages interoperate with it. After all, this is an > important part of their strategy to move developers from Linux to > Windows. There's no doubt this has been their Win32 strategy. But .NET? At this point, the only part of Microsoft that I believe thinks scripting is important to .NET is the marketing department. After all, they've killed there own scripting language - VBScript. (see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnclinic/ht ml/scripting11122001.asp Note the spin of the article. The death of VBScript is mentioned as an aside to birth of JScript.NET. Not that very many are going to mourn the demise of VBScript.) > [Paul Prescod] > Of course, if Microsoft could get everybody to their languages, they > would. But getting people onto their *platforms* is much, much more > important than getting them to use their languages. Still, scripting > languages are to Microsoft as hobbits are to wizards. I wouldn't expect > them to offer much help or to go out of their way to make our lives > harder. Well put! Finally, many *nix users of Python my not realize that Python is about to become less functional on Windows without the .NET tagged on. (No ASP.NET or .NET Web services.) Whatever your religious platform, I'd hope you'd agree that losing functionality in Windows doesn't bode well for ANY language. Don From akuchlin at mems-exchange.org Thu Jan 3 22:02:50 2002 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 03 Jan 2002 16:02:50 -0500 Subject: Mono and Python References: Message-ID: <3dvgejno5h.fsf@dust.mems-exchange.org> "Don Tuttle" writes: > Finally, many *nix users of Python my not realize that Python is about to > become less functional on Windows without the .NET tagged on. (No ASP.NET > or .NET Web services.) And why should Unix users should care about this, if Python loses functionality on a platform they never use? If Windows people are worried about this, they're the one who should actually expend some effort on fixing the problem. --amk From pedronis at bluewin.ch Thu Jan 3 22:33:55 2002 From: pedronis at bluewin.ch (Samuele Pedroni) Date: Thu, 3 Jan 2002 22:33:55 +0100 Subject: Mono and Python References: Message-ID: <3c34ceef$1_2@news.bluewin.ch> mmh, > > Finally, many *nix users of Python my not realize that Python is about to > become less functional on Windows without the .NET tagged on. (No ASP.NET > or .NET Web services.) > > Whatever your religious platform, I'd hope you'd agree that losing > functionality in Windows doesn't bode well for ANY language. > That sounds pretty "intimidatory". Anyway I repeat, you probably don't need any kind of hero, just a bunch of more or less motivated people. Jython is 35 KLOC of core plus 10 KLOC for the built-in modules and I'm counting blank lines too ;). Writing it was a *big* *thing* from the part of Jim Hugunin (btw all my acknowledgements), but now every one can read the code, it's prior art. I think that probably much of the ideas and code in Jython have a straightforward translation to C#/CLR/.NET... You can also try other approaches and someone brilliant will do that ... but this is a doable path. regards. From tuttledon at mailandnews.com Fri Jan 4 05:55:38 2002 From: tuttledon at mailandnews.com (Don Tuttle) Date: Fri, 04 Jan 2002 04:55:38 GMT Subject: Mono and Python References: <3c34ceef$1_2@news.bluewin.ch> Message-ID: "Samuele Pedroni" > That sounds pretty "intimidatory". Anyway I repeat, > you probably don't need any kind of hero, just a bunch > of more or less motivated people. > > Jython is 35 KLOC of core plus 10 KLOC > for the built-in modules and I'm counting blank > lines too ;). > > Writing it was a *big* *thing* from the part > of Jim Hugunin (btw all my acknowledgements), > but now every one can read the code, > it's prior art. > > I think that probably much of the ideas and code in Jython > have a straightforward translation to C#/CLR/.NET... > > You can also try other approaches and someone > brilliant will do that ... but this is a doable path. Sounds like a plan! Sure you don't want to give it a go? ;-) Don From pedronis at bluewin.ch Fri Jan 4 13:24:47 2002 From: pedronis at bluewin.ch (Samuele Pedroni) Date: Fri, 4 Jan 2002 13:24:47 +0100 Subject: Mono and Python References: <3c34ceef$1_2@news.bluewin.ch> Message-ID: <3c359fbb$1_1@news.bluewin.ch> > "Samuele Pedroni" > > That sounds pretty "intimidatory". Anyway I repeat, > > you probably don't need any kind of hero, just a bunch > > of more or less motivated people. > > > > Jython is 35 KLOC of core plus 10 KLOC > > for the built-in modules and I'm counting blank > > lines too ;). > > > > Writing it was a *big* *thing* from the part > > of Jim Hugunin (btw all my acknowledgements), > > but now every one can read the code, > > it's prior art. > > > > I think that probably much of the ideas and code in Jython > > have a straightforward translation to C#/CLR/.NET... > > > > You can also try other approaches and someone > > brilliant will do that ... but this is a doable path. > > Sounds like a plan! Sure you don't want to give it a go? ;-) I hope that the means you're rhetoric question knows its answer, namely: no. Anyway if you read carefully, that's the plan for a bunch of motivated people. Am I a bunch of people? and motivated? I already do my little coding with other people for "multi-platform" python, I wish I could do more in my directions, but I feel not too much guilty indicating reasonable plans for other motivated parties with different interests . We have chatted enough. Really this is going from nowhere to nowhere. Just chatting: that's the nature of usenet when someone does not eventually tries things out (at a terminal if it's hacking). Although if someone has a *concrete* point to make, then he should. I made mine. regards, Samuele Pedroni. From db3l at fitlinxx.com Fri Jan 4 00:11:00 2002 From: db3l at fitlinxx.com (David Bolen) Date: 03 Jan 2002 18:11:00 -0500 Subject: Mono and Python References: Message-ID: "Don Tuttle" writes: > Economic conditions haven't been good for over a year. So you realize this > just begs the question, "Then why did ActiveState ever start it? What did > they hope to achieve?" I believe Microsoft funded it (or at least part of it), so it was probably a low risk activity and presumably may have produced some knowledge benefit in terms of potential for future products. -- -- 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 tuttledon at mailandnews.com Fri Jan 4 02:26:15 2002 From: tuttledon at mailandnews.com (Don Tuttle) Date: Fri, 04 Jan 2002 01:26:15 GMT Subject: Mono and Python References: Message-ID: [Don Tuttle] > > Finally, many *nix users of Python my not realize that Python is about to > > become less functional on Windows without the .NET tagged on. (No ASP.NET > > or .NET Web services.) > > > > Whatever your religious platform, I'd hope you'd agree that losing > > functionality in Windows doesn't bode well for ANY language. [Andrew Kuchling] > And why should Unix users should care about this, if Python loses > functionality on a platform they never use? If Windows people are > worried about this, they're the one who should actually expend some > effort on fixing the problem. If you are in the "DIE WINDOZ DIE" camp you may be tempted to think this way. After all if Microsoft is betting the farm on .NET, why do anything that might remotely advance .NET. Especially when, by just sitting passively, doing nothing, you might help Microsoft lose the farm. But before you choose that path consider an alternative approach. A politician (Lincoln?) once said, "I keep my friends close and my enemies closer!" For WHATEVER reason, Microsoft has put C# and CLI/CLR into the public arena. What better way to keep the enemy close than to study the plans he's bet his future on! It's a rare opportunity that shouldn't be squandered by a religious war. Microsoft has built it's fortune by selling easy to use "good enough" software. Never cutting edge or innovative. Just good enough to keep the general public happy. Their philosophy about quality has amounted to "Ship first, fix later". .NET rests on the fact that it needs the Windows OS to run. The promise of the Mono project is a .NET on a Linux box. Sure it won't have all the bells and whistles that Microsoft can provide, but it will be "GOOD ENOUGH" to get the job done! Microsoft sales strategy for .NET is to bypass the IT dept. and pitch directly to upper management. Upper management is always in tune with $$$. (Some would say it's the only thing their in tune with ;-) What better way to counter the pitch then, "Gee, we're already doing that for free!" And even if the Mono project should go bust, just think what insights you could glean from Microsoft's $1,000,000,000.00 R&D budget and how they could then be applied to Parrot. Don From akuchlin at mems-exchange.org Fri Jan 4 16:35:32 2002 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 04 Jan 2002 10:35:32 -0500 Subject: Mono and Python References: Message-ID: <3d7kqyku2j.fsf@ute.mems-exchange.org> "Don Tuttle" writes: > passively, doing nothing, you might help Microsoft lose the farm. But > before you choose that path consider an alternative approach. You've missed my point. I don't care at all about whether Python runs on .net. I also don't care whether it runs on OS/2 or RISCOS. As it happens, Python does run on OS/2 and RISCOS, and it does so because people, presumably people who use those systems, contributed patches and code to make it happen. Python will run on .net, therefore, if some subset of .net users actually bother to make it happen. If no one bothers to do so, that's a good indicator that no one cares. --amk From paul at zope.com Fri Jan 4 16:55:50 2002 From: paul at zope.com (Paul Everitt) Date: Fri, 04 Jan 2002 10:55:50 -0500 Subject: Mono and Python References: <3d7kqyku2j.fsf@ute.mems-exchange.org> Message-ID: <3C35D086.3020103@zope.com> Hear, hear, Andrew! Well stated. There's a certain Darwinism of ideas in a volunteer community. Almost by definition, a good idea is one that someone actually works on, rather than lobbies for. By contrast, a bad idea is one that generates a hundred posts by people volunteering _others_ to do the work. To paraphrase, ask not what your Python community can do for you, but ask instead what you can do for your Python community. --Paul Andrew Kuchling wrote: > "Don Tuttle" writes: > >>passively, doing nothing, you might help Microsoft lose the farm. But >>before you choose that path consider an alternative approach. >> > > You've missed my point. I don't care at all about whether Python runs > on .net. I also don't care whether it runs on OS/2 or RISCOS. As it > happens, Python does run on OS/2 and RISCOS, and it does so because > people, presumably people who use those systems, contributed patches > and code to make it happen. Python will run on .net, therefore, if > some subset of .net users actually bother to make it happen. If no > one bothers to do so, that's a good indicator that no one cares. > > --amk > From ngps at madcap.netmemetic.com Fri Jan 4 17:57:17 2002 From: ngps at madcap.netmemetic.com (Ng Pheng Siong) Date: 4 Jan 2002 16:57:17 GMT Subject: Mono and Python References: Message-ID: According to Don Tuttle : > .NET rests on the fact that it needs the Windows OS to run. The promise of > the Mono project is a .NET on a Linux box. Maybe people who don't run Windows _nor_ Linux don't care both ways. ;-) The Mono FAQ does say: """Question 54: Will Mono only work on Linux? Currently, we are doing our work on Linux-based systems and Windows. We do not expect many Linux-isms in the code, so it should be easy to port Mono to other UNIX variants. """ -- Ng Pheng Siong * http://www.netmemetic.com From paul at prescod.net Sat Jan 5 04:01:48 2002 From: paul at prescod.net (Paul Prescod) Date: Fri, 04 Jan 2002 19:01:48 -0800 Subject: Mono and Python References: Message-ID: <3C366C9C.BEE5B563@prescod.net> Don Tuttle wrote: > >... > > Economic conditions haven't been good for over a year. So you realize this > just begs the question, "Then why did ActiveState ever start it? What did > they hope to achieve?" Financially, it was a joint project with Microsoft. Strategically, ActiveState also wanted to push the scripting world toward .NET for the reasons that you have discussed. But eventually the scripting world needs to get interested and involved. >... > > As to the Mono project I agree with you. But does anyone doubt Microsoft's > commitment to .NET? No, but the transition to .NET may take years and the COM interop is useful in the meantime. >... > As to why some young code slinger, eager to make a name for themselves, > hasn't already taken on the Python.NET project-- Could it be...ahum...that > it is because ActiveState said THEY would tackle the project, that said hero > never tried? That slinger would download ActiveState's start and finish it. There is significant intellectual value there. Furthermore, ActiveState did its part before the code slinger would have had access to the .NET documentation. So they should consider the code a running start. But .NET has not touched real programmer's lives yet, so people don't care. Open source programmers work on scratching itches. >... > Finally, many *nix users of Python my not realize that Python is about to > become less functional on Windows without the .NET tagged on. (No ASP.NET > or .NET Web services.) You can access .NET web services using any SOAP implementation. You can create .NET-compatible web services using any SOAP implementation, too. Paul Prescod From tuttledon at mailandnews.com Sat Jan 5 05:59:01 2002 From: tuttledon at mailandnews.com (Don Tuttle) Date: Sat, 05 Jan 2002 04:59:01 GMT Subject: Mono and Python References: Message-ID: Hi Paul, Thanks for clearing this up. I'm in your debt. From now on I'm going to pretend my last name is Bush and not be troubled by "that vision thing". And maybe a tatoo with your line- "Open source programmers work on scratching itches", lest I ever forget. ;-) One last note. I see your not using an ActiveState email account. I hope this just to avoid "The Opinions Expressed Here Are Not..." legal bs and doesn't mean you've been axed too! Don From paul at prescod.net Sun Jan 6 00:58:41 2002 From: paul at prescod.net (Paul Prescod) Date: Sat, 05 Jan 2002 15:58:41 -0800 Subject: Mono and Python References: Message-ID: <3C379331.E84FF4B9@prescod.net> Don Tuttle wrote: > >... > > One last note. I see your not using an ActiveState email account. I hope > this just to avoid "The Opinions Expressed Here Are Not..." legal bs and > doesn't mean you've been axed too! Before the layoffs I chose to switch to a part-time position at ActiveState so that I could engage in some research directions that didn't have anything to do with ActiveState. As such, I have some insight into why ActiveState does what it does but I don't really speak for them. Paul Prescod From mhammond at skippinet.com.au Fri Jan 4 05:10:26 2002 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 04 Jan 2002 04:10:26 GMT Subject: Mono and Python References: Message-ID: <3C352B3B.8020704@skippinet.com.au> Don Tuttle wrote: > In particular I was thinking about a post I made last month to the > ActivePython list about the furture of Python and .NET that went unanswered. I must have missed that - I would have made some reply had I seen it - even to not say much :) > I'd like to know if ActiveState's apparent abandonment of this project was > because it proved to technically difficult (imposable?) or simply because > they felt the ROI wasn't there. ROI really. There is a lot of work, and not a huge amount of interest. Mark. From tuttledon at mailandnews.com Thu Jan 3 07:56:57 2002 From: tuttledon at mailandnews.com (Don Tuttle) Date: Thu, 03 Jan 2002 06:56:57 GMT Subject: Mono and Python References: Message-ID: (ps) "Tim Peters" > If I had spare cycles, I'd devote them to pushing Armin > Rigo's Psyco along -- but I don't. http://student.ulb.ac.be/~arigo/psyco/ I can see why you'd want to! Here's hoping you win the lottery and have cycles to burn! > if-an-area-attracts-neither-volunteers-nor-cash-...-ly y'rs - tim Understood. :-( Don From tuttledon at mailandnews.com Thu Jan 3 18:40:25 2002 From: tuttledon at mailandnews.com (Don Tuttle) Date: Thu, 03 Jan 2002 17:40:25 GMT Subject: Mono and Python References: Message-ID: [Don] >> does anyone knows how this compares to Perl.NET? [Brian Quinlan] > Mark's Python .NET prototype actually compiles Python code down to IL > for execution by the CLR (common language runtime). Perl .NET works in a > completely different fashion - bridge code is generated but the usual > Perl interpreter is still used at runtime. I think what your referring to is called PerlNET (no dot, see http://aspn.activestate.com/ASPN/NET You gotta love marketing people ;-). What I'm curious about is how their experimental Perl compiler compares to their Python compiler. And for that matter whether the Perl .NET compiler project is still alive. Don From paul at prescod.net Sat Jan 5 04:10:08 2002 From: paul at prescod.net (Paul Prescod) Date: Fri, 04 Jan 2002 19:10:08 -0800 Subject: Mono and Python References: Message-ID: <3C366E90.7DB46AB@prescod.net> Don Tuttle wrote: > >... > > I think what your referring to is called PerlNET (no dot, see > http://aspn.activestate.com/ASPN/NET You gotta love marketing people ;-). > > What I'm curious about is how their experimental Perl compiler compares to > their Python compiler. I think that the Python one is more complete and usable. > ... And for that matter whether the Perl .NET compiler > project is still alive. It is open source software so anyone can continue work on it, but I don't think that ActiveState will do much more work on it. Paul Prescod From bvdpoel at uniserve.com Wed Jan 2 03:14:08 2002 From: bvdpoel at uniserve.com (bvdpoel at uniserve.com) Date: Tue, 01 Jan 2002 19:14:08 -0700 Subject: Deleting from a list Message-ID: <3C326CF0.A28B9FC7@uniserve.com> Does python have a notion as to where the current item in a list is? I have something like: for l in lines: if something ... if something else: delete l from list Of course, this doesn't work. So, I tried: for i in len(lines): l=lines[i] ... if ...: lines.pop(i) and this causes problems since 'i' can now point to out of range lines. I ired: for l in lines: if...: lines.remove(l) But, this buggers the sequence. If you have [1,2,3,6,6,6,7] and delete on the condition l==6, you only delete 2 '6's, not all 3. So, finally, I did: for i in len(lines) l=lines(i) ... if ..: lines[i]=None while(lines.count(None): lines.remove(None) My question: Is there a cleaner way to do all this? Having 2 loops seems to be ugly. -- Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bvdpoel at uniserve.com WWW: http://users.uniserve.com/~bvdpoel From bbollenbach at home.com Wed Jan 2 04:07:13 2002 From: bbollenbach at home.com (Brad Bollenbach) Date: Wed, 02 Jan 2002 03:07:13 GMT Subject: Deleting from a list References: <3C326CF0.A28B9FC7@uniserve.com> Message-ID: wrote in message news:3C326CF0.A28B9FC7 at uniserve.com... > > Does python have a notion as to where the current item in a list is? [snip examples attempts at removing an item from a list] You could do, simply: foo = [1, 2, 3, 4] for i in range(foo): if foo[i] == 3: del foo[i] foo would then contain [1, 2, 4] HTH, Brad From bbollenbach at home.com Wed Jan 2 04:25:38 2002 From: bbollenbach at home.com (Brad Bollenbach) Date: Wed, 02 Jan 2002 03:25:38 GMT Subject: Deleting from a list (correction) References: <3C326CF0.A28B9FC7@uniserve.com> Message-ID: "Brad Bollenbach" wrote in message news:BPuY7.18080$L4.1822646 at news2.calgary.shaw.ca... > wrote in message > news:3C326CF0.A28B9FC7 at uniserve.com... > > > > Does python have a notion as to where the current item in a list is? > [snip examples attempts at removing an item from a list] > > You could do, simply: > > foo = [1, 2, 3, 4] > > for i in range(foo): > if foo[i] == 3: > del foo[i] > > foo would then contain [1, 2, 4] Bah, silly me. Scrap that. Depending on what you want to do, you may consider either: a.) using del foo[i] if you know i in advance (that is, no looping required). b.) use filter(func, foo) to construct a list consist of those elements for which func returns true (chances to use filter() shouldn't be passed up! :). c.) use foo.remove("value") to remove the item with the smallest index if that's suitable for your situation. From skip at pobox.com Wed Jan 2 04:16:22 2002 From: skip at pobox.com (Skip Montanaro) Date: Tue, 1 Jan 2002 21:16:22 -0600 Subject: Deleting from a list In-Reply-To: <3C326CF0.A28B9FC7@uniserve.com> References: <3C326CF0.A28B9FC7@uniserve.com> Message-ID: <15410.31622.504130.996008@12-248-41-177.client.attbi.com> Bob> ... I tried: Bob> for i in len(lines): Bob> l=lines[i] Bob> ... Bob> if ...: Bob> lines.pop(i) Bob> and this causes problems since 'i' can now point to out of range Bob> lines. Try walking backward through the list: for i in range(len(lines)-1,-1,-1): if something: del lines[i] -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From jason at jorendorff.com Wed Jan 2 04:42:19 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Tue, 1 Jan 2002 21:42:19 -0600 Subject: Deleting from a list In-Reply-To: <3C326CF0.A28B9FC7@uniserve.com> Message-ID: > My question: Is there a cleaner way to do all this? Having 2 loops seems > to be ugly. i = 0 while i < len(lines): line = lines[i] ... if should_delete_this(line): del lines[i] continue # This intentionally doesn't increment i. ... i += 1 But I usually just build the result list as I go instead. It's clearer. ok_lines = [] for line in lines: ... ... if ok(line): ok_lines.append(line) ## Jason Orendorff http://www.jorendorff.com/ From emile at fenx.com Wed Jan 2 04:53:42 2002 From: emile at fenx.com (Emile van Sebille) Date: Tue, 1 Jan 2002 19:53:42 -0800 Subject: Deleting from a list References: <3C326CF0.A28B9FC7@uniserve.com> Message-ID: wrote in message news:3C326CF0.A28B9FC7 at uniserve.com... > > Does python have a notion as to where the current item in a list is? I > have something like: > > for l in lines: > if something ... > if something else: > delete l from list > > Of course, this doesn't work. So, I tried: > > for i in len(lines): > l=lines[i] > ... > if ...: > lines.pop(i) > > and this causes problems since 'i' can now point to out of range lines. > > I ired: > > for l in lines: > if...: > lines.remove(l) > > But, this buggers the sequence. If you have [1,2,3,6,6,6,7] and delete > on the condition l==6, you only delete 2 '6's, not all 3. > > So, finally, I did: > > for i in len(lines) > l=lines(i) > ... > if ..: > lines[i]=None > > while(lines.count(None): > lines.remove(None) > > > My question: Is there a cleaner way to do all this? Having 2 loops seems > to be ugly. > Deleting from a list while in a for loop can lead to trouble. Doing it yourself is safer: >>> l = [1,2,3,6,6,6,7] >>> i = 0 >>> while i < len(l): if l[i] == 6: del l[i] else: i += 1 >>> l [1, 2, 3, 7] >>> Or you may want to consider something like: >>> l = [1,2,3,6,6,6,7] >>> [ i for i in l if i != 6] [1, 2, 3, 7] -- Emile van Sebille emile at fenx.com --------- From wurmy at earthlink.net Wed Jan 2 05:13:24 2002 From: wurmy at earthlink.net (Hans Nowak) Date: Wed, 02 Jan 2002 04:13:24 GMT Subject: Deleting from a list References: <3C326CF0.A28B9FC7@uniserve.com> Message-ID: <3C328893.B41CE323@earthlink.net> bvdpoel at uniserve.com wrote: > > Does python have a notion as to where the current item in a list is? I > have something like: > > for l in lines: > if something ... > if something else: > delete l from list > > Of course, this doesn't work. So, I tried: > > for i in len(lines): > l=lines[i] > ... > if ...: > lines.pop(i) > > and this causes problems since 'i' can now point to out of range lines. You can traverse the list backwards: >>> x = [1, 2, 3, 6, 7, 8, 1, 1, 7, 1] >>> for i in range(len(x)-1,-1,-1): if x[i] == 1: # or a condition of your choice del x[i] >>> x [2, 3, 6, 7, 8, 7] >>> HTH, --Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA==\n') # decode for email address ;-) Site:: http://www.awaretek.com/nowak/ From bvdpoel at uniserve.com Wed Jan 2 17:39:18 2002 From: bvdpoel at uniserve.com (bvdpoel at uniserve.com) Date: Wed, 02 Jan 2002 09:39:18 -0700 Subject: Deleting from a list References: <3C326CF0.A28B9FC7@uniserve.com> <3C328893.B41CE323@earthlink.net> Message-ID: <3C3337B6.5625F6B0@uniserve.com> Thanks for all the suggestions guys! I think that walking the list backwards probably makes my life the easiest... Hans Nowak wrote: > > bvdpoel at uniserve.com wrote: > > > > Does python have a notion as to where the current item in a list is? I > > have something like: > > > > for l in lines: > > if something ... > > if something else: > > delete l from list > > > > Of course, this doesn't work. So, I tried: > > > > for i in len(lines): > > l=lines[i] > > ... > > if ...: > > lines.pop(i) > > > > and this causes problems since 'i' can now point to out of range lines. > > You can traverse the list backwards: > > >>> x = [1, 2, 3, 6, 7, 8, 1, 1, 7, 1] > >>> for i in range(len(x)-1,-1,-1): > if x[i] == 1: # or a condition of your choice > del x[i] > >>> x > [2, 3, 6, 7, 8, 7] > >>> > > HTH, > > --Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA==\n') > # decode for email address ;-) > Site:: http://www.awaretek.com/nowak/ -- Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bvdpoel at uniserve.com WWW: http://users.uniserve.com/~bvdpoel From wurmy at earthlink.net Wed Jan 2 05:15:30 2002 From: wurmy at earthlink.net (Hans Nowak) Date: Wed, 02 Jan 2002 04:15:30 GMT Subject: Deleting from a list (reprise) References: <3C326CF0.A28B9FC7@uniserve.com> Message-ID: <3C32891A.C5E683A1@earthlink.net> bvdpoel at uniserve.com wrote: > I ired: > > for l in lines: > if...: > lines.remove(l) > > But, this buggers the sequence. If you have [1,2,3,6,6,6,7] and delete > on the condition l==6, you only delete 2 '6's, not all 3. If you want to remove all occurrences of a certain object/number from the list, you can do something like the following: >>> x = [1, 2, 3, 1, 2, 8, 3, 1, 1, 1, 6] >>> while 1 in x: x.remove(1) >>> x [2, 3, 2, 8, 3, 6] >>> -- --Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA==\n') # decode for email address ;-) Site:: http://www.awaretek.com/nowak/ From anthony at interlink.com.au Wed Jan 2 07:16:49 2002 From: anthony at interlink.com.au (Anthony Baxter) Date: Wed, 02 Jan 2002 17:16:49 +1100 Subject: Deleting from a list (reprise) In-Reply-To: Message from Hans Nowak of "Wed, 02 Jan 2002 04:15:30 GMT." <3C32891A.C5E683A1@earthlink.net> Message-ID: <200201020616.g026Gnh07288@mbuna.arbhome.com.au> >>> Hans Nowak wrote > >>> x = [1, 2, 3, 1, 2, 8, 3, 1, 1, 1, 6] > >>> while 1 in x: > x.remove(1) > >>> x > [2, 3, 2, 8, 3, 6] > >>> note that this is pretty inefficient, as it starts at the start of the list each time through the loop. I know my python hindbrain tends to prick up it's little ears whenever it sees my stupid frontbrain write code like "foo in listobj" to make sure I shouldn't be using something like a dictionary instead. Anthony From wurmy at earthlink.net Wed Jan 2 08:50:01 2002 From: wurmy at earthlink.net (Hans Nowak) Date: Wed, 02 Jan 2002 07:50:01 GMT Subject: Deleting from a list (reprise) References: Message-ID: <3C32BB53.C52BD2B7@earthlink.net> Anthony Baxter wrote: > > >>> Hans Nowak wrote > > >>> x = [1, 2, 3, 1, 2, 8, 3, 1, 1, 1, 6] > > >>> while 1 in x: > > x.remove(1) > > >>> x > > [2, 3, 2, 8, 3, 6] > > >>> > > note that this is pretty inefficient, as it starts at the start of > the list each time through the loop. Agreed. For small lists, the performance difference is trivial, though. I made a silly little benchmark (not posted) that shows that walking through the list backwards is almost always faster than the 'while x in lst' method shown above. How much faster depends on the frequency of the object-to-be-removed. --Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA==\n') # decode for email address ;-) Site:: http://www.awaretek.com/nowak/ From aleax at aleax.it Wed Jan 2 10:02:05 2002 From: aleax at aleax.it (Alex Martelli) Date: Wed, 2 Jan 2002 10:02:05 +0100 Subject: Deleting from a list (reprise) References: <3C32BB53.C52BD2B7@earthlink.net> Message-ID: "Hans Nowak" wrote in message news:3C32BB53.C52BD2B7 at earthlink.net... > Anthony Baxter wrote: > > > > >>> Hans Nowak wrote > > > >>> x = [1, 2, 3, 1, 2, 8, 3, 1, 1, 1, 6] > > > >>> while 1 in x: > > > x.remove(1) > > > >>> x > > > [2, 3, 2, 8, 3, 6] > > > >>> > > > > note that this is pretty inefficient, as it starts at the start of > > the list each time through the loop. > > Agreed. For small lists, the performance difference is trivial, > though. I made a silly little benchmark (not posted) that shows > that walking through the list backwards is almost always > faster than the 'while x in lst' method shown above. How much > faster depends on the frequency of the object-to-be-removed. Benchmarking is a good idea: intuition often fails to give the "right" answer. Try, for example, the following: import time, random def do_bench(n, func, *args): start = time.clock() for i in range(n): func(*args) stend = time.clock() print " %s %.2f"%(func.__name__, stend-start) def delwhile(sequence, marker): sequence[:] = sequence while marker in sequence: sequence.remove(marker) def delreverse(sequence, marker): sequence[:] = sequence for i in range(len(sequence), 0, -1): if sequence[i-1]==marker: del sequence[i-1] def delfilter(sequence, marker): sequence[:] = sequence def nomarker(item, marker=marker): return item != marker sequence[:] = filter(nomarker, sequence) def bench_run(length=100, freqma=0.2): # prepare reference sequence refr = range(length) marker = length+1 for i in range(length): if random.random()python -O benchy.py l=10 p=0.05 delwhile 0.01 delreverse 0.04 delfilter 0.07 l=10 p=0.10 delwhile 0.01 delreverse 0.04 delfilter 0.08 l=10 p=0.15 delwhile 0.01 delreverse 0.04 delfilter 0.07 l=20 p=0.05 delwhile 0.01 delreverse 0.06 delfilter 0.11 l=20 p=0.10 delwhile 0.01 delreverse 0.06 delfilter 0.10 l=20 p=0.15 delwhile 0.01 delreverse 0.05 delfilter 0.09 l=50 p=0.05 delwhile 0.02 delreverse 0.12 delfilter 0.22 l=50 p=0.10 delwhile 0.02 delreverse 0.12 delfilter 0.20 l=50 p=0.15 delwhile 0.02 delreverse 0.11 delfilter 0.19 C:\Python22> Counter-intuitively to me, the trivial 'delwhile' approach appears to be substantially faster than the "advanced" ideas on this benchmark run -- and not by trivial amounts, either: 5 or 10 times faster is NOT a speedup to sneer at. As this sharply contradicts your findings about "almost always faster", it's no doubt worth double checking both this benchmark and yours: it IS quite possibly that I've goofed up somewhere (though I can't see it). Alex From wurmy at earthlink.net Wed Jan 2 11:05:46 2002 From: wurmy at earthlink.net (Hans Nowak) Date: Wed, 02 Jan 2002 10:05:46 GMT Subject: Deleting from a list (reprise) References: <3C32BB53.C52BD2B7@earthlink.net> Message-ID: <3C32DB2D.D7005713@earthlink.net> Alex Martelli wrote: > Counter-intuitively to me, the trivial 'delwhile' approach appears to > be substantially faster than the "advanced" ideas on this benchmark > run -- and not by trivial amounts, either: 5 or 10 times faster is NOT > a speedup to sneer at. > > As this sharply contradicts your findings about "almost always faster", > it's no doubt worth double checking both this benchmark and yours: it > IS quite possibly that I've goofed up somewhere (though I can't see it). Well, I tested it with lists of 10,000 elements... lists as small as 50 elements would all give me runtimes of 0.0 seconds. :-( Of course, I could repeat the function N times, like you are doing, but I wasn't that interested, and it's 5 AM here, so... :-) Here's my benchmark code: #---begin--- import random import time def create_random_list(amplitude, num_elems): return [int(random.random() * amplitude) for i in range(num_elems)] def test(amplitude, num_elems): print "Testing with amplitude", amplitude, "and", num_elems, "elements" lst1 = create_random_list(amplitude, num_elems) lst2 = lst1[:] # method 1: while x in list start = time.time() while 1 in lst1: lst1.remove(1) stop = time.time() print "Method 1:", stop - start, "seconds" # method 2: walk through the list in reverse start = time.time() for i in range(len(lst2)-1,-1,-1): if lst2[i] == 1: del lst2[i] stop = time.time() print "Method 2:", stop - start, "seconds" test(10, 10000) test(100, 10000) test(1000, 10000) #---end--- I don't use benchmarks often, so maybe I've done something wrong. (Well, aside from this method's inability to accurately measure the results for small lists...) --Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA==\n') # decode for email address ;-) Site:: http://www.awaretek.com/nowak/ From jason at jorendorff.com Wed Jan 2 19:07:58 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Wed, 2 Jan 2002 12:07:58 -0600 Subject: Deleting from a list (reprise) In-Reply-To: Message-ID: > def delwhile(sequence, marker): > sequence[:] = sequence > while marker in sequence: sequence.remove(marker) I think you mean sequence = sequence[:] # make a copy of 'sequence' What you wrote splices the list into itself (basically a no-op), with the result that the original sequence is modified in-place. The other runs, therefore, work with freqma=0. Also: try this one. It's pretty quick. def delcomp(sequence, marker): sequence = [i for i in sequence if i != marker] ## Jason Orendorff http://www.jorendorff.com/ From aleax at aleax.it Wed Jan 2 23:17:15 2002 From: aleax at aleax.it (Alex Martelli) Date: Wed, 2 Jan 2002 23:17:15 +0100 Subject: Deleting from a list (reprise) In-Reply-To: References: Message-ID: <02010223171504.29195@arthur> On Wednesday 02 January 2002 19:07, Jason Orendorff wrote: > > def delwhile(sequence, marker): > > sequence[:] = sequence > > while marker in sequence: sequence.remove(marker) > > I think you mean > sequence = sequence[:] # make a copy of 'sequence' > > What you wrote splices the list into itself (basically a no-op), > with the result that the original sequence is modified in-place. Ooops -- yes. I definitely DID intend a copy to be taken!-) Alex From emile at fenx.com Wed Jan 2 20:50:52 2002 From: emile at fenx.com (Emile van Sebille) Date: Wed, 2 Jan 2002 11:50:52 -0800 Subject: Deleting from a list (reprise) References: Message-ID: "Jason Orendorff" wrote in message news:mailman.1009995124.12967.python-list at python.org... > > def delwhile(sequence, marker): > > sequence[:] = sequence > > while marker in sequence: sequence.remove(marker) > > I think you mean > sequence = sequence[:] # make a copy of 'sequence' > > What you wrote splices the list into itself (basically a no-op), > with the result that the original sequence is modified in-place. > The other runs, therefore, work with freqma=0. > > Also: try this one. It's pretty quick. > > def delcomp(sequence, marker): > sequence = [i for i in sequence if i != marker] > This doesn't modify sequence, but creates a new one within the function. It'll work if you add 'return sequence' and invoke it as sequence=delcomp(sequence,marker) Alternately, this combination of the two modifies sequence: >>> seq [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> def delcomp(sequence, marker): sequence[:] = [i for i in sequence if i != marker] >>> seq [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> delcomp(seq,3) >>> seq [0, 1, 2, 4, 5, 6, 7, 8, 9] >>> -- Emile van Sebille emile at fenx.com --------- From jason at jorendorff.com Wed Jan 2 23:39:17 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Wed, 2 Jan 2002 16:39:17 -0600 Subject: Deleting from a list (reprise) In-Reply-To: Message-ID: > > Also: try this one. It's pretty quick. > > > > def delcomp(sequence, marker): > > sequence = [i for i in sequence if i != marker] > > > > This doesn't modify sequence, but creates a new one within the function. > > It'll work if you add 'return sequence' and invoke it as > sequence=delcomp(sequence,marker) Yes, but it's just a benchmark. We don't care about the result except that the algorithm must be correct. ## Jason Orendorff http://www.jorendorff.com/ From tim.one at home.com Wed Jan 2 05:02:41 2002 From: tim.one at home.com (Tim Peters) Date: Tue, 1 Jan 2002 23:02:41 -0500 Subject: threading.py -> winthreading.c : Some results In-Reply-To: Message-ID: [posted & mailed] [Jason Orendorff] > I've reimplemented the synchronization objects of threading.py > in non-portable, Win32-only C. Sorry I haven't had time to follow up on this -- it's interesting and I want to encourage you (so I don't have to do it later ). > The C versions of RLock, Event, Semaphore, and Condition perform > at least 5x faster than their standard counterparts in threading.py > in every situation I've tried. Acquiring an RLock runs 25x faster. > Condition.wait(timeout) runs 500x faster. > > This benchmark: > http://www.bagley.org/~doug/shootout/bench/prodcons/prodcons.python > runs 6.3 times as fast under the C version of Condition. > That's fast enough to post a reasonably non-humiliating benchmark > number; it closes the gap between Python and Java considerably. > ...If you care about such things. ...As of course no sane person > does. > > Whether this C code would mean a significant performance increase > in a real-life program remains to be proven. Comments? It depends on the program, of course. You could also consider solving a simpler problem, which would definitely increase performance of real-life programs: "Python locks" are also used internally by Python, most notoriously for the global interpreter lock. A Python lock has the unusual property that it's neither "owned" nor reentrant: any thread can release a Python lock, whether or not it was the thread that acquired it. And it's legit for any thread to try to acquire a Python lock, even if the thread has already acquired it (and in that case, the thread blocks until some other thread releases the lock -- the point is that this is defined and reliable behavior of a Python lock, but of few other flavors of lock). However, Python's internal uses of locks-- and particularly the GIL --don't need these unusual (relative to what platforms usually offer in the way of native synch gimmicks) semantics. The GIL is "owned": a thread T that acquires the GIL won't try to acquire it again while it's acquired, T will eventually release it itself, and no other thread will attempt to release it while T has it held. Most platforms have a more efficient synch implementation for this simple usage, but we never got around to creating an internal lock type to exploit this. Just about *any* mutex gimmick would suffice except for a spin lock (the GIL can be held by a thread for an arbitrarily long time): the GIL exists solely to enforce serialization. c'mon-you've-been-working-on-this-for-a-year-already-ly y'rs - tim From phr-n2002a at nightsong.com Wed Jan 2 06:24:44 2002 From: phr-n2002a at nightsong.com (Paul Rubin) Date: 01 Jan 2002 21:24:44 -0800 Subject: threading.py -> winthreading.c : Some results References: Message-ID: <7xn0zx8gv7.fsf@ruckus.brouhaha.com> "Tim Peters" writes: > However, Python's internal uses of locks-- and particularly the GIL --don't > need these unusual (relative to what platforms usually offer in the way of > native synch gimmicks) semantics. The GIL is "owned": a thread T that > acquires the GIL won't try to acquire it again while it's acquired, T will > eventually release it itself, and no other thread will attempt to release it > while T has it held. Most platforms have a more efficient synch > implementation for this simple usage, but we never got around to creating an > internal lock type to exploit this. Just about *any* mutex gimmick would > suffice except for a spin lock (the GIL can be held by a thread for an > arbitrarily long time): the GIL exists solely to enforce serialization. Is it feasible to replace the GIL with something else, that allows Python programs to use the parallelism on multi-cpu systems? From db3l at fitlinxx.com Wed Jan 2 19:07:39 2002 From: db3l at fitlinxx.com (David Bolen) Date: 02 Jan 2002 13:07:39 -0500 Subject: threading.py -> winthreading.c : Some results References: <7xn0zx8gv7.fsf@ruckus.brouhaha.com> Message-ID: Paul Rubin writes: > "Tim Peters" writes: > > However, Python's internal uses of locks-- and particularly the > > GIL --don't need these unusual (relative to what platforms usually > > offer in the way of native synch gimmicks) semantics. The GIL is > > "owned": a thread T that acquires the GIL won't try to acquire it > > again while it's acquired, T will eventually release it itself, > > and no other thread will attempt to release it while T has it > > held. Most platforms have a more efficient synch implementation > > for this simple usage, but we never got around to creating an > > internal lock type to exploit this. Just about *any* mutex > > gimmick would suffice except for a spin lock (the GIL can be held > > by a thread for an arbitrarily long time): the GIL exists solely > > to enforce serialization. > > Is it feasible to replace the GIL with something else, that allows > Python programs to use the parallelism on multi-cpu systems? Theoretically, sure, but that's a ton more work than just providing a native GIL. The GIL provides the assurance that no two executions of Python core code occur simultaneously, and most of the Python core is written with this specific assumption, so any change to that assumption would also mean a far reaching set of changes to much/most of the core code. You also have the potential overhead for introducing the extra fine grained checking, which might actually slow things down in the (currently) more typical single-CPU system. Whether or not the work falls into the "feasible" category probably depends on someone having the time and resource to work on it - from prior discussions on the subject my guess is nobody yet qualifies :-) -- -- 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 tim.one at home.com Thu Jan 3 06:16:48 2002 From: tim.one at home.com (Tim Peters) Date: Thu, 3 Jan 2002 00:16:48 -0500 Subject: threading.py -> winthreading.c : Some results In-Reply-To: <7xn0zx8gv7.fsf@ruckus.brouhaha.com> Message-ID: [Paul Rubin] > Is it feasible to replace the GIL with something else, that allows > Python programs to use the parallelism on multi-cpu systems? Python does use it: if you restrict yourself to one process, Python helps out by letting other programs use all the other CPUs . You can search the archives for "free threading" for many prior discussions of this. Bottom line: Greg Stein did this once when it was easier than it would be now; it worked; it was a major effort; and it slowed single-thread Python programs by about a factor of 2 (due to dynamic mountains of new finer-grained internal synch gimmicks needed to preserve enough atomicity to keep semantics sane). From jason at jorendorff.com Wed Jan 2 07:07:45 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Wed, 2 Jan 2002 00:07:45 -0600 Subject: threading.py -> winthreading.c : Some results In-Reply-To: Message-ID: Jason Orendorff: > > I've reimplemented the synchronization objects of threading.py > > in non-portable, Win32-only C. Tim Peters: > Sorry I haven't had time to follow up on this -- it's interesting > and I want to encourage you (so I don't have to do it later ). Thanks for your encouragement! It seems there's no demand for this right now. But I'd like to submit what I have, so that in any case it can be kept in reserve against the chance that someone will someday need it. How should I do this...? Tim again: > You could also consider solving a simpler problem, [...] Hmm. Now *that's* interesting. ## Jason Orendorff http://www.jorendorff.com/ From tim.one at home.com Thu Jan 3 06:22:45 2002 From: tim.one at home.com (Tim Peters) Date: Thu, 3 Jan 2002 00:22:45 -0500 Subject: threading.py -> winthreading.c : Some results In-Reply-To: Message-ID: [Jason Orendorff] > It seems there's no demand for this right now. Ya, but people don't know what they need until after you give it to them and later take it away. Nobody *asked* for Stackless Python either, not to mention tabnanny.py . For that matter, Guido personally rammed Python down an uninterested world's constricted throat. > ut I'd like to submit what I have, so that in any case it can be > kept in reserve against the chance that someone will someday need it. > How should I do this...? Upload a patch to SourceForge. Then it won't get lost, it's with all the other contributed ideas that may actually go somwhere, and interested parties can (and will) play with it. From jason at jorendorff.com Mon Jan 7 18:20:30 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Mon, 7 Jan 2002 11:20:30 -0600 Subject: winthreading is on SourceForge In-Reply-To: Message-ID: > > I'd like to submit what I have, so that in any case it can be > > kept in reserve against the chance that someone will someday need it. > > How should I do this...? > > Upload a patch to SourceForge. Then it won't get lost, it's with all the > other contributed ideas that may actually go somwhere, and interested > parties can (and will) play with it. Okay, this is finally done. C source code, a PYD file, and test cases in Python: http://sourceforge.net/tracker/index.php?func=detail&aid=500447&group_id=547 0&atid=305470 ## Jason Orendorff http://www.jorendorff.com/ From jlh at home.com Wed Jan 2 06:20:24 2002 From: jlh at home.com (Jeff Hinrichs) Date: Tue, 1 Jan 2002 23:20:24 -0600 Subject: cgi.FieldStorage and POST Message-ID: <08b801c1934d$2ec2ae80$6702a8c0@gato> I'm playing with python's cgi module and I am encountering an unexpected problem. I have a form that will work if I use method="GET", .FieldStorage() returns the expected values. But if I change the method in the form to POST, .FieldStorage() is empty. ...code snippet... form = cgi.FieldStorage() print form.keys() a GET returns ['a', 'c', 'cmdUpload'] a POST returns [] The form is simplistic, 1 input, 1 hidden and 1 submit I am running other python cgi's with no problem. Running ActiveState Python 2.1.1 build 212 I assume that I'm doing something wrong, but searching on google hasn't resulted in my clue phone ringing. -jeff From maxm at mxm.dk Wed Jan 2 10:00:55 2002 From: maxm at mxm.dk (maxm) Date: Wed, 2 Jan 2002 10:00:55 +0100 Subject: cgi.FieldStorage and POST References: Message-ID: We really need to see the form also. If ie. you are uploading a file, you need to set enctype="multipart/form-data". Which is easy to forget. regards Max M "Jeff Hinrichs" wrote in message news:mailman.1009948862.8390.python-list at python.org... > I'm playing with python's cgi module and I am encountering an unexpected > problem. From jlh at home.com Thu Jan 3 00:50:25 2002 From: jlh at home.com (Jeff Hinrichs) Date: Wed, 2 Jan 2002 17:50:25 -0600 Subject: cgi.FieldStorage and POST Message-ID: <0ac901c193e8$3fefcb20$6702a8c0@gato> Max, Here is the info you requested and some more just in case you need. Thanks, Jeff Here is the form: ------------------ Module Upload
crap
Here is my server: ------------------ from BaseHTTPServer import HTTPServer from CGIHTTPServer import CGIHTTPRequestHandler import os print "Starting Python Web Server..." port = 999 servr = HTTPServer(('', port), CGIHTTPRequestHandler) servr.serve_forever() and here is my cgi: --------------------- # Actually on CGI is required, but sys allows us to redirect stderr import cgi,sys #make sure errors go to standard out, first thing to do in script sys.stderr = sys.stdout print 'Content-type: text/html\n' def printFormVars(fields): for key in fields.keys(): print key, "=>",fields[key].value, '
' #def getValue(fields,key): # return pipes.quote(fields[key].value) form = cgi.FieldStorage() #print form.keys() if not form: #display blank form print '' print ' Module Upload' print '' print '
' print '' print '' print '' print 'crap' print '
' print '' print '' else : #perform action #REMEMBER TO SANITIZE INPUT i.e. user = pipes.quote(form"user"].value) print '' print ' Module Upload' print '' printFormVars(form) print '' print '' > ----- Original Message ----- > From: "maxm" > To: "Jeff Hinrichs" > Sent: Wednesday, January 02, 2002 3:00 AM > Subject: Re: cgi.FieldStorage and POST > > > > We really need to see the form also. > > > > If ie. you are uploading a file, you need to set > > enctype="multipart/form-data". Which is easy to forget. > > > > regards Max M > > > > "Jeff Hinrichs" wrote in message > > news:mailman.1009948862.8390.python-list at python.org... > > > I'm playing with python's cgi module and I am encountering an unexpected > > > problem. > > > > > > > > > > > From matt at lorfeld.com Wed Jan 2 06:21:15 2002 From: matt at lorfeld.com (mlorfeld) Date: 1 Jan 2002 21:21:15 -0800 Subject: Python-cgi Web Cobrowsing app Message-ID: <32c382ad.0201012121.3fc2731e@posting.google.com> I posted this message earlier, but as it was on Christmas Eve, so apologies for those who have read, but still an urgent request for your thoughts. I am involved with a project that is developing a web based collaboration tool. Currently we are using web-embedded voice over IP for classroom and other purposes (http://www.cu-hearme.com). To better communicate we would like to enable everyone involved to be able to Cobrowse. By cobrowse I mean when one person enters a url (in a frame for instance) everyone in that collaboration session would be pushed the same web page. I have looked at java implementations (coldbeans java servlets) as well as integrated collaborations tools (www.blackboard.com). These however don't quite fit the niche we are looking for. I have also looked at Zope, yet as I'm posting this, I am still just browsing through the documentation so I don't know if it is even the right way to look. Another approach to this that I've been tinkering with is using a python cgi script to call from an sql database the most recent url posted. I desprately need another perspective, as I have a gut instinct I'm approaching this the wrong way. I believe that python would be the best developement language as it lends itself nicely for rapid developement. Any suggestions, code, directions would be greatly appreciated. Again the goal is to allow for a member of a group to push a URL to others real time. This needs to be done either server side, or within the browser as interoperability is essential. Thanks, Matt Lorfeld From gleki at gol.ge Thu Jan 3 19:38:03 2002 From: gleki at gol.ge (Giorgi Lekishvili) Date: Thu, 03 Jan 2002 10:38:03 -0800 Subject: Python-cgi Web Cobrowsing app References: <32c382ad.0201012121.3fc2731e@posting.google.com> Message-ID: <3C34A50B.9C6AF549@gol.ge> Hi! I would recommend you Slither... I am not quite sure that's what you need:( Nevertheless, the book "Web Programming in Python" will be of certain iterest to you: ISBN 0-13-041065-9 The authors: George K. Thiruvathukal, Thomas W. Christopher & John P. Shafaee Grtz, Giorgi mlorfeld wrote: > I posted this message earlier, but as it was on Christmas Eve, so > apologies for those who have read, but still an urgent request for > your thoughts. > > I am involved with a project that is developing a web based > collaboration tool. Currently we are using web-embedded voice over IP > for classroom and other purposes (http://www.cu-hearme.com). To > better communicate we would like to enable everyone involved to be > able to Cobrowse. By cobrowse I mean when one person enters a url (in > a frame for instance) everyone in that collaboration session would be > pushed the same web page. I have looked at java implementations > (coldbeans java servlets) as well as integrated collaborations tools > (www.blackboard.com). These however don't quite fit the niche we are > looking for. I have also looked at Zope, yet as I'm posting this, I > am still just browsing through the documentation so I don't know if it > is even the right way to look. Another approach to this that I've > been tinkering with is using a python cgi script to call from an sql > database the most recent url posted. I desprately need another > perspective, as I have a gut instinct I'm approaching this the wrong > way. I believe that python would be the best developement language as > it lends itself nicely for rapid developement. Any suggestions, code, > directions would be greatly appreciated. Again the goal is to allow > for a member of a group to push a URL to others real time. This needs > to be done either server side, or within the browser as > interoperability is essential. > > Thanks, > Matt Lorfeld From ajm at enteract.com Wed Jan 2 06:51:49 2002 From: ajm at enteract.com (Alan Miller) Date: Tue, 1 Jan 2002 23:51:49 -0600 Subject: US taxes: parsing postscript and/or pdf? References: Message-ID: Harry George (hgg9140 at seanet.com) wrote: >If not, my next approach is to download IRS forms in PDF or >Postscript, and then manipulate those templates. That requires >parsing the pdf or postscript, detecting named fields, putting in new >data, and regenrating the printable format. If the IRS-provided PDF forms are fillable PDFs, look into FDFs. Information should be available on FDF formats. If you're looking at parsing the raw PDF or PS and trying to determine what's supposed to be fillable and what's not, good luck. Your best bet would probably be to check on what the PDFs actually support right now, and consider getting Acrobat to add fillable fields to them if needed. ajm From hgg9140 at seanet.com Thu Jan 3 00:58:43 2002 From: hgg9140 at seanet.com (Harry George) Date: 02 Jan 2002 15:58:43 -0800 Subject: US taxes: parsing postscript and/or pdf? References: Message-ID: Alan Miller writes: > Harry George (hgg9140 at seanet.com) wrote: > >If not, my next approach is to download IRS forms in PDF or > >Postscript, and then manipulate those templates. That requires > >parsing the pdf or postscript, detecting named fields, putting in new > >data, and regenrating the printable format. > > If the IRS-provided PDF forms are fillable PDFs, look into FDFs. > Information should be available on FDF formats. > > If you're looking at parsing the raw PDF or PS and trying to determine > what's supposed to be fillable and what's not, good luck. > > Your best bet would probably be to check on what the PDFs actually > support right now, and consider getting Acrobat to add fillable fields > to them if needed. > They appear to be dumb PDF's, intended only for printing. I've discovered the postscripts are not actually valid postscripts (generated by MS tools -- who would have guessed) -- so a generic postscript parser wouldn't work after all. Given the limited number of forms (and thus the limited number of fields), it still seems like a possible avenue. Worht a try anyway. > ajm -- Harry George hgg9140 at seanet.com From djrassoc01 at mindspring.com Thu Jan 3 07:58:55 2002 From: djrassoc01 at mindspring.com (Dr. David J. Ritchie, Sr.) Date: Thu, 03 Jan 2002 00:58:55 -0600 Subject: US taxes: parsing postscript and/or pdf? References: Message-ID: <3C34012C.F1045362@mindspring.com> Harry George wrote: > Alan Miller writes: > > > Harry George (hgg9140 at seanet.com) wrote: > > >If not, my next approach is to download IRS forms in PDF or > > >Postscript, and then manipulate those templates. That requires > > >parsing the pdf or postscript, detecting named fields, putting in new > > >data, and regenrating the printable format. > > > > They appear to be dumb PDF's, intended only for printing. I've > discovered the postscripts are not actually valid postscripts > (generated by MS tools -- who would have guessed) -- so a generic > postscript parser wouldn't work after all. > You might look at: http://cddocs.fnal.gov/cfdocs/productsDB/ProdDetail.CFM?ProdNum=PU0283 for some utilities which "fix" various Postscripts such as those generated by MS. You'll have to look at http://fnkits.fnal.gov/ to get the source. I don't have any idea what platforms it runs on (I have used it on SunOS a while ago, I think). --D. -- Dr. David J. Ritchie, Sr. djrassoc01 at mindspring.com http://home.mindspring.com/~djrassoc01/ From issac at myfirstlink.net Wed Jan 2 06:56:48 2002 From: issac at myfirstlink.net (Issac) Date: Tue, 1 Jan 2002 23:56:48 -0600 Subject: ANN: c2py.py 0.0.1 Message-ID: <009801c19352$453fe060$6401a8c0@mojave> This is a script to partially automate conversion from C/C++ to Python. It's not totally automatic for much the same reasons that you might want to change a program over to Python in the first place. Issac --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.311 / Virus Database: 172 - Release Date: 12/27/2001 -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: c2py.py URL: From issac at myfirstlink.net Wed Jan 2 07:42:33 2002 From: issac at myfirstlink.net (Issac) Date: Wed, 2 Jan 2002 00:42:33 -0600 Subject: c2py.py 0.0.1 References: <009801c19352$453fe060$6401a8c0@mojave> Message-ID: <00c001c19358$aab55460$6401a8c0@mojave> > This is a script to partially automate conversion from C/C++ to Python. > > It's not totally automatic for much the same reasons that you might want to > change a program over to Python in the first place. OK, so that's not exactly true. I change some things to Python for many reasons other than the not-so-nice syntax of C and especially C++. Still, the semantic ambiguity of C/C++ declarations (such as pointers being used as references, array begginings, and linked-list beginnings) makes it daunting to write any kind of conversion utility from these languages. The script only translates easy things. Issac --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.311 / Virus Database: 172 - Release Date: 12/28/2001 From parker at gol.com Wed Jan 2 07:06:28 2002 From: parker at gol.com (Ian Parker) Date: Wed, 02 Jan 2002 06:06:28 GMT Subject: printing from Word using win32com References: <3C2D2007.AD251D51@optonline.net> Message-ID: In article <3C2D2007.AD251D51 at optonline.net>, Frederick H. Bartlett writes >How do I get rid of the UnicodeError in > > something = myWord.ActiveDocument.Paragraphs > for item in something: > try: > print str(item).encode('latin-1') > except UnicodeError: > print "XXX There was a Unicode Error." > >Thanks! If you check the actual exception and get the following UnicodeError: ASCII decoding error: ordinal not in range(128) you're having the same problem I had with Excel. Python defaults to ASCII data (7bit - 128 characters). To handle the full 8 bits (256 characters) you may need "Latin-1". I put the following into sitecustomize.py import sys encoding = 'latin-1' sys.setdefaultencoding(encoding) This solved all my problems with handling English language MS software. I got this tip from Paul Moore, who explained everything much more clearly, see email below #! rnews 2172 Path: nnrp.gol.com!newsfeed.gol.com!newsfeed.mathworks.com!btnet- peer!btnet!diablo.netcom.net.uk!netcom.net.uk!newsfeeds.belnet.be!news.b elnet.be!newsfeed1.news.nl.uu.net!sun4nl!C1S5EXCH.Origin-it.com NNTP-Posting-Host: 172.16.244.177 Newsgroups: comp.lang.python Date: Mon, 30 Oct 2000 17:18:49 +0100 Message-ID: From: Paul Moore Subject: Re: Using more than 7 bit ASCII on windows. References: <8tdlgd$r0t$1 at news.nuri.net> <39FA90D9.7070403 at ActiveState.c om> <8tfpf7$jnn$2 at troll.powertech.no> <39FCA0B5.6040606 at ActiveState.com> <+k=9Obpkexxebyymyh8GKU+y+ 3g8 at 4ax.com> <8tjusf01d0 at news1.newsguy.com> X-Newsreader: Forte Agent 1.6/32.525 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 29 Xref: newsfeed.gol.com comp.lang.python:103458 X-Received-Date: Tue, 31 Oct 2000 01:36:57 JST (nnrp.gol.com) On Mon, 30 Oct 2000 14:54:24 +0100, "Alex Martelli" wrote: >print couldn't care less -- it delegates the transform-into-string >to str. str applied to a Unicode object, in turn, wants _ASCII_ >encoding, as the message on the UnicodeError is telling you. > >os.chdir is apparently also "calling str" (the C API equivalent >thereof, no doubt, in both cases:-), with similar results. That makes sense, and (sort of) clears up the confusion. I'm lost in a mess of conflicting code pages, though (latin1, vs cp437 (OEM), ...) But that's not a Python problem... >It sure would be nice to have a way to control the default >encoding -- not have ASCII hard-wired. There is a function >(not in the 2.0 docs -- doc error?), sys.getdefaultencoding(), >that _tells_ you what the default encoding is (and guess >which one...:-), but I do not know of a way to *change* it. Put the following in sitecustomize.py. The problem is that site.py deletes sys.setdefaultencoding at the end, presumably so that user code can't change it... import sys sys.setdefaultencoding("latin1") Hope this helps, Paul. (Happy to be supplying an answer rather than a question!) -- Ian Parker From mhammond at skippinet.com.au Wed Jan 2 07:43:53 2002 From: mhammond at skippinet.com.au (Mark Hammond) Date: Wed, 02 Jan 2002 06:43:53 GMT Subject: printing from Word using win32com References: <3C2D2007.AD251D51@optonline.net> Message-ID: <3C32AC2E.3030704@skippinet.com.au> Ian Parker wrote: > In article <3C2D2007.AD251D51 at optonline.net>, Frederick H. Bartlett > writes Oops - I missed the original: >> try: >> print str(item).encode('latin-1') >> except UnicodeError: >> print "XXX There was a Unicode Error." Just: print item.encode('latin-1') should work assuming item is always a COM string (ie, a Unicode object). Note that using "mbcs" may be a better choice depending on your user base. > you're having the same problem I had with Excel. Python defaults to > ASCII data (7bit - 128 characters). To handle the full 8 bits (256 > characters) you may need "Latin-1". > > I put the following into sitecustomize.py > > > import sys > encoding = 'latin-1' > sys.setdefaultencoding(encoding) > > > This solved all my problems with handling English language MS software. > > I got this tip from Paul Moore, who explained everything much more > clearly, see email below I am not too keen on this solution. Python chose not to use latin-1 for good reason, and while a PITA, I believe that explicit conversions are better in the long run. Mark. From pinard at iro.umontreal.ca Wed Jan 2 15:39:25 2002 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 02 Jan 2002 09:39:25 -0500 Subject: printing from Word using win32com In-Reply-To: <3C32AC2E.3030704@skippinet.com.au> References: <3C2D2007.AD251D51@optonline.net> <3C32AC2E.3030704@skippinet.com.au> Message-ID: [Mark Hammond] > I am not too keen on this solution. Python chose not to use latin-1 > for good reason, and while a PITA, I believe that explicit conversions > are better in the long run. Neither I am, yet reality is that a lot of code is not written to be widely disseminated, and there is practical, in-shop Python code for many shops. It is my feeling that Python seek for universality, which is undoubtedly a good thing, does not enough take into consideration the needs of closed teams. For example, if a shop uses Latin-1 all over, internally, it is just cumbersome and unneeded having to state it everywhere in Python scripts. P.S. - It is also unwelcome and irritating, endlessly having to choose between writing all identifiers in English, or having to drop the necessary diacritics when writing identifiers, for Python code meant to be local. I know some people that spend a long life programming, quietly, and very usefully, with almost no knowledge of English, and a love of their own native language. I even admire some of them. I believe Python could be made more attractive to such people, and get a definite advantage over other programming languages, by being more respectful to local habits. The original goal of program internationalisation is localisation, I think we are often loosing sight of this, even with Python. Internationalisation goal is not really to manage so English is used internationally :-). -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From fbartlet at wiley.com Wed Jan 2 16:26:58 2002 From: fbartlet at wiley.com (Frederick H. Bartlett) Date: 2 Jan 2002 07:26:58 -0800 Subject: printing from Word using win32com References: <3C2D2007.AD251D51@optonline.net> <3C32AC2E.3030704@skippinet.com.au> Message-ID: Mark Hammond wrote in message news:<3C32AC2E.3030704 at skippinet.com.au>... Mark, Thanks for the response. But item.encode('latin-1') gives me AttributeError: .encode so I must not have a COM string. But if it's not a COM string, what could it be? Python's print will work so long as the object contains only 7-bit characters. The items I'm trying to print are Word paragraphs, as in something = myWord.ActiveDocument.Paragraphs for item in something: Happy New Year! Fred > Oops - I missed the original: > > >> try: > >> print str(item).encode('latin-1') > >> except UnicodeError: > >> print "XXX There was a Unicode Error." > > > Just: > print item.encode('latin-1') > > should work assuming item is always a COM string (ie, a Unicode object). > Note that using "mbcs" may be a better choice depending on your user base. From syver-en+usenet at online.no Wed Jan 2 23:59:57 2002 From: syver-en+usenet at online.no (Syver Enstad) Date: 02 Jan 2002 23:59:57 +0100 Subject: printing from Word using win32com References: <3C2D2007.AD251D51@optonline.net> <3C32AC2E.3030704@skippinet.com.au> Message-ID: fbartlet at wiley.com (Frederick H. Bartlett) writes: > Mark Hammond wrote in message > news:<3C32AC2E.3030704 at skippinet.com.au>... > Thanks for the response. But item.encode('latin-1') gives me > AttributeError: .encode > so I must not have a COM string. But if it's not a COM string, what > could it be? Python's print will work so long as the object contains > only 7-bit characters. Just of the top of my head, often you'll have to write .Value when dealing with com objects. Try it. -- Vennlig hilsen Syver Enstad From sheershion at mailexpire.com Thu Jan 3 02:10:42 2002 From: sheershion at mailexpire.com (Robert Amesz) Date: Thu, 03 Jan 2002 01:10:42 -0000 Subject: printing from Word using win32com References: <3C2D2007.AD251D51@optonline.net> <3C32AC2E.3030704@skippinet.com.au> Message-ID: Frederick H. Bartlett wrote: > But item.encode('latin-1') gives me > AttributeError: .encode > so I must not have a COM string. But if it's not a COM string, > what could it be? Python's print will work so long as the object > contains only 7-bit characters. Why then don't you use str(item).encode('latin-1')? The print statment uses str() or repr() to convert non-strings to strings. Or does str() itself raise an exception? In that case, use a property from item which *does* yield a proper unicode string. For Excel, I used the .text property for Cell-objects which I needed to read. For Word, you'd expect to be able to use something similar. Secondly, depending on the locale of your Windows version, you might want to use the proper character set for that locale, e.g.: encode("CP1252", 'replace') Note that CP1252 is the native Windows character set, which is a superset of LATIN-1 (aka ISO-8859-1). LATIN 1 has a hole in the range 128-159, but CP1252 does have some characters mapped for that range. By using 'replace' you can make sure no exceptions will be raised, but any characters outside the CP1252 will be replaced by a valid character from the set, typically a '?'. HTH, Robert Amesz From fbartlet at wiley.com Thu Jan 3 17:29:43 2002 From: fbartlet at wiley.com (Frederick H. Bartlett) Date: 3 Jan 2002 08:29:43 -0800 Subject: printing from Word using win32com References: <3C2D2007.AD251D51@optonline.net> <3C32AC2E.3030704@skippinet.com.au> Message-ID: Thanks, all, for your help and hints. This function works: def simpleSample(): myWord = Dispatch('Word.Application') myWord.Visible = 0 myDoc = myWord.Documents.Add(MYDIR + '\\sampFile.doc') something = myWord.ActiveDocument.Paragraphs numParas = something.Count i = 1 while i < numParas: i = i + 1 try: print something.Item(i).Range().encode('utf-8') except UnicodeError: print "XXX There was a Unicode Error." myWord.Quit() I think I understand Python objects; I'm sure I don't understand Microsoft objects. *sigh* Why should utf-8 work where latin-1 doesn't? I thought M$ used (sort of) latin 1? (But I guess that's OT for a Python ng.) Fred From sheershion at mailexpire.com Fri Jan 4 02:31:24 2002 From: sheershion at mailexpire.com (Robert Amesz) Date: Fri, 04 Jan 2002 01:31:24 -0000 Subject: printing from Word using win32com References: <3C2D2007.AD251D51@optonline.net> <3C32AC2E.3030704@skippinet.com.au> Message-ID: Frederick H. Bartlett wrote: > def simpleSample(): > myWord = Dispatch('Word.Application') > myWord.Visible = 0 > > myDoc = myWord.Documents.Add(MYDIR + '\\sampFile.doc') > something = myWord.ActiveDocument.Paragraphs > numParas = something.Count > i = 1 > while i < numParas: > i = i + 1 > try: > print something.Item(i).Range().encode('utf-8') > except UnicodeError: > print "XXX There was a Unicode Error." > myWord.Quit() > > I think I understand Python objects; I'm sure I don't understand > Microsoft objects. *sigh* Why should utf-8 work where latin-1 > doesn't? Because UTF-8 can handle *any* Unicode character you throw at it. But it probably does *not* do what you expect it to do: any character above 127 is encoded as 2, 3 or 4 bytes with the top bit set. For the IS0- 8859 character sets two bytes will suffise, more exotic character sets will require three or even four. If you find pairs of consecutive accented letters in the output that would be a fairly reliable indication that UTF-8 characters are being interpreted as native 8-bit characters, as those pairs rarely occur in normal text. > I thought M$ used (sort of) latin 1? It does, at least for the most common locale. It's called CP-1252. But Win32 is capable of handling Unicode (which they call 'wide characters'; in C that's wchar_t), so it's not that unlikely that a character outside the CP-1252 set could get into a Word document, especially if the document originated from, for instance, a Windows set to a different locale. (In that case the default Windows character set could be something like CP-1250, which is eastern european, IIRC.) Robert Amesz From peevee78 at yahoo.com Wed Jan 2 09:33:05 2002 From: peevee78 at yahoo.com (peevee78) Date: Wed, 02 Jan 2002 08:33:05 -0000 Subject: py2exe for python 2.2.? Message-ID: Hi! I'm currently using python 2.2. I was trying to install py2exe on my system but the installer could not find my python installation. Is there a py2exe installer specifically for python 2.2 or do is there a way I can install it by just using the source codes? Please help. Thanks. Paul From atuc at gmx.de Wed Jan 2 10:06:51 2002 From: atuc at gmx.de (Tuca Atuc) Date: Wed, 2 Jan 2002 10:06:51 +0100 Subject: newhttplib, creates automatic headers? Message-ID: hallo, i changed to the new python httplib and looked with a packet analyser and wondering why the new lib always sets this 2 headers automatically? Host: www.google.com Accept-Encoding: identity i would like to set all headers by hand and tryed it with: c = httplib.HTTPConnection( server, 80 ) #### den Request (z.b. IE5 Simulation) c.putrequest('GET', path) c.putheader('Accept', 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*') c.putheader('Accept-Language', 'de') c.putheader('User-Agent', 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0') #c.putheader('Host', server) c.putheader('Connection', 'Keep-Alive') c.endheaders() r = c.getresponse() print r.status, r.reason data = r.read() is it possible to avoid automatic appending of this 2 headers in the new httplib? thanks, alex From Nadav at envision.co.il Wed Jan 2 10:15:01 2002 From: Nadav at envision.co.il (Nadav Horesh) Date: Wed, 02 Jan 2002 11:15:01 +0200 Subject: Distutil problep? Installation of SciPY with python 2.2 on RH7.1 Message-ID: <3C32CF95.7080603@envision.co.il> An HTML attachment was scrubbed... URL: From vvainio at karhu.tp.spt.fi Wed Jan 2 12:04:56 2002 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 02 Jan 2002 13:04:56 +0200 Subject: age of new pythonistas [was: The Editor Poll results are in!] References: <60c49aa9.0112202148.7218555b@posting.google.com> Message-ID: pinard at iro.umontreal.ca (Fran?ois Pinard) writes: > > Ditto with TCL. When I see 8 backslashes in a row, I look elsewhere > > ;-). > > One may be rebuked by surface aspects, indeed. But seriously, we have to Number of backslashes is not a surface aspect - it shows how much you have to escape stuff. Excessive escaping makes things unpredictable. It's not at all about aesthetics. > Even if I prefer Python to Perl, I would never even think that Perl is not > well designed. When I was using Perl, as a user (not as a reader of books > about it :-), I found that Perl allowed me to quickly write my code, it > was full of good ideas, and I felt the language quite fulfilled its promises. I also thought that Perl initially felt neat, when doing simple programs with it. But reading some books shows how dirty it actually is. One doesn't really know all the evils of perl before reading books about it. > make something necessarily bad. And besides, wandering around a bit with an > opened mind allows someone to improve its culture and to evolve his tastes. Yes, that is definitely true: I'm glad I have taken cursory glance over several very different, "rare" languages (functional, OO, procedural), but I am less glad about the time I took to learn perl. I mean, I gave the language a chance, and implemented several scripts (cgi or not) with it, but I wish I didn't. It's kinda like the BASIC many of us learned as kids, though I'm not sure whether the damage to the brain is as severe. For "real" programming, that is. I still use perl as awk&sed++. Which is the way it was meant to be used in the first place. "Bad design" can just mean a design with different goals. -- Ville Vainio - http://www.tp.spt.fi/~vvainio - ICQ #115524762 Wild geese have no intention to cast a reflection Water has no mind to assume their form From pmullh at yahoo.com Wed Jan 2 21:32:34 2002 From: pmullh at yahoo.com (PM) Date: 2 Jan 2002 12:32:34 -0800 Subject: age of new pythonistas [was: The Editor Poll results are in!] References: <60c49aa9.0112202148.7218555b@posting.google.com> Message-ID: <4be6f063.0201021232.2e37da2b@posting.google.com> pinard at iro.umontreal.ca wrote in message > Even if I prefer Python to Perl, I would never even think that Perl is not > well designed. When I was using Perl, as a user (not as a reader of books > about it :-), I found that Perl allowed me to quickly write my code, it > was full of good ideas, and I felt the language quite fulfilled its promises. > Perl seemed to me to be well designed but not 'easily accessible'. There's an overhead to Perl. I found that I always was aware of the fact that I was 'programming in Perl'. In Python, I usually am only vaguely aware that I'm 'programming' as opposed to just thinking. Just my $0.02, Patrick From pzw1 at hotmail.com Wed Jan 2 16:58:35 2002 From: pzw1 at hotmail.com (Peter Wang) Date: 2 Jan 2002 07:58:35 -0800 Subject: age of new pythonistas [was: The Editor Poll results are in!] References: <60c49aa9.0112202148.7218555b@posting.google.com> Message-ID: Steven Rumbalski wrote in message news:... > Ville Vainio wrote: > > > > Ditto with TCL. When I see 8 backslashes in a row, I look elsewhere > > Ditto with Python. When I see lines of code terminated by nothing but > whitespace, I look elsewhere. > > asthetic-shock-a-poor-judge-ly yours, > Steven Rumbalski point taken, but bad example. the Hamming distance between 7 and 8 backslashes is very small to a programmer but very large to a computer, whereas programmer and computer will generally agree as to whether whitespace is terminal. -peter From jpolaski at rgs.uci.edu Thu Jan 3 02:40:51 2002 From: jpolaski at rgs.uci.edu (Jeff Polaski) Date: 2 Jan 2002 17:40:51 -0800 Subject: age of new pythonistas [was: The Editor Poll results are in!] References: Message-ID: I'm 33 As a web programmer I've done a lot of scripting, so I really tend to favor scripting languages. I've been programming in Python for about four years. IIRC I discovered it through a slashdot post. At the time I was using Perl to maintain web sites for Rockwell's Space Systems Division (soon after bought by Boeing). The external site had about 25,000 documents, and the intranet had about 200,000 documents. There was no way I could have maintained that site without using a scripting language. I tried Perl first, and Perl ran a lot faster, but I found Python was a lot easier to maintain in the long run. Most importantly, I just enjoyed programming in Python more than Perl. There were far fewer "surprises". Everything seemed to just work like I thought it should. Python certainly wasn't as efficient as Perl, though. Some of the Python scripts might take an hour longer to run, but it wasn't a big deal as I could just run them from a separate machine while I did other things. While Python isn't my main programming language, I write Python about an hour a day. I'll use it for many different things: data munging, prototyping, etc... I'm constantly writing scripts to make "process improvements". Right now I have a script that verifies transactions and makes sure files get exported correctly. It's a fairly small script, but it provides important assurance that everything went O.K. with our web applications. Also, I use Python a lot to automate repetitive coding in ColdFusion or Java. A lot of what I do sits on top of a database. It's easy to write a script that generates most of the code. It's faster than I can do by hand, and more consistent. Right now most of my programming is done in ColdFusion and Java. I've used also used Pascal, Object Pascal (Delphi), C, C++, SQL, ASP, VB, JavaScript, and XML. By far my favorite language is Python. Please don't construe this the wrong way. I don't want this to come off as language bigotry. I have programs written in Perl and C++ that I'm working on now, just for myself, and, all in all, I enjoy them. I'm also teaching myself Scheme (through The Little Schemer*). But when I just want to program for fun, I reach for Python first. *A previous posts mentioned The Pragmatic Programmer: "Learn at least one new language every year." I agree. Scheme is my choice, this year. Then, maybe, Lisp. Jeff Polaski From aleax at aleax.it Wed Jan 2 12:27:09 2002 From: aleax at aleax.it (Alex Martelli) Date: Wed, 2 Jan 2002 12:27:09 +0100 Subject: Scoped change of a global variable References: Message-ID: "Luigi Ballabio" wrote in message news:mailman.1009966443.13747.python-list at python.org... ... > precision = 2 > > def add(x,y): > sum = x+y > tens = math.pow(10.0,precision) > return math.floor(sum*tens+0.5)/tens > > Now let's say that I want to call add with a different precision but I > politely want to restore the previous value after I'm done. What I do is: > > oldPrecision = precision # store old value > precision = 3 # change current value > x = add(1.0,0.3456) # do the deed > precision = oldPrecision # restore old value > > The question is: how can I encapsulate the logic in the comments above? For example, if the function whose globals you want to tweak (here, 'add') takes no keyword arguments, a nice interface might be: def changingGlobals(func, *args, **kwds): save = func.func_globals.copy() func.func_globals.update(kwds) try: result = func(*args) finally: func.func_globals.update(save) return result Note you do need the try/finally, because you want to ensure that the original globals of the function are restored even if the function should raise an exception (I see that's missing in your snippet). Another issue with your snippet is that it does not work in any module except the module where function add was defined. The changingGlobals function has no such limitation, since it makes the function itself tell it which 'globals' dictionary is to be tweaked/restored. Now, x = changingGlobals(add, 1.0, 0.3456, precision=3) does what you desire. Of course, it's easy to write a less-general version of changingGlobals specialized to change a hardwired function-global name rather than whatever set is specified in the call, etc, etc. > However, the problem is that even the simple assignment above requires one > to define a function since it can't be done inside a lambda. Thus, the Yes, the natural unit for passing code as arguments in Python is the function. You just put the assignment _outside_ changingGlobals, as shown above. Have all functions communicate through the arguments they receive and the results they return: this is by far the most Pythonic arrangement of things. > P.S. the name of the game here is encapsulating the > store-set-calculate-restore logic; it is not to show me that there are > better ways to implement the above than to access a global variable. I > know. The above is just a contrived 10 lines example to show my point. ...and that point IS...? The 'set' part is best seen as a function return in Python, rather than binding some arbitrary name (forcing it to be global [to what module?!]) -- just as the variable parameter would be better framed as a function-argument rather than as a function-global. Passing a generic piece of code that is not a function (basically using arguments and return values) is not a normal Python arrangement. When "environment" dependencies and modifications are desired, that is often best arranged by building an object (and accessing all the environment parts as self.something, of course); customization is then often most easily done by subclassing. In Python, like in every other language, you'll generally get better mileage if you use the language as it was designed to be used, rather than throwing your energies at mimicking the way some OTHER language was designed to be used. Alex From ballabio at mac.com Wed Jan 2 15:35:26 2002 From: ballabio at mac.com (Luigi Ballabio) Date: Wed, 02 Jan 2002 14:35:26 +0000 Subject: Scoped change of a global variable In-Reply-To: References: Message-ID: <5.1.0.14.0.20020102130941.00a565d0@mail.mac.com> Greetings, At 12:27 PM 1/2/02 +0100, Alex Martelli wrote: >In Python, like in every other language, you'll generally get better >mileage if you use the language as it was designed to be used, rather >than throwing your energies at mimicking the way some OTHER language >was designed to be used. Absolutely. Hence my question, namely, "How does one do this in Python", "this" being the abstraction of storing, changing and restoring a global variable, not the particular way it is done in other language. The snippets in other languages were not meant as models but rather as clarification of what I meant by "abstracting": the global variable change in one point, the wrapped code in another. Then again, I probably expressed myself poorly. I should know better than sending mails before my second coffee :) > > P.S. the name of the game here is encapsulating the > > store-set-calculate-restore logic; it is not to show me that there are > > better ways to implement the above than to access a global variable. I > > know. The above is just a contrived 10 lines example to show my point. > >...and that point IS...? Ouch, my fault again. I keep hoping that a problem can be shown in a few lines of code out of context, not to bore people with details. Seems like I managed to mislead you instead. The context is: I'm trying to implement the OMG specification for Currencies. The particular issue is: a class Money is defined which contains an amount of money and the currency in which the amount is expressed. If two Money instances are added which have the same currency, the result is a Money instance whose currency is the same and whose amount is the sum of the amounts of the addends. If the two instances have different currencies, a global variable determines whether 1) an error is raised, 2) the result is converted in the currency of the first operand, or 3) the result is converted in a base currency which is stored in another global variable. >The 'set' part is best seen as a function >return in Python, rather than binding some arbitrary name (forcing >it to be global [to what module?!]) To the current scope. The idea was: #!/usr/bin/python # Some code here which initializes the script, # defines variables, whatever. # Let's say that I have read a list of Money instances # which represent payments. Now I want to add them all. # here is the store-and-set thing oldBaseCurrency = Currency.BaseCurrency Currency.BaseCurrency = EUR # Here are the calculations, during which Money.__add__ uses # Currency.BaseCurrency to determine what to do. # They could be a single function call such as: sum = reduce(lambda x,y: x+y, paymentList) # or a few lines of code with control structures inside such as: sum = Money() for payment in paymentList: sum += payment # Money.__iadd__ uses Currency.BaseCurrency # here is the restore thing Currency.BaseCurrency = oldBaseCurrency # more code here However, I see that encapsulating in _one_ point the store-change-restore logic might be impossible here... >the natural unit for passing code as arguments in Python is >the function. You just put the assignment _outside_ changingGlobals, >as shown above. Have all functions communicate through the arguments >they receive and the results they return: this is by far the most >Pythonic arrangement of things. Point taken. Thanks for the help, Luigi From aleax at aleax.it Wed Jan 2 16:09:11 2002 From: aleax at aleax.it (Alex Martelli) Date: Wed, 2 Jan 2002 16:09:11 +0100 Subject: Scoped change of a global variable References: Message-ID: "Luigi Ballabio" wrote in message news:mailman.1009977602.11777.python-list at python.org... I've also answered Luigi on the Italian list, but just in case somebody else is following this in English, here's a short summary of my response, translated back into English: > # here is the store-and-set thing > oldBaseCurrency = Currency.BaseCurrency > Currency.BaseCurrency = EUR # easy to further generalize, but, just as an example: class TweakAttributes: def __init__(self, subject, **kwds): self.subject = subject self.saved = () for name, value in kwds: self.saved.append((name, getattr(subject, name))) setattr(subject, name, value) def restore(self): for name, value in self.saved: setattr(self.subject, name, value) self.saved = () # ensure .restore is idempotent, just in case saved = TweakAttributes(Currency, BaseCurrency=EUR) try: # just indent all the calculations 4 spaces rightwards > # here is the restore thing > Currency.BaseCurrency = oldBaseCurrency finally: saved.restore() The try/finally ensures restoration happens even if some statement in the try block raises an exception. In general, this is important. > However, I see that encapsulating in _one_ point the store-change-restore > logic might be impossible here... Yes, in a sense: try and finally are part of the same statements, but in different "points" of the code (just like other clauses that make up a statement, such as an if and the corresponding else). In C++, you could use an auto variable and use its destructor for the purpose for which here I use the restore method of the class TweakAttributes. In modern Python (just as in Java, etc) there is no guarantee that a destructor runs when you'd like it to: today, finalization should be best done explicitly with a try/finally statement. Alex From aleax at aleax.it Thu Jan 3 09:07:59 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 3 Jan 2002 09:07:59 +0100 Subject: Scoped change of a global variable References: Message-ID: "Steven Majewski" wrote in message news:mailman.1010015222.20515.python-list at python.org... > > [ To follow myself up ] ... but the more Pythonic solution > would probably be to avoid using global values for defaults > and to use a class instead: > > > >>> class NameSpace: > ... default = 1 > ... def __init__( self, **kws ): > ... for key,value in kws.items(): > ... setattr( self, key, value ) In a classic-classes environment, I'd rephrase this __init__ as the somewhat more compact and faster: def __init__(self, **kwds): self.__dict__.update(kwds) Admittedly, your setattr-based approach is more general (e.g. it works if NameSpace is mixin-inherited from together with some other mixin that defines __setattr__, while the __dict__.update approach would bypass __setattr__ in this case). Alex From ballabio at mac.com Wed Jan 2 12:29:45 2002 From: ballabio at mac.com (Luigi Ballabio) Date: Wed, 02 Jan 2002 11:29:45 +0000 Subject: Scoped change of a global variable Message-ID: <5.1.0.14.0.20020102104029.00a84ec0@n/a> Greetings everybody, the statement of the case: let's say I have a function which adds two numbers and returns their sum rounded with a precision which is not passed as a parameter but rather stored in a global variable, as in: precision = 2 def add(x,y): sum = x+y tens = math.pow(10.0,precision) return math.floor(sum*tens+0.5)/tens Now let's say that I want to call add with a different precision but I politely want to restore the previous value after I'm done. What I do is: oldPrecision = precision # store old value precision = 3 # change current value x = add(1.0,0.3456) # do the deed precision = oldPrecision # restore old value The question is: how can I encapsulate the logic in the comments above? For example, in Scheme I can define a macro with-precision so that writing: (with-precision 3 (set! x (add 1.0 0.3456))) sets x to 1.346 and restores the precision to its old value. In Ruby, I can define a function withPrecision so that writing: withPrecision(1) { x = add(1.0,0.3456) } sets x to 1.3 etc. etc. Now, what about Python? One could write def withPrecision(newPrecision,block): global precision oldPrecision = precision precision = newPrecision result = block() precision = oldPrecision return result However, the problem is that even the simple assignment above requires one to define a function since it can't be done inside a lambda. Thus, the simple Scheme or Ruby idiom becomes as crufty as: def doIt(): global x x = add(1.0,0.3456) withPrecision(1,doIt) which does the trick but isn't as concise and expressive (not to mention elegance and lack of clarity if the above has to be done in the middle of a longer block of code). Any ideas? Thanks, Luigi P.S. the name of the game here is encapsulating the store-set-calculate-restore logic; it is not to show me that there are better ways to implement the above than to access a global variable. I know. The above is just a contrived 10 lines example to show my point. From gioco at nekhem.com Wed Jan 2 11:53:14 2002 From: gioco at nekhem.com (Corrado Gioannini) Date: Wed, 2 Jan 2002 11:53:14 +0100 Subject: Scoped change of a global variable In-Reply-To: <5.1.0.14.0.20020102104029.00a84ec0@n/a> References: <5.1.0.14.0.20020102104029.00a84ec0@n/a> Message-ID: <20020102115314.E590@zephyr> On Wed, Jan 02, 2002 at 11:29:45AM +0000, Luigi Ballabio wrote: [...snip...] You could define a class like: precision = 2 class Add: def __init__(self): self.precision = precision def add(self, x, y): ... def setPrecision(self, n): self.precision = n def restorePrecision(self): self.precision = precision and then simply: a = Add() a.add(1.0, 0.3456) a.setPrecision(3) a.add(1.0, 0.3456) a.restorePrecision() Of course you can use a class variable instead of a global variable: class Add: default_precision = 2 ... (same as above with self.default_precision instead of precision) This if you really don't want to use parameters... precision = 2 def add(x, y, z=precision): ... Hope this helps, Corrado -- Corrado Gioannini "Thought is only a flash between two long nights, but this flash is everything." (H. Poincar?) From ballabio at mac.com Wed Jan 2 13:30:20 2002 From: ballabio at mac.com (Luigi Ballabio) Date: Wed, 02 Jan 2002 12:30:20 +0000 Subject: Scoped change of a global variable In-Reply-To: <20020102115314.E590@zephyr> References: <5.1.0.14.0.20020102104029.00a84ec0@n/a> <5.1.0.14.0.20020102104029.00a84ec0@n/a> Message-ID: <5.1.0.14.0.20020102121912.00a4b3c0@mail.mac.com> Corrado, At 11:53 AM 1/2/02 +0100, Corrado Gioannini wrote: >On Wed, Jan 02, 2002 at 11:29:45AM +0000, Luigi Ballabio wrote: >[...snip...] > >You could define a class like: > >precision = 2 >class Add: > def __init__(self): > self.precision = precision > def add(self, x, y): > ... > def setPrecision(self, n): > self.precision = n > def restorePrecision(self): > self.precision = precision > >and then simply: > >a = Add() >a.add(1.0, 0.3456) >a.setPrecision(3) >a.add(1.0, 0.3456) >a.restorePrecision() Well, the logic is only half-encapsulated here---you still have to call restorePrecision() explicitly. >This if you really don't want to use parameters... > >precision = 2 >def add(x, y, z=precision): Well, add(x,y) was a simple way to write an example. My real purpose would be the __add__ method for a class of a numeric kind, which can only take the two operands as parameters. The corresponding Ruby example would be: withPrecision(1) { a = b+c } Grazie comunque, Luigi From jason at jorendorff.com Wed Jan 2 19:13:12 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Wed, 2 Jan 2002 12:13:12 -0600 Subject: Scoped change of a global variable In-Reply-To: <5.1.0.14.0.20020102104029.00a84ec0@n/a> Message-ID: > P.S. the name of the game here is encapsulating the > store-set-calculate-restore logic; it is not to show me that there are > better ways to implement the above than to access a global variable. I > know. The above is just a contrived 10 lines example to show my point. There's no convenient way to do that in Python. Different languages have different degrees of syntax mutability. Lisp is at one end of the scale. At the other end, there's Java. Python and Ruby are both somewhere in the middle, with Python taking a conservative approach and Ruby a more liberal one. In Python, if you want to wrap some code, wrap it in a function. ## Jason Orendorff http://www.jorendorff.com/ From sdm7g at Virginia.EDU Thu Jan 3 00:29:54 2002 From: sdm7g at Virginia.EDU (Steven Majewski) Date: Wed, 2 Jan 2002 18:29:54 -0500 (EST) Subject: Scoped change of a global variable In-Reply-To: Message-ID: An interesting problem: that sort of construct, both in builtin's like 'with-open-file' and custom ones using 'let' is one of the most commonly used (and useful) applications of nested scope in Lisp Now that Python 2.2 has nested scopes, I would have thought there was a simple way to do it, but if there is, it eludes me. The one simple way of doing it doesn't use nested scopes at all, but uses new.function to construct a function with a new global dict: >>> import new >>> >>> gg = 1 >>> def plusgg( n ): ... global gg ... print gg+n ... >>> plusgg(1) 2 >>> new.function( plusgg.func_code, { 'gg': 100 } )(1) 101 >>> gg 1 -- Steve Majewski From sdm7g at Virginia.EDU Thu Jan 3 00:46:42 2002 From: sdm7g at Virginia.EDU (Steven Majewski) Date: Wed, 2 Jan 2002 18:46:42 -0500 (EST) Subject: Scoped change of a global variable In-Reply-To: Message-ID: [ To follow myself up ] ... but the more Pythonic solution would probably be to avoid using global values for defaults and to use a class instead: >>> class NameSpace: ... default = 1 ... def __init__( self, **kws ): ... for key,value in kws.items(): ... setattr( self, key, value ) ... def __call__( self, n ): ... print n + self.default ... >>> NameSpace.default 1 >>> NameSpace()(2) 3 >>> NameSpace( default=100 )(2) 102 >>> NameSpace.default 1 >>> -- Steve Majewski From sdm7g at Virginia.EDU Thu Jan 3 02:58:54 2002 From: sdm7g at Virginia.EDU (Steven Majewski) Date: Wed, 2 Jan 2002 20:58:54 -0500 (EST) Subject: Dynamic and Static scoping in Lisp vs. Python [was: Scoped change of a global variable] In-Reply-To: Message-ID: On Wed, 2 Jan 2002, Steven Majewski, talking to himself again, wrote: > > An interesting problem: that sort of construct, both in builtin's like > 'with-open-file' and custom ones using 'let' is one of the most commonly > used (and useful) applications of nested scope in Lisp > > Now that Python 2.2 has nested scopes, I would have thought there was a > simple way to do it, but if there is, it eludes me. I was confusing myself about what happens in Lisp vs. Python. In Lisp, there are 'special variables' which are dynamically bound, and are declared special and usually follow the name convention of: *something* . Basically, all module globals in Python are 'special'. (This is one of the ways in which Python is usually more dynamic than Lisp -- this was asked in another thread.) But in Lisp, I can rebind even those special variables using nested scopes: (let (( *readtable* (make-new-readtable .. ))) ( read ... The first time I tried to do something like that in Lisp I used UNWIND-PROTECT (the Lisp equiv. of try/finally) in a similar way to Alex's example, to change the readtable and reset it when I was done. Then I discovered that the idiom above was the easier way to do it. Both Python and Lisp support both static scoping and dynamic variables, but the difference is that Python doesn't have any sort of block structure other than function definition in which to create new bindings. If there was a Python equivalent of Lisp's LET block, then the python code would be something like: globalModuleVar = 1 ## define functions which access globalModuleVar ## value in function will be whatever globalModuleVar is bound to ## at the time of execution. block: globalModuleVar = 100 # call functions in env. where globalModuleVar = 100 ## outside of that block, the old binding is active. Which is just a syntactically sugured version of Alex's try: save old globals, assign new values, do something... finally: restore old globals Except that in Python, global references in a function are to the module in which the function is defined. There's no top-level scope as in Lisp. In Python, __main__ is just another module. Lisp code typically contains a lot more static scoping blocks, and so it tends to restrict the symbols that need to be dynamically looked up (compared to Python). > The one simple way of doing it doesn't use nested scopes at all, > but uses new.function to construct a function with a new global > dict: A more general purpose version would need to keep all of the other bindings from the global namespace -- the example I used didn't call any other functions (which would have given a NameError), but used the print statement, witch is part of the language, not a name lookup. Something like: >>> def rebind( func, **newbindings ): ... "return a new function with bindings to new global symbols" ... newdict = copy.copy( func.func_globals ) ... newdict.update( newbindings ) ... return new.function( func.func_code, newdict ) ... -- Steve Majewski From sholden at holdenweb.com Wed Jan 2 12:43:51 2002 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 2 Jan 2002 06:43:51 -0500 Subject: O'Reilly book production (was Re: Wine applicability) References: Message-ID: "A. Keyton Weissinger" wrote in message news:mailman.1009568013.22371.python-list at python.org... > I've written two books for O'Reilly, one of which has two editions out. The > Word template works very well for me. Now FrameMaker, their production > application sucks, but fortunately you rarely have to deal with that. > Gasp! FrameMaker sucks??!!?? It's a while since I used it, but I used to know it well -- I was the first UK reseller for the package, and sold it to many corporates for their long document requirements. When I think of the trouble Word has given me over the years I simply don't understand how anyone writing a book could prefer Word to FrameMaker. This after just having written a book with Word, and having watched it go through the production processes. Shudder. one-man's-meat-ly y'rs - steve -- http://www.holdenweb.com/ From anthony at interlink.com.au Wed Jan 2 13:09:43 2002 From: anthony at interlink.com.au (Anthony Baxter) Date: Wed, 02 Jan 2002 23:09:43 +1100 Subject: O'Reilly book production (was Re: Wine applicability) In-Reply-To: Message from "Steve Holden" of "Wed, 02 Jan 2002 06:43:51 CDT." Message-ID: <200201021209.g02C9hN08754@mbuna.arbhome.com.au> > Gasp! FrameMaker sucks??!!?? It's a while since I used it, but I used to > know it well -- I was the first UK reseller for the package, and sold it to > many corporates for their long document requirements. When I think of the > trouble Word has given me over the years I simply don't understand how > anyone writing a book could prefer Word to FrameMaker. This after just > having written a book with Word, and having watched it go through the > production processes. Shudder. Frame _used_ to be great. Then Adobe took it over, and did sod-all with it. -- Anthony Baxter It's never too late to have a happy childhood. From vvainio at karhu.tp.spt.fi Wed Jan 2 13:11:16 2002 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 02 Jan 2002 14:11:16 +0200 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> Message-ID: Oleg Broytmann writes: > file = open(...) > if not file: report_error() One great thing about exceptions as opposed to retval-checking is that when you are making the initial version, you don't have to implement error-checking at all! Whenever something weird happens, you will know where and why it happened through the traceback. And when you do implement error checking, you can do that for errors you can recover from. It's ok for fatal & unexpected errors to crash the program, as long as you know what happened. Simply put, exceptions reduce tedious, stereotypical if (command) || die() code. -- Ville Vainio - http://www.tp.spt.fi/~vvainio - ICQ #115524762 Wild geese have no intention to cast a reflection Water has no mind to assume their form From pinard at iro.umontreal.ca Wed Jan 2 15:11:55 2002 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 02 Jan 2002 09:11:55 -0500 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) In-Reply-To: References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> Message-ID: [Ville Vainio] > One great thing about exceptions as opposed to retval-checking is that > when you are making the initial version, you don't have to implement > error-checking at all! This is great, indeed. Besides, it is extremely heavy to correctly error-check all calls to library functions. I remember having worked in some C code in which the original programmer tested the return value of each and every `printf', with appropriate error reporting. This yielded code which is noisy, hard to read, and irritating to maintain. My feeling is that C programmers (and I still work at C programs once in a while :-) do a "reasonable" error checking, but are rarely fully thorough with it. A compromise is needed, because both extremes (no error checking at all, checking every possible error) are just unbearable in real programs. I'm very convinced that Python has a fruitful approach on this. All errors are handled in some way, and the user always have control for errors to be reported with nicer diagnostics, or handled more gracefully, at the price of writing only a few lines then. That's very bearable, and better. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From mkelly2002NOSPAM at earthlink.net Wed Jan 2 17:17:40 2002 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Wed, 02 Jan 2002 16:17:40 GMT Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> Message-ID: On 02 Jan 2002 09:11:55 -0500, pinard at iro.umontreal.ca (Fran?ois Pinard) wrote: >My feeling is that C programmers (and I still work at C programs once in a >while :-) do a "reasonable" error checking, but are rarely fully thorough >with it. A compromise is needed, because both extremes (no error checking >at all, checking every possible error) are just unbearable in real programs. There was an interesting article in one of the programmer magazines(maybe C/C++ User Journal but I don't recall) about how doing error checking for memory allocations was pretty much a waste of time and effort(since usually if you are that short of resources you can't do anything to recover anyway.) Also in languages with built-in garbage collection you take it for granted but with do it yourself memory management like in C++ it would really be tedious to deallocate all resources manually in every error checking block of code. The exception handling calls the destructors of local objects automagically. Where it can get weird though is in VC++ where you have like 3 flavors of exception handling that don't play well together. :) Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From aleax at aleax.it Wed Jan 2 17:50:47 2002 From: aleax at aleax.it (Alex Martelli) Date: Wed, 2 Jan 2002 17:50:47 +0100 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> Message-ID: "Michael Kelly" wrote in message news:vbc63u8okomlah7e0m6c5b9th1vh82fsb8 at 4ax.com... > On 02 Jan 2002 09:11:55 -0500, pinard at iro.umontreal.ca (Fran?ois > Pinard) wrote: > > >My feeling is that C programmers (and I still work at C programs once in a > >while :-) do a "reasonable" error checking, but are rarely fully thorough > >with it. A compromise is needed, because both extremes (no error checking > >at all, checking every possible error) are just unbearable in real programs. > > There was an interesting article in one of the programmer > magazines(maybe C/C++ User Journal but I don't recall) > about how doing error checking for memory allocations > was pretty much a waste of time and effort(since usually > if you are that short of resources you can't do anything > to recover anyway.) Big applications written by people with some smarts start with the equivalent of: global_emergency_ballast = malloc(a_reasonably_big_chunk); The ballast is released in emergency short-of-memory situations, exactly to finesse these kinds of issues. Alex From mkelly2002NOSPAM at earthlink.net Wed Jan 2 19:36:19 2002 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Wed, 02 Jan 2002 18:36:19 GMT Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> Message-ID: On Wed, 2 Jan 2002 17:50:47 +0100, "Alex Martelli" wrote: >Big applications written by people with some smarts start >with the equivalent of: > > global_emergency_ballast = malloc(a_reasonably_big_chunk); > >The ballast is released in emergency short-of-memory situations, >exactly to finesse these kinds of issues. > > Delphi has it built in to its "out of memory" error handler. Doesn't mean it does much 'cept print a message and crap out anyway. Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From mkelly2002NOSPAM at earthlink.net Wed Jan 2 19:39:18 2002 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Wed, 02 Jan 2002 18:39:18 GMT Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> Message-ID: On Wed, 2 Jan 2002 17:50:47 +0100, "Alex Martelli" wrote: >Big applications written by people with some smarts start >with the equivalent of: > > global_emergency_ballast = malloc(a_reasonably_big_chunk); > >The ballast is released in emergency short-of-memory situations, >exactly to finesse these kinds of issues. btw- what do "big applications written by people with some smarts" do when this global_emergency_ballast block of memory happens to be the one that got corrupted? Let me take a wild guess. They get an access violation when they try to print a message and crap out. :-) Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From amuys at shortech.com.au Thu Jan 3 00:55:48 2002 From: amuys at shortech.com.au (Andrae Muys) Date: 2 Jan 2002 15:55:48 -0800 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> Message-ID: <7934d084.0201021555.5c306329@posting.google.com> Michael Kelly wrote in message news:... > On Wed, 2 Jan 2002 17:50:47 +0100, "Alex Martelli" > wrote: > > >Big applications written by people with some smarts start > >with the equivalent of: > > > > global_emergency_ballast = malloc(a_reasonably_big_chunk); > > > >The ballast is released in emergency short-of-memory situations, > >exactly to finesse these kinds of issues. > > btw- what do "big applications written by people with some smarts" > do when this global_emergency_ballast block of memory happens > to be the one that got corrupted? Let me take a wild guess. > They get an access violation when they try to print a message > and crap out. :-) > Ok I'll bite. What corruption? And even if it was corrupted, how could you get an access violation (I'm assuming SIGSEV/SIGBUS on a unixen os) attempting to use it? If you're recovering from a OOM condition, you just manually allocate the necessary memory to log it from global_emergency_balast, and ensure you use direct syscall's to dump/sync any debugging/logging info, before free()'ing the block/doing other resource reaping. I'm very curious to know how you can get a SIGSEV/BUS from the above, unless it's from the free() (which is optional, if all you want is a clean shutdown with necessary logging/etc, you just use use the balast in-place to do that). Of course if free() fail's with a fault it indicates another bug elsewhere has corrupted your malloc tables, an orthoginal error to OOM conditions. Specifically a "bug-free" system needs to gracefully handle OOM, OTOH corrupted malloc tables is symptom of a bug. Still if I'm missed anything I'm very interested to know what it is. Andrae Muys From jkraska at san.rr.com Thu Jan 3 02:57:21 2002 From: jkraska at san.rr.com (Courageous) Date: Thu, 03 Jan 2002 01:57:21 GMT Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> <7934d084.0201021555.5c306329@posting.google.com> Message-ID: <1be73u8rrpkaccutgj39ko8b2it20s13qs@4ax.com> >> btw- what do "big applications written by people with some smarts" >> do when this global_emergency_ballast block of memory happens >> to be the one that got corrupted? Your signal handler for SIG_SEGV gets tripped and calls longjmp() to return you to your main event loop. :) C// From ralph at inputplus.demon.co.uk Thu Jan 3 10:10:46 2002 From: ralph at inputplus.demon.co.uk (Ralph Corderoy) Date: 3 Jan 2002 09:10:46 GMT Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <7934d084.0201021555.5c306329@posting.google.com> Message-ID: Hi Andrae, > If you're recovering from a OOM condition, you just manually allocate > the necessary memory to log it from global_emergency_balast, and > ensure you use direct syscall's to dump/sync any debugging/logging > info, before free()'ing the block/doing other resource reaping. WRT the direct syscalls bit, what if that requires more memory for C stack frames? Don't some architectures chain memory for stack frames together, allocating more from somewhere when necessary? Cheers, Ralph. From mkelly2002NOSPAM at earthlink.net Thu Jan 3 18:48:11 2002 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Thu, 03 Jan 2002 17:48:11 GMT Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> <7934d084.0201021555.5c306329@posting.google.com> Message-ID: On 2 Jan 2002 15:55:48 -0800, amuys at shortech.com.au (Andrae Muys) wrote: >Ok I'll bite. What corruption? And even if it was corrupted, how >could you get an access violation (I'm assuming SIGSEV/SIGBUS on a >unixen os) attempting to use it? If you're recovering from a OOM >condition, you just manually allocate the necessary memory to log it >from global_emergency_balast, and ensure you use direct syscall's to >dump/sync any debugging/logging info, before free()'ing the >block/doing other resource reaping. I'm not going to rehash all the issues discussed in the article. The author was already paid to do that, which he did quite well. So I'd recommend if you are interested to do a web search on the programming zines. But anyway, assuming a flavor of Unix is a real big assumption. Windows9x for example, is notorious in that reports of memory available are just about meaningless. I'm not saying the memory reserve trick never works but I am saying you can't depend on it to work. If you have a business applicatin on a dedicated platform then odds are much better, that I grant, but Windows likes to do things like let you reserve virtual memory, commit it, and then it swaps it out and/or gives it to another process. So much for commitment! It's kind of like a reservation at a hotel. It tells you that space is assured so that you will try to use it. Whether it's actually there when you go to access it is another matter. So, you have your emergency memory reserve, you have a problem, you free it, and bingo! you get swapped out and some other process starved for memory allocates it, or they already have it and are using it! Or, the problem is invalid page faults 'cause the windows system itself is corrupted, so you are depending on the very unstable subsystem for recovery that is causing the error. The list goes on and on so I'll not rehash all the issues. Send email to the author if you find him. :) Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From aleax at aleax.it Fri Jan 4 18:00:54 2002 From: aleax at aleax.it (Alex Martelli) Date: Fri, 4 Jan 2002 18:00:54 +0100 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> <7934d084.0201021555.5c306329@posting.google.com> Message-ID: "Michael Kelly" wrote in message news:ig593uogii9sjfmkjiunb9i7ilsni5s0lr at 4ax.com... ... > for commitment! It's kind of like a reservation > at a hotel. It tells you that space is assured so > that you will try to use it. Whether it's actually > there when you go to access it is another matter. Again, Windows is not original: I well recall when AIX started doing *THAT* ('overcommitting' memory) back when RS6000 had just come out. IBM got enough flack about *THAT*, that they eventually made this behavior 'optional' (some 'option'...!). Our workaround was to give our users a configuration option to go and TOUCH the preallocated memory to make sure it was committed, not just reserved. Made startup slower, but still saved them often enough from losing work that, I gather, most did use this option. > it! Or, the problem is invalid page faults 'cause the > windows system itself is corrupted, so you are > depending on the very unstable subsystem for > recovery that is causing the error. The list goes When the entire OS craps out from under me, and even trashes my tiny super-solid "watchdog process", then, of course, that's it. Ad impossibilia nemo tenetur. But highly-defensive programming in this regard still slashes errors causing loss of substantial work to the end-user by at least an order of magnitude. Alex From ralph at inputplus.demon.co.uk Wed Jan 2 18:46:59 2002 From: ralph at inputplus.demon.co.uk (Ralph Corderoy) Date: 2 Jan 2002 17:46:59 GMT Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> Message-ID: Hi Fran?ois, > I remember having worked in some C code in which the original > programmer tested the return value of each and every `printf', with > appropriate error reporting. This yielded code which is noisy, hard > to read, and irritating to maintain. He could have written myprintf, a wrapper around vprintf. Cheers, Ralph. From pinard at iro.umontreal.ca Thu Jan 3 00:59:31 2002 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 02 Jan 2002 18:59:31 -0500 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) In-Reply-To: References: <3C2A9D33.67FEC261@earthlink.net> Message-ID: > > I remember having worked in some C code in which the original > > programmer tested the return value of each and every `printf', with > > appropriate error reporting. This yielded code which is noisy, hard > > to read, and irritating to maintain. [Ralph Corderoy] > He could have written myprintf, a wrapper around vprintf. Maybe. The code had to work with an older system, where there was probably not such `vprintf'. In any case, less I see that code, better I feel! :-) It is part of that push that keeps me close to Python, whenever possible! -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From grey at despair.dmiyu.org Thu Jan 3 01:30:29 2002 From: grey at despair.dmiyu.org (Steve Lamb) Date: Thu, 03 Jan 2002 00:30:29 -0000 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> Message-ID: On 02 Jan 2002 09:11:55 -0500, Fran?ois Pinard wrote: > I remember having worked in some C code in which the original programmer > tested the return value of each and every `printf', with appropriate error > reporting. This yielded code which is noisy, hard to read, and irritating > to maintain. Ok, I'll bite, how did he report an error without getting into endless recursion of checking for errors? -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. To email: Don't despair! | -- Lenny Nero, Strange Days -------------------------------+--------------------------------------------- From logiplexsoftware at earthlink.net Thu Jan 3 01:32:49 2002 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Wed, 2 Jan 2002 16:32:49 -0800 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) In-Reply-To: References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> Message-ID: <20020102163249.0b5958e0.logiplexsoftware@earthlink.net> On Thu, 03 Jan 2002 00:30:29 -0000 Steve Lamb wrote: > On 02 Jan 2002 09:11:55 -0500, Fran?ois Pinard > wrote: > > I remember having worked in some C code in which the original programmer > > tested the return value of each and every `printf', with appropriate error > > reporting. This yielded code which is noisy, hard to read, and irritating > > to maintain. > > Ok, I'll bite, how did he report an error without getting into endless > recursion of checking for errors? Then again, he never said he /reported/ the error ;-) -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From grey at despair.dmiyu.org Thu Jan 3 02:29:17 2002 From: grey at despair.dmiyu.org (Steve Lamb) Date: Thu, 03 Jan 2002 01:29:17 -0000 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> Message-ID: On Wed, 2 Jan 2002 16:32:49 -0800, Cliff Wells wrote: > On Thu, 03 Jan 2002 00:30:29 -0000 > Steve Lamb wrote: > >> On 02 Jan 2002 09:11:55 -0500, Fran?ois Pinard >> wrote: >> > I remember having worked in some C code in which the original programmer >> > tested the return value of each and every `printf', with appropriate >> > error reporting. This yielded code which is noisy, hard to read, and >> > irritating to maintain. >> >> Ok, I'll bite, how did he report an error without getting into >> endless recursion of checking for errors? > Then again, he never said he /reported/ the error ;-) Sure he did. Right there, "with appropriate error reporting." -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. To email: Don't despair! | -- Lenny Nero, Strange Days -------------------------------+--------------------------------------------- From logiplexsoftware at earthlink.net Thu Jan 3 02:43:36 2002 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Wed, 2 Jan 2002 17:43:36 -0800 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) In-Reply-To: References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> Message-ID: <20020102174336.5b63fc20.logiplexsoftware@earthlink.net> On Thu, 03 Jan 2002 01:29:17 -0000 Steve Lamb wrote: > > Then again, he never said he /reported/ the error ;-) > > Sure he did. Right there, "with appropriate error reporting." Yeah... well... that's only if you read the whole thing... -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From grey at despair.dmiyu.org Thu Jan 3 10:01:26 2002 From: grey at despair.dmiyu.org (Steve Lamb) Date: Thu, 03 Jan 2002 09:01:26 -0000 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> Message-ID: On Wed, 2 Jan 2002 17:43:36 -0800, Cliff Wells wrote: > On Thu, 03 Jan 2002 01:29:17 -0000 > Steve Lamb wrote: >> > Then again, he never said he /reported/ the error ;-) >> Sure he did. Right there, "with appropriate error reporting." > Yeah... well... that's only if you read the whole thing... *cough* Ok. Gee, you're right, he didn't say he reported the error. ;) -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. To email: Don't despair! | -- Lenny Nero, Strange Days -------------------------------+--------------------------------------------- From michael at stroeder.com Wed Jan 2 18:04:22 2002 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 02 Jan 2002 18:04:22 +0100 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> Message-ID: <3C333D96.2C56BA55@stroeder.com> Ville Vainio wrote: > > One great thing about exceptions as opposed to retval-checking is that > when you are making the initial version, you don't have to implement > error-checking at all! Whenever something weird happens, you will know > where and why it happened through the traceback. Agreed. Example: Since most people are too lazy to install my web software locally for testing I let it run on a web server and log all unhandled exceptions with some extra information. After pointing them to the URL of the online demo they help me testing. This is very helpful! Ciao, Michael. From michael at stroeder.com Wed Jan 2 17:58:28 2002 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 02 Jan 2002 17:58:28 +0100 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> <3c2deb81.11823921@news.t-online.de> <871yhd7red.fsf@kursk.kassube.de> <3C2E498B.6DC757E0@stroeder.com> <3C2E6A51.589E7F1D@earthlink.net> <3C2F2920.89841C81@stroeder.com> Message-ID: <3C333C34.C758F2D8@stroeder.com> Andreas Kostyrka wrote: > > IMHO, there is a huge difference between buffer overflows and exec/eval: > -) exec/Eval just behave like documented, and like some "functions" might > pose security risks if passed untrusted data. Exactly. You have to check the input no matter which programming language. > -) buffer overflows (basically fooling around with pointers) OTOH makes > the code do completly unexpected things. And that's just because there is no such simple thing like string handling in C. > (There are always C language modules ;) ) ;-) > For some interesting thoughts about runtime safety, one should consider > Modula3, which does have the safe/unsafe concept explicitly in the language. (Sigh!) Ciao, Michael. From michael at stroeder.com Wed Jan 2 18:01:19 2002 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Wed, 02 Jan 2002 18:01:19 +0100 Subject: Who needs exceptions References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> <3c2deb81.11823921@news.t-online.de> Message-ID: <3C333CDF.B5C8B7D0@stroeder.com> Oleg Broytmann wrote: > > On Sat, Dec 29, 2001 at 04:16:03PM +0000, Gerson Kurz wrote: > > def lower(): > > file = open(...) > > if file: > > return file.read() > > report_error("lower failed()") > > That's wrong solution. Imagine I am writing a library (that includes the > "lower" function). This is librry, so I cannot define "report_error" > function. > Later you write few different interfaces to the library - web interface, > text interface (command line), curses, GUI... How can I call different > report_errors()? > Exception handling solves this easily. Real men (AKA C programmers) use call-back functions (shudder!)... ;-) Ciao, Michael. From mats at laplaza.org Mon Jan 7 19:00:00 2002 From: mats at laplaza.org (Mats Wichmann) Date: Mon, 07 Jan 2002 18:00:00 GMT Subject: O'Reilly book production (was Re: Wine applicability) References: <3C2A9D33.67FEC261@earthlink.net> <200112281405.IAA20884@starbase.neosoft.com> <200112281642.KAA24897@starbase.neosoft.com> <3c2cca88.13089772@127.0.0.1> Message-ID: <3c39e1df.1921412@news.laplaza.org> On Fri, 28 Dec 2001 19:38:12 GMT, root at 127.0.0.1 ((Five Fresh) Fish) wrote: :On 28 Dec 2001 09:41:30 -0800, aahz at panix.com (Aahz Maruch) wrote: : :>In article , :>Alex Martelli wrote: :>>"Cameron Laird" wrote in message :>>news:200112281642.KAA24897 at starbase.neosoft.com... :>>>Alex: :>>>> :>>>>that's my primary need -- Word with O'Reilly customized macros &c, :>>>>as that's what I'm required to use for one of the books. So, I :>>> :>>> O'REILLY MAKES YOU USE WORD MACROS?!??!!? :>>> I've got to talk with those boys. That strikes me as an atrocity. :>> :>>"makes" is probably an overbid. The Cookbook I'm doing in XML with a :>>custom DTD, and that's just fine - I get to use VIM:-). But for the :>>Nutshell, that wasn't an option. :> :>Really? May you explain why? (I'm still hoping to do a book with :>O'Reilly and I *really* don't want to use Word.) : :Especially when WordPerfect supports SGML/XML. And supports long documents :far more readily than Word does. : :Silly, really. O'Reilly should use the best software for the task, not the :most popular. That's actually the choice they've made: they use FrameMaker for the production, which is far from "the most popular". Like a number of other shops (I know this is true for Manning), they let their authors prepare their manuscript in something that can be converted to, or imported into, Frame. Wouldn't be helpful to force everyone to learn Frame if they're already comfortable in something else. Mats Wichmann From jgardn at alumni.washington.edu Thu Jan 10 23:49:41 2002 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Fri, 11 Jan 2002 07:49:41 +0900 Subject: REPOST: PythonCard, ease of use, and the GUI problem/opportunity/niche In-Reply-To: <3$--$$_----_-%$_$$@news.noc.cabal.int> References: <3C2A9D33.67FEC261@earthlink.net> <458b194a.0112282052.1123341@posting.google.com> <3$--$$_----_-%$_$$@news.noc.cabal.int> Message-ID: <200201102243.g0AMfEJ09911@my.knctv.co.kr> On Saturday 29 December 2001 03:24 pm, Ron Stephens wrote: > Bingo! Boy, oh, boy, do I agree with you on this. I think you hit the nail > right on the head. > > Building a gui now using Python, compared to using VB, really sucks. Yes, > it's that bad. > Qt Designer with PyQt. Easy as pie. It doesn't create the templates for you, but it ain't rocket science. I think TheKompany has a better solution with BlackAdder, but I haven't used it. Jonathan From logiplexsoftware at earthlink.net Thu Jan 10 23:53:40 2002 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Thu, 10 Jan 2002 14:53:40 -0800 Subject: PythonCard, ease of use, and the GUI problem/opportunity/niche In-Reply-To: <200201102243.g0AMfEJ09911@my.knctv.co.kr> References: <3C2A9D33.67FEC261@earthlink.net> <458b194a.0112282052.1123341@posting.google.com> <3$--$$_----_-%$_$$@news.noc.cabal.int> <200201102243.g0AMfEJ09911@my.knctv.co.kr> Message-ID: <20020110145340.41a7d228.logiplexsoftware@earthlink.net> On Saturday 29 December 2001 03:24 pm, Ron Stephens wrote: > Bingo! Boy, oh, boy, do I agree with you on this. I think you hit the nail > right on the head. > > Building a gui now using Python, compared to using VB, really sucks. Yes, > it's that bad. Then again, programming now using VB, compared to using Python, really sucks. Yes, it's that bad. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From dbeech at bigpond.net.au Fri Jan 11 14:15:35 2002 From: dbeech at bigpond.net.au (David Beech) Date: Sat, 12 Jan 2002 00:15:35 +1100 Subject: PythonCard, ease of use, and the GUI problem/opportunity/niche In-Reply-To: <20020110145340.41a7d228.logiplexsoftware@earthlink.net> References: <200201102243.g0AMfEJ09911@my.knctv.co.kr> Message-ID: <3C3F8027.24557.18192670@localhost> On 10 Jan 2002, at 14:53, Cliff Wells wrote: > On Saturday 29 December 2001 03:24 pm, Ron Stephens wrote: > > Bingo! Boy, oh, boy, do I agree with you on this. I think you hit the > nail > > right on the head. > > > > Building a gui now using Python, compared to using VB, really sucks. Yes, > > it's that bad. > > Then again, programming now using VB, compared to using Python, really > sucks. Yes, it's that bad. > In Australia VB is known as a beer. Much use of VB leaves you legless and useless for any serious work. Australia has several kinds of python, one, the water python is very fast and agile in its environment and is powerful enough to kill small crocodiles, feral cats, foxes and dingoes. And the occasional (small) VB user. It is sometimes mistaken for a Taipan. David From peter at engcorp.com Sat Jan 12 01:24:49 2002 From: peter at engcorp.com (Peter Hansen) Date: Fri, 11 Jan 2002 19:24:49 -0500 Subject: PythonCard, ease of use, and the GUI problem/opportunity/niche References: <200201102243.g0AMfEJ09911@my.knctv.co.kr> Message-ID: <3C3F8251.4C05B96E@engcorp.com> David Beech wrote: > > On 10 Jan 2002, at 14:53, Cliff Wells wrote: > > Then again, programming now using VB, compared to using Python, really > > sucks. Yes, it's that bad. > > In Australia VB is known as a beer. Much use of VB leaves you > legless and useless for any serious work. Australia has several > kinds of python, one, the water python is very fast and agile in > its environment and is powerful enough to kill small crocodiles, > feral cats, foxes and dingoes. And the occasional (small) VB > user. It is sometimes mistaken for a Taipan. What, they're too gentle to kill cats that aren't feral? Weird... -Peter From dbeech at bigpond.net.au Sat Jan 12 02:55:24 2002 From: dbeech at bigpond.net.au (David Beech) Date: Sat, 12 Jan 2002 12:55:24 +1100 Subject: PythonCard, ease of use, and the GUI problem/opportunity/niche In-Reply-To: <3C3F8251.4C05B96E@engcorp.com> Message-ID: <3C40323C.3180.1AD0C96C@localhost> On 11 Jan 2002, at 19:24, Peter Hansen wrote: > David Beech wrote: > > > > On 10 Jan 2002, at 14:53, Cliff Wells wrote: > > > Then again, programming now using VB, compared to using Python, really > > > sucks. Yes, it's that bad. > > > > In Australia VB is known as a beer. Much use of VB leaves you > > legless and useless for any serious work. Australia has several > > kinds of python, one, the water python is very fast and agile in > > its environment and is powerful enough to kill small crocodiles, > > feral cats, foxes and dingoes. And the occasional (small) VB > > user. It is sometimes mistaken for a Taipan. > > What, they're too gentle to kill cats that aren't feral? Weird... > > -Peter > Not too gentle, just lacking a module. Perhaps: from xmlrpclib import kill_domestic_cat ... target = kill_domestic_cat( server = ' ... ', cat = 'Tabby', modus = 'choke' ) David From access at thomas-guettler.de Wed Jan 2 13:04:29 2002 From: access at thomas-guettler.de (Thomas Guettler) Date: Wed, 02 Jan 2002 13:04:29 +0100 Subject: zope: which adapter for oracle? Message-ID: <3C32F74D.2020503@thomas-guettler.de> There are two adapters for zope: http://www.zope.org/Products/DCOracle and http://www.zope.org/Members/matt/dco2 Can someone compare these adapters? What are the (dis)advantages? thomas (I know that it is OT, but I can't subscribe to the zope mailinglist at the moment) From anthony at interlink.com.au Wed Jan 2 13:11:04 2002 From: anthony at interlink.com.au (Anthony Baxter) Date: Wed, 02 Jan 2002 23:11:04 +1100 Subject: zope: which adapter for oracle? In-Reply-To: Message from Thomas Guettler of "Wed, 02 Jan 2002 13:04:29 BST." <3C32F74D.2020503@thomas-guettler.de> Message-ID: <200201021211.g02CB4d08769@mbuna.arbhome.com.au> >>> Thomas Guettler wrote > There are two adapters for zope: > http://www.zope.org/Products/DCOracle > and > http://www.zope.org/Members/matt/dco2 DCOracle2 is newer. it has more features, supports more neat Oracle knobx and whistles. But it is newer, and so might be less stable. DCOracle2 is also, iirc, not yet out of beta... Anthony -- Anthony Baxter It's never too late to have a happy childhood. From aleax at aleax.it Wed Jan 2 13:17:54 2002 From: aleax at aleax.it (Alex Martelli) Date: Wed, 2 Jan 2002 13:17:54 +0100 Subject: REPOST: Help - command line arguments References: <7$--$$_----__%--%$@news.noc.cabal.int> Message-ID: "Steve Zatz" wrote in message news:7$--$$_----__%--%$@news.noc.cabal.int... ... > test.py -a -b > > runs fine from the *Windows XP* command prompt. > > From the Python command line, I can do the following: > > import test > test.main() > > which doesn't produce an exception but I can't figure out how to input the > command line arguments. import sys sys.argv = "test.py -a -b".split() import test test.main() However, this does differ in one important respect from running test at the command prompt. When you do the latter, then, within test.py, global variable __name__ is set to the string '__main__'. With this approach, on the other hand, it's set to '__test__'. This is how a script tells whether it's being run, or imported as a module. If you want to make the script BELIEVE it's being imported, you CAN, though it IS slightly tricky: import sys sys.argv = "test.py -a -b".split() import imp imp.load_module('__main__',*imp.find_module('test')) this makes the module believe its name is __main__, i.e., that it's being run as a script rather than imported. If the script is not on the sys.path (which is what implicity gets searched by imp.find_module), just pass the directory as the second argument of find_module (you can automate this with os.path.split and os.path.splitext). If you do this often, you're best off making this into a function and sticking it into __builtins__ from sitecustomize.py. Alex From marklists at mceahern.com Wed Jan 2 18:01:07 2002 From: marklists at mceahern.com (Mark McEahern) Date: Wed, 2 Jan 2002 09:01:07 -0800 Subject: Help - command line arguments In-Reply-To: Message-ID: checkout optik for option parsing. http://optik.sourceforge.net/ // m From apps_xertel at hotmail.com Wed Jan 2 13:20:58 2002 From: apps_xertel at hotmail.com (Aparna Shivakumar) Date: Wed, 02 Jan 2002 12:20:58 +0000 Subject: subject=unsubscribe Message-ID: An HTML attachment was scrubbed... URL: From phr-n2002a at nightsong.com Wed Jan 2 13:54:40 2002 From: phr-n2002a at nightsong.com (Paul Rubin) Date: 02 Jan 2002 04:54:40 -0800 Subject: How to make a program exit? Message-ID: <7xitak7w1b.fsf_-_@ruckus.brouhaha.com> What's the preferred way of making a multi-threaded program exit? I have a SocketServer application using ThreadingMixin, i.e. a multi-threaded socket listener. I want the server to support a shutdown command, i.e. if a client connects and sends a certain string, the whole server should shut down gracefully. In a non-threaded application I'd just call sys.exit(), but that only collects the current listener thread rather than shutting down the whole server. I can think of some brutal ways to stop the server, but it's not clear from the docs if there's a nice way. Any advice? Thanks. From mkelly2002NOSPAM at earthlink.net Wed Jan 2 17:23:32 2002 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Wed, 02 Jan 2002 16:23:32 GMT Subject: How to make a program exit? References: <7xitak7w1b.fsf_-_@ruckus.brouhaha.com> Message-ID: <8mc63uo705hecdn406o43r208iv3sm5i7f@4ax.com> On 02 Jan 2002 04:54:40 -0800, Paul Rubin wrote: >I can think of some brutal ways to stop the server, but it's not clear >from the docs if there's a nice way. > >Any advice? Thanks. The recommended technique is to communicate somehow with the running threads that they should commit suicide and only kill them off if they haven't died in some acceptable interval. You should of course use a thread-safe method of communication so that you don't get a memory access exceptions. Then your main thread waits until either they have all complied with the request or the main thread decides it must resort to murder. So I guess this implies that you don't do operations that block indefinitely. There should be a time-out or some signalling mechanism so that periodically your worker threads can check the flag to see if it should shut down. Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From ungrzr2 at ubatxbat.pbz Thu Jan 3 09:32:18 2002 From: ungrzr2 at ubatxbat.pbz ({-- Rot13 - Hateme) Date: 3 Jan 2002 08:32:18 GMT Subject: How to make a program exit? References: <7xitak7w1b.fsf_-_@ruckus.brouhaha.com> Message-ID: Paul Rubin wrote in news:7xitak7w1b.fsf_- _ at ruckus.brouhaha.com: > > In a non-threaded application I'd just call sys.exit(), but that > only collects the current listener thread rather than shutting down > the whole server. > > I can think of some brutal ways to stop the server, but it's not clear > from the docs if there's a nice way. > They will always advice you to 'always wait for other threads to finish' but we don't always care if other threads are finished or not. I use os.exit() which does exit on multithread scripts. From tmagna at online.no Wed Jan 2 14:01:01 2002 From: tmagna at online.no (Brandvik) Date: Wed, 02 Jan 2002 14:01:01 +0100 Subject: Python and UTF-8 Message-ID: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> I'm making a small automated managing system for my website and I think I will go for Python and CGI. I have one question though: my website is in Norwegian and in valid XHTML. All characters need to be encoded in UTF-8. The way I'm currently doing it is that all articles go through me for formatting and validation. When switching to a CMS everybody with access to the system will be able to put articles on my website and this means that all kinds of formatting will be used. This will make the W3C validator choke and my site would not validate. Is it possible to make a python script that would change the character to UTF-8 no matter what the encoding of the input is? I have heard that Python has some great functions for Unicode formatting so this might be an easy and trivial task, but I'm new to Python so I really don't know... -Brandvik From martin at v.loewis.de Wed Jan 2 22:28:47 2002 From: martin at v.loewis.de (Martin v. Loewis) Date: 02 Jan 2002 22:28:47 +0100 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> Message-ID: Brandvik writes: > Is it possible to make a python script that would change the character > to UTF-8 no matter what the encoding of the input is? I have heard > that Python has some great functions for Unicode formatting so this > might be an easy and trivial task, but I'm new to Python so I really > don't know... You have to know the encoding the data is currently, say current_encoding. Then, converting it into UTF-8, you write data = unicode(data, current_encoding).encode('utf-8') HTH, Martin From mhuening at zedat.fu-berlin.de Thu Jan 3 13:39:31 2002 From: mhuening at zedat.fu-berlin.de (Matthias Huening) Date: 3 Jan 2002 12:39:31 GMT Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> Message-ID: martin at v.loewis.de (Martin v. Loewis) wrote in news:m3itak5to0.fsf at mira.informatik.hu-berlin.de: > > You have to know the encoding the data is currently, say > current_encoding. Then, converting it into UTF-8, you write > > data = unicode(data, current_encoding).encode('utf-8') > Yes, but what if I don't know? I have been playing around with Unicode/Python/Tkinter, but I just don't get is... Seems like I need some help on Unicode... Would there be a good tutorial or book on this topic which answers questions like: How does Python handle Unicode-files? How does sorting work with Unicode? Can I use locales with Unicode (e.g. to sort words according to the German convention?) How? How to use regular expressions with Unicode? etc. Thanks, Matthias From loewis at informatik.hu-berlin.de Thu Jan 3 18:58:58 2002 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Jan 2002 18:58:58 +0100 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> Message-ID: Matthias Huening writes: > > You have to know the encoding the data is currently, say > > current_encoding. Then, converting it into UTF-8, you write > > > > data = unicode(data, current_encoding).encode('utf-8') > > > > Yes, but what if I don't know? If you get byte data from some source, and want to interpret those byte data as character strings, you *have* to know the encoding - if you don't, consider re-architecting your application so that you do. If you still cannot know, guess. If you guess wrong often enough, your users will complain so that they are willing to accept additional infrastructure to properly identify the encoding of byte data. > How does Python handle Unicode-files? There is no such thing as a Unicode file. Files are byte-oriented on all systems I know. So when opening a file, you need to specify the encoding. You can use codecs.open to read from a file and get Unicode strings out of it. > How does sorting work with Unicode? By default, it sorts by Unicode numeral value. > Can I use locales with Unicode (e.g. to sort words according to the > German convention?) How? You sort plain (byte) strings according to locale with locale.strcoll. In theory, this function ought to work for Unicode strings, too; it is a bug that it currently doesn't. To work around this, you need to encode the Unicode strings into the locale's character set, and compare the resulting byte strings with strcoll. > How to use regular expressions with Unicode? Just use the re module: it fully supports Unicode. Regards, Martin From mhuening at zedat.fu-berlin.de Thu Jan 3 19:46:06 2002 From: mhuening at zedat.fu-berlin.de (Matthias Huening) Date: 3 Jan 2002 18:46:06 GMT Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> Message-ID: Martin von Loewis wrote in news:j4itajb9jx.fsf at informatik.hu-berlin.de: > There is no such thing as a Unicode file. Files are byte-oriented on > all systems I know. So when opening a file, you need to specify the > encoding. You can use codecs.open to read from a file and get Unicode > strings out of it. > Hhmm, but how come that reading a text file with Python and displaying it in a Tkinter text widget (with a Unicode font) will show the text just fine -- regardless of the encoding used to save the file (Latin-1 or UTF- 8) and without specifying the encoding when opening it. Does Python guess itself? As I said in my earlier posting, I just don't get how it works... > You sort plain (byte) strings according to locale with > locale.strcoll. In theory, this function ought to work for Unicode > strings, too; it is a bug that it currently doesn't. Okay, this explains the trouble I got into, when trying to use locale.strcoll with Unicode strings... Thanks, Martin! Matthias From martin at v.loewis.de Fri Jan 4 02:48:41 2002 From: martin at v.loewis.de (Martin v. Loewis) Date: 04 Jan 2002 02:48:41 +0100 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> Message-ID: Matthias Huening writes: > Hhmm, but how come that reading a text file with Python and displaying it > in a Tkinter text widget (with a Unicode font) will show the text just > fine -- regardless of the encoding used to save the file (Latin-1 or UTF- > 8) and without specifying the encoding when opening it. Does Python guess > itself? No, it is Tk that guesses - although exactly how that works depends on the Tk version, and using a questionable algorithm. If a Tk widget gets a byte string (rather than a Unicode string), it first assumes that it is UTF-8. There is an almost reliable algorithm to tell whether data is UTF-8, so that is fine. If it finds that it is not UTF-8, it falls back. I don't exactly remember what it falls back to: either Latin-1, or the locale's encoding. Either fall-back is broken: the data may not be in that encoding, but there is no way to reliably to find out. If you open a KOI-8 file in a Latin locale, I'm pretty sure the display will be garbage. Regards, Martin From mhuening at zedat.fu-berlin.de Fri Jan 4 12:33:44 2002 From: mhuening at zedat.fu-berlin.de (Matthias Huening) Date: 4 Jan 2002 11:33:44 GMT Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> Message-ID: Well, I still don't really understand it, but I got things to work. Thanks to everybody who responded! Matthias From matthias.huening at t-online.de Thu Jan 3 20:41:24 2002 From: matthias.huening at t-online.de (Matthias Huening) Date: Thu, 3 Jan 2002 20:41:24 +0100 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> Message-ID: Martin von Loewis wrote in news:j4itajb9jx.fsf at informatik.hu-berlin.de: >> How to use regular expressions with Unicode? > > Just use the re module: it fully supports Unicode. > Not really... At least the combination of re.I and re.U fails on texts in German. But that again could be a result of the combination of 'locale' and Unicode, right? I tried this (Win 98, Python 2.1, Idle): ---------------------- >>> import locale >>> locale.setlocale(locale.LC_ALL,"") 'German_Germany.1252' >>> t = 'M?hsam ern?hrt sich das Eichh?rnchen.' >>> print t.upper() M?HSAM ERN?HRT SICH DAS EICHH?RNCHEN. >>> tu = unicode(t, 'latin-1').encode('utf-8') >>> print tu.upper() M?HSAM ERN?HRT SICH DAS EICHH?RNCHEN. >>> ---------------------- This should work, I think. But it doesn't. Did I miss something? Matthias From ws at mystrobl.de Thu Jan 3 23:15:09 2002 From: ws at mystrobl.de (Wolfgang Strobl) Date: Thu, 03 Jan 2002 23:15:09 +0100 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> Message-ID: <2ol93uk1qirctovnpdtgaqbjmh9ei9b1mh@4ax.com> On Thu, 3 Jan 2002 20:41:24 +0100, Matthias Huening wrote : >---------------------- >>>> import locale >>>> locale.setlocale(locale.LC_ALL,"") >'German_Germany.1252' >>>> t = 'M?hsam ern?hrt sich das Eichh?rnchen.' >>>> print t.upper() >M?HSAM ERN?HRT SICH DAS EICHH?RNCHEN. >>>> tu = unicode(t, 'latin-1').encode('utf-8') >>>> print tu.upper() Won't work. 'upper' doesn't know anything about the utf-8-encoding. it assumes cp1252 according to the locale settings. 'tu' isn't an unicode string. >M?HSAM ERN?HRT SICH DAS EICHH?RNCHEN. >>>> >---------------------- (W2K, Ger) Welcome To PyCrust 0.7 - The Flakiest Python Shell Sponsored by Orbtech.com - Your Source For Python Development Services Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import locale >>> locale.setlocale(locale.LC_ALL,"") 'German_Germany.1252' >>> t="M?hsam ern?hrt sich das Eichh?rnchen" >>> tu=unicode(t,"latin-1") >>> tu u'M\xfchsam ern\xe4hrt sich das Eichh\xf6rnchen' >>> tu.upper() u'M\xdcHSAM ERN\xc4HRT SICH DAS EICHH\xd6RNCHEN' >>> print tu.upper().encode("latin-1") M?HSAM ERN?HRT SICH DAS EICHH?RNCHEN -- Wir danken f?r die Beachtung aller Sicherheitsbestimmungen From ws at mystrobl.de Thu Jan 3 23:15:13 2002 From: ws at mystrobl.de (Wolfgang Strobl) Date: Thu, 03 Jan 2002 23:15:13 +0100 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> Message-ID: On Thu, 3 Jan 2002 20:41:24 +0100, Matthias Huening wrote : >Martin von Loewis wrote in >news:j4itajb9jx.fsf at informatik.hu-berlin.de: > >>> How to use regular expressions with Unicode? >> >> Just use the re module: it fully supports Unicode. >> > >Not really... >At least the combination of re.I and re.U fails on texts in German. >But that again could be a result of the combination of 'locale' and >Unicode, right? S.I doesn't honor the locale settings. From the manual: IGNORECASE Perform case-insensitive matching; expressions like [A-Z] will match lowercase letters, too. This is not affected by the current locale -- Thank you for observing all safety precautions From michael at stroeder.com Thu Jan 3 23:31:57 2002 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 03 Jan 2002 23:31:57 +0100 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> Message-ID: <3C34DBDD.CB24E646@stroeder.com> Matthias Huening wrote: > > >>> t = 'M?hsam ern?hrt sich das Eichh?rnchen.' > >>> print t.upper() > M?HSAM ERN?HRT SICH DAS EICHH?RNCHEN. > >>> tu = unicode(t, 'latin-1').encode('utf-8') > >>> print tu.upper() > M?HSAM ERN?HRT SICH DAS EICHH?RNCHEN. > >>> > ---------------------- > > This should work, I think. But it doesn't. > Did I miss something? >>> tu = unicode(t, 'latin-1') >>> print tu.upper().encode('latin-1') M?HSAM ERN?HRT SICH DAS EICHH?RNCHEN. >>> tu.upper().encode('utf-8') 'M\xc3\x9cHSAM ERN\xc3\x84HRT SICH DAS EICHH\xc3\x96RNCHEN.' >>> Ciao, Michael. From gleki at gol.ge Thu Jan 3 19:45:30 2002 From: gleki at gol.ge (Giorgi Lekishvili) Date: Thu, 03 Jan 2002 10:45:30 -0800 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> Message-ID: <3C34A6CA.81EB93A1@gol.ge> I wonder if you find time to give me a hint where can I get the information on which encoding schemes are currently suported in Python... Grtz, Giorgi "Martin v. Loewis" wrote: > Brandvik writes: > > > Is it possible to make a python script that would change the character > > to UTF-8 no matter what the encoding of the input is? I have heard > > that Python has some great functions for Unicode formatting so this > > might be an easy and trivial task, but I'm new to Python so I really > > don't know... > > You have to know the encoding the data is currently, say > current_encoding. Then, converting it into UTF-8, you write > > data = unicode(data, current_encoding).encode('utf-8') > > HTH, > Martin From johnroth at ameritech.net Thu Jan 3 15:47:31 2002 From: johnroth at ameritech.net (John Roth) Date: Thu, 3 Jan 2002 06:47:31 -0800 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> <3C34A6CA.81EB93A1@gol.ge> Message-ID: "Giorgi Lekishvili" wrote in message news:3C34A6CA.81EB93A1 at gol.ge... > I wonder if you find time to give me a hint where can I get the information > on which encoding schemes are currently suported in Python... > Grtz, > Giorgi It doesn't seem to be very well documented. The only way I ever figured it out was to go into the Python21/Lib/encodings directory and look. > > "Martin v. Loewis" wrote: > > > Brandvik writes: > > > > > Is it possible to make a python script that would change the character > > > to UTF-8 no matter what the encoding of the input is? I have heard > > > that Python has some great functions for Unicode formatting so this > > > might be an easy and trivial task, but I'm new to Python so I really > > > don't know... > > > > You have to know the encoding the data is currently, say > > current_encoding. Then, converting it into UTF-8, you write > > > > data = unicode(data, current_encoding).encode('utf-8') > > > > HTH, > > Martin > From =?iso-8859-5?Q?=DF=D5=DD=D3=E3=D8=DD=D8=E1=E2=D0?= at =?iso-8859-5?Q?=DC=D0=D8=DB?=.=?iso-8859-5?Q?=DD=D5=E2?=.=?iso-8859-5?Q?=DC=DA?= Thu Jan 3 16:44:55 2002 From: =?iso-8859-5?Q?=DF=D5=DD=D3=E3=D8=DD=D8=E1=E2=D0?= at =?iso-8859-5?Q?=DC=D0=D8=DB?=.=?iso-8859-5?Q?=DD=D5=E2?=.=?iso-8859-5?Q?=DC=DA?= (=?iso-8859-5?Q?=B4=D0=DC=F8=D0=DD_=B3=2E?=) Date: Thu, 3 Jan 2002 16:44:55 +0100 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> <3C34A6CA.81EB93A1@gol.ge> Message-ID: <3c347c76$1@news.mt.net.mk> > I wonder if you find time to give me a hint where can I get the information > on which encoding schemes are currently suported in Python... On Unix systems, Python 2.1, /usr/lib/python2.1/encodings/ -- ?????? The dark ages were caused by the Y1K problem. From loewis at informatik.hu-berlin.de Thu Jan 3 18:29:05 2002 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Jan 2002 18:29:05 +0100 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> <3C34A6CA.81EB93A1@gol.ge> Message-ID: Giorgi Lekishvili writes: > I wonder if you find time to give me a hint where can I get the > information on which encoding schemes are currently suported in > Python... Currently, there is no programmatic way to find all supported encodings. In general, take the IANA registry of character sets at http://www.iana.org/assignments/character-sets as a starting point, and use the names in that registry (if there is a preferred MIME name as an alias, use that, otherwise use the Name, not an Alias). To get an idea of what is supported, see /lib/python/encodings For a module foo_bar.py in this directory, you can use alternative spellings, like "foo-bar", or "foo_BAR" (i.e. all of ISO-8859-1, iso-8859-1, and ISO_8859-1 refer to the same encoding). If there is an encoding that is not supported by Python which you need, please report it as a bug at sf.net/projects/python. Meanwhile, you may find the additional codecs at sf.net/projects/python-codecs useful. In particular, on Unix, the iconv codec will give you access to many additional encodings (depending on your operating system). HTH, Martin From DaveP at dpawsonNOSPam.freeserve.co.uk Fri Jan 4 19:45:03 2002 From: DaveP at dpawsonNOSPam.freeserve.co.uk (Dave Pawson) Date: 4 Jan 2002 18:45:03 GMT Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> Message-ID: martin at v.loewis.de (Martin v. Loewis) wrote in news:m3itak5to0.fsf at mira.informatik.hu-berlin.de: > Brandvik writes: > >> Is it possible to make a python script that would change the character >> to UTF-8 no matter what the encoding of the input is? I have heard >> that Python has some great functions for Unicode formatting so this >> might be an easy and trivial task, but I'm new to Python so I really >> don't know... > > You have to know the encoding the data is currently, say > current_encoding. Then, converting it into UTF-8, you write > > data = unicode(data, current_encoding).encode('utf-8') If, having a file with 8859-1 encodings, can I use the same approach? This prior to xslt processing, with older html files originating in Scandanavia, which blow up when XSLT gets hold of them with no encoding specified! I figured out how to add the encoding, but a utf-8 input would make it far easier! Regards DaveP From martin at v.loewis.de Sat Jan 5 08:27:43 2002 From: martin at v.loewis.de (Martin v. Loewis) Date: 05 Jan 2002 08:27:43 +0100 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> Message-ID: Dave Pawson writes: > > You have to know the encoding the data is currently, say > > current_encoding. Then, converting it into UTF-8, you write > > > > data = unicode(data, current_encoding).encode('utf-8') > > If, having a file with 8859-1 encodings, can I use the same > approach? Certainly. Just use 'iso-8859-1' as current_encoding, and data as the file contents. > This prior to xslt processing, with older html files > originating in Scandanavia, which blow up when XSLT > gets hold of them with no encoding specified! If these are HTML files, the likely have other problems beyond encoding, such as missing closing tags. Notice that, AFAIK, the default encoding of HTML is Latin-1, so not specifying any other encoding implies Latin-1. A HTML processor should know that. If you want to convert HTML documents to XHTML, I recommend to use HTML Tidy. Regards, Martin From gleki at gol.ge Thu Jan 3 01:43:03 2002 From: gleki at gol.ge (Giorgi Lekishvili) Date: Wed, 02 Jan 2002 16:43:03 -0800 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> Message-ID: <3C33A917.4506E731@gol.ge> Just a related topic: I have a similar problem: I would like to make an online service enabling to recode latin letters into the georgian alphabet (quite independent, one of the 14 existing ones). What I know are the the georgian encoding, see e.g., http://www.paratype.com/default.asp?page=/library/languag/codepages.html?ncoding=17 and the rules the latin characters are to be substituted by the georgian ones. What I do not know is the way I can forse Python to print the octals in the right manner... I am affraid that this question is not for this group... If so, please, accept my appologoes:( Best wishes, Giorgi Brandvik wrote: > I'm making a small automated managing system for my website and I > think I will go for Python and CGI. I have one question though: my > website is in Norwegian and in valid XHTML. All characters need to be > encoded in UTF-8. The way I'm currently doing it is that all articles > go through me for formatting and validation. When switching to a CMS > everybody with access to the system will be able to put articles on my > website and this means that all kinds of formatting will be used. This > will make the W3C validator choke and my site would not validate. > > Is it possible to make a python script that would change the character > to UTF-8 no matter what the encoding of the input is? I have heard > that Python has some great functions for Unicode formatting so this > might be an easy and trivial task, but I'm new to Python so I really > don't know... > > -Brandvik From fbartlet at wiley.com Thu Jan 3 16:22:04 2002 From: fbartlet at wiley.com (Frederick H. Bartlett) Date: 3 Jan 2002 07:22:04 -0800 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> <3C33A917.4506E731@gol.ge> Message-ID: Giorgi, I'm interested in your problem; I'm learning about encodings in Python for other purposes at the moment. I am somewhat familiar with the Georgian alphabet. (I once tried to translate an aria from paliashvili's _abessalom da eteri_ for my wife -- but I ended up translating from the Russian. No offense, but Georgian really is an *impossible* language!). There are certainly some interesting issues: Capitalization, for one. And do you want the reencoding to be, essentially, a transliteration? Perhaps we should take this offline; you can contact me at my personal email address, fbartlet (at) optonline (dot) net. Fred Giorgi Lekishvili wrote in message news:<3C33A917.4506E731 at gol.ge>... > Just a related topic: > > I have a similar problem: > > I would like to make an online service enabling to recode latin letters > into the georgian alphabet (quite independent, one of the 14 existing > ones). > > What I know are the the georgian encoding, see e.g., > http://www.paratype.com/default.asp?page=/library/languag/codepages.html?ncoding=17 > > and the rules the latin characters are to be substituted by the georgian > ones. > > What I do not know is the way I can forse Python to print the octals in > the right manner... > > I am affraid that this question is not for this group... If so, please, > accept my appologoes:( > > Best wishes, > Giorgi > > Brandvik wrote: > > > I'm making a small automated managing system for my website and I > > think I will go for Python and CGI. I have one question though: my > > website is in Norwegian and in valid XHTML. All characters need to be > > encoded in UTF-8. The way I'm currently doing it is that all articles > > go through me for formatting and validation. When switching to a CMS > > everybody with access to the system will be able to put articles on my > > website and this means that all kinds of formatting will be used. This > > will make the W3C validator choke and my site would not validate. > > > > Is it possible to make a python script that would change the character > > to UTF-8 no matter what the encoding of the input is? I have heard > > that Python has some great functions for Unicode formatting so this > > might be an easy and trivial task, but I'm new to Python so I really > > don't know... > > > > -Brandvik From loewis at informatik.hu-berlin.de Thu Jan 3 19:04:29 2002 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Jan 2002 19:04:29 +0100 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> <3C33A917.4506E731@gol.ge> Message-ID: fbartlet at wiley.com (Frederick H. Bartlett) writes: > I am somewhat familiar with the Georgian alphabet. (I once tried to > translate an aria from paliashvili's _abessalom da eteri_ for my wife > -- but I ended up translating from the Russian. No offense, but > Georgian really is an *impossible* language!). There are certainly > some interesting issues: Capitalization, for one. And do you want the > reencoding to be, essentially, a transliteration? It depends in what format you have the Georgian data. E.g. if you have them in Mac OS Georgian, you can define a codec that encodes to Unicode. Regards, Martin From daniel_shane_eicon_junk at hotmail.com Wed Jan 2 15:54:37 2002 From: daniel_shane_eicon_junk at hotmail.com (Daniel Shane) Date: 2 Jan 2002 06:54:37 -0800 Subject: What is the "best" network event framework for python? Message-ID: <2a6452dc.0201020654.3d323a5b@posting.google.com> Hi, After looking at python during the holidays, I finaly decided to take the big plunge and switch from perl to python :) Unfortunately, my main task involves writing network protocols/servers. To this extent, I used to use perl POE (poe.perl.org), which I think is wonderfull. Perl POE is a framework that will call methods in response to asynchronous events. Note that in perl POE evey object can generate asynchronous events, not only sockets. For example, I can tell perl POE to run a command line application and trigger an event when that program either gets killed or if it sends some text to stdout. Is there an equivalent module in python? I know that as a last resource I could live with the asyncore module, but it offers very little functionality compared to perl POE (poe.perl.org), and it only deals with sockets. I saw twisted (www.tsiwtedmatrix.com) that looks like perl POE, but since there is so little doc/examples I dont know if this is the most widely used event framework for python. What do the experts use? Thanks in advance! Daniel Shane From hellotel at zaza.info Wed Jan 2 15:57:34 2002 From: hellotel at zaza.info (Çï·Î¿ìÅÚ) Date: Wed, 02 Jan 2002 23:57:34 +0900 Subject: [±¤°í] ÀüÈ­¿ä±Ý °¡Àå ½Î°Ô ¾²´Â ¹æ¹ý Message-ID: <20020102235734.-1306206073@super> An HTML attachment was scrubbed... URL: From gb at cs.unc.edu Wed Jan 2 16:40:25 2002 From: gb at cs.unc.edu (Gary Bishop) Date: Wed, 02 Jan 2002 10:40:25 -0500 Subject: Problems in win32all-141.exe with wxPython 2.3.2 Message-ID: <3C3329E8.454D9298@cs.unc.edu> When I use win32all-141.exe with Python2.2 on Win2k I get undefined references to build._safeQQQ from genpy.py. I see a function _safeQuotedString in build that might be the correct target for this call. If I change _safeQQQ to _safeQuotedString it appears to work. Is this what was intended? Once I have made this change it mostly appears to work but embeding IE in a wxPython window no longer works. You can see the problem by running the ActiveXWrapper_IE demo that comes with the wxPython package. On my system it dies fairly soon after startup. If I comment out the methods that the IE com uses to do callbacks then it will work. Thanks for any help, gb From mhammond at skippinet.com.au Fri Jan 4 05:33:09 2002 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 04 Jan 2002 04:33:09 GMT Subject: Problems in win32all-141.exe with wxPython 2.3.2 References: <3C3329E8.454D9298@cs.unc.edu> Message-ID: <3C35308E.4020202@skippinet.com.au> Gary Bishop wrote: > When I use win32all-141.exe with Python2.2 on Win2k I get undefined > references to build._safeQQQ from genpy.py. I see a function > _safeQuotedString in build that might be the correct target for this > call. If I change _safeQQQ to _safeQuotedString it appears to work. Is > this what was intended? > > Once I have made this change it mostly appears to work but embeding IE > in a wxPython window no longer works. You can see the problem by running > the ActiveXWrapper_IE demo that comes with the wxPython package. On my > system it dies fairly soon after startup. If I comment out the methods > that the IE com uses to do callbacks then it will work. > Yeah - not sure how that happened :( I will release 142 soon. Mark. From Eric.Chamberland at videotron.ca Wed Jan 2 16:42:21 2002 From: Eric.Chamberland at videotron.ca (Eric Chamberland) Date: Wed, 02 Jan 2002 10:42:21 -0500 Subject: Problem with any of os.system(), os.fork() & os.execp() and os.spawn() Message-ID: <3C332A5D.1A841338@videotron.ca> Hi, Al I want is to execute a simple tcsh script from a python process. But the problem is that a put processes in the background in my tcsh shell (with &) and the execution of the script is stopped _only_ when the console from which I started the python process has been terminated. Here is my simple python script: ---------------------------- #!/usr/bin/env python import os,time time.sleep(5) lArgs=['/tmp/myscript'] # we fork and execute the script #if (os.fork() == 0): # os.execv(lArgs[0],lArgs) #else: # os.wait() #we execute the script with os.system: os.system(lArgs[0]) ---------------------------- and here is my simple script (put it in /tmp/myscript): ---------------------------- #!/bin/tcsh rm -f /tmp/out.txt echo "first" > /tmp/out.txt& echo "second" >> /tmp/out.txt& echo "third" >> /tmp/out.txt& ---------------------------- Here is how to reproduce the problem: 1- execute the python program and put it in background 2- before 5 seconds, exit the shell from which you executed the python program 3- wait .. ;-) 4- look at the file /tmp/out.txt, it will contain only one line, in occurance the word "first" If you don't exit the sheel from which you started the python program, it will work fine. Also, if you don't put the echo's in the background in "/tmp/myscript/, it will also work. So, I need to have commands in "myscript" to be run in background, so how do I make this simple thing work correctly? I tried, fork and execv, spawn, and they all have the same behavior... Anyone can help? Thanks, Eric From martin at v.loewis.de Wed Jan 2 22:54:31 2002 From: martin at v.loewis.de (Martin v. Loewis) Date: 02 Jan 2002 22:54:31 +0100 Subject: Problem with any of os.system(), os.fork() & os.execp() and os.spawn() References: <3C332A5D.1A841338@videotron.ca> Message-ID: Eric Chamberland writes: > So, I need to have commands in "myscript" to be run in background, > so how do I make this simple thing work correctly? This has nothing to do with python. Please try (sleep 5;/tmp/myscript) & in your shell. You will see that the same effect happens. If you strace the shell, you will see that tcsh executes the sequence ... 1912 write(1, "first\n", 6) = 6 1912 _exit(0) = ? 1905 setpgid(1912, 1912) = 0 This is the fragment where the first subshell exits; 1905 is the tcsh and 1912 the echo process. Shortly afterwards, you see 1905 write(17, "[1] 1912\n", 9) = -1 EIO (Input/output error) 1905 munmap(0x40017000, 33577) = 0 1905 _exit(1) = ? FD 17, in this case, is a dup of stdout. Since the terminal is closed, the write operation gets a SIGIO. In turn, tcsh decides to exit, instead of invoking the rest of the script. So if there is a problem, it is in tcsh. I'd recommend to rewrite this script in Python. Regards, Martin From donn at u.washington.edu Thu Jan 3 01:26:02 2002 From: donn at u.washington.edu (Donn Cave) Date: 3 Jan 2002 00:26:02 GMT Subject: Problem with any of os.system(), os.fork() & os.execp() and os.spawn() References: <3C332A5D.1A841338@videotron.ca> Message-ID: Quoth Eric Chamberland : | Al I want is to execute a simple tcsh script from a python process. But the problem is | that a put processes in the background in my tcsh shell (with &) and the execution of the | script is stopped _only_ when the console from which I started the python process has been | terminated. Good luck! Your problem here is really tcsh. The only advice I can give you is "never write scripts in csh", and that goes for tcsh as well. I went so far as to verify that it works for me on NetBSD if I use, for example, bash. I wouldn't waste a second trying to figure out what's wrong with tcsh or how it can be fixed, seriously. Donn Cave, donn at u.washington.edu From andy47 at halfcooked.com Thu Jan 3 06:41:01 2002 From: andy47 at halfcooked.com (Andy Todd) Date: 3 Jan 2002 05:41:01 GMT Subject: Problem with any of os.system(), os.fork() & os.execp() and os.spawn() References: <3C332A5D.1A841338@videotron.ca> Message-ID: Donn Cave wrote in : >Quoth Eric Chamberland : >| Al I want is to execute a simple tcsh script from a python process. >| But the problem is that a put processes in the background in my tcsh >| shell (with &) and the execution of the script is stopped _only_ when >| the console from which I started the python process has been >| terminated. > >Good luck! Your problem here is really tcsh. The only advice I can >give you is "never write scripts in csh", and that goes for tcsh as >well. > >I went so far as to verify that it works for me on NetBSD if I use, for >example, bash. I wouldn't waste a second trying to figure out what's >wrong with tcsh or how it can be fixed, seriously. > > Donn Cave, donn at u.washington.edu And if Donn and Martin haven't convinced you that writing scripts in any variant of the c shell is bad, have a look at; http://www.notelrac.com/essays.dir/softeng.dir/csh_harmful.html Regards, Andy -- Content free posts a speciality From donn at u.washington.edu Thu Jan 3 19:03:47 2002 From: donn at u.washington.edu (Donn Cave) Date: 3 Jan 2002 18:03:47 GMT Subject: Problem with any of os.system(), os.fork() & os.execp() and os.spawn() References: <3C332A5D.1A841338@videotron.ca> Message-ID: Quoth andy47 at halfcooked.com (Andy Todd): ... | And if Donn and Martin haven't convinced you that writing scripts in any | variant of the c shell is bad, have a look at; | | http://www.notelrac.com/essays.dir/softeng.dir/csh_harmful.html Bah, a half-hearted attempt. Someone who really cared could put together a much larger list of botches, including things that tcsh has to inherit. He mentions Plan 9 "rc", and it is indeed a fine shell language, pure, austere elegance. See http://www.star.le.ac.uk/~tjg/rc/ for the UNIX port, a tiny shell that you can't expect to get in any UNIX vendor's distribution, but it's portable - and what Python programmer expects the interpreter to already be there? Donn Cave, donn at u.washington.edu From paul at boddie.net Wed Jan 2 18:13:43 2002 From: paul at boddie.net (Paul Boddie) Date: 2 Jan 2002 11:13:43 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jan 2) Message-ID: <4855F26636D6E2A4.2D932D4A5DE8FFEC.A779FCEF4BC9CB3E@lp.airnews.net> After alphas, betas and release candidates, Python 2.2 "final" is available at long last. http://groups.google.com/groups?selm=mailman.1008968762.11408.clpa-moderators%40python.org Jython 2.1 was released recently, too. http://groups.google.com/groups?selm=mailman.1009809280.21269.python-list%40python.org One of the "special edition" versions of Python 2.2 is the one available for OS/2+EMX. http://groups.google.com/groups?selm=mailman.1009405444.3732.clpa-moderators%40python.org Binary packages do exist for less well-known operating systems - how about RISC OS? http://groups.google.com/groups?selm=mailman.1009109461.13764.clpa-moderators%40python.org Back in the "mainstream", MacPython 2.2 also quickly follows the main Python 2.2 release. http://groups.google.com/groups?selm=mailman.1009493112.645.clpa-moderators%40python.org And even the Sharp Zaurus gets Python 2.2c1, courtesy of Phil Thompson. http://groups.google.com/groups?selm=mailman.1008893605.27468.python-list%40python.org But will Python ever be available for Mono or .NET... or Parrot? Ron Stephens starts the new year with discussions on those themes. http://groups.google.com/groups?th=76afb2052769d3a7 http://groups.google.com/groups?th=f02f9f01e9d30d78 Stackless threads raise deep issues about coding style, concurrency mechanisms, and more. http://groups.google.com/groups?th=2442680516e6e52a http://groups.google.com/groups?th=597402650b88d48a Seemingly offering DTML-like templating, "Albatross is a small toolkit for developing highly stateful web applications." http://groups.google.com/groups?selm=mailman.1009405443.3730.clpa-moderators%40python.org How about client-side DHTML scripting in Python? A simple example is posted. http://groups.google.com/groups?th=c4ed88a3ad1fad59 Zope's documentation gets critical attention. How easy is it to persuade one's boss that Zope is just the thing? http://groups.google.com/groups?th=1221d8b190933982 Which of the Python books are most suitable for non-beginners? http://groups.google.com/groups?th=6d7debe411f805e2 It may excite more than a few people that Bruce Eckel's long-awaited work "Thinking in Python" is progressing. http://www.mindview.net/Books/TIPython It's a real shock when Python seems to have gone missing. In classic comp.lang.python style, the discussion wanders into areas such as line endings, distutils and Red Hat. http://groups.google.com/groups?th=b91141f106be4c9d Indeed, which version of Python is commonly in use, and what's going on with Python 1.5.2 on Red Hat Linux? http://groups.google.com/groups?th=c2ff830ed213cc1f Ciphon 0.3.5 is available - it's a CPAN-like package installer/downloader for Python. http://groups.google.com/groups?selm=slrna2n8hb.5kj.ssthapa%40hepcat.telocity.com XML Matters in Python, at least at IBM developerWorks. http://www-106.ibm.com/developerworks/xml/library/x-matters15.html?open&l=968,t=gr,p=rpc For all those game writing types, PyGame 1.3 is released to make their lives even easier. http://groups.google.com/groups?selm=3C219665.1050804%40shinners.org Michal Wallace invites comments on his Python billing system. http://www.sixthdev.com/wiki.cgi/duckbill Andreas Jung announces PyStemmer - a wrapper around the Snowball project. http://groups.google.com/groups?selm=mailman.1008886382.30332.clpa-moderators%40python.org And the greatest minds of Python put their heads together to work out how old they all are. http://groups.google.com/groups?th=13768ad1bd18542 ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Michael Hudson continued Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list once every other week, into July 2001. Any volunteers to re-start this valuable series? http://starship.python.net/crew/mwh/summaries/ http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ The Python Software Foundation has replaced the Python Consortium as an independent nexus of activity http://www.python.org/psf/ Cetus does much of the same http://www.cetus-links.de/oo_python.html Python FAQTS http://python.faqts.com/ The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://python.sourceforge.net/peps/pep-0042.html Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Tenth International Python Conference http://www.python10.org Archive probing tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://www.ddj.com/topics/pythonurl/ http://purl.org/thecliff/python/url.html (dormant) or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From mlh at vier.idi.ntnu.no Wed Jan 2 19:07:42 2002 From: mlh at vier.idi.ntnu.no (Magnus Lie Hetland) Date: Wed, 2 Jan 2002 18:07:42 +0000 (UTC) Subject: Hooray for PyXML 0.7 Message-ID: I just downloaded and installed PyXML 0.7 -- and it went very smoothly. Nice. Earlier I had to install lots of separate things (Expat, 4Suite) to get xslt support, for instance. I really like the fact that it's now all in one package. (Looking forward to getting xml.xslt and xml.xpath in the standard lib :) Thumbs up! -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.org From rcena at epcor.ca Wed Jan 2 19:16:24 2002 From: rcena at epcor.ca (Resty Cena) Date: 2 Jan 2002 10:16:24 -0800 Subject: Update Oreilly books? References: <47d2cd7c.0112171300.3c3483e9@posting.google.com> Message-ID: <458b194a.0201021016.2ce65219@posting.google.com> llewin at oreilly.com (Laura Lewin) wrote in message news:<47d2cd7c.0112171300.3c3483e9 at posting.google.com>... > Hi, > I wanted to write to respond to the comments on ORA books. First off, > thanks for writing about this. I take your comments very seriously, > and try to incorporate your suggestions whenever possible. > > We aren't updating Programming Python right away. The author is > currently working on the update to Learning Python. Please note that > when we do update Programming Python again, we will make sure to put > some language reference in the book, along with the tools and > applications. I understand that folks are missing this, and we will > meet the needs of readers. Please feel free to email me with any > other comments or suggestions. > > Laura > LLewin at oreilly.com > Hi, I'd prefer for the Pocket Reference to have an index. Typically I don't know which Table of Contents entry a topic is under. Also, tiny examples would be nice to have. For example, given the syntax: chdir(path), a beginner typing in chdir('c:\myprojects') would get an error. I know what I want to say, and I go to Pocket to find out how to say it. (I know this is encroaching on David Beazely's book.) rmc From LLewin at oreilly.com Wed Jan 2 22:29:46 2002 From: LLewin at oreilly.com (Laura Lewin) Date: 2 Jan 2002 13:29:46 -0800 Subject: Update Oreilly books? References: <47d2cd7c.0112171300.3c3483e9@posting.google.com> <458b194a.0201021016.2ce65219@posting.google.com> Message-ID: Hi, We'll take these comments into consideration for the pocket reference, but I think the kind of book you want is more than a pocket reference, really. You are describing a different kind of book, a more full-scale approach to a reference, something like what we plan to do in our forthcoming Python in a Nutshell (by Alex Martelli). I would look out for that book--we hope to get it published by Summer. Thanks for your suggestions! Laura LLewin at oreilly.com rcena at epcor.ca (Resty Cena) wrote in message > > > Hi, > I'd prefer for the Pocket Reference to have an index. Typically I > don't know which Table of Contents entry a topic is under. Also, tiny > examples would be nice to have. For example, given the syntax: > chdir(path), a beginner typing in chdir('c:\myprojects') would get an > error. I know what I want to say, and I go to Pocket to find out how > to say it. (I know this is encroaching on David Beazely's book.) > rmc From aleax at aleax.it Thu Jan 3 14:16:19 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 3 Jan 2002 14:16:19 +0100 Subject: Update Oreilly books? References: <47d2cd7c.0112171300.3c3483e9@posting.google.com> <458b194a.0201021016.2ce65219@posting.google.com> Message-ID: "Laura Lewin" wrote in message news:a05ac97c.0201021329.7e5983e2 at posting.google.com... ... > full-scale approach to a reference, something like what we plan to do > in our forthcoming Python in a Nutshell (by Alex Martelli). I would > look out for that book--we hope to get it published by Summer. I hear you loud and clear!!! Just a couple days more unwinding on c.l.p, then I'll be back to Nutshell work, I promise!!! Alex From jae at jerhard.org Tue Jan 15 03:10:10 2002 From: jae at jerhard.org (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Tue, 15 Jan 2002 03:10:10 +0100 Subject: Update Oreilly books? In-Reply-To: (aleax@aleax.it) References: <47d2cd7c.0112171300.3c3483e9@posting.google.com> <458b194a.0201021016.2ce65219@posting.google.com> Message-ID: >>>>> "Alex" == Alex Martelli writes: Alex> "Laura Lewin" wrote in message Alex> news:a05ac97c.0201021329.7e5983e2 at posting.google.com... Alex> ... >> full-scale approach to a reference, something like what we plan >> to do in our forthcoming Python in a Nutshell (by Alex >> Martelli). I would look out for that book--we hope to get it >> published by Summer. Alex> I hear you loud and clear!!! Just a couple days more Alex> unwinding on c.l.p, then I'll be back to Nutshell work, I Alex> promise!!! Hmm, Alex and "In a Nutshell"... why does that strike me as an odd match? (I won't say mismatch, mind you. ;-) Bye, J -- J?rgen A. Erhard (juergen.erhard at gmx.net) My WebHome: http://jerhard.org The 80-20 rule for an NT project: 20% time for real coding -- 80% time for working around NT bugs -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From aleax at aleax.it Tue Jan 15 09:31:34 2002 From: aleax at aleax.it (Alex Martelli) Date: Tue, 15 Jan 2002 09:31:34 +0100 Subject: Update Oreilly books? References: <47d2cd7c.0112171300.3c3483e9@posting.google.com> <458b194a.0201021016.2ce65219@posting.google.com> Message-ID: "J?rgen A. Erhard" wrote in message news:mailman.1011060693.24789.python-list at python.org... > Hmm, Alex and "In a Nutshell"... why does that strike me as > an odd match? (I won't say mismatch, mind you. ;-) I think it's because you're not considering the ample variety of nuts -- http://www.marx-brothers.org/watching/fcocoanu.htm . Note Groucho's character's name (Italian "Martelli"=="hammers"). Alex From pythonnet at hotmail.com Wed Jan 2 20:00:27 2002 From: pythonnet at hotmail.com (Andrew Nguyen) Date: 2 Jan 2002 11:00:27 -0800 Subject: Classes & Instances Message-ID: <40dbad98.0201021100.2731aecd@posting.google.com> We all know that you can't use classes without instances. Now, for the problem. How do I get a class, so that when an instance is made of it, the class records the instance's name to a list. e.g, class a: pass f = a ---- how do I get f into a list. And remember, my goal is _flexability_ so: class a: pass f = a foolist = ['f'] Will NOT work for my goal, but, if let's say there is a function, 'TakeInstanceName()': class a: foolist[:-1]=TakeInstanceName()#This function takes the Instance name # whenever the class is refered to f = a #Now after that, foolist should have ['f'], but, my question is, what IS the #function that would take the TakeInstanceName()'s place? ----- From marklists at mceahern.com Wed Jan 2 20:23:07 2002 From: marklists at mceahern.com (Mark McEahern) Date: Wed, 2 Jan 2002 11:23:07 -0800 Subject: Classes & Instances In-Reply-To: <40dbad98.0201021100.2731aecd@posting.google.com> Message-ID: class a: pass f = a() for k in locals().keys(): if isinstance(locals()[k], a): print k This probably isn't what you want. I can't help but wonder what problem you're trying to solve? Maybe this is an area where metaclasses would help? // mark From marklists at mceahern.com Wed Jan 2 20:35:29 2002 From: marklists at mceahern.com (Mark McEahern) Date: Wed, 2 Jan 2002 11:35:29 -0800 Subject: Classes & Instances In-Reply-To: Message-ID: original post essentially asked: how do I get an instance's name? pseudocode: class A: def instanceName(self):pass f = a() print f.instanceName # should print "f" a tangential suggestion might be to look into implementing one of the creational patterns from GoF in Python to control the creation of class instances, thereby allowing you to keep track of them. // mark From tim.hochberg at ieee.org Wed Jan 2 20:26:03 2002 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 02 Jan 2002 19:26:03 GMT Subject: Classes & Instances References: <40dbad98.0201021100.2731aecd@posting.google.com> Message-ID: "Andrew Nguyen" wrote in message news:40dbad98.0201021100.2731aecd at posting.google.com... > We all know that you can't use classes without instances. > > Now, for the problem. How do I get a class, so that when an instance > is made of it, the class records the instance's name to a list. > > e.g, > class a: > pass > > f = a I assume you means "f = a()" here. If so, you probably want something like: >>> class A: ... instances = [] ... def __init__(self, name): ... self.instances.append(self) ... self.name = name ... def __repr__(self): ... return '' % self.name # Name is only around so this prints something legible ... >>> f = A('spam') >>> g = A('eggs') >>> h = A('more spam') >>> A.instances [, , ] You don't have to make instances a part of the class A, but that's what I'd do. -tim > ---- > > how do I get f into a list. And remember, my goal is _flexability_ so: > > class a: > pass > > f = a > > foolist = ['f'] > > Will NOT work for my goal, but, if let's say there is a function, > 'TakeInstanceName()': > > class a: > foolist[:-1]=TakeInstanceName()#This function takes the Instance > name # whenever the class is refered to > > f = a > > #Now after that, foolist should have ['f'], but, my question is, what > IS the #function that would take the TakeInstanceName()'s place? > ----- From marklists at mceahern.com Wed Jan 2 20:37:35 2002 From: marklists at mceahern.com (Mark McEahern) Date: Wed, 2 Jan 2002 11:37:35 -0800 Subject: Classes & Instances In-Reply-To: Message-ID: Tim Hochberg: [snip] > ... def __init__(self, name): original poster may complain that this requires the following inelegance: f = a('f') // mark From romany at actimize.com Wed Jan 2 20:42:20 2002 From: romany at actimize.com (Roman Yakovenko) Date: Wed, 2 Jan 2002 21:42:20 +0200 Subject: Classes & Instances Message-ID: <7647A9F4B298E74DB6793865DA67285004ACA2@exchange.adrembi.com> May be this will be helpfull for you >>> class Obj: def Class(self): return Obj >>> f = Obj() >>> f_class = f.Class() >>> f_class -----Original Message----- From: Andrew Nguyen [mailto:pythonnet at hotmail.com] Sent: Wednesday, January 02, 2002 9:00 PM To: python-list at python.org Subject: Classes & Instances We all know that you can't use classes without instances. Now, for the problem. How do I get a class, so that when an instance is made of it, the class records the instance's name to a list. e.g, class a: pass f = a ---- how do I get f into a list. And remember, my goal is _flexability_ so: class a: pass f = a foolist = ['f'] Will NOT work for my goal, but, if let's say there is a function, 'TakeInstanceName()': class a: foolist[:-1]=TakeInstanceName()#This function takes the Instance name # whenever the class is refered to f = a #Now after that, foolist should have ['f'], but, my question is, what IS the #function that would take the TakeInstanceName()'s place? ----- -- http://mail.python.org/mailman/listinfo/python-list From wurmy at earthlink.net Wed Jan 2 21:05:45 2002 From: wurmy at earthlink.net (Hans Nowak) Date: Wed, 02 Jan 2002 20:05:45 GMT Subject: Classes & Instances References: <40dbad98.0201021100.2731aecd@posting.google.com> Message-ID: <3C3367CA.EDB7C4E0@earthlink.net> Andrew Nguyen wrote: > We all know that you can't use classes without instances. Sure you can: class Options: readonly = 0 verbose = 0 if something: Options.verbose = 1 Useful if you want a pseudo-singleton struct. :-) > Now, for the problem. How do I get a class, so that when an instance > is made of it, the class records the instance's name to a list. > > e.g, > class a: > pass > > f = a Note that this does not create an instance of a. The correct syntax is: f = a() > how do I get f into a list. Instances, unlike classes, do not have an inherent name. Code like x = y = z = a() creates three equally valid names for the same instance of a. None of these is the "real" name of the instance. The following code uses a class that has a list of names, shared between instances. You'll need to explicitly name the class, though, for reasons mentioned above (the name of an instance is whatever name(s) you define for it in the namespace). So you'll need to do something like foo = B(1, "foo") (The value, 1, isn't necessary, but I added it to the class to make it a bit more real-life. :-) #---begin--- class B: names = [] def __init__(self, value, name): self.value = value self.name = name B.names.append(name) def __del__(self): B.names.remove(self.name) foo = B(1, "foo") bar = B(2, "bar") baz = B(3, "baz") print B.names del foo print B.names #---end-- HTH, --Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA==\n') # decode for email address ;-) Site:: http://www.awaretek.com/nowak/ From tjreedy at home.com Wed Jan 2 21:50:57 2002 From: tjreedy at home.com (Terry Reedy) Date: Wed, 02 Jan 2002 20:50:57 GMT Subject: Classes & Instances References: <40dbad98.0201021100.2731aecd@posting.google.com> Message-ID: > Now, for the problem. How do I get a class, so that when an instance > is made of it, the class records the instance's name to a list. Python objects do not have 'a name'. Rather, 0 to n names can be bound to any object. Functions, classes, and modules have definition_names which may or may not correspond to any names currently bound to the object. As others have pointed out, if you want instances to also have a definition name, you will have to pass in into __init__ and set it explicitly. Terry J. Reedy From aleax at aleax.it Thu Jan 3 14:37:52 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 3 Jan 2002 14:37:52 +0100 Subject: Classes & Instances References: Message-ID: "Mark McEahern" wrote in message news:mailman.1010000166.31356.python-list at python.org... > original post essentially asked: > > how do I get an instance's name? > > pseudocode: > > class A: > def instanceName(self):pass > > f = a() > > print f.instanceName # should print "f" > > a tangential suggestion might be to look into implementing one of the > creational patterns from GoF in Python to control the creation of class > instances, thereby allowing you to keep track of them. You need no such complication to "keep track of" a class's instances -- it's easy and idiomatic to do it e.g. by appending a reference (I'd suggest a weakref) to a per-class list in the instance's __init__, for example. This has nothing to do with *NAMES*, and the fact that the original poster's request, properly translated into "how do I get the name to which, in the future, the instance that is being created right now will be bound" has no Python solution. First of all, Guido would have to insert in Python his beloved time machine, because, as the instance is being created, no name yet is bound to it. Even that would not make things SIMPLE -- what "name" should be returned in the case of somelistorother.append(a()) or x=y=z=t=a() or f(a(),a(),a(),a()) or...?! The only solution is apparently an exhaustive search, AFTER the binding has taken place, into all possile "names" that MIGHT now be bound to the generated instance (some careful definition will be needed regarding attributes, since of course after x.y = a() there's no guarantee whatsoever that x.y is bound to the same object... maybe x.ZZZ might now be, or ...). It's not worth it. Maybe in some kind of debugging mode for a development-environment, but I have my doubts even then. Alex From cesar.douady at asim.lip6.fr Thu Jan 10 15:34:34 2002 From: cesar.douady at asim.lip6.fr (Cesar Douady) Date: Thu, 10 Jan 2002 15:34:34 +0100 Subject: Classes & Instances References: Message-ID: <20020110.153433.1065103348.21247@asim.lip6.fr> I actually have the same problem in my application (I am actually trying to represent some various pieces of information with a Python program). My conclusion is that the right way to do it is to overload the globals() or locals() dictionary, such as : class NamingDict(dict): def __setitem__(self,key,val): try: val.name=key except: pass dict.__setitem__(self,key,val) class Foo: pass d=NamingDict({"a":Foo()}) exec "b=a;print 'a has name :','name' in dir(a)" in d,None but it prints : "a has name : 0" instead of "a has name : 1" I cannot retrieve the reference, but I understood that this feature was considered normal by Guido, although he has optimization problems for local accesses. The current situation is that this works neither with locals nor globals, and the reason is that the Python interpreter directly calls the dict method, even if the globals() dict has overridden methods (for locals, it is even more optimized). I have a very simple patch to the interpreter to make things work with globals (no measurable performance impact) and the situation is significantly more complex for locals but I think I can come to an implementation in which performance is not degraded in the normal case (i.e. when locals() is a plain dict) and in which the full semantic of exec and eval is ensured. Because I think that people needing this feature are the exceptions more than the rule, I do not expect anyone to actually update the interpreter. My question now is : how do I propose a patched interpreter so that it becomes (if accepted, of course) integrated in a future release (note that this is more a bug fix than a new feature) ? Note also that you cannot set the local dictionary of a function call through exec. For example : def foo(): try: print "x = %s"%x except: print "x is not set" x=0 # make x a local variable exec foo.func_code in {"x":1} # set both locals and globals outputs : "x is not set" instead of "x = 1" This also should be fixed and I am prepared to do the work as well. In article , "Alex Martelli" wrote: > "Mark McEahern" wrote in message > news:mailman.1010000166.31356.python-list at python.org... >> original post essentially asked: >> >> how do I get an instance's name? >> >> pseudocode: >> >> class A: >> def instanceName(self):pass >> >> f = a() >> >> print f.instanceName # should print "f" >> >> a tangential suggestion might be to look into implementing one of the >> creational patterns from GoF in Python to control the creation of class >> instances, thereby allowing you to keep track of them. > > You need no such complication to "keep track of" a class's instances -- > it's easy and idiomatic to do it e.g. by appending a reference (I'd > suggest a weakref) to a per-class list in the instance's __init__, for > example. > > This has nothing to do with *NAMES*, and the fact that the original > poster's request, properly translated into "how do I get the name to > which, in the future, the instance that is being created right now will > be bound" has no Python solution. First of all, Guido would have to > insert in Python his beloved time machine, because, as the instance is > being created, no name yet is bound to it. Even that would not make > things SIMPLE -- what "name" should be returned in the case of > somelistorother.append(a()) > or > x=y=z=t=a() > or > f(a(),a(),a(),a()) > or...?! > > The only solution is apparently an exhaustive search, AFTER the binding > has taken place, into all possile "names" that MIGHT now be bound to the > generated instance (some careful definition will be needed regarding > attributes, since of course after > x.y = a() > there's no guarantee whatsoever that x.y is bound to the same object... > maybe x.ZZZ might now be, or ...). > > It's not worth it. Maybe in some kind of debugging mode for a > development-environment, but I have my doubts even then. > > > Alex > > > From aleax at aleax.it Thu Jan 10 17:34:08 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 10 Jan 2002 17:34:08 +0100 Subject: Classes & Instances References: <20020110.153433.1065103348.21247@asim.lip6.fr> Message-ID: "Cesar Douady" wrote in message news:20020110.153433.1065103348.21247 at asim.lip6.fr... ... > My question now is : how do I propose a patched interpreter so that it > becomes (if accepted, of course) integrated in a future release (note that > this is more a bug fix than a new feature) ? You can submit a patch (a context-diff) to python.sourceforge.net. Alex From sjmachin at lexicon.net Fri Jan 11 11:38:16 2002 From: sjmachin at lexicon.net (John Machin) Date: 11 Jan 2002 02:38:16 -0800 Subject: Classes & Instances References: Message-ID: "Roman Yakovenko" wrote in message news:... > May be this will be helpfull for you > >>> class Obj: > def Class(self): > return Obj > > > >>> f = Obj() > >>> f_class = f.Class() > >>> f_class > What's wrong with >>> f_class = f.__class__ ??? From mlh at vier.idi.ntnu.no Wed Jan 2 20:32:13 2002 From: mlh at vier.idi.ntnu.no (Magnus Lie Hetland) Date: Wed, 2 Jan 2002 19:32:13 +0000 (UTC) Subject: Deltas with difflib? Message-ID: Is it possible (in any easy way) to use difflib to create deltas (which don't include the entire contents of both the compared files/texts)? I realise one can strip off all lines beginning with two spaces or something, but how about using that delta to restore one file based on the other? I guess one could insert line counts etc. The question is basically if anyone has done this sort of thing, or if something like it exists. (Or if I just missed some functionality :) As is probably obvious, I'm thinking of using this in a simple custom version-control system. -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.org From tim.one at home.com Thu Jan 3 03:51:20 2002 From: tim.one at home.com (Tim Peters) Date: Wed, 2 Jan 2002 21:51:20 -0500 Subject: Deltas with difflib? In-Reply-To: Message-ID: [Magnus Lie Hetland] > Is it possible (in any easy way) to use difflib to create deltas > (which don't include the entire contents of both the compared > files/texts)? Read the docs for difflib's SequenceMatcher class, in particular the get_opcodes() method. This gives you a compact accounting of how to turn one sequence into the other. If you don't care about matching blocks, ignore the "equal" tuples; etc. From Aristotle_00 at yahoo.com Wed Jan 2 21:24:53 2002 From: Aristotle_00 at yahoo.com (Mark) Date: 2 Jan 2002 12:24:53 -0800 Subject: Behavior of os.system() with redirection Message-ID: <12e3779b.0201021224.143b9849@posting.google.com> Well, I'm scratching my head over the following: #!/usr/bin/python import os print "hi" os.system("ls -l > results") os.system("cat results") Now, if I run the program, I get the following: [mfenner at bacon tmp]$ ../calltest.py hi total 0 -rw-rw-r-- 1 mfenner mfenner 0 Jan 2 15:21 results [mfenner at bacon tmp]$ which is all well and good. However, if I redirect the output: [mfenner at bacon tmp]$ ../calltest.py > out and THEN look at the results: [mfenner at bacon tmp]$ cat out total 0 -rw-rw-r-- 1 mfenner mfenner 0 Jan 2 15:21 out -rw-rw-r-- 1 mfenner mfenner 0 Jan 2 15:21 results hi I get something quite a bit different. Now, I'm not concerned with the extra file ("out") since that is an artifact of the redirection. However, I am concerned about the "hi" being AFTER the "ls" output in one case and BEFORE it in the other. What's going on here? How can I get a uniform ("hi" always first) behavior? Regards, Mark From martin at v.loewis.de Wed Jan 2 23:06:14 2002 From: martin at v.loewis.de (Martin v. Loewis) Date: 02 Jan 2002 23:06:14 +0100 Subject: Behavior of os.system() with redirection References: <12e3779b.0201021224.143b9849@posting.google.com> Message-ID: Aristotle_00 at yahoo.com (Mark) writes: > What's going on here? sys.stdout is buffered. The subprocess completes first, and writes to the file. Then python completes, and writes the sys.stdout buffer to the file. > How can I get a uniform ("hi" always first) behavior? You can call sys.stdout.flush. Alternatively, you can invoke python with -u, or set the PYTHONUNBUFFERED environment variable. However, I would not recommend to invoke /bin/ls through os.system. Instead, use os.listdir. Regards, Martin From Aristotle_00 at yahoo.com Thu Jan 3 18:20:12 2002 From: Aristotle_00 at yahoo.com (Mark) Date: 3 Jan 2002 09:20:12 -0800 Subject: Behavior of os.system() with redirection References: <12e3779b.0201021224.143b9849@posting.google.com> Message-ID: <12e3779b.0201030920.7be1065a@posting.google.com> > However, I would not recommend to invoke /bin/ls through > os.system. Instead, use os.listdir. Thanks for your response. In reality, I'm using a different program (another script) written in R. Since I haven't looked into higher level interfaces for Python/R, I'm just using the system call. This was just a toy example to prevent posting 100s of lines of codes when that had the essence of the problem. Regards, Mark From mcherm at destiny.com Wed Jan 2 22:07:26 2002 From: mcherm at destiny.com (Michael Chermside) Date: Wed, 02 Jan 2002 16:07:26 -0500 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) Message-ID: <3C33768E.9000805@destiny.com> > > > btw- what do "big applications written by people with some smarts" > do when this global_emergency_ballast block of memory happens > to be the one that got corrupted? Let me take a wild guess. > They get an access violation when they try to print a message > and crap out. :-) > I thought we were talking about what to do when we run out of memory, not when we corrupt it. When an unknown block of memory has been corrupted there really isn't much of ANYTHING we can do about it safely... whatever code you intend to run to fix it might be stored in the memory that was corrupted. Big applications written by people with some smarts probably don't corrupt memory... hey, they may even be written in a language the doesn't allow arbitrary memory to be corrupted. But they still have to deal with situations like running out of resources. -- Michael Chermside From aleax at aleax.it Thu Jan 3 14:25:43 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 3 Jan 2002 14:25:43 +0100 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: Message-ID: "Michael Chermside" wrote in message news:mailman.1010005623.16986.python-list at python.org... ... > > btw- what do "big applications written by people with some smarts" > > do when this global_emergency_ballast block of memory happens > > to be the one that got corrupted? Let me take a wild guess. ... > Big applications written by people with some smarts probably don't > corrupt memory... hey, they may even be written in href="python.org">a language the doesn't allow arbitrary memory to > be corrupted. But they still have to deal with situations like running > out of resources. Unfortunately, disaster cases such as corrupted memory DO happen, and, in some kinds of applications, need to be dealt with (by a graceful shutdown with good error reporting rather than a crash). For example, bugs in operating systems' virtual memory subsystems are NOT unheard of. There's nothing a language running on top of such an OS can really do to stop the OS from going crazy under it. Less dramatically, any major application will have (or, similar thing, run on top of) some components and subsystems that are coded in assembler, C, or other low-level language, for speed and machine-access. The OS is just a special case of that and most often you need other libraries as well. So, while I WAS indeed talking about the far more common case of resource exhaustion, the corruption case also needs to be dealt with. In most cases, I've found that a separate "watchdog process" that watches over the application process[es] is the best architecture to deal with memory-corruption and similar problems. Not totally foolproof, if the OS starts dirtying memory at random, of course, but then, "ad impossibilia nemo tenetur". The point is that the amount of isolation that separate processes provide is a good thing to have when you suspect one process may be destroying its own environment. The watchdog process can likely still be intact in this case, and proceed to shutdown the errant application process while logging potentially-useful data about the error. That's not unrelated to "preallocate a tad of extra resources" -- here, the "extra resource" is a process and some memory &c for it (the errant process might not be in a condition to fork a NEW process for error-reporting at the time of trouble -- better do it earlier). But the extras need to be kept separate, "arm's length", from the main operating capital, lest they too be consumed in the case of a crash. Any parallel with prudent financial management and supervision is entirely intended; Enron doceat...!-) Alex From mkelly2002NOSPAM at earthlink.net Thu Jan 3 19:03:16 2002 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Thu, 03 Jan 2002 18:03:16 GMT Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: Message-ID: On Thu, 3 Jan 2002 14:25:43 +0100, "Alex Martelli" wrote: >For example, bugs in operating systems' virtual memory subsystems >are NOT unheard of. There's nothing a language running on top of >such an OS can really do to stop the OS from going crazy under it. Also the fact that a gazillion PCs come with the equivalent of Windows9x preinstalled means that lots of stuff will be running on that platform that shouldn't. Anyway, I *do* think the memory reserve thing is worth doing. Don't get me wrong. I just think this article points out some interesting things to take into consideration. Anyway, any in depth discussion of the issue, esp. on Windows will probably point out many of the same "gotcha's" this fellow did. Sorry but I don't get a hit on web search or I'd post a URL for those interested. Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From mcherm at destiny.com Thu Jan 3 15:25:48 2002 From: mcherm at destiny.com (Michael Chermside) Date: Thu, 03 Jan 2002 09:25:48 -0500 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) Message-ID: <3C3469EC.8060202@destiny.com> > Unfortunately, disaster cases such as corrupted memory DO happen, > and, in some kinds of applications, need to be dealt with (by a > graceful shutdown with good error reporting rather than a crash). [...] > So, while I WAS indeed talking about the far more common case of > resource exhaustion, the corruption case also needs to be dealt > with. [...] > In most cases, I've found that a separate "watchdog process" that > watches over the application process[es] is the best architecture > to deal with memory-corruption and similar problems. [...] > > That's not unrelated to "preallocate a tad of extra resources" -- > here, the "extra resource" is a process and some memory &c for it > (the errant process might not be in a condition to fork a NEW > process for error-reporting at the time of trouble -- better do > it earlier). But the extras need to be kept separate, "arm's > length", from the main operating capital, lest they too be > consumed in the case of a crash. Any parallel with prudent > financial management and supervision is entirely intended; Enron > doceat...!-) > > > Alex Thanks, Alex... very nice way to think about it. -- Michael Chermside From gleki at gol.ge Wed Jan 2 22:13:44 2002 From: gleki at gol.ge (Giorgi Lekishvili) Date: Wed, 02 Jan 2002 13:13:44 -0800 Subject: Modul gotchas:) Message-ID: <3C337808.ECCE968E@gol.ge> Hi all! happy new year, first of all!!! My question is simple, yet I missed the right answer, although have lots of books on Python:( Suppose, one has a module, which defines some set of functions. The question: How can one get the names of all these functions as list entries? E.g., all_func=[] import myModule all_func=myModule.functions() of course, this will not work. What is to be done? Some special functions are to be written or, is there a built-in tool? thanks a lot! Grtz, Giorgi From aleax at aleax.it Wed Jan 2 13:31:24 2002 From: aleax at aleax.it (Alex Martelli) Date: Wed, 2 Jan 2002 13:31:24 +0100 Subject: Modul gotchas:) References: <3C337808.ECCE968E@gol.ge> Message-ID: "Giorgi Lekishvili" wrote in message news:3C337808.ECCE968E at gol.ge... ... > Suppose, one has a module, which defines some set of functions. > How can one get the names of all these functions as list entries? > all_func=[] You don't need to bind name all_func to anything: it gets rebound two statements later, so this binding has no effect at all. > import myModule > all_func=myModule.functions() > > of course, this will not work. No, but, after the import, you could for example do: all_func = [name for name in dir(myModule) if callable(getattr(myModule,name))] this isn't QUITE what you asked since it gives you the name of every CALLABLE object that is a module attribute: this includes functions, builtin-functions, and classes too (and potentially more things yet, such as instances of classes exposing a __call__ special method that the module is trying to "masquerade", aka "pass off as", functions:-)]. If you do need to check for FUNCTIONS specifically, and rule out every other callable object, you can to that, of course: import types import myModule all_func = [name for name in dir(myModule) if type(getattr(myModule,name)) is types.FunctionType] However, you're "normally" quite OK with accepting "stuff masquerading as functions" as equivalent to functions. The test for 'callable', while maybe a bit weak, is more likely closer to what you really need, than the test for type-identity with 'functions'. Still, it's up to you. > What is to be done? Some special functions are to be written or, is > there a built-in tool? There are several built-in functions: dir(obj) get all attributes name directly defined in obj getattr(obj, name) get attribute value given attribute name callable(obj) check if an object can be called as a function type(obj) get the typeobject for an object and language 'tools' such as list comprehensions, to put together lists. If you do this often, you may indeed want to write a "special function" of your own that puts together a few of these built-in tools to give you the overall functionality that you desire. Alex From syt at gemini.logilab.fr Wed Jan 2 13:55:24 2002 From: syt at gemini.logilab.fr (Sylvain Thenault) Date: Wed, 2 Jan 2002 12:55:24 +0000 (UTC) Subject: Modul gotchas:) References: <3C337808.ECCE968E@gol.ge> Message-ID: On Wed, 02 Jan 2002 13:13:44 -0800, Giorgi Lekishvili wrote: >Hi all! > >happy new year, first of all!!! > >My question is simple, yet I missed the right answer, although have lots >of books on Python:( > >Suppose, one has a module, which defines some set of functions. > >The question: > >How can one get the names of all these functions as list entries? > >E.g., > >all_func=[] > >import myModule > >all_func=myModule.functions() > >of course, this will not work. > >What is to be done? Some special functions are to be written or, is >there a built-in tool? you can use the built-in "dir" function to do things like that. The following code filters functions from the "dir" output: import myModule for f in dir(myModule): if callable(getattr(myModule, d)): print d cheers -- Sylvain Thenault LOGILAB http://www.logilab.org From gleki at gol.ge Wed Jan 2 23:20:40 2002 From: gleki at gol.ge (Giorgi Lekishvili) Date: Wed, 02 Jan 2002 14:20:40 -0800 Subject: Modul gotchas:) References: <3C337808.ECCE968E@gol.ge> Message-ID: <3C3387B8.74D0AE47@gol.ge> Thanx! Meanwhile, I found another solution: myModule.__dict__.keys() I guess it will produce the same result? Sylvain Thenault wrote: > On Wed, 02 Jan 2002 13:13:44 -0800, Giorgi Lekishvili wrote: > >Hi all! > > > >happy new year, first of all!!! > > > >My question is simple, yet I missed the right answer, although have lots > >of books on Python:( > > > >Suppose, one has a module, which defines some set of functions. > > > >The question: > > > >How can one get the names of all these functions as list entries? > > > >E.g., > > > >all_func=[] > > > >import myModule > > > >all_func=myModule.functions() > > > >of course, this will not work. > > > >What is to be done? Some special functions are to be written or, is > >there a built-in tool? > > you can use the built-in "dir" function to do things like that. > The following code filters functions from the "dir" output: > > import myModule > for f in dir(myModule): > if callable(getattr(myModule, d)): > print d > > cheers > > -- > Sylvain Thenault > > LOGILAB http://www.logilab.org From ehoute at zeelandnet+nl Wed Jan 2 14:22:31 2002 From: ehoute at zeelandnet+nl (Ewald) Date: 02 Jan 2002 13:22:31 GMT Subject: Modul gotchas:) References: <3C337808.ECCE968E@gol.ge> Message-ID: <3c330997$0$5765@news2.zeelandnet.nl> Giorgi Lekishvili wrote in news:3C337808.ECCE968E at gol.ge: > Hi all! > > happy new year, first of all!!! > > My question is simple, yet I missed the right answer, although have lots > of books on Python:( > > Suppose, one has a module, which defines some set of functions. > > The question: > > How can one get the names of all these functions as list entries? > > [snip] Chapter 2 of Dive Into Python show how this can be done (a little edited): def methodlist(object): return [method for method in dir(object) if callable(getattr (object, method))] See http://www.diveintopython.org/apihelper_divein.html From gleki at gol.ge Wed Jan 2 23:39:31 2002 From: gleki at gol.ge (Giorgi Lekishvili) Date: Wed, 02 Jan 2002 14:39:31 -0800 Subject: Modul gotchas:) References: <3C337808.ECCE968E@gol.ge> <3c330997$0$5765@news2.zeelandnet.nl> Message-ID: <3C338C23.68EA0294@gol.ge> Thanx! Just what I needed! Ewald wrote: > Giorgi Lekishvili wrote in news:3C337808.ECCE968E at gol.ge: > > > Hi all! > > > > happy new year, first of all!!! > > > > My question is simple, yet I missed the right answer, although have lots > > of books on Python:( > > > > Suppose, one has a module, which defines some set of functions. > > > > The question: > > > > How can one get the names of all these functions as list entries? > > > > [snip] > > Chapter 2 of Dive Into Python show how this can be done (a little edited): > > def methodlist(object): > return [method for method in dir(object) if callable(getattr > (object, method))] > > See http://www.diveintopython.org/apihelper_divein.html From gleki at gol.ge Wed Jan 2 23:35:32 2002 From: gleki at gol.ge (Giorgi Lekishvili) Date: Wed, 02 Jan 2002 14:35:32 -0800 Subject: Modul gotchas:) References: <3C337808.ECCE968E@gol.ge> Message-ID: <3C338B34.774DEF36@gol.ge> Thanx for the hint! However, when I applied this to the 'math' module, it yielded []... I must have missed something. If I have all_func list of the function names, i.e., strings, not pointers, I can do something like this: class someClass: .... def getVector(self, names): vector=[] import myModule all_func=myModule.some_way_to_get_the_names() for name in names: if name in all_func: f=eval('myModule.'+name) vector.append(f(self.somthing)) return vector the names must be the list of strings... Wolfgang Strobl wrote: > Giorgi Lekishvili schrieb am Wed, 02 Jan 2002 13:13:44 > -0800: > > >How can one get the names of all these functions as list entries? > > > >E.g., > > > >all_func=[] > > > >import myModule > > > >all_func=myModule.functions() > > > >of course, this will not work. > > > >What is to be done? Some special functions are to be written or, is > >there a built-in tool? > > all_func=filter(lambda x:type(myModule.__dict__[x])==\ > type(lambda x:x),myModule.__dict__.keys()) > > Now the question is: what are you going to do with that list? > > -- > #define print void main(){ printf( > print "signature under construction" > #define pass );} > pass From gleki at gol.ge Thu Jan 3 00:08:29 2002 From: gleki at gol.ge (Giorgi Lekishvili) Date: Wed, 02 Jan 2002 15:08:29 -0800 Subject: Modul gotchas:) References: <3C337808.ECCE968E@gol.ge> <3C338B34.774DEF36@gol.ge> <9p363uo3ckgd32k2nnsisdi086r56t8ffq@4ax.com> Message-ID: <3C3392ED.A69F667C@gol.ge> Right! thank you for the help! Wolfgang Strobl wrote: > Giorgi Lekishvili schrieb am Wed, 02 Jan 2002 14:35:32 > -0800: > > >However, when I applied this to the 'math' module, it yielded []... > >I must have missed something. > > Well, it depends on how you define "function". Are you perhaps looking > for builtin functions too? What about callable items? > > > > >If I have all_func list of the function names, i.e., strings, not > >pointers, I can do something like this: > > > >class someClass: > > .... > > > > def getVector(self, names): > > vector=[] > > import myModule > > all_func=myModule.some_way_to_get_the_names() > > for name in names: > > if name in all_func: > > f=eval('myModule.'+name) > > vector.append(f(self.somthing)) > > return vector > > Why don't you just use a list of functions and "apply"? > > -- > #define print void main(){ printf( > print "signature under construction" > #define pass );} > pass From gleki at gol.ge Thu Jan 3 00:09:00 2002 From: gleki at gol.ge (Giorgi Lekishvili) Date: Wed, 02 Jan 2002 15:09:00 -0800 Subject: Modul gotchas:) References: <3C337808.ECCE968E@gol.ge> Message-ID: <3C33930C.4CC90482@gol.ge> Thank you all for the help!!! Greetings, Giorgi Giorgi Lekishvili wrote: > Hi all! > > happy new year, first of all!!! > > My question is simple, yet I missed the right answer, although have lots > of books on Python:( > > Suppose, one has a module, which defines some set of functions. > > The question: > > How can one get the names of all these functions as list entries? > > E.g., > > all_func=[] > > import myModule > > all_func=myModule.functions() > > of course, this will not work. > > What is to be done? Some special functions are to be written or, is > there a built-in tool? > > thanks a lot! > > Grtz, > Giorgi From joshm at taconic.net Wed Jan 2 22:19:36 2002 From: joshm at taconic.net (Joshua Muskovitz) Date: Wed, 2 Jan 2002 16:19:36 -0500 Subject: Anyone looking to hire a Python/C++ developer? Message-ID: <3c337779_4@corp.newsgroups.com> Hey all, Are you looking to hire a competent developer? I'm actively seeking employment. I have 15+ years of commercial application development experience, and would be happy to send you a resume if you are looking to hire. Requests to joshm at taconic dot net. Hoping-to-kick-off-the-new-year-with-a-new-job-ly yrs, -- josh -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From thorj at east.no Thu Jan 3 02:21:55 2002 From: thorj at east.no (Thor Arne Johansen) Date: Thu, 3 Jan 2002 02:21:55 +0100 Subject: Anyone looking to hire a Python/C++ developer? References: <3c337779_4@corp.newsgroups.com> Message-ID: "Joshua Muskovitz" skrev i melding news:3c337779_4 at corp.newsgroups.com... > Hey all, > > Are you looking to hire a competent developer? Yes desperately :-) The question is: Will you consider relocating to Norway :) -- Thor A. Johansen Ibas AS http://www.ibas.com From jlh at home.com Thu Jan 3 02:57:19 2002 From: jlh at home.com (Jeff Hinrichs) Date: Wed, 2 Jan 2002 19:57:19 -0600 Subject: Anyone looking to hire a Python/C++ developer? References: <3c337779_4@corp.newsgroups.com> Message-ID: <0b4901c193f9$fa34d230$6702a8c0@gato> What are the taxes like? -jeff ----- Original Message ----- From: "Thor Arne Johansen" Newsgroups: comp.lang.python To: Sent: Wednesday, January 02, 2002 7:21 PM Subject: Re: Anyone looking to hire a Python/C++ developer? > > "Joshua Muskovitz" skrev i melding > news:3c337779_4 at corp.newsgroups.com... > > Hey all, > > > > Are you looking to hire a competent developer? > > Yes desperately :-) > > The question is: Will you consider relocating to Norway :) > > -- > Thor A. Johansen > Ibas AS > http://www.ibas.com > > > > > -- > http://mail.python.org/mailman/listinfo/python-list From joshm at taconic.net Thu Jan 3 04:22:51 2002 From: joshm at taconic.net (Joshua Muskovitz) Date: Wed, 2 Jan 2002 22:22:51 -0500 Subject: Anyone looking to hire a Python/C++ developer? References: <3c337779_4@corp.newsgroups.com> Message-ID: <3c33cd18_1@corp.newsgroups.com> > The question is: Will you consider relocating to Norway :) Somehow, I don't think my wife will go for the idea. But I *love* telecommuting! -- josh -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From paul at boddie.net Thu Jan 3 12:00:26 2002 From: paul at boddie.net (Paul Boddie) Date: 3 Jan 2002 03:00:26 -0800 Subject: Anyone looking to hire a Python/C++ developer? References: <3c337779_4@corp.newsgroups.com> Message-ID: <23891c90.0201030300.2400734d@posting.google.com> "Jeff Hinrichs" wrote in message news:... [Relocate to Norway?] > What are the taxes like? If you need to ask, you probably don't want to know. ;-) Paul From maxm at mxm.dk Thu Jan 3 12:34:35 2002 From: maxm at mxm.dk (maxm) Date: Thu, 3 Jan 2002 12:34:35 +0100 Subject: Anyone looking to hire a Python/C++ developer? References: <3c337779_4@corp.newsgroups.com> <23891c90.0201030300.2400734d@posting.google.com> Message-ID: From: "Paul Boddie" > [Relocate to Norway?] > > What are the taxes like? > If you need to ask, you probably don't want to know. ;-) I don't think they are that bad in Norway, since we here in Denmark graciously offerede them the part of the North Sea that was choke full of oil. ;-) But in Denmark it's close to 80% including VAT and other more hidden taxes! Depending on how much you earn off course. But as a software developer you earn enough that the high taxes kick in. So lets please not talk more about taxes here. I get depressed :-( regards Max M From aleax at aleax.it Thu Jan 3 13:23:54 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 3 Jan 2002 13:23:54 +0100 Subject: Anyone looking to hire a Python/C++ developer? References: <3c337779_4@corp.newsgroups.com> <23891c90.0201030300.2400734d@posting.google.com> Message-ID: "maxm" wrote in message news:jlXY7.7482$aS.1196809 at news010.worldonline.dk... > From: "Paul Boddie" > > > [Relocate to Norway?] > > > What are the taxes like? ... > But in Denmark it's close to 80% including VAT and other more hidden taxes! According to http://database.townhall.com/heritage/index/country.cfm?ID= ... with the ID values for various countries: Country top income tax rate average taxpayer's marginal tax rate Denmark 59 46 Sweden 56 20 France 54 33 Germany 51 35.4 Canada 48.75 26 includes Federal and Provincial Italy 46 34 Norway 41.5 28 UK 40 23 USA 39.6 28 NB Federal taxes only Finland 38 25.5 So, Norway ain't too bad -- indeed, you might be better off there than in some US states, depending on varying State-level taxation of income. Denmark, as maxm indicates, is indeed by far costliest, while Finland has a very attractive fiscal regime for individual earners. Of course, VAT and/or sales taxes also vary widely, and may influence your fiscal position, depending on what portion of your income you plan to *spend* (as opposed to saving/investing), and spend where. I believe they're not too far from 20% in various European states, lower in North America (down to no sales taxes at all in some US States). Similarly for other taxes, e.g. on real estate, depending in this case where you plan to live (direct effect on property, indirect on rents), and other taxes depending on your planned consumption patterns. E.g., I believe that Denmark has by far the highest tax rate of the listed countries on car purchases, and all European countries have high tax rates on car fuel, but on the other hand public transportation may enjoy net "negative taxes" (subsidies) so that you pay less for your bus tickets than their fair market price (in the US, this widely varies, by city even more than by State). Decisions about where to earn, where to spend, where to live, etc, are strongly correlated, but not entirely so (around borders, it's quite normal for people to live/work/spend in different fiscal areas -- e.g., there are large shopping areas in New Hampshire just across the border from Massachussets... guess why!-). Alex From teg at redhat.com Sun Jan 6 15:16:37 2002 From: teg at redhat.com (Trond Eivind =?iso-8859-1?q?Glomsr=F8d?=) Date: 06 Jan 2002 09:16:37 -0500 Subject: Anyone looking to hire a Python/C++ developer? References: <3c337779_4@corp.newsgroups.com> <23891c90.0201030300.2400734d@posting.google.com> Message-ID: "Alex Martelli" writes: > "maxm" wrote in message > news:jlXY7.7482$aS.1196809 at news010.worldonline.dk... > > From: "Paul Boddie" > > > > > [Relocate to Norway?] > > > > What are the taxes like? > ... > > But in Denmark it's close to 80% including VAT and other more hidden > taxes! > > According to http://database.townhall.com/heritage/index/country.cfm?ID= ... > with the ID values for various countries: > > Country top income tax rate average taxpayer's marginal tax rate > > Denmark 59 46 > Sweden 56 20 > France 54 33 > Germany 51 35.4 > Canada 48.75 26 includes Federal and > Provincial > Italy 46 34 > Norway 41.5 28 > UK 40 23 > USA 39.6 28 NB Federal taxes only > Finland 38 25.5 > > So, Norway ain't too bad -- indeed, you might be better off there than > in some US states, depending on varying State-level taxation of > income. Sorry, but the numbers for Norway aren't correct. It's more than 50% at the top level, and the average marginal tax rate is about 10% too low as well. The VAT is 23%. -- Trond Eivind Glomsr?d Red Hat, Inc. From aleax at aleax.it Sun Jan 6 16:19:59 2002 From: aleax at aleax.it (Alex Martelli) Date: Sun, 06 Jan 2002 15:19:59 GMT Subject: Anyone looking to hire a Python/C++ developer? References: <3c337779_4@corp.newsgroups.com> Message-ID: Trond Eivind Glomsr?d wrote: ... >> According to http://database.townhall.com/heritage/index/country.cfm?ID= ... >> Country top income tax rate average taxpayer's marginal tax rate ... >> Italy 46 34 >> Norway 41.5 28 >> UK 40 23 ... > Sorry, but the numbers for Norway aren't correct. It's more than 50% > at the top level, and the average marginal tax rate is about 10% too > low as well. The VAT is 23%. Please let the Heritage Foundation know they're publishing (and basing their country reports on) false data -- or, I'll do it myself, if you'll please send me an URL to a page with the correct number, thanks. Alex From andrew at acooke.org Thu Jan 3 13:28:05 2002 From: andrew at acooke.org (andrew at acooke.org) Date: Thu, 03 Jan 2002 12:28:05 GMT Subject: Teleowrking [Was: Anyone looking to hire a Python/C++ developer?] References: <3c337779_4@corp.newsgroups.com> Message-ID: Would you consider teleworking... ...from S America? :o) On a more serious, and perhaps more Python-related note, I've been teleworking for three years and (with certain provisos) it has worked very well. Companies looking for programmers with "rarer" skills might want to consider it (I'd be happy to answer questions here or by email if anyone is curious - I guess other people here will have experience too). Andrew (Who really is moving to Chile and looking for work there). Thor Arne Johansen wrote: > > "Joshua Muskovitz" skrev i melding > news:3c337779_4 at corp.newsgroups.com... >> Hey all, >> >> Are you looking to hire a competent developer? > > Yes desperately :-) > > The question is: Will you consider relocating to Norway :) [...] -- http://www.acooke.org From aleax at aleax.it Thu Jan 3 13:56:07 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 3 Jan 2002 13:56:07 +0100 Subject: teleworking tools and methodologies (was Re: Teleowrking [Was: Anyone looking to hire a Python/C++ developer?]) References: <3c337779_4@corp.newsgroups.com> Message-ID: wrote in message news:p7YY7.41526$ll6.5786405 at news6-win.server.ntlworld.com... > Would you consider teleworking... > > ...from S America? :o) > > On a more serious, and perhaps more Python-related note, I've been > teleworking for three years and (with certain provisos) it has worked > very well. Companies looking for programmers with "rarer" skills > might want to consider it (I'd be happy to answer questions here or by > email if anyone is curious - I guess other people here will have > experience too). I think the theme is very interesting, particularly the sub-theme of what methodologies and technologies work, and how well, in various teleworking situations. think3, inc, my current employer, has gone for a related geographical strategy of opening small development labs where certain key people wanted to live and work. As a result, we're now very spread-out, in geographical terms, compared to company size, with SW labs locate in half a dozen timezones stretching from Karnataka to California. Video-based (slow-scan) teleconferencing has apparently proved OK for typical managers' needs -- basically, "human" connection and chat beyond the confines of emails/newsgroups/intranet-based groupware. Not exactly cheap in terms of equipment and bandwidth, but those are definitely minor issues compared to, e.g., the cost of a plane roundtrip touching both US coasts, a couple of locations in Europe, and India. It does mean strange working times occasionally, but that's still less stress and fatigue than a plane trip, again. As a techie, I'm anything but satisfied of what we've come up with in terms of techie-to-techie close cooperation, though. Specifically, in my role as internal consultant/mentor/advisor, I know I've been hugely more effective face-to-face than via such tools as video, email, and so on. None of those, in particular, seem to support *pair-programming* and closely related practices of design and code inspection -- and yet these practices are key to effective close cooperation and mentoring. What tools and/or novel methodologies have you found effective in such pursuits? "Off-line" ideas (helpful across timezone gulfs are fine) -- CVS or other roughly equivalent schemes, email, wiki and/or newsgroups -- and some widespread "online" ideas also work, to some extent (muds/irc/intranet-based/...). But I keep thinking there must be something better -- some good ways to simulate and enhance sitting next to each other at a keyboard. VNC apparently supports that -- two VNC clients going to the same VNC server, with either client able to "drive" in keyboard and mouse terms. I've only tried VNC experimentally on a fast LAN, though, and not for "pair-programming like activities". Surely it should be possible to do better by building in similar abilities into suitable development environments such as IDLE or...? And/or integrate those with 'free chat' abilities, as in voice-over-IP or even just textual/messaging arrangements? Any applicable experience will be of interest! Alex From gmcm at hypernet.com Thu Jan 3 15:28:26 2002 From: gmcm at hypernet.com (Gordon McMillan) Date: 03 Jan 2002 14:28:26 GMT Subject: teleworking tools and methodologies (was Re: Teleowrking [Was: Anyone looking to hire a Python/C++ developer?]) References: <3c337779_4@corp.newsgroups.com> Message-ID: Alex Martelli wrote: [teleworking] > I think the theme is very interesting, particularly the sub-theme > of what methodologies and technologies work, and how well, in > various teleworking situations. I've been doing it for 6 years. In my experience the key factor is simply how responsive people are to email. CVS is also a necessity (well, one client used ClearCase - I worked out some scripts so I could keep my CVS in synch with their ClearCase). I live in rural Maine. No cable, no DSL (coming "soon" ), ISDN would cost me $400/month + long distance charges for each instant online. I've used VNC through a tunnel - man oh man, is that painful. Each mouse movement / click or keypress means a 2 to 10 second wait (I blame more than half of that on the pitiful box my client used for the tunnel). And don't run a DOS box on a remote Windows machine - the "just what changed" logic doesn't work, so the simple existence of the DOS box will saturate your connection. But I'm an independent developer, not an employee, so I get a little more leeway. [And like the guy who started this thread, I'm looking for new work, too.] -- Gordon http://www.mcmillan-inc.com/ From cliechti at gmx.net Thu Jan 3 16:06:08 2002 From: cliechti at gmx.net (Chris Liechti) Date: 3 Jan 2002 16:06:08 +0100 Subject: teleworking tools and methodologies (was Re: Teleowrking [Was: Anyone looking to hire a Python/C++ developer?]) References: <3c337779_4@corp.newsgroups.com> Message-ID: Gordon McMillan wrote in news:Xns918B606EF2ACFgmcmhypernetcom at 199.171.54.213: > i've > used VNC through a tunnel - man oh man, is that painful. Each mouse > movement / click or keypress means a 2 to 10 second wait (I blame more > than half of that on the pitiful box my client used for the tunnel). > And don't run a DOS box on a remote Windows machine - the "just what > changed" logic doesn't work, so the simple existence of the DOS box > will saturate your connection. i tested VNC over a cable connection (128kbits upstram) it worked good. also note that a VNC server on X is MUCH faster than on windows due to the fact that xvnc does know what has changed. (disable any fancy graphics anyway and select 8 bit mode for the VNC client) and just for those who don't know VNC, here's the link: http://www.uk.research.att.com/vnc/ -- Chris From anthony at interlink.com.au Thu Jan 3 17:46:06 2002 From: anthony at interlink.com.au (Anthony Baxter) Date: Fri, 04 Jan 2002 03:46:06 +1100 Subject: teleworking tools and methodologies (was Re: Teleowrking [Was: Anyone looking to hire a Python/C++ developer?]) In-Reply-To: Message from Chris Liechti of "03 Jan 2002 16:06:08 BST." Message-ID: <200201031646.g03Gk6M02539@mbuna.arbhome.com.au> Couple of things - check what encoding method is used. Some vnc clients default to a really, really stupid one. 'hextile' is ok. - if you're on a smaller connection, look at 'tightvnc' (check google for website). It's designed for this. - if talking to a windows box, tweak the vnc settings to make sure you're only polling the minimum needed - don't poll the whole screen if you don't have to do this. >>> Chris Liechti wrote > Gordon McMillan wrote in > news:Xns918B606EF2ACFgmcmhypernetcom at 199.171.54.213: > > > i've > > used VNC through a tunnel - man oh man, is that painful. Each mouse > > movement / click or keypress means a 2 to 10 second wait (I blame more > > than half of that on the pitiful box my client used for the tunnel). > > And don't run a DOS box on a remote Windows machine - the "just what > > changed" logic doesn't work, so the simple existence of the DOS box > > will saturate your connection. > > i tested VNC over a cable connection (128kbits upstram) it worked good. > also note that a VNC server on X is MUCH faster than on windows due to the > fact that xvnc does know what has changed. (disable any fancy graphics > anyway and select 8 bit mode for the VNC client) > > and just for those who don't know VNC, here's the link: > http://www.uk.research.att.com/vnc/ > > > -- > Chris > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Anthony Baxter It's never too late to have a happy childhood. From andrew at acooke.org Thu Jan 3 16:08:00 2002 From: andrew at acooke.org (andrew at acooke.org) Date: Thu, 03 Jan 2002 15:08:00 GMT Subject: teleworking tools and methodologies (was Re: Teleowrking [Was: Anyone looking to hire a Python/C++ developer?]) References: <3c337779_4@corp.newsgroups.com> Message-ID: Alex Martelli wrote: > As a techie, I'm anything but satisfied of what we've come up with > in terms of techie-to-techie close cooperation, though. Specifically, > in my role as internal consultant/mentor/advisor, I know I've been > hugely more effective face-to-face than via such tools as video, > email, and so on. None of those, in particular, seem to support > *pair-programming* and closely related practices of design and code > inspection -- and yet these practices are key to effective close > cooperation and mentoring. I wouldn't have though pair programming would have much chance of working if you weren't in front of the same terminal. I worked in a very different way - effectively on mini-projects - and did sometimes (about once every couple of months) visited "base". > What tools and/or novel methodologies have you found effective in > such pursuits? "Off-line" ideas (helpful across timezone gulfs > are fine) -- CVS or other roughly equivalent schemes, email, wiki > and/or newsgroups -- and some widespread "online" ideas also work, > to some extent (muds/irc/intranet-based/...). But I keep thinking > there must be something better -- some good ways to simulate and > enhance sitting next to each other at a keyboard. Being friends with the other developer(s) is probably worth its weight in gold. Chatting over a phone once a day is useful, even if you don't feel you're actually working. On a more mundane level, everyone (small company) posting once a day a summary of what they have done is useful (a summary of what they're going to do in the morning helps too). This helps replace the information you gather in "background noise" in an office. Both those comments have a similar theme - that it's the informal flow of information that needs help. Requirements, Specs and Designs can be emailed and read wherever you are, but when you're half way across the country you don't hear someone swearing about something in your code that could be easily changed... Regular release cycles help too - testing and bug fixing tends to generate some "communal spirit" and you get to poke around in each other's code (so a distributed bug tracking database is necessary). Andrew -- http://www.acooke.org From BgPorter at NOartlogicSPAM.com Thu Jan 3 16:38:56 2002 From: BgPorter at NOartlogicSPAM.com (Brett g Porter) Date: Thu, 03 Jan 2002 15:38:56 GMT Subject: teleworking tools and methodologies (was Re: Teleowrking [Was: Anyone looking to hire a Python/C++ developer?]) References: <3c337779_4@corp.newsgroups.com> Message-ID: "Alex Martelli" wrote in message news:a11kd5$iqg$1 at serv1.iunet.it... > What tools and/or novel methodologies have you found effective in > such pursuits? "Off-line" ideas (helpful across timezone gulfs > are fine) -- CVS or other roughly equivalent schemes, email, wiki > and/or newsgroups -- and some widespread "online" ideas also work, > to some extent (muds/irc/intranet-based/...). But I keep thinking > there must be something better -- some good ways to simulate and > enhance sitting next to each other at a keyboard. My company is 100% distributed -- no 2 of us are in the same place (except for admin staff at the home office in LA). From what I've seen, the success of telework is more or less dependant on the culture of the company. I keep running into people who have horror stories to tell about telecommuting (and every so often I see articles on the "Telecommuting Backlash"). Almost without fail, failures are tied to being a single telecommuter trying to work in concert with a traditional office group. I'm not surprised that those situations don't work most of the time. The tools that we use are FirstClass (a workgroup server), CVS, and the telephone when needed. Because all the other 'watercooler chatter' happens online in the same space, nothing is lost (once you get used to working like this). Most client communication happens on the workgroup server as well -- it's nice to have a paper trail of every decision on a project both internally and externally. (where 'nice' == 'crucial'). We don't use pair programming, so that hasn't been an issue for us. The only time that we've used video conferencing regularly (AFAIK) is when a team was working on video conferencing software, so that was debugging and test as well. I don't feel that I lose anything by not seeing faces. YMMV. BgP -- // Brett g Porter * Lead Engineer, Development Practices // BgPorter at artlogic.com * www.artlogic.com // Art & Logic, Inc. * software engineering and design // Desktop * Embedded * Web From russell_turpin at hotmail.com Thu Jan 3 23:49:17 2002 From: russell_turpin at hotmail.com (Russell Turpin) Date: 3 Jan 2002 14:49:17 -0800 Subject: Teleowrking [Was: Anyone looking to hire a Python/C++ developer?] References: <3c337779_4@corp.newsgroups.com> Message-ID: <8a12e538.0201031449.18d1dd20@posting.google.com> Thor Arne Johansen wrote: > The question is: Will you consider relocating to Norway :) That raises so many questions. (a) What do you pay? (b) Are you on the coast? (c) Does the sea freeze there? (d) How much do you pay? (e) Do I need to be fluent in Norwegian? Hee, hee. From sholden at holdenweb.com Thu Jan 3 23:48:47 2002 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 3 Jan 2002 17:48:47 -0500 Subject: Teleowrking [Was: Anyone looking to hire a Python/C++ developer?] References: <3c337779_4@corp.newsgroups.com> <8a12e538.0201031449.18d1dd20@posting.google.com> Message-ID: "Russell Turpin" wrote in message news:8a12e538.0201031449.18d1dd20 at posting.google.com... > Thor Arne Johansen wrote: > > The question is: Will you consider relocating to Norway :) > > That raises so many questions. (a) What do you pay? (b) Are > you on the coast? (c) Does the sea freeze there? (d) How > much do you pay? (e) Do I need to be fluent in Norwegian? > > Hee, hee. Who cares. Just think of those lovely blue parrots. regards Steve -- http://www.holdenweb.com/ From syver-en+usenet at online.no Fri Jan 4 01:38:43 2002 From: syver-en+usenet at online.no (Syver Enstad) Date: 04 Jan 2002 01:38:43 +0100 Subject: Teleowrking [Was: Anyone looking to hire a Python/C++ developer?] References: <3c337779_4@corp.newsgroups.com> <8a12e538.0201031449.18d1dd20@posting.google.com> <3c34e2f9.28051726@127.0.0.1> Message-ID: root at 127.0.0.1 ((Five Fresh) Fish) writes: > > Land of the midnight sun. I'd move to Norway... for the four months > of the > year they have warm weather and sun in the skies. :-) Warning hurt patriot ahead ;-) Bah, that's about as accurate as describing the climate in the Usa by describing Alaskas weather. Most of the country don't even have a midnight sun. So there! -- Vennlig hilsen Syver Enstad From thorj at ibas.no Fri Jan 4 18:51:21 2002 From: thorj at ibas.no (Thor A. Johansen) Date: Fri, 4 Jan 2002 18:51:21 +0100 Subject: SV: Teleowrking [Was: Anyone looking to hire a Python/C++ developer?] References: <3c337779_4@corp.newsgroups.com> <8a12e538.0201031449.18d1dd20@posting.google.com> <3c34e2f9.28051726@127.0.0.1> Message-ID: Great promotion of Norway there Syver :) Seriously though; Norway is very diverse in terms of climate and landscapes. We have a very long coast, with climate varying from arctic to temperate. We have large lush forest landscapes as well as vast baron mountain landscapes. We have glaciers, mountain plateaus, fjords, lakes, heck we have it all ;) (except tropics of course )We also have 4 very distinct seasons; all with their own charms and ills. For a less colored description :) see: http://www.atlapedia.com/online/countries/norway.htm As far as salaries, I don't know what the going rate for skilled programmers (C/C++/Python/Perl) with 4-6 years experience is out there in the world? I'm not even sure what it is in Norway. I'd guess in the range $35K-$85K depending on experience/responsibilites etc. This of course is becoming more important as more and more people will start considering the global village as their workplace and recruiting grounds. -- Thor A. Johansen Syver Enstad skrev i meldingsnyheter:uheq32bn0.fsf at online.no... > root at 127.0.0.1 ((Five Fresh) Fish) writes: > > > > Land of the midnight sun. I'd move to Norway... for the four months > > of the > > year they have warm weather and sun in the skies. :-) > > Warning hurt patriot ahead ;-) > > Bah, that's about as accurate as describing the climate in the Usa > by describing Alaskas weather. Most of the country don't even have a > midnight sun. > > So there! From boud at rempt.xs4all.nl Sun Jan 6 18:54:17 2002 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 6 Jan 2002 17:54:17 GMT Subject: Anyone looking to hire a Python/C++ developer? References: <3c337779_4@corp.newsgroups.com> Message-ID: Thor Arne Johansen wrote: > "Joshua Muskovitz" skrev i melding > news:3c337779_4 at corp.newsgroups.com... >> Hey all, >> >> Are you looking to hire a competent developer? > Yes desperately :-) > The question is: Will you consider relocating to Norway :) I would -- but I've got a wife and three kids to bring with me. -- Boudewijn Rempt | http://www.valdyas.org From andrew at acooke.org Wed Jan 2 22:27:52 2002 From: andrew at acooke.org (andrew at acooke.org) Date: Wed, 02 Jan 2002 21:27:52 GMT Subject: Nicer way to write folding? (list reversal?) Message-ID: Hi, In the code below, foldr2 is clearly uglier than the rest. Is there a nicer way (without destructive reversal - yuck - of the list argument)? Also, are these things built-in (can't find them)? Is recursion any faster than it used to be (I've not been following Python development so am wondering if anything in 2 (or 2.2) would help; foldr2 and fold2 are expected to be faster than foldl and foldr, although I've not done any timing). Thanks, Andrew # foldr: f(x1, f(x2, ... f(xn-1, f(xn, c))...)) # foldl: f(xn, f(xn-1, ... f(x2, f(x1, c))...)) def foldr(action, start, list): if not list: return start else: return action(list[0], foldr(action, start, list[1:])) def foldl(action, start, list): if not list: return start else: return foldl(action, action(list[0], start), list[1:]) def foldr2(action, start, list): for i in range(len(list), 0, -1): start = action(list[i-1], start) return start def foldl2(action, start, list): for x in list: start = action(x, start) return start print foldr(operator.add, "x", ["a", "b", "c"]) print foldl(operator.add, "x", ["a", "b", "c"]) print foldr2(operator.add, "x", ["a", "b", "c"]) print foldl2(operator.add, "x", ["a", "b", "c"]) abcx cbax abcx cbax -- http://www.acooke.org From jason at jorendorff.com Wed Jan 2 23:57:21 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Wed, 2 Jan 2002 16:57:21 -0600 Subject: Nicer way to write folding? (list reversal?) In-Reply-To: Message-ID: > In the code below, foldr2 is clearly uglier than the rest. Is there a > nicer way (without destructive reversal - yuck - of the list > argument)? Also, are these things built-in (can't find them)? foldr() is built-in. It's called reduce(). >>> from operator import add >>> nums = [1, 2, 3, 4, 5] >>> reduce(add, nums, 0) 15 ## Jason Orendorff http://www.jorendorff.com/ From andrew at acooke.org Thu Jan 3 08:37:45 2002 From: andrew at acooke.org (andrew at acooke.org) Date: Thu, 03 Jan 2002 07:37:45 GMT Subject: Nicer way to write folding? (list reversal?) References: Message-ID: [crossposting to comp.lang.functional in case someone there knows whether there's a convention, but followup still to comp.lang.python] Thanks, I didn't know that. It seems to be f(f(...f(f(c, xn), xn-1) ..., x2), x1) rather than f(x1, f(x2, ... f(xn-1, f(xn, c))...)) (ie the arguments to f are reversed). Is there any consensus across languages about which way round the arguments should be in foldr? In ML, it's the second argument to the function that takes the output of earlier results: - foldr; val it = fn : ('a * 'b -> 'b) -> 'b -> 'a list -> 'b Cheers, Andrew In article you wrote: >> In the code below, foldr2 is clearly uglier than the rest. Is there a >> nicer way (without destructive reversal - yuck - of the list >> argument)? Also, are these things built-in (can't find them)? > > foldr() is built-in. It's called reduce(). > > >>> from operator import add > >>> nums = [1, 2, 3, 4, 5] > >>> reduce(add, nums, 0) > 15 > > ## Jason Orendorff http://www.jorendorff.com/ > -- http://www.acooke.org From mwh at python.net Thu Jan 3 11:59:50 2002 From: mwh at python.net (Michael Hudson) Date: Thu, 3 Jan 2002 10:59:50 GMT Subject: Nicer way to write folding? (list reversal?) References: Message-ID: andrew at acooke.org writes: > Hi, > > In the code below, foldr2 is clearly uglier than the rest. Is there a > nicer way (without destructive reversal - yuck - of the list > argument)? No. It's not that bad is it? > Also, are these things built-in (can't find them)? Well, there's reduce, but it's almost always a bad idea. > Is recursion any faster than it used to be Nope. > (I've not been following Python development so am wondering if > anything in 2 (or 2.2) would help; Oh, if you're migrating from 1.5.2 it might be a touch quicker. Nothing really siginificant though. > foldr2 and fold2 are expected to be faster than foldl and > foldr, although I've not done any timing). I'd be amazed if they weren't. Now for some content : why are you writing these functions? It's not really a sensible way to program in Python. Cheers, M. From andrew at acooke.org Thu Jan 3 13:22:23 2002 From: andrew at acooke.org (andrew at acooke.org) Date: Thu, 03 Jan 2002 12:22:23 GMT Subject: Nicer way to write folding? (list reversal?) References: Message-ID: <32YY7.41493$ll6.5781902@news6-win.server.ntlworld.com> Michael Hudson wrote: [...] > Now for some content : why are you writing these functions? > It's not really a sensible way to program in Python. There's two answers: Superficial: I was manipulating paths - ended up writing an explodePath function that calls os.path.split again and again and then wanted to reassemble the result after processing. Realised I needed to fold os.path.join and started wondering about folds. Slightly deeper: I use Python only for odds n sods, but am learning ML with a particular (larger) task in mind. Realised that playing with this would hammer home the difference between the two folds and was also curious about whether 2/2.2 was any more functional than 1.5. I know that Python wasn't (and apparently still isn't) intended to be used "functionally". Actually, Python is quite nice for playing around learning things like this (especially now in 2.2 that scope seems to work like you'd expect). It's fun being able to swap between imperative and declarative code and compare them. Actually, after writing up to the end of the last sentence I just rewrote that pathExplode function that I mentioned above so that it's recursive - see what you're making me do with your silly questions! :-) Andrew -- http://www.acooke.org From bashan at newmail.net Wed Jan 2 23:33:24 2002 From: bashan at newmail.net (Guy Bashan) Date: Wed, 2 Jan 2002 14:33:24 -0800 Subject: RE Message-ID: <3c32fc76@news.bezeqint.net> Hello, I'm new to Python and having some Regular expressing problems: I want to find a pattern in HTML page. I have the HTML page in a variable named data. Now I would like to search a pattern that starts with: ----------------------------------------------- ------------------------------------------------------ and ends with: in the middle there can be any occurence. I wrote: result = re.search(r'style="color: #660000;">.*', data); if result: print result.group(); else: print 'no match'; but it seems like it doesn't work. Anyone has ideas ??? Thanks. Bashan. From christophe.delord at free.fr Sun Jan 6 22:26:29 2002 From: christophe.delord at free.fr (Christophe Delord) Date: Sun, 06 Jan 2002 22:26:29 +0100 Subject: RE References: <3c32fc76@news.bezeqint.net> Message-ID: <3C38C105.2070803@free.fr> Hello, In regular expressions, the dot (.) doesn't match newlines. Try to replace .* by (.|\n)* Christophe. Guy Bashan wrote: > Hello, I'm new to Python and having some Regular expressing problems: > I want to find a pattern in HTML page. I have the HTML page in a variable > named data. > Now I would like to search a pattern that starts with: > ----------------------------------------------- > class="w2b" style="color: #660000;"> > ------------------------------------------------------ > and ends with: > > > in the middle there can be any occurence. > > I wrote: > > result = re.search(r'style="color: #660000;"> dir=rtl>.*', data); > if result: > print result.group(); > else: > print 'no match'; > > but it seems like it doesn't work. > > Anyone has ideas ??? > > Thanks. > Bashan. > > > -- Christophe Delord http://christophe.delord.free.fr From careye at spamcop.net Mon Jan 7 08:37:48 2002 From: careye at spamcop.net (Carey Evans) Date: 07 Jan 2002 20:37:48 +1300 Subject: RE References: <3c32fc76@news.bezeqint.net> <3C38C105.2070803@free.fr> Message-ID: <87lmfa4nn7.fsf@psyche.dnsalias.org> Christophe Delord writes: > In regular expressions, the dot (.) doesn't match newlines. It does if you pass the re.S flag, e.g. re.search('(.*)', data, re.S) -- Carey Evans http://home.clear.net.nz/pages/c.evans/ Cavem canus. From reuter at portsite.de Wed Jan 2 23:44:11 2002 From: reuter at portsite.de (Tim Reuter) Date: 2 Jan 2002 14:44:11 -0800 Subject: Can't download paos and chautauqua Message-ID: It is not possible to download the sources from Mr. Maltzahns site: ( http://www.cs.colorado.edu/~carlosm/software.html ) ftp://ftp.cs.colorado.edu/users/carlosm/paos-1.4.tar.gz ftp://ftp.cs.colorado.edu/users/carlosm/chautauqua-1.4.tar.gz If there's anybody out there who can help, please mail me. Thanks in advance Tim From chris.gonnerman at newcenturycomputers.net Thu Jan 3 05:11:46 2002 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Wed, 2 Jan 2002 22:11:46 -0600 Subject: Can't download paos and chautauqua References: Message-ID: <00f001c1940c$e9f747a0$0101010a@local> The ftp server mentioned has hardly anything under the users directory. If I had to guess, I'd say Carlos doesn't live there anymore. The software listed is all for Python 1.4... ----- Original Message ----- From: "Tim Reuter" Newsgroups: comp.lang.python To: Sent: Wednesday, January 02, 2002 4:44 PM Subject: Can't download paos and chautauqua > It is not possible to download the sources from Mr. Maltzahns site: > ( http://www.cs.colorado.edu/~carlosm/software.html ) > ftp://ftp.cs.colorado.edu/users/carlosm/paos-1.4.tar.gz > ftp://ftp.cs.colorado.edu/users/carlosm/chautauqua-1.4.tar.gz > If there's anybody out there who can help, please mail me. > > Thanks in advance > Tim > -- > http://mail.python.org/mailman/listinfo/python-list > > From joel at OARcorp.com Thu Jan 3 00:11:05 2002 From: joel at OARcorp.com (Joel Sherrill) Date: 2 Jan 2002 15:11:05 -0800 Subject: tkinter - how do I make nice online help Message-ID: <608f3869.0201021511.25bd76b1@posting.google.com> Hi, I think the subject sums it up but here is some more information. I want to have nice help for an Python Tkinter application I am writing. I don't know the best approach. Is there a standard widget that would help? I saw a post from a while ago where it was suggested that using the Idle Browser class and writing the help in html was a good solution. Advice and nice examples would be greatly appreciated. Thanks Joel Sherrill joel at OARcorp.com Ask me about RTEMS -- a free RTOS From joel at OARcorp.com Thu Jan 3 00:14:02 2002 From: joel at OARcorp.com (Joel Sherrill) Date: 2 Jan 2002 15:14:02 -0800 Subject: tkinter best widget for file editting Message-ID: <608f3869.0201021514.289e9cc9@posting.google.com> Hi, I am writing an application where I need to let the user see and edit a relatively small amount of text. It will likely be less than an 80x24 screen. The contents will be saved in a file. A "notepad" type of widget that pops up would be ideal. I don't seem to be finding anything in my search but suspect it is because I am not using the right words. Thanks in advance. Joel Sherrill joel at OARcorp.com Ask me about RTEMS: a free RTOS From matt at mondoinfo.com Thu Jan 3 04:04:09 2002 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Thu, 03 Jan 2002 03:04:09 GMT Subject: tkinter best widget for file editting References: <608f3869.0201021514.289e9cc9@posting.google.com> Message-ID: On 2 Jan 2002 15:14:02 -0800, Joel Sherrill wrote: Dear Joel, >Hi, Hi! >I am writing an application where I need to let the user see and edit >a relatively small amount of text. It will likely be less than an >80x24 screen. The contents will be saved in a file. A "notepad" >type of widget that pops up would be ideal. I don't seem to be >finding anything in my search but suspect it is because I am not >using the right words. The Text widget might be good. There's also the standard ScrolledText widget (which is in its own module) and Pmw's flavor. If you haven't yet run across it, Fredrik Lundh's excellent An Introduction to Tkinter is very useful. It's at: http://www.pythonware.com/library/tkinter/introduction/index.htm I've long since save a copy locally to save Fredrik the bandwidth. And Pmw is at: http://pmw.sourceforge.net/ Regards, Matt From frudman at ix.netcom.com Thu Jan 3 00:21:43 2002 From: frudman at ix.netcom.com (Frederic Rudman) Date: Wed, 02 Jan 2002 23:21:43 GMT Subject: Porting Pythin to embedded platform Message-ID: I'm new to python. I'm looking for a small portable language to quickly port to a small-memory based embedded system. 1) Does anyone know where to best get info on that? 2) What's the general footprint of Python in an embedded system (ballpark) 3) Is there a "parser phase" output to python (so that I only need to port the interpreter to the embedded base: no interactivity needed there anyway) and if so, what's the general footprint of the interpreter? Or do I need to port the parser as well? 4) What level of ANSI C api do I need for a port: all of it, the memallocs only, something in between? Any other pointers for porting python to a non-linux, non-intel platforms would be appreciated. BTW: I'm not sure if this is the right group for these questions but it's the only group I found on my ISP (if there's a better suited group, please let me know, and sorry for the inconvenience). Sincerely, Frederic Rudman From phil at river-bank.demon.co.uk Thu Jan 3 02:51:55 2002 From: phil at river-bank.demon.co.uk (Phil Thompson) Date: Thu, 03 Jan 2002 01:51:55 +0000 Subject: Porting Pythin to embedded platform References: Message-ID: <3C33B93B.12D1B622@river-bank.demon.co.uk> Frederic Rudman wrote: > > I'm new to python. I'm looking for a small portable language to quickly port > to a small-memory based embedded system. > > 1) Does anyone know where to best get info on that? > 2) What's the general footprint of Python in an embedded system (ballpark) > 3) Is there a "parser phase" output to python (so that I only need to port > the interpreter to the embedded base: no interactivity needed there anyway) > and if so, what's the general footprint of the interpreter? Or do I need to > port the parser as well? > 4) What level of ANSI C api do I need for a port: all of it, the memallocs > only, something in between? > > Any other pointers for porting python to a non-linux, non-intel platforms > would be appreciated. I've just gone through the process of porting the latest Python to the Sharp Zaurus. This is Linux, but non-Intel. Python itself is quite small, but has fairly large number of extension modules and it isn't obvious how may of these are really used. I put most of the work into understanding the module interdependencies with the aim of producing a sensible core, but reducing some of the requirements of the core on (for example) distutils and pydoc. On the Zaurus the size of the interpreter is just under 800K, and the core modules another 300K. I haven't looked at run-time memory usage. Getting the code to compile was fairly straightforward. The Python build process isn't designed for cross-compilation - but it's easy enough to hack. Phil From gh_pythonlist at gmx.de Thu Jan 3 03:24:52 2002 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-15?Q?H=E4ring?=) Date: Thu, 3 Jan 2002 03:24:52 +0100 Subject: Porting Pythin to embedded platform In-Reply-To: References: Message-ID: <20020103022451.GA1510@lilith.hqd-internal> Le 02/01/02 ? 23:21, Frederic Rudman ?crivit: > I'm new to python. I'm looking for a small portable language to quickly port > to a small-memory based embedded system. I'm all for Python, but Lua is somewhat smaller than Python (and less powerful), while still having a nice syntax. Don't have the URL at hand. > 1) Does anyone know where to best get info on that? For specific problems, right on this list/newsgroup :-) Deeply Embedded Python might be interesting to you: http://www.abo.fi/~iporres/python/ It's a port of Python 1.5.1 to an embedded system without even an OS. > 2) What's the general footprint of Python in an embedded system (ballpark) > 3) Is there a "parser phase" output to python (so that I only need to port > the interpreter to the embedded base: no interactivity needed there anyway) If I understand correctly, this is what happens anyway when "embedding" Python, i. e. link to libpython.(a/so) resp. the Python DLL on Windows. > and if so, what's the general footprint of the interpreter? Or do I need to > port the parser as well? > 4) What level of ANSI C api do I need for a port: all of it, the memallocs > only, something in between? There Python core shouldn't need much ANSI C. You task will probably be to decide which modules you want to compile in. Just deselect the modules you don't want to have in the core by editing Modules/Setup, and for getting out even more, you can use a few #ifdefs. Also check the autoconf build options (if autoconf applies to your build process at all; else just "fake" it, like the Windows build process does: edit pyconfig.h by hand). You can for example build without threads and Unicode support. My only experience is that I cross-compiled Python 2.2 for my Compaq iPAQ running Linux/StrongArm. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From taw_usenet at yahoo.com Thu Jan 3 00:35:53 2002 From: taw_usenet at yahoo.com (ToddW) Date: 2 Jan 2002 15:35:53 -0800 Subject: Python 1.5.x vs Python 2.x.x References: <3C180FF7.DEAEA6C6@radical.ca> <7xhequjsgl.fsf@ruckus.brouhaha.com> <9vc581$g0h$1@peabody.colorado.edu> <97ae44ee.0112181624.2293a692@posting.google.com> <9vr8gp$3af$1@peabody.colorado.edu> Message-ID: <84a8bdbe.0201021535.2854e7c6@posting.google.com> Fernando P?rez wrote in message news:<9vr8gp$3af$1 at peabody.colorado.edu>... > Stephen wrote: > > > > I'm sat on a RedHat 7.2 box too and am very hesitant to upgrade to > > Python 2.x for fear of breaking a lot of the RedHat-distributed > > scripts, including the firewall. The alternative seems to be to > > install Python 2.1.1 without symlinking it to /usr/bin/python > > ie. Leave Python 1.5.2 the default Python and then use the hash-bang > > to explicitly call python 2.x (#!/usr/bin/python2) in my scripts. > > Is this right ? > > yes, this will work. You can install the python2 rpm alongside with > python1.5. Look into /usr/bin/python*, you'll see both side by side. The > trick is, python1.5 is the default, and *don't change that* (you'll break > everything if you do). But as long as you don't mind changing by hand > references to python2 in everything else you write or use, you'll be fine. > This is clumsy, and is why yesterday I wrote a detailed post on the issue > hoping to hear from the redhats for a reasonable explanation. As far as I > can tell, their python distribution is simply broken. The problems can be > worked around, but it's an annoyance. > > > On this note, I tried installing expat-1.1-4tummy.src.rpm and > > python2-2.1.1-3.src.rpm (following the instructions to 'rebuild' > > it, as per http://www.python.org/2.1.1/rpms.html) > > but where does the rebuilt python get installed ? > > > > Afterwards, it claims the RPM is not installed > > $ rpm -q python*rpm > > package python2-2.1.1-3.src.rpm is not installed > > query for the package name only, not the full filename. The rpm querying is > tricky to use, fire up kpackage and just look at the list, much easier. > > > Thanks for any help, > > > > Stephen > > cheers Use grep or egrep if you aren't sure of the name: rpm -qa | grep ython From taw_usenet at yahoo.com Thu Jan 3 00:50:49 2002 From: taw_usenet at yahoo.com (ToddW) Date: 2 Jan 2002 15:50:49 -0800 Subject: /usr/bin/env: python: No such file or directory References: <9vivft$593$1@peabody.colorado.edu> <171220010818339518%jwbaxter@spamcop.net> <9vnvue$m5d$1@peabody.colorado.edu> <3C1F9B6E.19471D84@alcyone.com> <3C1FCD73.F7DCB32@alcyone.com> Message-ID: <84a8bdbe.0201021550.60adaf2f@posting.google.com> Erik Max Francis wrote in message news:<3C1FCD73.F7DCB32 at alcyone.com>... > Trond Eivind Glomsr?d wrote: > > > Having the best compiler for a year and a half can hardly be called a > > fiasco for us - it is a problem that there were no decent official > > releases to ship, though. > > So good, in fact, that it prompted an immediate press release from the > GCC team that it was a development version, was never intended as an > official release, and a recommendation not to use it. > > http://gcc.gnu.org/gcc-2.96.html > > Note that additionally, the ABI in 2.96 was different than in _both_ > 2.95.x and 3.x. That's what one gets for releasing a development > snapshot as if it were a true release. They over reacted. Plus lots of things break ABI from release to release, including stable gcc releases. 2.96 was such a good decision. The C++ programmers especially sighed a big sigh of relief. But, bero said it so much better: http://www.bero.org/gcc296.html From daniels at developNET.com Thu Jan 3 01:47:10 2002 From: daniels at developNET.com (Scott David Daniels) Date: 2 Jan 2002 16:47:10 -0800 Subject: /usr/bin/env: python: No such file or directory References: <915a998f.0112161542.2ab07235@posting.google.com> <3C222B16.C1B1BC8D@attbi.com> <3C225488.AF5C93F4@attbi.com> Message-ID: <976e5b9f.0201021647.52132be6@posting.google.com> Chris Barker wrote in message news:<3C225488.AF5C93F4 at attbi.com>... > Cliff Wells wrote: > How would the interpreter know what version was required? That's exactly > what I think we need...A way to tell the interpreter what version is > required by a script. How about: import sys assert 0x2010000 < sys.hexversion < 0x2030000 at the top of the script (to insist on 2.1 or 2.2). -Scott From logiplexsoftware at earthlink.net Thu Jan 3 01:52:52 2002 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Wed, 2 Jan 2002 16:52:52 -0800 Subject: /usr/bin/env: python: No such file or directory In-Reply-To: <976e5b9f.0201021647.52132be6@posting.google.com> References: <915a998f.0112161542.2ab07235@posting.google.com> <3C222B16.C1B1BC8D@attbi.com> <3C225488.AF5C93F4@attbi.com> <976e5b9f.0201021647.52132be6@posting.google.com> Message-ID: <20020102165252.107a87bf.logiplexsoftware@earthlink.net> On 2 Jan 2002 16:47:10 -0800 daniels at developNET.com (Scott David Daniels) wrote: > Chris Barker wrote in message news:<3C225488.AF5C93F4 at attbi.com>... > > Cliff Wells wrote: > > How would the interpreter know what version was required? That's exactly > > what I think we need...A way to tell the interpreter what version is > > required by a script. um... Chris said that, not me (not that I disagree with his sentiment). -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From cjensen at bioeng.ucsd.edu Thu Jan 3 01:52:44 2002 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: 2 Jan 2002 16:52:44 -0800 Subject: affects on extended modules References: <3C051775.A8D4FD66@bioeng.ucsd.edu> <83pu5zrvbl.fsf@panacea.canonical.org> <3C0E7138.FD485D1D@bioeng.ucsd.edu> <1be8d8b.0112271705.50940295@posting.google.com> Message-ID: <1be8d8b.0201021652.772e4100@posting.google.com> Pedro wrote in message news:... > "Curtis Jensen" wrote: > > > Pedro wrote in message > > news:... > >> "Curtis Jensen" wrote: > >> > >> > Kragen Sitaker wrote: > >> >> > >> >> Curtis Jensen writes: > >> >> > We have created a python interface to some core libraries of our > >> >> > own making. We also have a C interface to these same libraries. > >> >> > However, the the python interface seems to affect the speed of the > >> >> > extended libraries. ie. some library routines have their own > >> >> > benchmark code, and the time of exection from the start of the > >> >> > library routine to the end of the library routine (not including > >> >> > any python code execution), takes longer than it's C counterpart. > >> >> > >> >> In the Python version, the code is in a Python extension module, > >> >> right? > >> >> A .so or .dll file? Is it also in the C counterpart? (If that's > >> >> not > >> >> it, can you provide more details on how you compiled and linked the > >> >> two?) > >> >> > >> >> In general, referring to dynamically loaded things through symbols > >> >> --- even from within the same file --- tends to be slower than > >> >> referring to things that aren't dynamically loaded. > >> >> > >> >> What architecture are you on? If you're on the x86, maybe Numeric > >> >> is being stupid and allocating things that aren't maximally aligned. > >> >> But you'd probably notice a pretty drastic difference in that case. > >> >> > >> >> ... or maybe Numeric is being stupid and allocating things in a way > >> >> that causes cache-line contention. > >> >> > >> >> Hope this helps. > >> > > >> > Thanks for the responce. The C counterpart is directly linked > >> > together into one large binary (yes, the python is using a dynamicaly > >> > linked object file, a .so). So, That might be the source of the > >> > problem. I can try and make a dynamicaly linked version of the C > >> > counterpart and see how that affects the speed. We are running on > >> > IRIX 6.5 machines (mips). > >> > Thanks. > >> > > >> > > >> Don't know if this helps but I had a similar problem on Linux. > >> > >> The context was : a python script was calling an external program and > >> parsing output (with popen) many times. I decided to optimize this by > >> turning the external program into a dynamicaly linked library with > >> python bindings. I expected to gain the extra system calls to fork and > >> start a new process, but it turned out that this solution was slower. > >> > >> The problem was caused by multithreading stuff. When using the library > >> straight from a C program, I didn't link with multithreaded libraries > >> and so all system calls weren't protected (they don't need to lock and > >> unlock their resources). > >> > >> Unfortunately, the library was reading files with fgetc (character by > >> character :( ). Since the Python version I used was compiled with > >> multi-threading enabled, it turned out that the fgetc function used in > >> this case lock/unlock features, which cause the extra waste of time. > >> > >> To find this, I compiled my library with profiling (I think I needed to > >> use some system call to activate profiling from the library, since I > >> couldn't rebuild Python). > >> > >> OT : at the end I fixed the library (fgetc replaced by fgets), and > >> didn't gain anything by turning the external program into a python > >> extension. Since it seemed that Linux disk cache was good, I removed > >> the python extension thus keeping a pure Python program, and > >> implemented a cache for the results of the external program. This was > >> much simpler and more efficient in this case. > > > > > > Is this a problem with i/o only? Our the code sections that we > > benchmarked has no i/o in it. > > > > -- > > Curtis Jensen > > In my case, it was only i/o related. > > If your problem, as I understand it, is : > + I've got a function f() written in C > + f() execution is doing some benchmark telling how much time it took > to complete > + calling f() from a C binary gives a (significant) shorter duration > than calling (the same) f() from a Python extension > > you may have to check what f() is doing, because , what I was stating is, > that it may be affected by the python environment : > > - Are doing extensive calls to an external library ? > In my case, some glibc calls need to inforce reentrancy protection > when running in a multithreaded context. These protections blew out > any gain. > > - If you're doing calls to external libraries, are you linked against > the same versions ? (ldd on binaries and libraries may help) > > - More basicaly, did you compile with the same options ? > Could the differences point to a possible source of your problem ? > (may be worth checking optimization, debug, conditional compilation > options) > > Regards, Your summary of the problem is correct. We do make calls to an external library (NAg) I don't know if this makes a difference, but we are also calling Fortran. In any case, we link with the same libraries and with the same compiler options. It seems to me that we are not experiencing the same problem that you incountered. Thanks for your help. -- Curtis Jensen From phil at river-bank.demon.co.uk Thu Jan 3 03:11:17 2002 From: phil at river-bank.demon.co.uk (Phil Thompson) Date: Thu, 03 Jan 2002 02:11:17 +0000 Subject: ANN: Python 2.2 Port to Sharp Zaurus Message-ID: <3C33BDC5.33EB5373@river-bank.demon.co.uk> The port of Python to the Sharp Zaurus PDA has been updated to Python 2.2 and is available for download at http://www.river-bank.demon.co.uk/software/Zaurus. What's there should work fine, but not all modules have been ported. The modules have been packaged into related "collections". Some modules have been slightly (and transparently) changed to reduce inter-module dependencies. The selection of modules has been based on the assumption that the Zaurus will be used as a client rather than a server or development platform. All to do with reducing memory footprint. Phil From resolve at repose.REMOVE.cx Thu Jan 3 03:16:49 2002 From: resolve at repose.REMOVE.cx (Damien Elmes) Date: Thu, 03 Jan 2002 02:16:49 GMT Subject: Extension libraries, spawned threads, and the global interpreter lock Message-ID: <864rm4dvqd.fsf@reflex.repose.cx> Hi folks, If I haven't already scared you off with the subject field, please humour me. I'm still in the beginner to intermediate stages with Python, and I apologise if the answer to this is in an obvious place. Basically I'm wrapping an xlib based library that was written by a third party. I have access to the source. This library spawns two threads to deal with certain xlib events. The call chain to do this is roughly: thewrapper() -> (in C) wrapper_ext_module_init() -> (in C) xlib_stuff_init() and it's in that third function that two threads are spawned. Now, from my understanding of the docs, the C extension module function which I've created operates under a global interpreter lock. But the two threads spawned would not (as the lock would be cleared when the spawning function returned). The problem I'm getting is that C-c when running from the interactive interpreter is killing python, like so: reflex$ python Python 2.1.1+ (#1, Dec 21 2001, 01:01:30) [GCC 2.95.4 20011006 (Debian prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import pyosd >>> >>> # this code runs the extension module which spawns the threads >>> p = pyosd.osd(pyosd.default_font, "white") >>> >>> # now we hit C-c KeyboardInterrupt >>> KeyboardInterrupt >>> KeyboardInterrupt >>> >>> # and again KeyboardInterrupt KeyboardInterrupt KeyboardInterrupt >>> Segmentation fault I get similar results when not using the readline module. If, however, I create a file which sleeps in a try: except block, and I catch the keyboard interrupt exception, these problems don't surface. So my question is: am I correct in thinking it's a problem with the GIL not being held in the other threads? If so, would explicitly grabbing and freeing the lock in the xlib threads solve the problem? If so, is there a better way? I'd prefer not to have to delve into their source. I hope I've been coherent. If anyone could offer any suggestions, I'd really appreciate it. -- Damien Elmes resolve at repose.REMOVE.cx Usenet replies are fine, please parse my email address if you want to send directly. From martin at v.loewis.de Thu Jan 3 04:16:03 2002 From: martin at v.loewis.de (Martin v. Loewis) Date: 03 Jan 2002 04:16:03 +0100 Subject: Extension libraries, spawned threads, and the global interpreter lock References: <864rm4dvqd.fsf@reflex.repose.cx> Message-ID: Damien Elmes writes: > So my question is: am I correct in thinking it's a problem with the GIL not > being held in the other threads? Probably not. Do the other threads ever call back into Python code, or invoke Python interpreter API? If so, they need to hold the lock while doing so. If they are completely separate, they are not concerned with the GIL. > If so, would explicitly grabbing and freeing the lock in the xlib > threads solve the problem? At what time would you free it? As long as one of the threads holds the lock, your main thread will not advance. More likely, you have a problem with signal handlers. Python installs a SIGINT handler, to generate the KeyboardInterrupt. This can break badly if the signal handler is not delivered to a Python thread, or more specifically, to the main Python thread. You have a number of choices: - don't install the SIGINT handler, but live with the default SIGINT processing (i.e. process termination) - block SIGINT in the other threads. How to do this much depends on your operating system. - find out why delivering the signal to another process causes a problem (it *may* be that you have to get the GIL inside Modules/signalmodule.c:signal_handler; in theory, the current code is supposed to deal with this case, but perhaps it breaks for some reason, e.g. if getpid() returns the same value in all threads). Regards, Martin From resolve at repose.REMOVE.cx Thu Jan 3 07:30:02 2002 From: resolve at repose.REMOVE.cx (Damien Elmes) Date: Thu, 03 Jan 2002 06:30:02 GMT Subject: Extension libraries, spawned threads, and the global interpreter lock References: <864rm4dvqd.fsf@reflex.repose.cx> Message-ID: <86r8p8rlos.fsf@reflex.repose.cx> Thanks for your feedback, Martin. More below. martin at v.loewis.de (Martin v. Loewis) writes: > Damien Elmes writes: > > > So my question is: am I correct in thinking it's a problem with the GIL not > > being held in the other threads? > > Probably not. Do the other threads ever call back into Python code, or > invoke Python interpreter API? If so, they need to hold the lock while > doing so. If they are completely separate, they are not concerned with > the GIL. They're entirely seperate, and thus, I thought, safe from the GIL. This problem appears to crop up when multiple threads receive SIGINT at once. > > If so, would explicitly grabbing and freeing the lock in the xlib > > threads solve the problem? > > At what time would you free it? As long as one of the threads holds > the lock, your main thread will not advance. Thought of that while lying in bed last night :-) Silly of me to mention it in the first place. > More likely, you have a problem with signal handlers. Python installs > a SIGINT handler, to generate the KeyboardInterrupt. This can break > badly if the signal handler is not delivered to a Python thread, or > more specifically, to the main Python thread. > > You have a number of choices: > > - don't install the SIGINT handler, but live with the default SIGINT > processing (i.e. process termination) The problem is that the interactive interpreter installs a sigint handler, which is sort of rude for a library to remove when it's instantianted. I think the 'default' behavior for interactive use is installed once per statement anyway, so if I were to try modify the behavior, it wouldn't change this problem. > - block SIGINT in the other threads. How to do this much depends on > your operating system. Maybe this is worth looking into. So far I've been able to determine: * when this class calls the backend stuff, two threads are forked, to a total of three "processes" in a ps listing. * sending an INT signal to any one of them yields the correct behavior. * sending an INT signal to the main program thread, and any of the other two (but only one of the other two) yields the correct behavior * extmodulethread1 + extmodulethread2 yields the crash. This problem is compounded by the behaviour of the interactive interpreter - a C-c seemingly generates an interrupt signal to each of the threads instead of just the main one. This problem also doesn't seem to crop up when catching a keyboard error in my own code, which leads me to believe the erroneous interaction is with exception stuff - but as I understand it, that's all been thread-safe for a long time. This behaviour is really perplexing me :-) -- Damien Elmes resolve at repose.cx From mwh at python.net Thu Jan 3 12:04:20 2002 From: mwh at python.net (Michael Hudson) Date: Thu, 3 Jan 2002 11:04:20 GMT Subject: Extension libraries, spawned threads, and the global interpreter lock References: <864rm4dvqd.fsf@reflex.repose.cx> <86r8p8rlos.fsf@reflex.repose.cx> Message-ID: Damien Elmes writes: > The problem is that the interactive interpreter installs a sigint > handler, which is sort of rude for a library to remove when it's > instantianted. I think the 'default' behavior for interactive use is > installed once per statement anyway, so if I were to try modify the > behavior, it wouldn't change this problem. If the interactiuve interpreter is involved, you get to fight readline too. Good luck. You could try using a build without readline -- painful to use, but it might just help. Cheers, M. From resolve at repose.REMOVE.cx Thu Jan 3 14:57:32 2002 From: resolve at repose.REMOVE.cx (Damien Elmes) Date: Thu, 03 Jan 2002 13:57:32 GMT Subject: Extension libraries, spawned threads, and the global interpreter lock References: <864rm4dvqd.fsf@reflex.repose.cx> <86r8p8rlos.fsf@reflex.repose.cx> Message-ID: <86u1u3sfjd.fsf@reflex.repose.cx> Michael Hudson writes: > Damien Elmes writes: > > > The problem is that the interactive interpreter installs a sigint > > handler, which is sort of rude for a library to remove when it's > > instantianted. I think the 'default' behavior for interactive use is > > installed once per statement anyway, so if I were to try modify the > > behavior, it wouldn't change this problem. > > If the interactiuve interpreter is involved, you get to fight readline too. > > Good luck. Thanks :-) > You could try using a build without readline -- painful to use, but it > might just help. That stopped the segfaults from occuring - instead of three KeyboardInterrupt messages appearing at once, only one does. Does it seem likely the problem lies in the behavior of the readline module? I'm pretty it's just some silly oversight on my behalf, but I can't see why this is happening, as AFAIK, the signals should only be being directed to the main thread I've done PyEval_InitThreads(); in the extension module before any threads are forked, but these threads are created by the pthread library. I have no desire to access python functions from them, I just figured they may need an interpreter lock when they get a signal. I'll keep on hunting. Thanks for your patience. -- Damien Elmes resolve at repose.cx From resolve at repose.REMOVE.cx Mon Jan 7 19:27:25 2002 From: resolve at repose.REMOVE.cx (Damien Elmes) Date: Mon, 07 Jan 2002 18:27:25 GMT Subject: Extension libraries, spawned threads, and the global interpreter lock (resolved) References: <864rm4dvqd.fsf@reflex.repose.cx> <86r8p8rlos.fsf@reflex.repose.cx> <86u1u3sfjd.fsf@reflex.repose.cx> Message-ID: <86sn9iqbbm.fsf_-_@reflex.repose.cx> Hi Folks, Just thought I'd write and offer up the solution to this problem. In short, the readline module was causing weird behavior when a C-c was received in the interactive interpreter. Instead of the SIGINT handler being called once, it appeared to be being called once for each thread. I do not know if that is a bug or not - a non-readline enabled interpreter seems to function correctly. Anyway, the fix was to wrap the call to the threaded library, blocking the INT signal, so that to library's threads inherited the blocked behavior. This also meant I didn't have to change the threaded library, which didn't really seem appropriate here. The magical code is basically of the form: sigset_t newset; ... sigemptyset(&newset); sigaddset(&newset, SIGINT); sigprocmask(SIG_BLOCK, &newset, NULL); osd = xosd_init(fontdesc, colour, timeout, osd_pos, offset, shadow); sigprocmask(SIG_UNBLOCK, &newset, NULL); Thanks to those who jumped in and led me in the right direction. Damien Elmes writes: > Michael Hudson writes: > > > Damien Elmes writes: > > > > > The problem is that the interactive interpreter installs a sigint > > > handler, which is sort of rude for a library to remove when it's > > > instantianted. I think the 'default' behavior for interactive use is > > > installed once per statement anyway, so if I were to try modify the > > > behavior, it wouldn't change this problem. > > > > If the interactiuve interpreter is involved, you get to fight readline too. > > > > Good luck. > > Thanks :-) > > > You could try using a build without readline -- painful to use, but it > > might just help. > > That stopped the segfaults from occuring - instead of three KeyboardInterrupt > messages appearing at once, only one does. > > Does it seem likely the problem lies in the behavior of the readline module? > I'm pretty it's just some silly oversight on my behalf, but I can't see why > this is happening, as AFAIK, the signals should only be being directed to the > main thread > > I've done > > PyEval_InitThreads(); > > in the extension module before any threads are forked, but these threads are > created by the pthread library. I have no desire to access python functions > from them, I just figured they may need an interpreter lock when they get a > signal. > > I'll keep on hunting. Thanks for your patience. -- Damien Elmes resolve at repose.cx From tyler.w.wilson at gte.net Thu Jan 3 03:43:39 2002 From: tyler.w.wilson at gte.net (Tyler W. Wilson) Date: Thu, 03 Jan 2002 02:43:39 GMT Subject: New module for Python Message-ID: I am learning Pythin right now, and would like to write a new extension for the language, for both practive doing so, and to give something back to the community. I have many years of experience writing Windows code (esp. multimedia stuf), so perhaps something Windows-specific. Though I like to write code that can be portable. So, I am looking for input on what kind of module I should write. Right now I am thinking of a generic DirectShow module that would allow the playback of any media-type that DS supports. Pretty simple to do, but I did a search and saw that there is a package called snack that may provide the functionality I am thinking about. Any thoughts, comments, etc welcome. Thanks, Tyler Wilson From bbollenbach at home.com Thu Jan 3 04:28:40 2002 From: bbollenbach at home.com (Brad Bollenbach) Date: Thu, 03 Jan 2002 03:28:40 GMT Subject: New module for Python References: Message-ID: "Tyler W. Wilson" wrote in message news:vzPY7.1410$Tc4.180525 at dfiatx1-snr1.gtei.net... > I am learning Pythin right now, and would like to write a new extension for > the language, for both practive doing so, and to give something back to the > community. I have many years of experience writing Windows code (esp. > multimedia stuf), so perhaps something Windows-specific. Though I like to > write code that can be portable. > > So, I am looking for input on what kind of module I should write. Right now Port Perl's Mail::Audit into Python code. I'd love to see that. :) I find pycmail's interface freakishly weird, where Mail::Audit (by the excellent Simon Cozens) seems much more intuitive. Unfortunately this isn't Windows-specific, nor even really useful to the Average Windows Hacker, but hey, better to write something that will make your life easier (if you use Unix or a Unix-like OS by any chance). If you're really looking for something to write, believe me, if you concentrate hard enough on being lazy, you'll figure out something you can write that'll make YOU as happy as it'll make others. Hope that helps to get you started thinking of some ideas, Brad From krissepu at vip.fi Thu Jan 3 09:47:28 2002 From: krissepu at vip.fi (pekka niiranen) Date: Thu, 03 Jan 2002 08:47:28 GMT Subject: New module for Python References: Message-ID: <3C341AAF.1010805@vip.fi> Dear Sir, 1) Process Industry in moving to OPC in datacommunication: http://www.opcfoundation.org/ There exists a dll -file that enables one to write Visual Basic Interfaces to OPC -commands: http://www.opcfoundation.org/fp_07_down.htm It would be cool if one could do data queris from Python !!! - Pekka- Tyler W. Wilson wrote: >I am learning Pythin right now, and would like to write a new extension for >the language, for both practive doing so, and to give something back to the >community. I have many years of experience writing Windows code (esp. >multimedia stuf), so perhaps something Windows-specific. Though I like to >write code that can be portable. > >So, I am looking for input on what kind of module I should write. Right now >I am thinking of a generic DirectShow module that would allow the playback >of any media-type that DS supports. Pretty simple to do, but I did a search >and saw that there is a package called snack that may provide the >functionality I am thinking about. > >Any thoughts, comments, etc welcome. > >Thanks, >Tyler Wilson > > > From syver-en+usenet at online.no Thu Jan 3 13:03:29 2002 From: syver-en+usenet at online.no (Syver Enstad) Date: 03 Jan 2002 13:03:29 +0100 Subject: New module for Python References: Message-ID: "Tyler W. Wilson" writes: > I am thinking of a generic DirectShow module that would allow the > playback > > of any media-type that DS supports. Pretty simple to do, but I did a > search > > and saw that there is a package called snack that may provide the > functionality I am thinking about. Snack provides much, that's true... My two cents, do it anyway! You have an idea, the functionality would be cool and you would learn python really good. -- Vennlig hilsen Syver Enstad From tyler.w.wilson at gte.net Fri Jan 4 16:29:28 2002 From: tyler.w.wilson at gte.net (Tyler W. Wilson) Date: Fri, 04 Jan 2002 15:29:28 GMT Subject: New module for Python References: Message-ID: Thanks. I decided to do the DirectShow Module anyway. I know it, and there is enough to it that as you, I will learn a lot. So, I have the basic functionality working: you can play any media type that your local machine can play. I am going to build a simple Tk MediaPlayer interface, and try to get status notification working. So, the next question: what is the best way to get it out into the world? Sourceforge, Vaults of Parnassus, or my own home page (I guess I shoudl get one)? Thanks all, Tyler "Syver Enstad" wrote in message news:usn9nbq0e.fsf at online.no... > "Tyler W. Wilson" writes: > > > I am thinking of a generic DirectShow module that would allow the > > playback > > > > of any media-type that DS supports. Pretty simple to do, but I did a > > search > > > > and saw that there is a package called snack that may provide the > > functionality I am thinking about. > > Snack provides much, that's true... My two cents, do it anyway! You > have an idea, the functionality would be cool and you would learn > python really good. > -- > > Vennlig hilsen > > Syver Enstad From syver-en+usenet at online.no Fri Jan 4 19:07:56 2002 From: syver-en+usenet at online.no (Syver Enstad) Date: 04 Jan 2002 19:07:56 +0100 Subject: New module for Python References: Message-ID: "Tyler W. Wilson" writes: > So, I have the basic functionality working: you can play any media > type that your local machine can play. I am going to build a simple > Tk MediaPlayer interface, and try to get status notification > working. Cool > > So, the next question: what is the best way to get it out into the > world? > Sourceforge, Vaults of Parnassus, or my own home page (I guess I > shoudl get > one)? All of them, but first get it out somewhere fast so we can look at it. Maybe your own homepage would be fastest here? Post the url soon! -- Vennlig hilsen Syver Enstad From amackay at radical.ca Thu Jan 3 04:38:48 2002 From: amackay at radical.ca (Angus Mackay) Date: Wed, 02 Jan 2002 19:38:48 -0800 Subject: readline completion for python 2.1 on win32? Message-ID: <3C33D248.9231995A@radical.canada> I really want to get my hands on a copy of python 2.1 for win32 with working readline completion. I have found a nice readline port to win32 that works under MinGW (mingw32) and a readline replacement module that only provides line editing (no completion). c'mon people does nobody actually use python 2.1 under win32? life sucks without completion. also I have found a python module for python1.5 that uses this readline and works. why no 2.1 module? the port I speak of is: http://www.is.lg.ua/~paul/devel/readline/ cheers, Angus. From altis at semi-retired.com Thu Jan 3 07:32:30 2002 From: altis at semi-retired.com (Kevin Altis) Date: Wed, 2 Jan 2002 22:32:30 -0800 Subject: readline completion for python 2.1 on win32? References: <3C33D248.9231995A@radical.canada> Message-ID: Are you talking about command-completion in the interpreter? If so, make your life even better and use the PyCrust shell. http://sourceforge.net/projects/pycrust PyCrust supports auto-completion, shows tooltips, and also has a Namespace Viewer. PyCrust is included in the latest wxPython release (2.3.2.1) and is used by PythonCard too. http://www.wxpython.org/ http://pythoncard.sourceforge.net/ ka "Angus Mackay" wrote in message news:3C33D248.9231995A at radical.canada... > I really want to get my hands on a copy of python 2.1 for win32 with working > readline completion. I have found a nice readline port to win32 that works under > MinGW (mingw32) and a readline replacement module that only provides line > editing (no completion). > > c'mon people does nobody actually use python 2.1 under win32? life sucks without > completion. > > also I have found a python module for python1.5 that uses this readline and > works. why no 2.1 module? > > the port I speak of is: > http://www.is.lg.ua/~paul/devel/readline/ > > cheers, Angus. From mwh at python.net Thu Jan 3 12:05:42 2002 From: mwh at python.net (Michael Hudson) Date: Thu, 3 Jan 2002 11:05:42 GMT Subject: readline completion for python 2.1 on win32? References: <3C33D248.9231995A@radical.canada> Message-ID: Angus Mackay writes: > I really want to get my hands on a copy of python 2.1 for win32 with > working readline completion. I have found a nice readline port to > win32 that works under MinGW (mingw32) and a readline replacement > module that only provides line editing (no completion). Cygwin Python has readline support. It Just Works, as far as I can tell. Cheers, M. From amackay at radical.ca Thu Jan 3 19:54:12 2002 From: amackay at radical.ca (Angus Mackay) Date: Thu, 03 Jan 2002 10:54:12 -0800 Subject: readline completion for python 2.1 on win32? References: <3C33D248.9231995A@radical.canada> Message-ID: <3C34A8D4.E96F81FD@radical.ca> but cygwin is flaky, is there no MinGW version of python? Michael Hudson wrote: > Cygwin Python has readline support. It Just Works, as far as I can tell. > From gh_pythonlist at gmx.de Thu Jan 3 21:04:28 2002 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-15?Q?H=E4ring?=) Date: Thu, 3 Jan 2002 21:04:28 +0100 Subject: readline completion for python 2.1 on win32? In-Reply-To: <3C34A8D4.E96F81FD@radical.ca> References: <3C33D248.9231995A@radical.canada> <3C34A8D4.E96F81FD@radical.ca> Message-ID: <20020103200427.GB2080@lilith.hqd-internal> Le 03/01/02 ? 10:54, Angus Mackay ?crivit: > but cygwin is flaky, is there no MinGW version of python? Yes, the regular binary download from python.org. Only it's compiled with Visual C++ instead of mingw32. It's possible to compile Python with mingw32 if you write a custom Makefile. It would be even better to have the mingw32 build integrated in the autoconf based build process, but that's serious work. It's somewhere in the middle of my opensource-should-be-done-someday todo list. > Michael Hudson wrote: > > Cygwin Python has readline support. It Just Works, as far as I can tell. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From orosz at shaw.ca Thu Jan 3 07:44:29 2002 From: orosz at shaw.ca (Youbtheboss) Date: Wed, 02 Jan 2002 23:44:29 -0700 Subject: (no subject) Message-ID: <1704200214364429340@shaw.ca> **You are receiving this information as you either requested this or posted a link to one of my many FFA sites. Kindly reply with 'Remove' in subject to be deleted from mailing** You've expressed interest in starting a home-based business. If I could show you a way to earn an additional $12,000 (or more) per year, WOULD YOU BE INTERESTED? If you were to receive all the necessary tools and training required, WOULD YOU BE INTERESTED? If you were able to FIRE your BOSS, WOULD YOU BE INTERESTED? If you were able to take your children to your office everyday, WOULD YOU BE INTERESTED? If you said YES to any or all of the above, wouldn't it be worth checking out? Please reply with 'YES I'M INTERESTED!' in the subject line to mailto:youbtheboss at shaw.ca for all the details! No pressure, you will be given the information either via email or telephone, your choice. @@@@@@@@@@@@@@@@@@@@@@@@@@@ Build Residual Income for Your Retirement! http://www.youbtheboss.com New Year's #1 Resolution Answered Here! Loss Weight...& Get Paid For It! http://www.ezgethealthy.com Do You Shop Online? Why Not Get Paid for Your Shopping! FREE MEMBERSHIP!! http://www.bigcoop.com/SO134590 @@@@@@@@@@@@@@@@@@@@@@@@@@@ From issac at myfirstlink.net Thu Jan 3 08:53:43 2002 From: issac at myfirstlink.net (Issac) Date: Thu, 3 Jan 2002 01:53:43 -0600 Subject: ANN: dirview and dragdrop (pyqt demos) Message-ID: <00ae01c1942b$c47f5bb0$6401a8c0@mojave> Here are a couple of drag and drop demos that I ported to PyQt from the Qt C++ distribution. By the way, are these messages too big? Is there a convenient place to post little things like this? The sourceforge python foundry doesn't seem to support tarballs and I don't really want to make a whole new sourceforge project for each little program. Issac -------------- next part -------------- A non-text attachment was scrubbed... Name: dirview.tgz Type: application/x-compressed Size: 4550 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: dragdrop.tgz Type: application/x-compressed Size: 9343 bytes Desc: not available URL: From logiplexsoftware at earthlink.net Thu Jan 3 18:13:31 2002 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Thu, 3 Jan 2002 09:13:31 -0800 Subject: ANN: dirview and dragdrop (pyqt demos) In-Reply-To: <00ae01c1942b$c47f5bb0$6401a8c0@mojave> References: <00ae01c1942b$c47f5bb0$6401a8c0@mojave> Message-ID: <20020103091331.14c9824a.logiplexsoftware@earthlink.net> On Thu, 3 Jan 2002 01:53:43 -0600 "Issac" wrote: > Here are a couple of drag and drop demos that I ported > to PyQt from the Qt C++ distribution. > > By the way, are these messages too big? Is there a convenient place > to post little things like this? The sourceforge python foundry > doesn't seem to support tarballs and I don't really want to > make a whole new sourceforge project for each little program. You could submit them to the Vaults of Parnassus: www.vex.net/parnassus/ -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From issac at myfirstlink.net Thu Jan 3 20:32:16 2002 From: issac at myfirstlink.net (Issac) Date: Thu, 3 Jan 2002 13:32:16 -0600 Subject: ANN: dirview and dragdrop (pyqt demos) References: <00ae01c1942b$c47f5bb0$6401a8c0@mojave> <20020103091331.14c9824a.logiplexsoftware@earthlink.net> Message-ID: <007d01c1948d$5cc330c0$6401a8c0@mojave> > On Thu, 3 Jan 2002 01:53:43 -0600 > "Issac" wrote: > > > Here are a couple of drag and drop demos that I ported > > to PyQt from the Qt C++ distribution. > > > > By the way, are these messages too big? Is there a convenient place > > to post little things like this? The sourceforge python foundry > > doesn't seem to support tarballs and I don't really want to > > make a whole new sourceforge project for each little program. > > You could submit them to the Vaults of Parnassus: > > www.vex.net/parnassus/ OK, I tried this, but it looks like the Vaults require a link to some other place where the programs are stored. Why not just allow uploading (sufficiently small) programs? Issac > > > -- > Cliff Wells > Software Engineer > Logiplex Corporation (www.logiplex.net) > (503) 978-6726 x308 > (800) 735-0555 x308 > > -- > http://mail.python.org/mailman/listinfo/python-list From logiplexsoftware at earthlink.net Thu Jan 3 21:38:14 2002 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Thu, 3 Jan 2002 12:38:14 -0800 Subject: ANN: dirview and dragdrop (pyqt demos) In-Reply-To: <007d01c1948d$5cc330c0$6401a8c0@mojave> References: <00ae01c1942b$c47f5bb0$6401a8c0@mojave> <20020103091331.14c9824a.logiplexsoftware@earthlink.net> <007d01c1948d$5cc330c0$6401a8c0@mojave> Message-ID: <20020103123814.33b31186.logiplexsoftware@earthlink.net> On Thu, 3 Jan 2002 13:32:16 -0600 "Issac" wrote: > > On Thu, 3 Jan 2002 01:53:43 -0600 > > "Issac" wrote: > > > > > Here are a couple of drag and drop demos that I ported > > > to PyQt from the Qt C++ distribution. > > > > > > By the way, are these messages too big? Is there a convenient place > > > to post little things like this? The sourceforge python foundry > > > doesn't seem to support tarballs and I don't really want to > > > make a whole new sourceforge project for each little program. > > > > You could submit them to the Vaults of Parnassus: > > > > www.vex.net/parnassus/ > > OK, I tried this, but it looks like the Vaults require a link to some > other place where the programs are stored. Why not just allow > uploading (sufficiently small) programs? Hm. Perhaps you could create a SourceForge project that encompasses several smaller projects, for example "PyQt Demos". -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From bgfra at NOSPAM.hotmail.co Thu Jan 3 09:57:39 2002 From: bgfra at NOSPAM.hotmail.co (Franco) Date: 3 Jan 2002 08:57:39 GMT Subject: A tutorial for Database management Message-ID: Where can I find a good tutorial explaining from the beginning how to manage a database with Python? Thanks From andy47 at halfcooked.com Thu Jan 10 03:45:06 2002 From: andy47 at halfcooked.com (Andy Todd) Date: Thu, 10 Jan 2002 02:45:06 +0000 (UTC) Subject: A tutorial for Database management References: Message-ID: Franco wrote in news:a116e3$kq$1 at wanadoo.fr: > Where can I find a good tutorial explaining from the beginning how to > manage a database with Python? > > Thanks Franco, If you are talking about relational database management systems (Oracle, Sybase, DB2, SQL Server, etc.) you first point of call should be the database SIG (http://www.python.org/sigs/db-sig/), which should lead you to the database topic guide (http://www.python.org/topics/database). This should, at least, get you started. In particular take a look at the DB-API spec v2.0 as most of the database modules for Python adhere to it. If you want to store bits and pieces from your Python programs at the file system but don't need the overhead of a full relational database you should look at the pickle and shelve modules in the standard library (sections 3.14 and 3.17 of the Python Library Reference respectively). For a good intermediate solution, take a look at anydbm (section 7.8 of the Python Library Reference), which is also very well described in the 2nd Edition of "Programming Python" by Mark Lutz (http://www.oreilly.com/catalog/python2/) HTH, Andy -- Contents free posts a speciality From tatebll at aol.com Fri Jan 11 13:34:39 2002 From: tatebll at aol.com (Bill Tate) Date: 11 Jan 2002 04:34:39 -0800 Subject: A tutorial for Database management References: Message-ID: Franco wrote in message news:... > Where can I find a good tutorial explaining from the beginning how to > manage a database with Python? > > Thanks Franco, A little more information would be helpful. Is there a particular target environment (OS-wise)&/or DB vendor? Are there specific types of DBA activities you want to focus on or essentially the entire enchilada (backup, recovery, replication, security/user admin, scheduling, object permissions, etc., etc.)? Depending on what your circumstances are, you may be able to do an enormous amount of DBA stuff from within Python right away. In other cases, it may require creating an extension module or adding to an existing extension module in order to get the required functionality exposed from within Python. The best example of something available now is if you are using MS SQL Server and Mark Hammond's win32com module. MS's DTS, DMO, Replication, etc., services are available to you if you use win32com (presuming the requisite MSS COM dlls are also available). However, its more likely you will need to have MS documentation and/or DBA books on these services to be able to "orchestrate" things as opposed to "python specific documentation." I suspect you find that to be true of Oracle, Postgres, et.al, as well. If you are on the Unix side, I can imagine there are no shortage of folks who can provide useful insights on what's available or suggestions. Since each DB vendor has their own way of implementing DBA functionality, any more details you can shed on this would likely result in some clearer suggestions. cheers, Bill From jolsen at mailme.dk Thu Jan 3 10:45:14 2002 From: jolsen at mailme.dk (Jesper Olsen) Date: 3 Jan 2002 01:45:14 -0800 Subject: jython - extending with java Message-ID: Python is a really easy language to use, but for certain things not super fast. Hence, it is useful to be able to code certain things in other languages. Extending with C is realtively easy, but how about java? Is Jython the only way to do this? I have been looking a little at jython, and am a little disappointed with it. The distribution seems to be targeted mainly towards a WINDOWS platform (and not Linux). Also, it is quite slow... Is anyone using jython? Searching comp.python for jython brings up only posts; most recent is april 2001. Cheers Jesper From sholden at holdenweb.com Thu Jan 3 11:29:01 2002 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 3 Jan 2002 05:29:01 -0500 Subject: jython - extending with java References: Message-ID: <8qWY7.60908$a56.4778@atlpnn01.usenetserver.com> "Jesper Olsen" wrote in message news:cf0ad9fb.0201030145.18dbdc50 at posting.google.com... > Python is a really easy language to use, > but for certain things not super fast. > > Hence, it is useful to be able to code certain things > in other languages. > > Extending with C is realtively easy, > but how about java? > > Is Jython the only way to do this? > > I have been looking a little at jython, and am a little > disappointed with it. The distribution seems to be targeted > mainly towards a WINDOWS platform (and not Linux). > Also, it is quite slow... > > Is anyone using jython? Searching comp.python for jython brings up > only posts; most recent is april 2001. > Well, let's see, anything to help someone who's apparently never heard of Google :-) http://groups.google.com/groups?as_q=jython%20release&as_ugroup=comp.lang.py thon&lr=lang_en&hl=en The first post this search brings up is Finn Bock's December 12 (last year!) announcement of the Jython 2.1 beta. Can you take it from there? regards Steve -- http://www.holdenweb.com/ From aleax at aleax.it Thu Jan 3 11:30:46 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 3 Jan 2002 11:30:46 +0100 Subject: jython - extending with java References: Message-ID: "Jesper Olsen" wrote in message news:cf0ad9fb.0201030145.18dbdc50 at posting.google.com... > Python is a really easy language to use, > but for certain things not super fast. > > Hence, it is useful to be able to code certain things > in other languages. > > Extending with C is realtively easy, > but how about java? > > Is Jython the only way to do this? Of course not. See http://sourceforge.net/projects/jpe > I have been looking a little at jython, and am a little > disappointed with it. The distribution seems to be targeted > mainly towards a WINDOWS platform (and not Linux). ?! I don't know what you're talking about. I installed Jython 2.1 on Linux boxes (with Sunsoft's Java SDK 1.3) without a hitch. > Also, it is quite slow... Yes, so is everything Javaish in my experience. Apparently 1.4 of the SDK does make things a bit better wrt Jython. > Is anyone using jython? Searching comp.python for jython brings up > only posts; most recent is april 2001. Change your search engine. Using a good one, i.e. google: http://groups.google.com/groups?as_q=jython&as_ugroup=comp.lang.python&as_dr rb=b&as_mind=1&as_minm=12&as_miny=2001&as_maxd=3&as_maxm=1&as_maxy=2002&num= 20&hl=en gives me 84 hits -- these are posts in comp.lang.python mentioning jython since Dec 1, 2001 (i.e. in the last month). Clearly most jython-specific discussion takes place in its dedicated mailing lists, but jython discussion is also welcome here, of course. After all, jython IS Python! With Jython 2.1 final just released, and O'Reilly's "Essential Jython" due to hit the shelves shortly (and an excellent book, btw -- I'm biased by having technically reviewed it, but...), I wonder how anybody could happen to harbor such questions as "is anybody using jython" in their heads. Alex From graham.ashton at cis.co.uk Thu Jan 3 11:01:26 2002 From: graham.ashton at cis.co.uk (Graham Ashton) Date: 3 Jan 2002 02:01:26 -0800 Subject: Killing processes on win32 Message-ID: Hi. I've run into a bit of a brick wall when trying to kill a process on win98. I've read the killProcName.py script that comes with the win32 extensions, and have seen how it uses win32pdhutil to get a list of process IDs that can be passed into win32api.OpenProcess(). That would be great, if only I had the win32pdh library on this platform. When I import win32pdhutil I get an ImportError as win32pdh isn't found (I'm using 1.5.2c1. Yes, I know. Unfortunately it's way beyond my control). I don't know of any way to get a handle to a process other than passing a pid to win32api.OpenProcess(). I've not started this process from within the script. So what I'm looking for is an alternative way of killing a process. I've got kill.exe from the win98 resource kit, but it doesn't kill this particular process. :( Any thoughts? -- Graham From SSchukat at dspace.de Thu Jan 3 11:29:09 2002 From: SSchukat at dspace.de (Stefan Schukat) Date: Thu, 3 Jan 2002 11:29:09 +0100 Subject: Killing processes on win32 Message-ID: <84257D042AA7D411B3F700D0B7DB9B7C13AFCD@PDC-DSPACE> Hi, the pdh (performance data helper) library is only available for NT 2k and I think XP. Under Win9X you must use the "Toolhelp32" functions to find the process id for a process. But this api hasn't been wrapped or announced for Python until now. So you are out of luck getting a process id under Win9x. To kill a process under win9x you should write a pyd to get the process information. Stefan > -----Original Message----- > From: graham.ashton at cis.co.uk [mailto:graham.ashton at cis.co.uk] > Sent: Thursday, January 03, 2002 11:01 AM > To: python-list at python.org > Subject: Killing processes on win32 > > > Hi. > > I've run into a bit of a brick wall when trying to kill a process on > win98. I've read the killProcName.py script that comes with the win32 > extensions, and have seen how it uses win32pdhutil to get a list of > process IDs that can be passed into win32api.OpenProcess(). > > That would be great, if only I had the win32pdh library on this > platform. When I import win32pdhutil I get an ImportError as win32pdh > isn't found (I'm using 1.5.2c1. Yes, I know. Unfortunately it's way > beyond my control). > > I don't know of any way to get a handle to a process other than > passing a pid to win32api.OpenProcess(). I've not started this process > from within the script. > > So what I'm looking for is an alternative way of killing a process. > I've got kill.exe from the win98 resource kit, but it doesn't kill > this particular process. :( > > Any thoughts? > > -- > Graham > -- > http://mail.python.org/mailman/listinfo/python-list > From graham.ashton at cis.co.uk Thu Jan 3 14:20:57 2002 From: graham.ashton at cis.co.uk (Graham Ashton) Date: 3 Jan 2002 05:20:57 -0800 Subject: Killing processes on win32 References: Message-ID: Stefan Schukat wrote in message news:... > the pdh (performance data helper) library is only available for > NT 2k and I think XP. > > [snip] > > To kill a process under win9x you should write a pyd to get the > process information. Thanks for the (impressively speedy) response. I'm now off to find somebody with a copy of MSVC++. -- Graham From db3l at fitlinxx.com Fri Jan 4 00:13:22 2002 From: db3l at fitlinxx.com (David Bolen) Date: 03 Jan 2002 18:13:22 -0500 Subject: Killing processes on win32 References: Message-ID: graham.ashton at cis.co.uk (Graham Ashton) writes: > Thanks for the (impressively speedy) response. I'm now off to find > somebody with a copy of MSVC++. Why not just stick with a standalone utility (we use pskill from sysinternals)? Note that you mentioned that 'kill' from the resource kit won't kill the process. If that's the case, the odds are good you won't be able to via the other methods either, since they're all going to eventually boil down to the same underlying API call. It may just be wedged. -- -- 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 dgallion1 at yahoo.com Thu Jan 3 22:16:04 2002 From: dgallion1 at yahoo.com (Darrell) Date: 3 Jan 2002 13:16:04 -0800 Subject: Killing processes on win32 References: Message-ID: There are versions of ps and kill for windows. I use a pipe and parse the return values. We avoid using Win32 stuff to remain cross platform. --Darrell graham.ashton at cis.co.uk (Graham Ashton) wrote in message news:... > > So what I'm looking for is an alternative way of killing a process. > I've got kill.exe from the win98 resource kit, but it doesn't kill > this particular process. :( > > Any thoughts? From l8051 at portugalmail.com Thu Jan 3 11:03:58 2002 From: l8051 at portugalmail.com (l8051 at portugalmail.com) Date: Thu, 03 Jan 2002 05:03:58 -0500 Subject: IMAGING! THE UNTIMATE ORGANIZER... Message-ID: <000063686eed$00005fed$00002cfc@recife.net> An HTML attachment was scrubbed... URL: From bas.vangils at home.nl Thu Jan 3 11:44:09 2002 From: bas.vangils at home.nl (Bas van Gils) Date: Thu, 3 Jan 2002 11:44:09 +0100 Subject: sockets Message-ID: <20020103104409.GA18403@kub.nl> Hi I am building a `proof of concept' for my final thesis. This involves some socket-programming. I was new to this subject so I read some man pages and the relevant chapters from "Programming Python" (2nd edition). Here's what I came up with (in interactive mode): >>> from socket import * >>> sockobj = socket(AF_INET,SOCK_STREAM) >>> sockobj.connect( ("kubsuw.kub.nl",7124) ) >>> sockobj.recv(1024) 'Welcome to the Tagdemo server.\n' >>> sockobj.send("Dit is een test .\n") 18 >>> data = sockobj.recv(1024) >>> print data Dit//NNP is/VBZ een//RB test/VB ./. Since this worked fine I moved it to a script: from socket import * sockobj = socket(AF_INET,SOCK_STREAM) sockobj.connect( ("kubsuw.kub.nl",7124) ) # the server sends a welcome-mesg sockobj.recv(1024) # send a test-line to the tagger # receive the data and print it sockobj.send("Dit is een test .\\n") data = sockobj.recv(4096) print data # close the socket sockobj.close() print "end" However, that didn't word: bas at kubstu2:~$ python c2.py Welcome to the Tagdemo server. Dit end I found this rather odd.... I asked around with my collegues but they couldn't help out. Anyone on the list have a suggestion? many thanx in advance Bas -- Bas van Gils - http://members.home.nl/bas.vangils Build a system that even a fool can use, and only a fool will want to use it. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From aleax at aleax.it Thu Jan 3 14:10:36 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 3 Jan 2002 14:10:36 +0100 Subject: sockets References: Message-ID: "Bas van Gils" wrote in message news:mailman.1010054884.11667.python-list at python.org... [text ended up as a text-attachment so it's hard to reply to it. Anyway...]: Bas did, interactively: >>> sockobj.send("Dit is een test .\n") 18 >>> data = sockobj.recv(1024) >>> print data Dit//NNP is/VBZ een//RB test/VB ./. here, as he manually entered the "data = " &c statement, time passed, so no doubt the server had time to send the whole response. Then, he tried to put this in a script: sockobj.send("Dit is een test .\\n") data = sockobj.recv(4096) print data but then data was only bound to: Welcome to the Tagdemo server. Dit where the first part is something the server sent "earlier". Finally, Bas asks: """ I found this rather odd.... I asked around with my collegues but they couldn't help out. Anyone on the list have a suggestion? """ Remember socket-level network interactions take time, and the stream is sent in arbitrary chunks. You just cannot "bet" that a single recv call will give you all that you expect has been sent up to that point: if you make your recv call fast enough you may get one byte or two or 20, with more still to come -- and nothing in TCP/IP per se tells you HOW MUCH is "still to come". When you use module socket interactively, you insert human delays which slow things down to where such problems very rarely show up (unless the server is horribly busy, the line near-dead, etc:-). You need to be able to "parse" the data you're receiving in order to know when a "meaningful unit" of such data is done. For example, you may want to "receive up to the first \n", knowing that a '\n' IS going to come. Then, e.g.: def getlinefrom(sockobj): pieces = [] while 1: piece = sockobj.recv(1024) pieces.append(piece) if piece.count('\n'): break return ''.join(pieces) This is very rough, but, I hope, still a useful pointer. Either the data has a terminating-indication, or before the data comes some header telling how big the data is going to be. You also need to handle and gracefully deal with exceptional situations such as the line going down in mid-stream, ending the data prematurely. Alex From cliechti at gmx.net Thu Jan 3 14:12:54 2002 From: cliechti at gmx.net (Chris Liechti) Date: 3 Jan 2002 14:12:54 +0100 Subject: sockets References: Message-ID: Bas van Gils wrote in news:mailman.1010054884.11667.python-list at python.org: > I am building a `proof of concept' for my final thesis. This involves > some socket-programming. I was new to this subject so I read some man > pages and the relevant chapters from "Programming Python" (2nd edition). > Here's what I came up with (in interactive mode): > > >>> from socket import * > >>> sockobj = socket(AF_INET,SOCK_STREAM) > >>> sockobj.connect( ("kubsuw.kub.nl",7124) ) > >>> sockobj.recv(1024) > 'Welcome to the Tagdemo server.\n' > >>> sockobj.send("Dit is een test .\n") > 18 > >>> data = sockobj.recv(1024) > >>> print data > Dit//NNP is/VBZ een//RB test/VB ./. > > Since this worked fine I moved it to a script: > > from socket import * > > sockobj = socket(AF_INET,SOCK_STREAM) > sockobj.connect( ("kubsuw.kub.nl",7124) ) > > # the server sends a welcome-mesg > sockobj.recv(1024) > > # send a test-line to the tagger > # receive the data and print it > sockobj.send("Dit is een test .\\n") thats not the same as above: look at "\n" > data = sockobj.recv(4096) this receives up to 4096 bytes but it can also be only one.if you wanna be sure that you have the entire line, receive in a loop util you get "\n". you could also read until the connection is terminated from the server or use a simple protocol. > print data > > # close the socket > sockobj.close() > print "end" > > However, that didn't word: > > bas at kubstu2:~$ python c2.py > Welcome to the Tagdemo server. > > Dit > end > > I found this rather odd.... I asked around with my collegues but they > couldn't help out. Anyone on the list have a suggestion? > > many thanx in advance > > Bas > -- Chris From jason at jorendorff.com Thu Jan 3 18:04:38 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Thu, 3 Jan 2002 11:04:38 -0600 Subject: sockets In-Reply-To: <20020103104409.GA18403@kub.nl> Message-ID: > Since this worked fine I moved it to a script: > > from socket import * > > sockobj = socket(AF_INET,SOCK_STREAM) > sockobj.connect( ("kubsuw.kub.nl",7124) ) > > # the server sends a welcome-mesg > sockobj.recv(1024) > > # send a test-line to the tagger > # receive the data and print it > sockobj.send("Dit is een test .\\n") > data = sockobj.recv(4096) > print data > > # close the socket > sockobj.close() > print "end" > > However, that didn't word: > > bas at kubstu2:~$ python c2.py > Welcome to the Tagdemo server. > > Dit > end What's happening is probably: the server is sending the data in chunks, and you're calling recv() before all of the output has been received. You might want to try: # receive the data and print it sockfile = sockobj.makefile('r') data = sockfile.readline() print data The "readline()" method waits for the whole line of data to arrive. If that's not good enough, you can write a simple loop yourself, to gather data until you have all the data you want. ## Jason Orendorff http://www.jorendorff.com/ From laz at strakt.com Thu Jan 3 13:01:57 2002 From: laz at strakt.com (Fredrik Juhlin) Date: Thu, 3 Jan 2002 13:01:57 +0100 Subject: Meaningful use of "validate" and friends in Tkinter Message-ID: <20020103120157.GB672@strakt.com> Hello, I stumbled over the configurations "validate", "validatecommand" and friends in the Entry widget today. I tried to make something useful with it (eg, give the validation function the string to validate as an argument) but I found myself stumped. Has anyone been able to put them to good use, and if so, how? :) Thanks in advance, FJ From michael at stroeder.com Thu Jan 3 13:52:26 2002 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 03 Jan 2002 13:52:26 +0100 Subject: Accessing DB2 database on OS/390 host Message-ID: <3C34540A.AA498074@stroeder.com> HI! Any chance to access a IBM DB2 database running on a OS/390 host with a Python application running on Linux or Win32? Is it much effort? Ciao, Michael. From nospam at bigfoot.com Thu Jan 3 14:30:39 2002 From: nospam at bigfoot.com (Gillou) Date: Thu, 3 Jan 2002 14:30:39 +0100 Subject: Accessing DB2 database on OS/390 host References: <3C34540A.AA498074@stroeder.com> Message-ID: Get mxODBC from http://www.lemburg.com/files/python/mxODBC.html and an ODBC driver for DB2 and your client platform from your DB2 vendor. And you're about 3 or 4 lines of Python away from your data. HTH --Gillou "Michael Str?der" a ?crit dans le message news: 3C34540A.AA498074 at stroeder.com... > HI! > > Any chance to access a IBM DB2 database running on a OS/390 host > with a Python application running on Linux or Win32? Is it much > effort? > > Ciao, Michael. From michael at stroeder.com Thu Jan 3 13:55:57 2002 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Thu, 03 Jan 2002 13:55:57 +0100 Subject: Python 2.2 incompabilities Message-ID: <3C3454DD.8A24A9C1@stroeder.com> HI! I have some code which works just fine under Python 2.0 und 2.1 but is broken under Python 2.2. I glanced over various docs describing the changes in 2.2 but could not figure out which issues to examine first. Anyone having experience which code snippets are most likely incompatible in 2.2? Some kind of a incompability hit list... ;-) Ciao, Michael. From emile at fenx.com Thu Jan 3 16:50:06 2002 From: emile at fenx.com (Emile van Sebille) Date: Thu, 3 Jan 2002 07:50:06 -0800 Subject: Python 2.2 incompabilities References: <3C3454DD.8A24A9C1@stroeder.com> Message-ID: "Michael Str?der" wrote in message news:3C3454DD.8A24A9C1 at stroeder.com... > HI! > > I have some code which works just fine under Python 2.0 und 2.1 but > is broken under Python 2.2. I glanced over various docs describing > the changes in 2.2 but could not figure out which issues to examine > first. > > Anyone having experience which code snippets are most likely > incompatible in 2.2? Some kind of a incompability hit list... ;-) > Did you already see http://www.python.org/2.2/bugs.html -- Emile van Sebille emile at fenx.com --------- From guillaume.sauzon at caramail.com Thu Jan 3 14:15:20 2002 From: guillaume.sauzon at caramail.com (Guillaume SAUZON) Date: 3 Jan 2002 05:15:20 -0800 Subject: Zope external methods and Python: Access to object with a dot in the name Message-ID: <3b13b89e.0201030515.4b5635f2@posting.google.com> Hello, I using the great zope and the externals methods which is the python integration corresponding. From theses methods, you can access the zope objects through the self that is passed to that methods. You can also access the sub-directories of these objects using the dot. My method is called in the main folder and it contains an image folder: main | | | |-images | |-hello.jpg |-other.jpg So, if I try to access the hello.jpg image, to get the height, I will type something like: size = self.images.hello.jpg.height And here is my problem: There is no folder named hello in the folder images. Python tries to extend the name in the object hierarchy of course. Is it possible to do that? I think so cause zope is using the same internal representation for the objects no ? In python, can we have a class name containing a . ?? There should be a way. If you have any ideas !!! Guillaume From phd at phd.pp.ru Thu Jan 3 14:31:38 2002 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 3 Jan 2002 16:31:38 +0300 Subject: Zope external methods and Python: Access to object with a dot in the name In-Reply-To: <3b13b89e.0201030515.4b5635f2@posting.google.com>; from guillaume.sauzon@caramail.com on Thu, Jan 03, 2002 at 05:15:20AM -0800 References: <3b13b89e.0201030515.4b5635f2@posting.google.com> Message-ID: <20020103163138.A21186@phd.pp.ru> On Thu, Jan 03, 2002 at 05:15:20AM -0800, Guillaume SAUZON wrote: > |-images > | > |-hello.jpg > |-other.jpg > > So, if I try to access the hello.jpg image, to get the height, I will > type something like: > size = self.images.hello.jpg.height size = getattr(self, "hello.jpg").height Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From vdbergh at luc.ac.be Thu Jan 3 14:27:05 2002 From: vdbergh at luc.ac.be (Michel Van den Bergh) Date: Thu, 03 Jan 2002 14:27:05 +0100 Subject: SSL problem Message-ID: <3C345C29.604F674E@luc.ac.be> Hello, I am having a problem with opening an https connection with the following script: #!/usr/bin/python2 import sys, httplib, urllib, re, getopt,time h=httplib.HTTPSConnection('telemeter.telenet.be') h.set_debuglevel(1) h.request('GET','/be/telenet/afe/isps/TelemeterLogin.jsp') response=h.getresponse() h.close() The output is: send: 'GET /be/telenet/afe/isps/TelemeterLogin.jsp HTTP/1.1\r\n' send: 'Host: telemeter.telenet.be:443\r\n' send: 'Accept-Encoding: identity\r\n' send: '\r\n' Traceback (most recent call last): File "test.py", line 9, in ? response=h.getresponse() File "/usr/lib/python2.2/httplib.py", line 570, in getresponse response = self.response_class(self.sock, self.debuglevel) File "/usr/lib/python2.2/httplib.py", line 98, in __init__ self.fp = sock.makefile('rb', 0) File "/usr/lib/python2.2/httplib.py", line 607, in makefile buf = self.__ssl.read() socket.sslerror: (5, 'EOF occurred in violation of protocol') Needless to say that Netscape and Konqueror can access this URL without problems. The same script works fine for other URLs. Am I doing something wrong? Is there a way of debugging https connections? (Ethereal does not work for obvious reasons!). All help appreciated! egards, Michel From syver-en+usenet at online.no Thu Jan 3 14:58:01 2002 From: syver-en+usenet at online.no (Syver Enstad) Date: 03 Jan 2002 14:58:01 +0100 Subject: SSL problem References: <3C345C29.604F674E@luc.ac.be> Message-ID: Michel Van den Bergh writes: > Needless to say that Netscape and Konqueror can access this URL > without > > problems. > The same script works fine for other URLs. Hi Michel, I tried the same url with urllib2 it returned lots of stuff, the first lines I got was this: Have you tried using urllib2/urllib instead? This might help you diagnose where the error is located. -- Vennlig hilsen Syver Enstad From vdbergh at luc.ac.be Thu Jan 3 15:19:47 2002 From: vdbergh at luc.ac.be (Michel Van den Bergh) Date: Thu, 03 Jan 2002 15:19:47 +0100 Subject: SSL problem References: <3C345C29.604F674E@luc.ac.be> Message-ID: <3C346883.D2FE7035@luc.ac.be> Thanks a lot! I had thought of using urllib2, but I thought that if it didn't work with httplib then it couldn't possibly work with urllib2! Seems I was wrong. Best regards, Michel Syver Enstad wrote: > Michel Van den Bergh writes: > > > Needless to say that Netscape and Konqueror can access this URL > > without > > > > problems. > > The same script works fine for other URLs. > > Hi Michel, I tried the same url with urllib2 it returned lots of > stuff, the first lines I got was this: > > > > Have you tried using urllib2/urllib instead? This might help you > diagnose where the error is located. > > -- > > Vennlig hilsen > > Syver Enstad -- Michel Van den Bergh Tel. 32-11-26.82.27 http://alpha.luc.ac.be/Research/Algebra Fax. 32-11-26.82.99 ------------------------------------------------------------- Take back your computer. Use Gnu/Linux. From vdbergh at luc.ac.be Thu Jan 3 16:56:00 2002 From: vdbergh at luc.ac.be (Michel Van den Bergh) Date: Thu, 03 Jan 2002 16:56:00 +0100 Subject: SSL problem References: <3C345C29.604F674E@luc.ac.be> Message-ID: <3C347F10.68EA07CA@luc.ac.be> Unfortunately it still doesn't work with urllib2. I get the same error. I upgraded to the lastest versions of the openssl libraries. To no avail. I am using RH 7.1. import sys, httplib, urllib, urllib2, re, getopt,time h=urllib2.urlopen("https://telemeter.telenet.be/be/telenet/afe/isps/TelemeterLogin.js") data=h.read() print data Best regards, Michel Syver Enstad wrote: > Michel Van den Bergh writes: > > > Needless to say that Netscape and Konqueror can access this URL > > without > > > > problems. > > The same script works fine for other URLs. > > Hi Michel, I tried the same url with urllib2 it returned lots of > stuff, the first lines I got was this: > > > > Have you tried using urllib2/urllib instead? This might help you > diagnose where the error is located. > > -- > > Vennlig hilsen > > Syver Enstad -- Michel Van den Bergh Tel. 32-11-26.82.27 http://alpha.luc.ac.be/Research/Algebra Fax. 32-11-26.82.99 ------------------------------------------------------------- Take back your computer. Use Gnu/Linux. From syver-en+usenet at online.no Thu Jan 3 18:43:10 2002 From: syver-en+usenet at online.no (Syver Enstad) Date: 03 Jan 2002 18:43:10 +0100 Subject: SSL problem References: <3C345C29.604F674E@luc.ac.be> <3C347F10.68EA07CA@luc.ac.be> Message-ID: Michel Van den Bergh writes: >Unfortunately it still doesn't work with urllib2. I get the same >error. The SSL installation on your box? Or python installation? -- Vennlig hilsen Syver Enstad From vdbergh at luc.ac.be Thu Jan 3 20:11:15 2002 From: vdbergh at luc.ac.be (Michel Van den Bergh) Date: Thu, 03 Jan 2002 19:11:15 GMT Subject: SSL problem References: <3C345C29.604F674E@luc.ac.be> <3C347F10.68EA07CA@luc.ac.be> Message-ID: <3C34AC96.6C9EE9D4@luc.ac.be> Syver Enstad wrote: > Michel Van den Bergh writes: > >Unfortunately it still doesn't work with urllib2. I get the same > >error. > > The SSL installation on your box? Or python installation? > > -- > > Vennlig hilsen > > Syver Enstad Well I installed the latest openssl, recompiled python 2.2 from source and still it doesn't work. Which platform do you use? Regards, Michel From syver-en+usenet at online.no Thu Jan 3 22:37:44 2002 From: syver-en+usenet at online.no (Syver Enstad) Date: 03 Jan 2002 22:37:44 +0100 Subject: SSL problem References: <3C345C29.604F674E@luc.ac.be> <3C347F10.68EA07CA@luc.ac.be> <3C34AC96.6C9EE9D4@luc.ac.be> Message-ID: Michel Van den Bergh writes: > Well I installed the latest openssl, recompiled python 2.2 from source > > and > still it doesn't work. > > Which platform do you use? python 2.1, win2k, and I downloaded some ssl binaries once upon a time, and finally got them to work by rebuilding the socket module. Try some earlier SSL? > > Regards, > Michel > > -- Vennlig hilsen Syver Enstad From vdbergh at luc.ac.be Thu Jan 3 22:54:11 2002 From: vdbergh at luc.ac.be (Michel Van den Bergh) Date: Thu, 03 Jan 2002 21:54:11 GMT Subject: SSL problem References: <3C345C29.604F674E@luc.ac.be> <3C347F10.68EA07CA@luc.ac.be> <3C34AC96.6C9EE9D4@luc.ac.be> Message-ID: <3C34D2D9.EFB37432@luc.ac.be> > python 2.1, win2k, and I downloaded some ssl binaries once upon a > time, and finally got them to work by rebuilding the socket module. > > Try some earlier SSL? > > Thanks for your interest. Perhaps this is a Linux problem? I'll just wait. It might go away eventually. Anyway here is the script again which highlights the problem. Perhaps some other people might like to try it. #!/usr/bin/python2 import httplib h=httplib.HTTPSConnection('telemeter.telenet.be') h.set_debuglevel(1) h.request('GET','/be/telenet/afe/isps/TelemeterLogin.jsp') response=h.getresponse() h.close() Here is the output: send: 'GET /be/telenet/afe/isps/TelemeterLogin.jsp HTTP/1.1\r\n' send: 'Host: telemeter.telenet.be:443\r\n' send: 'Accept-Encoding: identity\r\n' send: '\r\n' Traceback (most recent call last): File "test.py", line 8, in ? response=h.getresponse() File "/var/tmp/python2-2.2-root/usr/lib/python2.2/httplib.py", line 570, in getresponse response = self.response_class(self.sock, self.debuglevel) File "/var/tmp/python2-2.2-root/usr/lib/python2.2/httplib.py", line 98, in __init__ self.fp = sock.makefile('rb', 0) File "/var/tmp/python2-2.2-root/usr/lib/python2.2/httplib.py", line 607, in makefile buf = self.__ssl.read() socket.sslerror: (5, 'EOF occurred in violation of protocol') Best regards, Michel From ngps at madcap.netmemetic.com Fri Jan 4 16:55:13 2002 From: ngps at madcap.netmemetic.com (Ng Pheng Siong) Date: 4 Jan 2002 15:55:13 GMT Subject: SSL problem References: <3C345C29.604F674E@luc.ac.be> <3C34AC96.6C9EE9D4@luc.ac.be> <3C34D2D9.EFB37432@luc.ac.be> Message-ID: According to Michel Van den Bergh : > Anyway here is the script again which highlights the problem. > Perhaps some other people might like to try it. > > #!/usr/bin/python2 > > import httplib > > h=httplib.HTTPSConnection('telemeter.telenet.be') > h.set_debuglevel(1) > h.request('GET','/be/telenet/afe/isps/TelemeterLogin.jsp') > response=h.getresponse() > h.close() Here's using M2Crypto on Python 2.0. (I just built Python 2.2 last night, haven't tested M2Crypto with it.) ngps at madcap:~$ python Python 2.0 (#4, Oct 18 2000, 23:09:30) [GCC 2.95.2 19991024 (release)] on freebsd4 Type "copyright", "credits" or "license" for more information. >>> from M2Crypto import httpslib >>> h = httpslib.HTTPSConnection('telemeter.telenet.be') >>> h.set_debuglevel(1) >>> h.request('GET', '/be/telenet/afe/isps/TelemeterLogin.jsp') send: 'GET /be/telenet/afe/isps/TelemeterLogin.jsp HTTP/1.1\015\012' send: 'Host: telemeter.telenet.be\015\012' send: 'Accept-Encoding: identity\015\012' send: '\015\012' >>> resp = h.getresponse() reply: 'HTTP/1.0 200 OK\015\012' header: Date: Fri, 04 Jan 2002 15:52:37 GMT header: Pragma: no-cache header: Server: WebLogic 6.0 Service Pack 2 05/24/2001 11:55:28 #117037 header: Content-Length: 3031 header: Content-Type: text/html; charset=ISO-8859-1 header: Expires: Thu, 01 Jan 1970 00:00:00 GMT header: Set-Cookie: JSESSIONID=PDXPxZWqCDolz5PlBxX2w8HszY1nt1PCji52yNXjUH06C8oJm2g0!-1350228968832003849!wls1.oasis.telenet.be!8017!8018; path=/ header: Cache-Control: no-cache >>> h.close() >>> Cheers. -- Ng Pheng Siong * http://www.netmemetic.com From martin at v.loewis.de Fri Jan 4 03:01:23 2002 From: martin at v.loewis.de (Martin v. Loewis) Date: 04 Jan 2002 03:01:23 +0100 Subject: SSL problem References: <3C345C29.604F674E@luc.ac.be> Message-ID: Michel Van den Bergh writes: > Needless to say that Netscape and Konqueror can access this URL without > problems. > The same script works fine for other URLs. > > Am I doing something wrong? Is there a way of debugging https > connections? IMO, this is a bug in IIS, which is (probably) the server on the end of your connection (didn't check). See http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=494762 for the analysis done so far. What happens is that IIS closes the connection without performing an SSL connection shutdown (it just sends the end of the underlying TCP connection). OpenSSL reports that as an error. Python 2.1 treats this error as the end of the conversation; Python 2.2 reports the error to the application. Now, it is possible to work around that bug: one could a) take into account the Content-Length header of the response from IIS. This is probably what netscape does. Just read Content-Length bytes from the connection, then close it, regardless of anything else that may or may not be sent by the server. This is a reasonable approach, but it is not straight-forward to implement in httplib, and it may fail if the server does not send a Content-Length header (since it is optional; I guess IIS always sends that header). b) treat this specific exception as an orderly end of the conversation as well. This is a hack, IMO, but would solve the problem for good. No attempt has been made to implement either approach; contributions are welcome. Regards, Martin From phr-n2002a at nightsong.com Fri Jan 4 03:46:30 2002 From: phr-n2002a at nightsong.com (Paul Rubin) Date: 03 Jan 2002 18:46:30 -0800 Subject: SSL problem References: <3C345C29.604F674E@luc.ac.be> Message-ID: <7xitaial4p.fsf@ruckus.brouhaha.com> martin at v.loewis.de (Martin v. Loewis) writes: > IMO, this is a bug in IIS, which is (probably) the server on the end > of your connection (didn't check). See The server at the other end is c2 Stronghold (Apache with the Ben Laurie SSL module). I was able to connect to it ok with with openssl s_client. I haven't tried the python libs but might get around to doing so. I've been wondering about them anyway. From vdbergh at luc.ac.be Fri Jan 4 12:19:29 2002 From: vdbergh at luc.ac.be (Michel Van den Bergh) Date: Fri, 04 Jan 2002 12:19:29 +0100 Subject: SSL problem References: <3C345C29.604F674E@luc.ac.be> Message-ID: <3C358FC1.9484D5DD@luc.ac.be> http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=494762 Thanks for pointing me to the above bug report. I implemented the "workaround" suggested there and now everything seems to work. ***As far as I could tell the workaround amounts to manually editing httplib.py. Am I correct in this? ***** Best regards, Michel From vdbergh at luc.ac.be Fri Jan 4 12:32:31 2002 From: vdbergh at luc.ac.be (Michel Van den Bergh) Date: Fri, 04 Jan 2002 12:32:31 +0100 Subject: SSL problem References: <3C345C29.604F674E@luc.ac.be> <3C358FC1.9484D5DD@luc.ac.be> Message-ID: <3C3592CF.7EF0D222@luc.ac.be> Michel Van den Bergh wrote: > http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=494762 > > Thanks for pointing me to the above bug report. I implemented > > the "workaround" suggested there and now everything seems > > to work. > > ***As far as I could tell the workaround amounts to manually > > editing httplib.py. Am I correct in this? ***** > > Best regards, > Michel Answering to my own post...... I now realize that it is possible to subclass HTTPSConnection (overriding "connect") and FakeSocket. (overriding "makefile"). This is of course the correct python way to do it. Best regards, Michel -------------- next part -------------- An HTML attachment was scrubbed... URL: From loewis at informatik.hu-berlin.de Fri Jan 4 17:33:14 2002 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 04 Jan 2002 17:33:14 +0100 Subject: SSL problem References: <3C345C29.604F674E@luc.ac.be> <3C358FC1.9484D5DD@luc.ac.be> Message-ID: Michel Van den Bergh writes: > ***As far as I could tell the workaround amounts to manually > > editing httplib.py. Am I correct in this? ***** Indeed. Please contribute your patch to sf.net/projects/python, for review and possible inclusion into Python 2.2.1. Regards, Martin From nikolai.kirsebom at siemens.no Thu Jan 3 14:48:10 2002 From: nikolai.kirsebom at siemens.no (Nikolai Kirsebom) Date: Thu, 03 Jan 2002 13:48:10 GMT Subject: Python 2.2 / Properties Message-ID: <3c345e9d.108916173@news.mch.sni.de> I have not downloaded the new version yet - but will do so in the new future. One question relating to the Properties. I'm currently developping a small "inspector" where I from a Python program will be able to read/write attributes of C++ objects in another process (where Python is not possible to integrate). I'll also be able to execute some methods. Anyhow, system is based on useing socket for communication and the protocol is very simple. Text string consisting of object name and attribute name separated by '.'. As an example: cmd="Object.Attr1" will send the command to read Attr1 of the object named "Object". cmd="Object.Attr2=345" will send the command to set Attr2 to the value 345 of the same object. (I'm using bison/flex to parse the commands). Now to the question: I would like to use the same property-get and property-set methods (functions) for the remote attributes (as seen from Python). The example code below illustrates this. -------------------------- class RemoteObj(object): name = "abc" def remPropGet(self, x): # Send command to remote object to set attribute value resp = Cmd.Send("%s.%s" % (name, NAME_OF_THIS_PROPERTY(x))) if resp['Status'] == OK: return resp['Result'] return resp['Default'] def remPropSet(self, newVal): resp = Cmd.Send("%s.%s=%s" % (name, NAME_OF_THIS_PROPERTY(x), str(newVal))) RecordId = property(remPropGet, None, None, "RecordId") ItemNbr = property(remPropGet, remPropSet, None, "ItemNbr") -------------------------- But is it possible in the methods to find out the name of the property being 'handled' - or maybe I somehow could get to the doc-string for the property. Thanks for any hints/help. Nikolai Kirsebom From cliechti at gmx.net Thu Jan 3 15:15:27 2002 From: cliechti at gmx.net (Chris Liechti) Date: 3 Jan 2002 15:15:27 +0100 Subject: Python 2.2 / Properties References: <3c345e9d.108916173@news.mch.sni.de> Message-ID: [posted and mailed] nikolai.kirsebom at siemens.no (Nikolai Kirsebom) wrote in news:3c345e9d.108916173 at news.mch.sni.de: > I have not downloaded the new version yet - but will do so in the new > future. > > One question relating to the Properties. > > I'm currently developping a small "inspector" where I from a Python > program will be able to read/write attributes of C++ objects in > another process (where Python is not possible to integrate). I'll > also be able to execute some methods. Anyhow, system is based on > useing socket for communication and the protocol is very simple. Text > string consisting of object name and attribute name separated by '.'. > As an example: > > cmd="Object.Attr1" > will send the command to read Attr1 of the object named "Object". > > cmd="Object.Attr2=345" > will send the command to set Attr2 to the value 345 of the same > object. > > (I'm using bison/flex to parse the commands). > > Now to the question: I would like to use the same property-get and > property-set methods (functions) for the remote attributes (as seen > from Python). The example code below illustrates this. > > -------------------------- > class RemoteObj(object): > name = "abc" > def remPropGet(self, x): > # Send command to remote object to set attribute value > resp = Cmd.Send("%s.%s" % (name, NAME_OF_THIS_PROPERTY(x))) > if resp['Status'] == OK: > return resp['Result'] > return resp['Default'] > > def remPropSet(self, newVal): > resp = Cmd.Send("%s.%s=%s" % (name, NAME_OF_THIS_PROPERTY(x), > str(newVal))) > > RecordId = property(remPropGet, None, None, "RecordId") > ItemNbr = property(remPropGet, remPropSet, None, "ItemNbr") > -------------------------- > > But is it possible in the methods to find out the name of the property > being 'handled' - or maybe I somehow could get to the doc-string for > the property. > > Thanks for any hints/help. why not use __getattr__ and __setattr__ ? >>> class A: ... def __getattr__(self, item): ... try: ... return self.__dict__[item] ... except: ... if item not in ('__members__',): #because of pythonwin ... print "get", item ... return "hello" ... def __setattr__(self, item, value): ... if item in self.__dict__: ... self.__dict__[item] = value ... else: ... print "set", item, value ... >>> a = A() >>> a.h get h 'hello' >>> a.v = 2 set v 2 the special attributes like __members__ etc are not yet handled correct by the above code. chris > Nikolai Kirsebom > > > -- Chris From r.b.rigilink at chello.nl Thu Jan 3 19:31:31 2002 From: r.b.rigilink at chello.nl (Roeland Rengelink) Date: Thu, 03 Jan 2002 18:31:31 GMT Subject: Python 2.2 / Properties References: <3c345e9d.108916173@news.mch.sni.de> Message-ID: <3C34A3DA.EBA74AEC@chello.nl> Hi Nikolai, In 2.2 properties are subclassable. So this works (note the nested scopes): class altproperty(property): def __init__(self, name, docstr): def getter(inst): print 'Get %s of %s' % (name, inst) return getattr(inst, '_'+name) def setter(inst, val): print 'Set %s of %s to %s' % (name, inst, val) setattr(inst, '_'+name, val) property.__init__(self, getter, setter, None, docstr) class A(object): a = altproperty('a', 'a doc') b = altproperty('b', 'b doc') a = A() print a a.a = 10 print a.a a.b = 20 print a.b giving Set a of <__main__.A object at 0x814894c> to 10 Get a of <__main__.A object at 0x814894c> 10 Set b of <__main__.A object at 0x814894c> to 20 Get b of <__main__.A object at 0x814894c> 20 Replace the getter with your repProp* and Presto! Nikolai Kirsebom wrote: > > I have not downloaded the new version yet - but will do so in the new > future. > > One question relating to the Properties. > > I'm currently developping a small "inspector" where I from a Python > program will be able to read/write attributes of C++ objects in > another process (where Python is not possible to integrate). I'll > also be able to execute some methods. Anyhow, system is based on > useing socket for communication and the protocol is very simple. Text > string consisting of object name and attribute name separated by '.'. > As an example: > > cmd="Object.Attr1" > will send the command to read Attr1 of the object named "Object". > > cmd="Object.Attr2=345" > will send the command to set Attr2 to the value 345 of the same > object. > > (I'm using bison/flex to parse the commands). > > Now to the question: I would like to use the same property-get and > property-set methods (functions) for the remote attributes (as seen > from Python). The example code below illustrates this. > > -------------------------- > class RemoteObj(object): > name = "abc" > def remPropGet(self, x): > # Send command to remote object to set attribute value > resp = Cmd.Send("%s.%s" % (name, NAME_OF_THIS_PROPERTY(x))) > if resp['Status'] == OK: > return resp['Result'] > return resp['Default'] > > def remPropSet(self, newVal): > resp = Cmd.Send("%s.%s=%s" % (name, NAME_OF_THIS_PROPERTY(x), > str(newVal))) > > RecordId = property(remPropGet, None, None, "RecordId") > ItemNbr = property(remPropGet, remPropSet, None, "ItemNbr") > -------------------------- > > But is it possible in the methods to find out the name of the property > being 'handled' - or maybe I somehow could get to the doc-string for > the property. > > Thanks for any hints/help. > > Nikolai Kirsebom Hope this helps, Roeland -- r.b.rigilink at chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From clpy at snakefarm.org Thu Jan 3 15:09:59 2002 From: clpy at snakefarm.org (Carsten Gaebler) Date: Thu, 03 Jan 2002 15:09:59 +0100 Subject: Python 2.2: segmentation fault in test_strftime Message-ID: <3C346637.C81A5182@snakefarm.org> Hi there, after compiling Python 2.2 on Linux 2.2.19, 'make test' gave me a segmentation fault in test_strftime. I tracked it down to a problem in the calendar module: Python 2.2 (#2, Jan 3 2002, 14:18:23) [GCC 2.7.2.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import calendar >>> calendar.day_abbr[0] 'Mon' >>> calendar.day_abbr[1] 'Tue' >>> calendar.day_abbr[2] Segmentation fault (core dumped) Any ideas what this could be? Regards Carsten. -- Search for extraterrestrial idiots - join SETI at home. From mwh at python.net Thu Jan 3 18:05:14 2002 From: mwh at python.net (Michael Hudson) Date: Thu, 3 Jan 2002 17:05:14 GMT Subject: Python 2.2: segmentation fault in test_strftime References: <3C346637.C81A5182@snakefarm.org> Message-ID: Carsten Gaebler writes: > Hi there, > > after compiling Python 2.2 on Linux 2.2.19, 'make test' gave me a > segmentation fault in test_strftime. I tracked it down to a problem in > the calendar module: > > Python 2.2 (#2, Jan 3 2002, 14:18:23) > [GCC 2.7.2.3] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> import calendar > >>> calendar.day_abbr[0] > 'Mon' > >>> calendar.day_abbr[1] > 'Tue' > >>> calendar.day_abbr[2] > Segmentation fault (core dumped) > > Any ideas what this could be? Nope. Doesn't crash for me. What does a backtrace show? What version of glibc do you have? Cheers, M. -- MARVIN: Oh dear, I think you'll find reality's on the blink again. -- The Hitch-Hikers Guide to the Galaxy, Episode 12 From clpy at snakefarm.org Fri Jan 4 11:42:22 2002 From: clpy at snakefarm.org (Carsten Gaebler) Date: Fri, 04 Jan 2002 11:42:22 +0100 Subject: Python 2.2: segmentation fault in test_strftime References: <3C346637.C81A5182@snakefarm.org> Message-ID: <3C35870D.F75E9B56@snakefarm.org> Michael Hudson wrote: > > Carsten Gaebler writes: > > Python 2.2 (#2, Jan 3 2002, 14:18:23) > > [GCC 2.7.2.3] on linux2 > > Type "help", "copyright", "credits" or "license" for more information. > > >>> import calendar > > >>> calendar.day_abbr[0] > > 'Mon' > > >>> calendar.day_abbr[1] > > 'Tue' > > >>> calendar.day_abbr[2] > > Segmentation fault (core dumped) > > > > Any ideas what this could be? > > Nope. Doesn't crash for me. > > What does a backtrace show? What version of glibc do you have? Uhm, excuse my ignorance, but what is a backtrace? glibc is 2.0.7. Seems to be broken - if you can call it 'broken': strftime() with all fields of the tm struct set to 2 (this is what calendar.day_abbr does) segfaults. I tested it with a small C program. I think I can live with that, since this is an extremely pathological case. cg. -- Python is taken from python site. What to do? What is that? -- scenes from comp.lang.python From mwh at python.net Fri Jan 4 12:56:10 2002 From: mwh at python.net (Michael Hudson) Date: Fri, 4 Jan 2002 11:56:10 GMT Subject: Python 2.2: segmentation fault in test_strftime References: <3C346637.C81A5182@snakefarm.org> <3C35870D.F75E9B56@snakefarm.org> Message-ID: Carsten Gaebler writes: > Michael Hudson wrote: > > > > Carsten Gaebler writes: > > > > Python 2.2 (#2, Jan 3 2002, 14:18:23) > > > [GCC 2.7.2.3] on linux2 > > > Type "help", "copyright", "credits" or "license" for more information. > > > >>> import calendar > > > >>> calendar.day_abbr[0] > > > 'Mon' > > > >>> calendar.day_abbr[1] > > > 'Tue' > > > >>> calendar.day_abbr[2] > > > Segmentation fault (core dumped) > > > > > > Any ideas what this could be? > > > > Nope. Doesn't crash for me. > > > > What does a backtrace show? What version of glibc do you have? > > Uhm, excuse my ignorance, but what is a backtrace? Well, when you get the above "Segmentation fault (core dumped)" message, there should be a file "core" somewhere, probably in the directory you build python in. In this directory run "gdb ./python core" and type "bt" at the prompt. What you get is a backtrace. In this case it seems to be irrelevant: > glibc is 2.0.7. Seems to be broken - if you can call it 'broken': > strftime() with all fields of the tm struct set to 2 (this is what > calendar.day_abbr does) segfaults. Oops. > I tested it with a small C program. I think I can live with that, > since this is an extremely pathological case. Certainly, it seems unlikely to be a Python problem... Cheers, M. -- The Programmer's Quick Guide To Python (Time Machine version): You try to shoot yourself in the foot, only to realize that there's no need, since Guido thoughtfully shot you in the foot years ago. -- Nick Mathewson, comp.lang.python From dalke at dalkescientific.com Thu Jan 3 21:38:03 2002 From: dalke at dalkescientific.com (Andrew Dalke) Date: Thu, 3 Jan 2002 13:38:03 -0700 Subject: Python 2.2: segmentation fault in test_strftime References: <3C346637.C81A5182@snakefarm.org> Message-ID: Carsten Gaebler wrote: >after compiling Python 2.2 on Linux 2.2.19, 'make test' gave me a >segmentation fault in test_strftime. I tracked it down to a problem in >the calendar module: ... >>>> calendar.day_abbr[2] >Segmentation fault (core dumped) > >Any ideas what this could be? I saw a similar problem with strftime a month or so back. I was able to reproduce it in straight C code. The code was written as documented and ran on other OSes, so I figured it was a bug in glibc. It worked on another glibc so I concluded my library was probably out of date, but didn't investigate further. Don't have the machine handy to test your reproducible. Andrew dalke at dalkescientific.com From thomas.heller at ion-tof.com Thu Jan 3 15:12:44 2002 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 3 Jan 2002 15:12:44 +0100 Subject: ANN: py2exe version 0.2.7 released Message-ID: Release 0.2.7: Support (and a binary distribution) for Python 2.2. Fixed the problems with readonly source files. Parsing the setup.cfg file should now work correctly. Other small bug fixes as well. py2exe is a distutils extension to convert python scripts into executable windows programs, able to run on computers without requiring a python installation. Download from the usual location: http://starship.python.net/crew/theller/py2exe/ Happy new year, Thomas From GeorgLohrer at gmx.de Thu Jan 3 15:37:49 2002 From: GeorgLohrer at gmx.de (Georg Lohrer) Date: Thu, 03 Jan 2002 15:37:49 +0100 Subject: Is types.InstanceType no longer valid with Python 2.2 Message-ID: Hi, after updating to Python 2.2 I've gotten some errors yielded by my lines: class foo: pass ss = 'foo()' ff = eval(ss) assert(type(ff) == types.InstanceType) Because until version 2.1 of Python any instantiated object has its type 'instance', but with Python 2.2 this has been changed. Now the same object if for example is created dynamically with 'eval()' (in my case) it's a 'new-style'-class and its type-output has been changed: type(ff) = '__main__.foo' That's okay, but with my asserts I only wanted to assure that there an instantiated object, instead of a list or a tuple will be used! For deeper leveled classes it will look like: from BBX.Base.corbautil import ORBFacade orb_facade = ORBFacade() type(orb_facade) >>> 'BBX.Base.corbautil.ORBFacade' I don't want to add the whole nesting level of the testable object in an 'isinstance'-call nor can I use the assert-statement any longer. Do you know a short way to assure that the variable is an object independent of the class-type? Any comments and issues are appreciated. Ciao, Georg From emile at fenx.com Thu Jan 3 16:39:28 2002 From: emile at fenx.com (Emile van Sebille) Date: Thu, 3 Jan 2002 07:39:28 -0800 Subject: Is types.InstanceType no longer valid with Python 2.2 References: Message-ID: "Georg Lohrer" wrote in message news:rnq83usnib0vh8cma37kc1cufh4qbb2bvj at 4ax.com... > Hi, > > after updating to Python 2.2 I've gotten some errors yielded by my > lines: > > class foo: > pass > > ss = 'foo()' > ff = eval(ss) > assert(type(ff) == types.InstanceType) > > Because until version 2.1 of Python any instantiated object has its > type 'instance', but with Python 2.2 this has been changed. Now the > same object if for example is created dynamically with 'eval()' (in my > case) it's a 'new-style'-class and its type-output has been changed: > > type(ff) = '__main__.foo' > > That's okay, but with my asserts I only wanted to assure that there an > instantiated object, instead of a list or a tuple will be used! > > For deeper leveled classes it will look like: > > from BBX.Base.corbautil import ORBFacade > orb_facade = ORBFacade() > type(orb_facade) > > >>> 'BBX.Base.corbautil.ORBFacade' > > I don't want to add the whole nesting level of the testable object in > an 'isinstance'-call nor can I use the assert-statement any longer. > > Do you know a short way to assure that the variable is an object > independent of the class-type? > > Any comments and issues are appreciated. > > Ciao, Georg assert isinstance(ff, foo) -- Emile van Sebille emile at fenx.com --------- From GeorgLohrer at gmx.de Thu Jan 3 17:49:34 2002 From: GeorgLohrer at gmx.de (Georg Lohrer) Date: Thu, 03 Jan 2002 17:49:34 +0100 Subject: Is types.InstanceType no longer valid with Python 2.2 References: Message-ID: <43293uk34r6dgn5vgel7j0uiekhg6jp0no@4ax.com> Emile, On Thu, 3 Jan 2002 07:39:28 -0800, "Emile van Sebille" wrote: [snipped] > >assert isinstance(ff, foo) thanks for coming back. It's a pity, but I really have to apologize for myself not having spended more time to describe my problem in shorter terms. I'm only looking for a solution to decide wether a variable is an instantiated object. The class's name is not of any interest. In my special case I 'flatten' a deeply structured Python-object via recursively calling a small helper script. Inside of that the type of the current passed variable to flatten have to be decided. The algorithm itself does not know anything about the type. It's only some sort of meta-processing -- only dealing with the data, not changing or interpreting them. If the passed variable is an instance of a class, the __dict__ entries will be examined by calling the algorithm again. Lists and dictionaries have to be handled in a different manner. Therefore I need recognizing an instantion of a class. If I could be assured that only a class-instantiation could have a __dict__ then a possible solution would be try..catch AttributeError to catch all other items. But with Python 2.1 the InstanceType decision was more elegant. Ciao, Georg From emile at fenx.com Thu Jan 3 19:51:51 2002 From: emile at fenx.com (Emile van Sebille) Date: Thu, 3 Jan 2002 10:51:51 -0800 Subject: Is types.InstanceType no longer valid with Python 2.2 References: <43293uk34r6dgn5vgel7j0uiekhg6jp0no@4ax.com> Message-ID: "Georg Lohrer" wrote in message news:43293uk34r6dgn5vgel7j0uiekhg6jp0no at 4ax.com... [snipped] > Therefore I need recognizing an instantion of a class. If I could be > assured that only a class-instantiation could have a __dict__ then a > possible solution would be try..catch AttributeError to catch all > other items. But with Python 2.1 the InstanceType decision was more > elegant. > > Ciao, Georg > Aside from Skip verifying that InstanceType works in 2.2 (which I hadn't, but have since) and so it should for you, one attribute that may do it is __class__. I'm not aware that this is used otherwise. HTH, -- Emile van Sebille emile at fenx.com --------- From martin at v.loewis.de Fri Jan 4 03:02:35 2002 From: martin at v.loewis.de (Martin v. Loewis) Date: 04 Jan 2002 03:02:35 +0100 Subject: Is types.InstanceType no longer valid with Python 2.2 References: <43293uk34r6dgn5vgel7j0uiekhg6jp0no@4ax.com> Message-ID: "Emile van Sebille" writes: > Aside from Skip verifying that InstanceType works in 2.2 (which I hadn't, > but have since) and so it should for you, one attribute that may do it is > __class__. I'm not aware that this is used otherwise. Python 2.2+ (#486, Dec 22 2001, 21:46:52) [GCC 2.95.3 20010315 (SuSE)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> list.__class__ Regards, Martin From aleax at aleax.it Fri Jan 4 18:09:12 2002 From: aleax at aleax.it (Alex Martelli) Date: Fri, 4 Jan 2002 18:09:12 +0100 Subject: Is types.InstanceType no longer valid with Python 2.2 References: <43293uk34r6dgn5vgel7j0uiekhg6jp0no@4ax.com> Message-ID: "Georg Lohrer" wrote in message news:43293uk34r6dgn5vgel7j0uiekhg6jp0no at 4ax.com... ... > If the passed variable is an instance of a class, the __dict__ entries > will be examined by calling the algorithm again. Lists and > dictionaries have to be handled in a different manner. So what do you want to do if the passed variable is an instance of a class (with its own __dict__ or __slots__) AND is a list or dictionary too? class fooledyou(list): def __init__(self, *any): list.__init__(self, *any) self.also = 'an attribute' This is Python 2.2, and indeed the key improvement out of all the many ones that are in 2.2 over 2.1. "Being a class's instance", "having a __dict__", and "being a list" (or dict) are not mutually exclusive any more. So, you probably need to re-think your approach. Alex From GeorgLohrer at gmx.de Sat Jan 5 14:29:34 2002 From: GeorgLohrer at gmx.de (Georg Lohrer) Date: Sat, 05 Jan 2002 14:29:34 +0100 Subject: Is types.InstanceType no longer valid with Python 2.2 References: <43293uk34r6dgn5vgel7j0uiekhg6jp0no@4ax.com> Message-ID: <0aud3u82fr1k2i0mepgqloh9q2dk085v9e@4ax.com> On Fri, 4 Jan 2002 18:09:12 +0100, "Alex Martelli" wrote: >"Georg Lohrer" wrote in message >news:43293uk34r6dgn5vgel7j0uiekhg6jp0no at 4ax.com... > ... >> If the passed variable is an instance of a class, the __dict__ entries >> will be examined by calling the algorithm again. Lists and >> dictionaries have to be handled in a different manner. > >So what do you want to do if the passed variable is an instance of >a class (with its own __dict__ or __slots__) AND is a list or dictionary >too? > >class fooledyou(list): > def __init__(self, *any): > list.__init__(self, *any) > self.also = 'an attribute' > >This is Python 2.2, and indeed the key improvement out of all the >many ones that are in 2.2 over 2.1. "Being a class's instance", >"having a __dict__", and "being a list" (or dict) are not mutually >exclusive any more. > >So, you probably need to re-think your approach. After having a look at the code you mentioned, their seems no way to differ between instances of class-objects and all other built-in types using something like the already mentioned types.InstanceType. So, I really have to change the algorithm and check for other indicators than to that one. Thank you and all the others for information, Ciao, Georg From skip at pobox.com Thu Jan 3 17:17:13 2002 From: skip at pobox.com (Skip Montanaro) Date: Thu, 3 Jan 2002 10:17:13 -0600 Subject: Is types.InstanceType no longer valid with Python 2.2 In-Reply-To: References: Message-ID: <15412.33801.660462.887224@12-248-41-177.client.attbi.com> Georg> after updating to Python 2.2 I've gotten some errors yielded by Georg> my lines: Georg> class foo: Georg> pass Georg> ss = 'foo()' Georg> ff = eval(ss) Georg> assert(type(ff) == types.InstanceType) Georg> Because until version 2.1 of Python any instantiated object has Georg> its type 'instance', but with Python 2.2 this has been Georg> changed. Works for me: >>> class foo: pass ... >>> ff = foo() >>> type(ff) >>> import types >>> type(ff) == types.InstanceType 1 >>> ss = 'foo()' >>> ff = eval(ss) >>> type(ff) == types.InstanceType 1 Try pasting a simple interactive session or script (with output) that demonstrates that this fails for you. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From GeorgLohrer at gmx.de Fri Jan 4 17:29:03 2002 From: GeorgLohrer at gmx.de (Georg Lohrer) Date: Fri, 04 Jan 2002 17:29:03 +0100 Subject: Is types.InstanceType no longer valid with Python 2.2 References: Message-ID: <5slb3ugrr1l8tvgbbt0ma1d66qvejk7gu5@4ax.com> Skip, On Thu, 3 Jan 2002 10:17:13 -0600, Skip Montanaro wrote: [snipped] >Try pasting a simple interactive session or script (with output) that >demonstrates that this fails for you. Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.8 -- press F1 for help >>> import types >>> class foo: pass >>> f = foo() >>> type(f) >>> type(f) == types.InstanceType 1 >>> class foo2(object): pass >>> f2 = foo2() >>> type(f2) >>> type(f2) == types.InstanceType 0 >>> You see the problem?! With old-type classes the comparision succeeds, with new-type classes it fails. The type of the instance will show the whole class-structure, but that's not of any interest (as mentioned in posting to Emile). Okay, one way would be to compare the type of the object with all other types in 'types' (except InstanceType). If all fail, the object must be an instance of a class. Not very satisfying, is it. Ciao, Georg From jason at jorendorff.com Fri Jan 4 18:01:23 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Fri, 4 Jan 2002 11:01:23 -0600 Subject: Is types.InstanceType no longer valid with Python 2.2 In-Reply-To: <5slb3ugrr1l8tvgbbt0ma1d66qvejk7gu5@4ax.com> Message-ID: > You see the problem?! With old-type classes the comparision succeeds, > with new-type classes it fails. > The type of the instance will show the whole class-structure, but > that's not of any interest (as mentioned in posting to Emile). > Okay, one way would be to compare the type of the object with all > other types in 'types' (except InstanceType). If all fail, the object > must be an instance of a class. Not very satisfying, is it. isinstance(x, object) # true for all new-style instances issubclass(type(x), object) # ditto ## Jason Orendorff http://www.jorendorff.com/ From skip at pobox.com Fri Jan 4 18:19:25 2002 From: skip at pobox.com (Skip Montanaro) Date: Fri, 4 Jan 2002 11:19:25 -0600 Subject: Is types.InstanceType no longer valid with Python 2.2 In-Reply-To: <5slb3ugrr1l8tvgbbt0ma1d66qvejk7gu5@4ax.com> References: <5slb3ugrr1l8tvgbbt0ma1d66qvejk7gu5@4ax.com> Message-ID: <15413.58397.510961.348686@beluga.mojam.com> >>> f = foo() >>> type(f) >>> type(f) == types.InstanceType 1 >>> f2 = foo2() >>> type(f2) >>> type(f2) == types.InstanceType 0 Hmmm... Now I'm a bit perplexed. There's a whole lot of meta-stuff going on I think. First, I tried this: >>> hasattr(f1, "__class__") 1 >>> hasattr(f2, "__class__") 1 That seemed okay, except all the type constructors also have __class__ attributes: >>> hasattr(list, "__class__") 1 >>> hasattr(object, "__class__") 1 >>> hasattr(int, "__class__") 1 Bummer. Next I tried: >>> type(f1) == types.InstanceType or isinstance(f1, object) 1 >>> type(f2) == types.InstanceType or isinstance(f2, object) 1 Seemed logical, except the type constructors are also instances of object: >>> type(list) == types.InstanceType or isinstance(list, object) 1 The last thing I tried was using issubclass, but this gave me some bizarre results: >>> isinstance(f1, object) 1 Huh? I thought, "so foo must be a subclass of object", but it's not: >>> issubclass(foo, object) 0 How can foo be a classic class with no bases, f1 be both an instance of foo and of object, but foo not be a subclass of object? Just to pull all the bits together in a simple example, starting from a fresh interpreter prompt: >>> class foo: pass ... >>> f1 = foo() >>> f1.__class__ >>> f1.__class__.__bases__ () >>> isinstance(f1, foo) 1 >>> isinstance(f1, object) 1 >>> issubclass(foo, object) 0 I thought I understood this stuff, but my brain is about to explode, so I'll have to stop here. Skip From aleax at aleax.it Fri Jan 4 20:29:28 2002 From: aleax at aleax.it (Alex Martelli) Date: Fri, 04 Jan 2002 19:29:28 GMT Subject: Is types.InstanceType no longer valid with Python 2.2 References: <5slb3ugrr1l8tvgbbt0ma1d66qvejk7gu5@4ax.com> Message-ID: Skip Montanaro wrote: ... > How can foo be a classic class with no bases, f1 be both an instance of > foo > and of object, but foo not be a subclass of object? Just to pull all the Implementatively speaking, it boils down to half a line in source file: Objects/typeobject.c: 387 int 388 PyType_IsSubtype(PyTypeObject *a, PyTypeObject *b) 389 { ... 392 if (!(a->tp_flags & Py_TPFLAGS_HAVE_CLASS)) 393 return b == a || b == &PyBaseObject_Type; The "half a line" being the part of line 393 from the || to the ; -- basically, this says "if the second argument is builtin `object', then, yes, type a IS a subtype of it, WHATEVER type a may be". The insinstance built-in boils down to PyType_IsSubtype when the second argument is not a class -- in Objects/abstract.c: 1890 int 1891 PyObject_IsInstance(PyObject *inst, PyObject *cls) 1892 { ... 1897 if (PyClass_Check(cls) && PyInstance_Check(inst)) { ... 1902 else if (PyType_Check(cls)) { 1903 retval = PyObject_TypeCheck(inst, (PyTypeObject *)cls); OTOH, PyObject_IsSubclass (lines 1946 ff of the same source file) does not call PyType_IsSubtype under any circumstances -- rather, it works via abstract_get_bases (lines 1842 ff, same source). I'm not implying this is RIGHT, mind you -- I have no opinion on that yet; it's just what IS happening in this case you're observing. Alex From r.b.rigilink at chello.nl Sat Jan 5 00:24:10 2002 From: r.b.rigilink at chello.nl (Roeland Rengelink) Date: Fri, 04 Jan 2002 23:24:10 GMT Subject: Is types.InstanceType no longer valid with Python 2.2 References: <5slb3ugrr1l8tvgbbt0ma1d66qvejk7gu5@4ax.com> Message-ID: <3C3639F4.8CB79A1F@chello.nl> Skip Montanaro wrote: > [snip] > > How can foo be a classic class with no bases, f1 be both an instance of foo > and of object, but foo not be a subclass of object? Just to pull all the > bits together in a simple example, starting from a fresh interpreter prompt: > > >>> class foo: pass > ... > >>> f1 = foo() > >>> f1.__class__ > > >>> f1.__class__.__bases__ > () > >>> isinstance(f1, foo) > 1 > >>> isinstance(f1, object) > 1 > >>> issubclass(foo, object) > 0 > > I thought I understood this stuff, but my brain is about to explode, so I'll > have to stop here. > That surprised me a lot too. However, I noticed that: >>> class foo:pass ... >>> isinstance(foo(), object) 1 >>> issubclass(foo, object) 0 >>> issubclass(type(foo()), object) 1 >>> import types >>> issubclass(types.InstanceType, object) 1 >>> types.InstanceType.__bases__ (,) It may be that foo() appears to be an instance of object because type(foo()) is a subclass of object. not because object is some sort of hidden baseclass of foo. The surprise then, comes from type(foo()) != foo for old style classes. Since one of the results of healing the type class dichotomy would be type(foo()) == foo, and hence isinstance(A(), B) == issubclass(type(A()), B), I have halfway convinced myself that it does make sense after all. Hope this helps, Roeland -- r.b.rigilink at chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From martin at v.loewis.de Sat Jan 5 08:37:12 2002 From: martin at v.loewis.de (Martin v. Loewis) Date: 05 Jan 2002 08:37:12 +0100 Subject: Is types.InstanceType no longer valid with Python 2.2 References: <5slb3ugrr1l8tvgbbt0ma1d66qvejk7gu5@4ax.com> Message-ID: Skip Montanaro writes: > How can foo be a classic class with no bases, f1 be both an instance of foo > and of object, but foo not be a subclass of object? Would you agree that the following is sensible: >>> class foo:pass ... >>> f=foo() >>> import types >>> isinstance(f,types.InstanceType) 1 f's type is , so f is an instance of InstanceType, just as isinstance(1, int). Now, would you also agree that >>> types.InstanceType.__bases__ (,) is meaningful, i.e. that object is a base of instance? (every type, eventually, has object as a base type) If you accept both separately, you should also accept isinstance(f, object). Regards, Martin From wurmy at earthlink.net Sat Jan 5 18:27:14 2002 From: wurmy at earthlink.net (Hans Nowak) Date: Sat, 05 Jan 2002 17:27:14 GMT Subject: Is types.InstanceType no longer valid with Python 2.2 References: <5slb3ugrr1l8tvgbbt0ma1d66qvejk7gu5@4ax.com> Message-ID: <3C37372C.2318D0D1@earthlink.net> "Martin v. Loewis" wrote: > > Skip Montanaro writes: > > > How can foo be a classic class with no bases, f1 be both an instance of foo > > and of object, but foo not be a subclass of object? > > Would you agree that the following is sensible: > > >>> class foo:pass > ... > >>> f=foo() > >>> import types > >>> isinstance(f,types.InstanceType) > 1 > > f's type is , so f is an instance of InstanceType, > just as isinstance(1, int). Now, would you also agree that > > >>> types.InstanceType.__bases__ > (,) > > is meaningful, i.e. that object is a base of instance? (every type, > eventually, has object as a base type) > > If you accept both separately, you should also accept > isinstance(f, object). Python 2.2 is still sitting on my shelf, I don't have it installed, and the recent discussions don't really make me want to. I don't want to be a Python luddite, but all this messing around with classes and types doesn't give me a good feeling, to say the least. To stay on the subject, one would *think* that if isinstance(f, object) is true, then issubclass(foo, object) would be true too. This does not seem to be the case. It take it that custom (or "classic") class definitions do not automagically and implicitly inherit from object. But types do. This strikes me as odd. I thought the changes were supposed to mend the class/type dichotomy, not to make it more difficult. Because there's nothing mended: now you have objects that derive from object, and those that don't. Or was this decision made to ensure backward compatibility? Before 2.0, Python used to have a reputation of being small and easy to learn. I don't know what happened to it, but ever since, new features of dubious utility have been piling up, and I don't think the new type/class rules can be called "easy", either. I guess people may see me as one of those types who resist new features in the language, but this really isn't the case. It's just that I feel that these changes aren't very intuitive, and I'm putting it mildly. Of course, everybody has to read the fine manual to understand a language's features completely and use them correctly, and this is no different. Also, Guido & co are not dumb, and I'm sure they made the right decisions. I just think that Python is moving away from its original qualities of being small, easy and intuitive. Just my $0.02... let the flames begin... :-( --Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA==\n') # decode for email address ;-) Site:: http://www.awaretek.com/nowak/ From martin at v.loewis.de Sun Jan 6 21:17:52 2002 From: martin at v.loewis.de (Martin v. Loewis) Date: 06 Jan 2002 21:17:52 +0100 Subject: Is types.InstanceType no longer valid with Python 2.2 References: <5slb3ugrr1l8tvgbbt0ma1d66qvejk7gu5@4ax.com> <3C37372C.2318D0D1@earthlink.net> Message-ID: Hans Nowak writes: > To stay on the subject, one would *think* that if isinstance(f, object) > is true, then issubclass(foo, object) would be true too. This does > not seem to be the case. It take it that custom (or "classic") class > definitions do not automagically and implicitly inherit from object. > But types do. This strikes me as odd. I thought the changes were > supposed to mend the class/type dichotomy, not to make it more > difficult. Because there's nothing mended: now you have objects that > derive from object, and those that don't. Or was this decision made > to ensure backward compatibility? Exactly. Code that uses classic classes will continue to work as it did before. Types offer more functionality than before: you can define them using the class construct, and you can inherit from them, both in C an Python. Several things that people always expected to work do work now, e.g. "hello".__class__. I don't see a problem with the isinstance call: Since isinstance(x, object) yields 1 for any x, nobody would want to do this except to understand it better. Of course, it is now more difficult than it was before to tell apart instances of old-style classes from other objects - that result is expected if the class/type dichotomy is mended. > Before 2.0, Python used to have a reputation of being small > and easy to learn. I don't know what happened to it, but ever > since, new features of dubious utility have been piling up, and I > don't think the new type/class rules can be called "easy", either. There were always things that had been surprising. It is not different now; it is still easy to learn. To learn means to ignore. > I just think that Python is moving away from its original qualities > of being small, easy and intuitive. It is still easy and intuitive. If, by "small", you are referring to the syntax, it is still small also: the new-style classes did not add a single syntax construct to the language. If you refer to the library: It stopped being small in release 1.2 or so, and many people consider this a good thing. So far, the new-style classes are just extension to the library: types have additional features that they did not have before. You can use them or you can leave them. Regards, Martin From aleax at aleax.it Fri Jan 4 22:39:51 2002 From: aleax at aleax.it (Alex Martelli) Date: Fri, 04 Jan 2002 21:39:51 GMT Subject: Is types.InstanceType no longer valid with Python 2.2 References: <5slb3ugrr1l8tvgbbt0ma1d66qvejk7gu5@4ax.com> Message-ID: Georg Lohrer wrote: ... > Okay, one way would be to compare the type of the object with all > other types in 'types' (except InstanceType). If all fail, the object > must be an instance of a class. Not very satisfying, is it. Particularly not *correct* -- it would identify, e.g., the result of an array.array call as "an instance of a class", which it most surely ISN'T. Alex From mjbarber at ascc.artsci.wustl.edu Thu Jan 3 15:54:22 2002 From: mjbarber at ascc.artsci.wustl.edu (Michael James Barber) Date: 3 Jan 2002 08:54:22 -0600 Subject: Numeric and the new division operator Message-ID: I run into a problem when using the new "true division" operator in conjunction with Numeric. Do others see this too? I can't imagine what I could be doing wrong with what is below, but I hope someone can enlighten me if it is a usage problem. The problem is only in Numeric, btw - it works fine with floats and integers. Python 2.2 (#124, Dec 22 2001, 17:36:41) [CW CARBON GUSI2 THREADS GC] on mac Type "copyright", "credits" or "license" for more information. >>> from Numeric import arange >>> x = arange(10) >>> x array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>> x / 10 array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) >>> x / 10. array([ 0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]) >>> # classic division works as expected ... >>> # now let's try true division ... >>> from __future__ import division >>> x/10 Traceback (most recent call last): File "", line 1, in ? TypeError: unsupported operand type(s) for /: 'array' and 'int' >>> x / 10. Traceback (most recent call last): File "", line 1, in ? TypeError: unsupported operand type(s) for /: 'array' and 'float' >>> # oh, dear -- Michael J. Barber From cliechti at gmx.net Thu Jan 3 16:19:43 2002 From: cliechti at gmx.net (Chris Liechti) Date: 3 Jan 2002 16:19:43 +0100 Subject: Numeric and the new division operator References: Message-ID: [posted and mailed] mjbarber at ascc.artsci.wustl.edu (Michael James Barber) wrote in news:a11rau$h3h at ascc.artsci.wustl.edu: > > I run into a problem when using the new "true division" operator in > conjunction with Numeric. Do others see this too? > > I can't imagine what I could be doing wrong with what is below, but I > hope someone can enlighten me if it is a usage problem. The problem is > only in Numeric, btw - it works fine with floats and integers. > > > Python 2.2 (#124, Dec 22 2001, 17:36:41) [CW CARBON GUSI2 THREADS GC] > on mac > Type "copyright", "credits" or "license" for more information. >>>> from Numeric import arange >>>> x = arange(10) >>>> x > array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>>> x / 10 > array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) >>>> x / 10. > array([ 0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]) >>>> # classic division works as expected ... >>>> # now let's try true division ... >>>> from __future__ import division x/10 > Traceback (most recent call last): > File "", line 1, in ? > TypeError: unsupported operand type(s) for /: 'array' and 'int' >>>> x / 10. > Traceback (most recent call last): > File "", line 1, in ? > TypeError: unsupported operand type(s) for /: 'array' and 'float' >>>> # oh, dear from the docs: --------- __div__(self, other) __truediv__(self, other) The division operator (/) is implemented by these methods. The __truediv__() method is used when __future__.division is in effect, otherwise __div__() is used. If only one of these two methods is defined, the object will not support division in the alternate context; TypeError will be raised instead. --------- so i think they have not implemented __truediv__. maybe it would suffuce to say "__truediv__ = __div__" in the Nummeric classes, but i don't know them. -- Chris From mjbarber at ascc.artsci.wustl.edu Thu Jan 3 17:25:25 2002 From: mjbarber at ascc.artsci.wustl.edu (Michael James Barber) Date: 3 Jan 2002 10:25:25 -0600 Subject: Numeric and the new division operator References: Message-ID: [true division doesn't work with Numeric] In article , Chris Liechti wrote: > >from the docs: >--------- >__div__(self, other) >__truediv__(self, other) >The division operator (/) is implemented by these methods. The >__truediv__() method is used when __future__.division is in effect, >otherwise __div__() is used. If only one of these two methods is defined, >the object will not support division in the alternate context; TypeError >will be raised instead. >--------- > >so i think they have not implemented __truediv__. > Ah, that would explain it. Somehow I missed that in the docs -- too focused on finding something related to Numeric, I guess. Thanks for clarifying that. Looking further on the Numeric site, I have also found this: Version 20.3 Please note that the __future__ options wrt integer division in Python 2.2 are NOT available in Numeric at this time. at . I guess it's time to wait a bit longer. :( -- Michael J. Barber From jolsen at mailme.dk Thu Jan 3 16:20:13 2002 From: jolsen at mailme.dk (Jesper Olsen) Date: 3 Jan 2002 07:20:13 -0800 Subject: Jython Question Message-ID: With Jython it is easy to access existing Java classes - I tried the random number example at http://www.jython.org/docs/usejava.html?. But I failed to create an example myself. Is it only packages that can be imported? This is a java class that I would like to access class World { public World() { System.out.println("constructing World!"); } public void hi() { System.out.println("Hi World!"); } } from jython - however I get an exception when try to instantiate this class in jython. Can anyone point out what is wrong in this example? prompt% jython Jython 2.1 on java1.3.1 (JIT: null) Type "copyright", "credits" or "license" for more information. >>> import World >>> w=World() Traceback (innermost last): File "", line 1, in ? java.lang.IllegalAccessException at java.lang.reflect.Constructor.newInstance(Native Method) at org.python.core.PyReflectedConstructor.__call__(PyReflectedConstructor.java:126) at org.python.core.PyJavaInstance.__init__(PyJavaInstance.java:75) at org.python.core.PyJavaClass.__call__(PyJavaClass.java:846) at org.python.core.PyObject.__call__(PyObject.java:258) at org.python.pycode._pyx2.f$0(:1) at org.python.pycode._pyx2.call_function() at org.python.core.PyTableCode.call(PyTableCode.java:208) at org.python.core.PyCode.call(PyCode.java:14) at org.python.core.Py.runCode(Py.java:1135) at org.python.core.Py.exec(Py.java:1157) at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:148) at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:89) at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:70) at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:44) at org.python.util.InteractiveConsole.push(InteractiveConsole.java:83) at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:62) at org.python.util.jython.main(jython.java:199) java.lang.IllegalAccessException: java.lang.IllegalAccessException From andreas.ulbrich at gmx.net Thu Jan 3 17:30:32 2002 From: andreas.ulbrich at gmx.net (Andreas Ulbrich) Date: Thu, 03 Jan 2002 17:30:32 +0100 Subject: Jython Question References: Message-ID: <3C348728.30808@gmx.net> Making your World class public should help, i.e. public class World { ... Cheers, ulbi Jesper Olsen wrote: > With Jython it is easy to access existing Java classes > - I tried the random number example at > http://www.jython.org/docs/usejava.html?. > > But I failed to create an example myself. Is it only packages that > can be imported? > > This is a java class that I would like to access > > class World { > public World() { > System.out.println("constructing World!"); > } > > public void hi() { > System.out.println("Hi World!"); > } > } > > > from jython - however I get an exception when try to instantiate this > class > in jython. Can anyone point out what is wrong in this example? > > prompt% jython > Jython 2.1 on java1.3.1 (JIT: null) > Type "copyright", "credits" or "license" for more information. > >>>>import World >>>>w=World() >>>> > Traceback (innermost last): > File "", line 1, in ? > java.lang.IllegalAccessException > at java.lang.reflect.Constructor.newInstance(Native Method) > at org.python.core.PyReflectedConstructor.__call__(PyReflectedConstructor.java:126) > at org.python.core.PyJavaInstance.__init__(PyJavaInstance.java:75) > at org.python.core.PyJavaClass.__call__(PyJavaClass.java:846) > at org.python.core.PyObject.__call__(PyObject.java:258) > at org.python.pycode._pyx2.f$0(:1) > at org.python.pycode._pyx2.call_function() > at org.python.core.PyTableCode.call(PyTableCode.java:208) > at org.python.core.PyCode.call(PyCode.java:14) > at org.python.core.Py.runCode(Py.java:1135) > at org.python.core.Py.exec(Py.java:1157) > at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:148) > at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:89) > at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:70) > at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:44) > at org.python.util.InteractiveConsole.push(InteractiveConsole.java:83) > at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:62) > at org.python.util.jython.main(jython.java:199) > > java.lang.IllegalAccessException: java.lang.IllegalAccessException > From bzimmer at ziclix.com Thu Jan 3 21:35:58 2002 From: bzimmer at ziclix.com (brian zimmer) Date: 3 Jan 2002 12:35:58 -0800 Subject: Jython Question References: Message-ID: Your class is not declared to be public. This causes an IllegalAccessException when Jython attempts to create a new instance. Add the keyword 'public' before 'class World' and recompile. http://java.sun.com/j2se/1.3/docs/api/java/lang/IllegalAccessException.html brian jolsen at mailme.dk (Jesper Olsen) wrote in message news:... > With Jython it is easy to access existing Java classes > - I tried the random number example at > http://www.jython.org/docs/usejava.html?. > > But I failed to create an example myself. Is it only packages that > can be imported? > > This is a java class that I would like to access > > class World { > public World() { > System.out.println("constructing World!"); > } > > public void hi() { > System.out.println("Hi World!"); > } > } > > > from jython - however I get an exception when try to instantiate this > class > in jython. Can anyone point out what is wrong in this example? > > prompt% jython > Jython 2.1 on java1.3.1 (JIT: null) > Type "copyright", "credits" or "license" for more information. > >>> import World > >>> w=World() > Traceback (innermost last): > File "", line 1, in ? > java.lang.IllegalAccessException > at java.lang.reflect.Constructor.newInstance(Native Method) > at org.python.core.PyReflectedConstructor.__call__(PyReflectedConstructor.java:126) > at org.python.core.PyJavaInstance.__init__(PyJavaInstance.java:75) > at org.python.core.PyJavaClass.__call__(PyJavaClass.java:846) > at org.python.core.PyObject.__call__(PyObject.java:258) > at org.python.pycode._pyx2.f$0(:1) > at org.python.pycode._pyx2.call_function() > at org.python.core.PyTableCode.call(PyTableCode.java:208) > at org.python.core.PyCode.call(PyCode.java:14) > at org.python.core.Py.runCode(Py.java:1135) > at org.python.core.Py.exec(Py.java:1157) > at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:148) > at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:89) > at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:70) > at org.python.util.InteractiveInterpreter.runsource(InteractiveInterpreter.java:44) > at org.python.util.InteractiveConsole.push(InteractiveConsole.java:83) > at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:62) > at org.python.util.jython.main(jython.java:199) > > java.lang.IllegalAccessException: java.lang.IllegalAccessException From tyler.w.wilson at gte.net Thu Jan 3 16:39:35 2002 From: tyler.w.wilson at gte.net (Tyler W. Wilson) Date: Thu, 03 Jan 2002 15:39:35 GMT Subject: Writing an Extension: 2 questions (so far) Message-ID: 1) I have the basic skeleton working for an extension. Now I want to know on the C side when the user does a del . What entry in the PhMethodDef structure should I add, or is there a global function that is called? I noticed that after I do import then a del , my DLL is still in memory. Is this expected. I would have expected it to reference-counted like everything else, and cleaned up when no longer used. 2) I am writing one function which takes a string, either multibyte or Unicode. I want to call PyArg_ParseTuple once, and have it convert the string passed into my desired output (n this case, Unicode). Some thing like: ParseTuple(args, "u", &ustr); But it appears that the interpreter will not automatically do this for, or is there a way? Thank you, Tyler Wilson From sholden at holdenweb.com Thu Jan 3 16:52:48 2002 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 3 Jan 2002 10:52:48 -0500 Subject: Writing an Extension: 2 questions (so far) References: Message-ID: "Tyler W. Wilson" wrote in message news:WW_Y7.101$nu1.55992 at dfiatx1-snr1.gtei.net... > 1) I have the basic skeleton working for an extension. Now I want to know on > the C side when the user does a del . What entry in the PhMethodDef > structure should I add, or is there a global function that is called? > > I noticed that after I do import then a del , my DLL is > still in memory. Is this expected. I would have expected it to > reference-counted like everything else, and cleaned up when no longer used. > Only one answer: someone else can take care of the second question. Extension modules CANNOT be deleted or reloaded, so it isn't possible to reclaim the memory occupied by a shared library module containing such an extension (without terminating the interpreter, which limits you somewhat :-). Sorry. > 2) I am writing one function which takes a string, either multibyte or > Unicode. I want to call PyArg_ParseTuple once, and have it convert the > string passed into my desired output (n this case, Unicode). Some thing > like: ParseTuple(args, "u", &ustr); But it appears that the interpreter will > not automatically do this for, or is there a way? > regards Steve -- http://www.holdenweb.com/ From tyler.w.wilson at gte.net Thu Jan 3 17:07:47 2002 From: tyler.w.wilson at gte.net (Tyler W. Wilson) Date: Thu, 03 Jan 2002 16:07:47 GMT Subject: Writing an Extension: 2 questions (so far) References: Message-ID: I would expect _some_ kind of destructor-like facility at the extension-level. In my case, I have to call some Windows init functions (CoInitialize) on init, and then call the corresponding cleanup functions (CoUninitialize). Should I: 1) Write the standard DLL entrypoint and handle cleanup there? 2) Add an explicit 'close' method on the module interface? Thanks, Tyler "Steve Holden" wrote in message news:J9%Y7.64758$a56.28336 at atlpnn01.usenetserver.com... > "Tyler W. Wilson" wrote in message > news:WW_Y7.101$nu1.55992 at dfiatx1-snr1.gtei.net... > > 1) I have the basic skeleton working for an extension. Now I want to know > on > > the C side when the user does a del . What entry in the > PhMethodDef > > structure should I add, or is there a global function that is called? > > > > I noticed that after I do import then a del , my DLL is > > still in memory. Is this expected. I would have expected it to > > reference-counted like everything else, and cleaned up when no longer > used. > > > Only one answer: someone else can take care of the second question. > > Extension modules CANNOT be deleted or reloaded, so it isn't possible to > reclaim the memory occupied by a shared library module containing such an > extension (without terminating the interpreter, which limits you somewhat > :-). > > Sorry. > > > 2) I am writing one function which takes a string, either multibyte or > > Unicode. I want to call PyArg_ParseTuple once, and have it convert the > > string passed into my desired output (n this case, Unicode). Some thing > > like: ParseTuple(args, "u", &ustr); But it appears that the interpreter > will > > not automatically do this for, or is there a way? > > > > regards > Steve > -- > http://www.holdenweb.com/ > > > > > From loewis at informatik.hu-berlin.de Thu Jan 3 19:14:19 2002 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Jan 2002 19:14:19 +0100 Subject: Writing an Extension: 2 questions (so far) References: Message-ID: "Tyler W. Wilson" writes: > 2) I am writing one function which takes a string, either multibyte or > Unicode. I want to call PyArg_ParseTuple once, and have it convert the > string passed into my desired output (n this case, Unicode). Some thing > like: ParseTuple(args, "u", &ustr); But it appears that the interpreter will > not automatically do this for, or is there a way? No. If a multibyte string is passed, you expect a conversion to a Py_UNICODE*. Somebody needs to allocate the memory, and you would need to release it afterwards. However, you don't need release anything if you are passed a Unicode object. So the API you are proposing cannot work. Instead, I recommend to use O&, and a conversion function. This conversion function should always convert to a PyObject* representing a Unicode object, by: - INCREFing the argument if it is a Unicode object, or - invoking PyUnicode_FromEncodedObject if it is a MBCS string. Then, your application would get a PyUnicodeObject*, which it would need to DECREF. Regards, Martin From thomas.heller at ion-tof.com Thu Jan 3 17:28:40 2002 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 3 Jan 2002 17:28:40 +0100 Subject: ANNOUNCE: ciphon 0.3.5 References: Message-ID: "Suchandra Thapa" wrote in message news:slrna2n8hb.5kj.ssthapa at hepcat.telocity.com... > I've completed ciphon 0.3.5. Ciphon is an utility to provide features All I get when ciphon.py starts is: Updating servers.xml and packages.xml, please wait Traceback (most recent call last): File "C:\ciphon-0.3.5\ciphon.py", line 138, in ? open(os.path.join(ciphonDir, 'servers.xml'), 'w').write) File "C:\Python22\lib\ftplib.py", line 386, in retrbinary conn = self.transfercmd(cmd, rest) File "C:\Python22\lib\ftplib.py", line 347, in transfercmd return self.ntransfercmd(cmd, rest)[0] File "C:\Python22\lib\ftplib.py", line 333, in ntransfercmd sock = self.makeport() File "C:\Python22\lib\ftplib.py", line 294, in makeport resp = self.sendport(host, port) File "C:\Python22\lib\ftplib.py", line 258, in sendport return self.voidcmd(cmd) File "C:\Python22\lib\ftplib.py", line 248, in voidcmd return self.voidresp() File "C:\Python22\lib\ftplib.py", line 223, in voidresp resp = self.getresp() File "C:\Python22\lib\ftplib.py", line 216, in getresp raise error_perm, resp ftplib.error_perm: 504 Sorry, that address is excluded for security reasons. (BTW: I've updated ciphon 0.3.4 to run on windows, and would like to port these changes to 0.3.5) Thomas From ssthapa at classes.cs.uchicago.edu Thu Jan 3 22:58:44 2002 From: ssthapa at classes.cs.uchicago.edu (Suchandra Thapa) Date: Thu, 03 Jan 2002 21:58:44 GMT Subject: ANNOUNCE: ciphon 0.3.5 References: Message-ID: Thomas Heller wrote: > >All I get when ciphon.py starts is: > >Updating servers.xml and packages.xml, please wait > File "C:\Python22\lib\ftplib.py", line 216, in getresp > raise error_perm, resp >ftplib.error_perm: 504 Sorry, that address is excluded for security reasons. > >(BTW: I've updated ciphon 0.3.4 to run on windows, and would like to >port these changes to 0.3.5) That's curious, I think there is some wierd interaction between anonftpd (the server), ftplib , and windows that is causing this. Do you get the same problems with python 2.2 and ciphon 0.3.4? Also, I would like to get a copy of your patches if you think it's ready. -- ---------------------------------------------------------------------------- | Suchandra Thapa | "There are only two kinds of math . s-thapa-11 at NOSPAMalumni.uchicago.edu | books. Those you cannot read beyond | the first sentence, and those you | can not read beyond the first page." | -C.N. Yang ---------------------------------------------------------------------------- From rxg218 at psu.edu Thu Jan 3 17:29:37 2002 From: rxg218 at psu.edu (Rajarshi Guha) Date: Thu, 03 Jan 2002 11:29:37 -0500 Subject: calculating the size of an array passed to a function Message-ID: Hi, when I pass a 1D array to a function as a pointer sizeof() will give me the size of the pointer. Is there anyway I can calculate the size of the recieved array without having to pass a length parameter as well? TIA, -- ------------------------------------------------------------------- Rajarshi Guha | email: rajarshi at presidency.com 417 Davey Laboratory | web : www.jijo.cjb.net Department of Chemistry | www.rajarshi.outputto.com Pennsylvania State University | ICQ : 123242928 | AIM : LoverOfPanda ------------------------------------------------------------------- GPG Fingerprint: DCCB 4D1A 5A8B 2F5A B5F6 1F9E CDC4 5574 9017 AF2A Public Key : http://pgp.mit.edu/ ------------------------------------------------------------------- All seems condemned in the long run to approximate a state akin to Gaussian noise. -- James Martin From rxg218 at psu.edu Thu Jan 3 17:31:29 2002 From: rxg218 at psu.edu (Rajarshi Guha) Date: Thu, 03 Jan 2002 11:31:29 -0500 Subject: calculating the size of an array passed to a function References: Message-ID: Sorry - wrong group :( -- ------------------------------------------------------------------- Rajarshi Guha | email: rajarshi at presidency.com 417 Davey Laboratory | web : www.jijo.cjb.net Department of Chemistry | www.rajarshi.outputto.com Pennsylvania State University | ICQ : 123242928 | AIM : LoverOfPanda ------------------------------------------------------------------- GPG Fingerprint: DCCB 4D1A 5A8B 2F5A B5F6 1F9E CDC4 5574 9017 AF2A Public Key : http://pgp.mit.edu/ ------------------------------------------------------------------- Q: What's polite and works for the phone company? A: A deferential operator. From Filoux at orange.fr Thu Jan 3 17:47:03 2002 From: Filoux at orange.fr (Filoux) Date: 3 Jan 2002 08:47:03 -0800 Subject: List cd's content Message-ID: Hello!! I would like to create a procedure that will create a list of all directories and files which are burnt on a CD (mounted under linux). I'd like to use this procedure in order to create a file browser and a database. For the moment, I use 'du -ah > /_myfile_' for retrieving the CD content... Thanks in advance for your help, Best Regards, Filoux. From thomas at weholt.org Fri Jan 4 21:33:56 2002 From: thomas at weholt.org (Thomas Weholt) Date: Fri, 4 Jan 2002 21:33:56 +0100 Subject: List cd's content References: Message-ID: <5a3Z7.17739$KQ3.275841@news1.oke.nextra.no> I'm working on a simple program that will scan an entire cdrom, extract info from files like PkZip-archives, tar-files, mp3, AVI/Divx etc., generate CRC-values and store it all in a PostgreSQL-database for easy indexing and searching. All I need now is a code cleanup and a simple GUI. When the thing is done I'll post an announcement here. Mail me a bit later to get a progress-report. Thomas "Filoux" wrote in message news:f7c083d5.0201030847.392a5846 at posting.google.com... > Hello!! > > I would like to create a procedure that will create a list of all > directories and files which are burnt on a CD (mounted under linux). > I'd like to use this procedure in order to create a file browser and a > database. For the moment, I use > > 'du -ah > /_myfile_' > > for retrieving the CD content... > > Thanks in advance for your help, Best Regards, Filoux. From preben_er_t0ff at hotmail.com Thu Jan 3 17:48:41 2002 From: preben_er_t0ff at hotmail.com (Preben) Date: Thu, 03 Jan 2002 16:48:41 GMT Subject: interfacing the I/O-ports Message-ID: How do I open a connection to one of the I/O-ports of the PC, eg. the Parallel port? In which module? PS. its for use on a win32 platform From joonas at olen.to Sat Jan 5 00:32:14 2002 From: joonas at olen.to (Joonas Paalasmaa) Date: Sat, 05 Jan 2002 01:32:14 +0200 Subject: interfacing the I/O-ports References: Message-ID: <3C363B7E.684CA322@olen.to> Preben wrote: > > How do I open a connection to one of the I/O-ports of the PC, eg. the > Parallel port? > In which module? > > PS. its for use on a win32 platform Check the Vaults. http://www.vex.net/parnassus/apyllo.py?find=io+port From zooko at zooko.com Thu Jan 3 17:53:56 2002 From: zooko at zooko.com (Zooko) Date: Thu, 03 Jan 2002 08:53:56 -0800 Subject: trace.py and coverage.py Message-ID: Greetings Pythonismos, Pythonismas, Gareth Rees, and Andrew Dalke: I learned from Python-URL [1] that Gareth Rees [2] has published a code coverage tool called coverage.py [3]. On the web pages, Gareth compares coverage.py favorably against trace.py, but he appears to be using an old version of trace.py [4] from 1999 that is still sitting around on Andrew Dalke's FTP site. Python comes with a newer version of trace.py [5] which has been modified by Skip Montanaro and then by me [6]. Here are the differences that I see right now between current trace.py and coverage.py: 1. trace.py can do tracing as well as code coverage. It can do either or both, and also has a "listfuncs" mode which just tracks which functions are invoked at least once. 2. coverage.py actually parses so as to annotate lines correctly, where trace.py just ignores blank lines and comments. 3. coverage.py is much faster. In my tests, coverage.py takes less than 2 seconds where trace.py takes 30 seconds. 4. The usage interfaces are very different. Not sure which, if either, is better. 5. coverage.py only keeps a binary measure of whether each line was invoked or not, where trace.py counts how many times each line was invoked. 6. coverage.py has a nice summary output that looks like this: $ coverage.py -r -m foo.py bar.py Name Stmts Exec Cover Missing ------------------------------------ foo 64 56 87% 23, 57, 85, 119, 125, 133, 137, 152 bar 105 90 86% 78-86, 237-246 ------------------------------------ TOTAL 169 146 86% Here are my ideas: 1. Andrew Dalke removes that old version of trace.py from his FTP site! 2. We consider merging the best features of these two tools and replacing the standard distribution's trace.py with the new merged tool. 2.b. Who's this "we"? Well, I understand the trace.py code already, so my inclination would be to steal the "real parsing" feature from coverage.py and add it to trace.py, and to try to optimize trace.py. (By profiling it, I suppose. ;-)) Regards, Zooko --- zooko.com Security and Distributed Systems Engineering --- [1] http://www.pythonware.com/daily/ [2] http://www.garethrees.org/ [3] http://www.garethrees.org/2001/12/04/python-coverage/ [4] ftp://starship.python.net/pub/crew/dalke/ [5] http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/python/python/dist/src/Tools/scripts/trace.py [6] http://zooko.com/ [7] [7] These footnotes are getting a little out of hand. Footnote footnote! From gdr at ravenbrook.com Thu Jan 3 18:30:44 2002 From: gdr at ravenbrook.com (Gareth Rees) Date: Thu, 3 Jan 2002 17:30:44 +0000 Subject: trace.py and coverage.py In-Reply-To: References: Message-ID: At 08:53 -0800 2002-01-03, Zooko wrote: >The usage interfaces are very different. Not sure which, if either, >is better. I developed the coverage.py interface so that it will support coverage testing in a variety of testing scenarios. In the coverage.py model you run tests, generate a report, use the report to direct your testing activity to fruitful locations in the code, generate a new report based on all the testing so far, and so on. When you're testing things by hand, or when you're developing a test suite, it's important to be able to accumulate coverage information over a series of tests. It may not be cost-effective to go back and run the whole set of tests again with coverage turned on (either because the tests are expensive to set up or take too long to execute). Tracing is a different kind of activity from coverage testing and probably needs a different user interface. >coverage.py is much faster. In my tests, coverage.py takes less >than 2 seconds where trace.py takes 30 seconds. It's obvious where the bottleneck is in a tracing or coverage application: it's the function that you pass to sys.settrace. Here's the tracing function from coverage.py: c = {} def t(f, x, y): c[(f.f_code.co_filename, f.f_lineno)] = 1 return t Here's what led me to implement it this way: 1. If you try to increment a count of the number of times a line has been executed then you need to handle the initial case (when there's no entry for the line of code) and integer overflow. It's much cheaper to set the hash entry to 1. 2. I thought at first that because many lines of code get executed from each file, it would be better to write c[f.f_code.co_filename][f.f_lineno)] = 1 But it turns out that the extra code needed to handle the base cases takes more time than the construction of the pair, which happens in the Python core. 3. You can make Python run faster by giving variables shorter names! I presume that this is because variables are looked up by name in the environment at run time. So variables with shorter names can be looked up more quickly. Hence c, f, t, x, y in my code. >We consider merging the best features of these two tools and >replacing the standard distribution's trace.py with the new merged >tool. I think code sharing is appropriate between coverage testing and tracing tools (the parsing code in particular). The tracing function itself would need to be different (for reasons of speed as explained above). The user interfaces may need to be different (see my notes at the top of this e-mail), so I'm not 100% sure of the merits of a tool that tried to do both tasks. I think the coverage.py licence is flexible enough that you shouldn't have any trouble re-using my code. Let me know if you need my help. From zooko at zooko.com Thu Jan 3 19:26:05 2002 From: zooko at zooko.com (Zooko) Date: Thu, 03 Jan 2002 10:26:05 -0800 Subject: trace.py and coverage.py In-Reply-To: Message from Gareth Rees of "Thu, 03 Jan 2002 17:30:44 GMT." References: Message-ID: I, Zooko, wrote the lines prepended with "> >": Gareth Rees wrote: > > >The usage interfaces are very different. Not sure which, if either, > >is better. > > In the coverage.py model you run tests, generate a report, use the > report to direct your testing activity to fruitful locations in the > code, generate a new report based on all the testing so far, and so > on. I believe trace.py allows the same usage. > >coverage.py is much faster. In my tests, coverage.py takes less > >than 2 seconds where trace.py takes 30 seconds. > > It's obvious where the bottleneck is in a tracing or coverage > application: it's the function that you pass to sys.settrace. Here's > the tracing function from coverage.py: > > c = {} > def t(f, x, y): > c[(f.f_code.co_filename, f.f_lineno)] = 1 > return t I think you are right. Here's the function in trace.py: def localtrace_count(self, frame, why, arg): if why == 'line': (filename, lineno, funcname, context, lineindex,) = inspect.getframeinfo(frame) key = (filename, lineno,) self.counts[key] = self.counts.get(key, 0) + 1 return self.localtrace I vaguely recall changing from `f.f_code.co_filename' to `inspect.getframeinfo()' because I thought I had encountered some mysterious problems with the `f_' members. I'll experiment with coverage.py and see if it handles Mojo Nation as well as trace.py does. Regards, Zooko --- zooko.com Security and Distributed Systems Engineering --- From mwh at python.net Thu Jan 3 19:29:21 2002 From: mwh at python.net (Michael Hudson) Date: Thu, 3 Jan 2002 18:29:21 GMT Subject: trace.py and coverage.py References: Message-ID: Gareth Rees writes: > 3. You can make Python run faster by giving variables shorter > names! I find this very hard to believe. Can you provide evidence? > I presume that this is because variables are looked up by name in > the environment at run time. Erm, not local variables (which includes function arguments). They're assigned a numerical index at compile time, which is what is used to find the run time value. > So variables with shorter names can be looked up more quickly. Erm, not really. Even for global and builtin objects, the strings containing the names will be interned at compile time and have its hash value computed only once; this means that equality testing can be done by comparing pointers. The only way variable names can ever so slightly affect performance is if you manage to have names that end up in the same hash bucket in the relavent dictionary, and this (a) is pretty unlikely (b) probably has a neglible effect. > Hence c, f, t, x, y in my code. I think you need a better excuse for that :) Cheers, M. -- MARVIN: Do you want me to sit in a corner and rust, or just fall apart where I'm standing? -- The Hitch-Hikers Guide to the Galaxy, Episode 2 From skip at pobox.com Thu Jan 3 20:03:36 2002 From: skip at pobox.com (Skip Montanaro) Date: Thu, 3 Jan 2002 13:03:36 -0600 Subject: trace.py and coverage.py In-Reply-To: References: Message-ID: <15412.43784.265156.493578@12-248-41-177.client.attbi.com> zooko> 2. We consider merging the best features of these two tools and zooko> replacing the standard distribution's trace.py with the new zooko> merged tool. In the long run I think you'll be better off basing a code coverage tool on Jeremy Hylton's compiler package. During compilation you generate per-module counters that are incremented at the beginning of each basic block (not just one for each line) and save the correspondence between each counter and its location in the code. At exit you dump the counts into a db file of some sort which can then be post-processed into an annotated code listing. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From thomas.heller at ion-tof.com Thu Jan 3 17:58:26 2002 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 3 Jan 2002 17:58:26 +0100 Subject: ciphon 0.3.4 References: <9vsq4f$hk6cn$1@ID-59885.news.dfncis.de> Message-ID: "Sean Reifschneider" wrote in message news:mailman.1008909446.20883.python-list at python.org... > > I have a distutils patch which, at the time I submitted it, would allow the > user to add a "--submit" to one of the options for building distutils > packages so that the resulting file would be uploaded. I've been asked to > re-submit it so that it can hopefully make it into the post-2.2 distutils, > but then I've also been asked to change the way it works as well. ;-/ Sean, can you point me to the patch? Is it on SF? Thomas From fredegar at haftmann-online.de Thu Jan 3 18:10:11 2002 From: fredegar at haftmann-online.de (Florian Fredegar Haftmann) Date: Thu, 03 Jan 2002 17:10:11 +0000 Subject: Disc space on a floppy disc Message-ID: <3C349073.7070701@haftmann-online.de> Hi! Is there any possibility for python under Linux to test how much disc space on a floppy disc is free (except by parsing the output of the "df" command)? Thanks, FFH From rnd at onego.ru Thu Jan 3 17:31:04 2002 From: rnd at onego.ru (Roman Suzi) Date: Thu, 3 Jan 2002 19:31:04 +0300 (MSK) Subject: Disc space on a floppy disc In-Reply-To: <3C349073.7070701@haftmann-online.de> Message-ID: On Thu, 3 Jan 2002, Florian Fredegar Haftmann wrote: > Hi! > > Is there any possibility for python under Linux to test how much disc > space on a floppy disc is free (except by parsing the output of the "df" > command)? There is os.statvfs() function and constants of statvfs to interpret results of os.statvfs call. For example: >>> print os.statvfs("/boot") (1024, 1024, 23333, 13088, 11884, 6024, 5988, 5988, 0, 255) >>> os.system("df") Filesystem 1k-blocks Used Available Use% Mounted on ... /dev/hda4 23333 10245 11884 46% /boot ... (please, not that available space is not all space that is available. Usually 5% are reserved for root on ext2 filesystems. Not sure about floppies.) Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From mwh at python.net Thu Jan 3 18:07:27 2002 From: mwh at python.net (Michael Hudson) Date: Thu, 3 Jan 2002 17:07:27 GMT Subject: Disc space on a floppy disc References: <3C349073.7070701@haftmann-online.de> Message-ID: Florian Fredegar Haftmann writes: > Hi! > > Is there any possibility for python under Linux to test how much disc > space on a floppy disc is free (except by parsing the output of the > "df" command)? Does os.statvfs help? (I don't know, but it might). Cheers, M. -- I'm okay with intellegent buildings, I'm okay with non-sentient buildings. I have serious reservations about stupid buildings. -- Dan Sheppard, ucam.chat (from Owen Dunn's summary of the year) From robin at jessikat.fsnet.co.uk Thu Jan 3 18:21:48 2002 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 3 Jan 2002 17:21:48 +0000 Subject: frozen win32com problem Message-ID: I am attempting to implement a frozen python win32com object. We are using a variant of Gordon McMillan's 4.x installer framework to create a python.exe which works fine. Most .pycs are in a .pyz file, but the win32/lib files and win32com/server+client files are in the real file system. I have only got pythoncom21.dll, pywintypes21.dll, win32api.pyd and win32trace.pyd on the target system. I find that I can use my objects if I manually register them to use my localserver only. So I have a working setup except for registration on the target machine. When I try to use the standard command line registration/unregistration mechanism I'm getting an error from win32com.server.register._cat_registrar eg with the cut down file \tmp\dingo.py import pythoncom def _cat_registrar(): return pythoncom.CoCreateInstance( pythoncom.CLSID_StdComponentCategoriesMgr, None, pythoncom.CLSCTX_INPROC_SERVER, pythoncom.IID_ICatRegister ) print 'CLSID_StdComponentCategoriesMgr', pythoncom.CLSID_StdComponentCategoriesMgr print 'CLSCTX_INPROC_SERVER', pythoncom.CLSCTX_INPROC_SERVER print 'IID_ICatRegister', pythoncom.IID_ICatRegister print _cat_registrar() C:\ReportLab>\tmp\dingo.py CLSID_StdComponentCategoriesMgr CLSCTX_INPROC_SERVER 1 IID_ICatRegister Traceback (most recent call last): File "C:\tmp\dingo.py", line 13, in ? print _cat_registrar() File "C:\tmp\dingo.py", line 7, in _cat_registrar pythoncom.IID_ICatRegister pywintypes.com_error: (-2147221164, 'Class not registered', None, None) this is on an NT4 system that has no python/pythonwin etc. Any ideas what I'm missing/haven't registered? -- Robin Becker From gmcm at hypernet.com Thu Jan 3 21:05:08 2002 From: gmcm at hypernet.com (Gordon McMillan) Date: 03 Jan 2002 20:05:08 GMT Subject: frozen win32com problem References: Message-ID: Robin Becker wrote: > I am attempting to implement a frozen python win32com object. > We are using a variant of Gordon McMillan's 4.x installer framework > to create a python.exe which works fine. Most .pycs are in a .pyz file, > but the win32/lib files and win32com/server+client files are in > the real file system. > > I have only got pythoncom21.dll, pywintypes21.dll, win32api.pyd and > win32trace.pyd on the target system. > > I find that I can use my objects if I manually register them to use my > localserver only. So I have a working setup except for registration on > the target machine. localserver only applies if you're using LOCAL_SERVER. > When I try to use the standard command line registration/unregistration > mechanism I'm getting an error from > win32com.server.register._cat_registrar > > eg with the cut down file \tmp\dingo.py > > import pythoncom > def _cat_registrar(): > return pythoncom.CoCreateInstance( > pythoncom.CLSID_StdComponentCategoriesMgr, > None, > pythoncom.CLSCTX_INPROC_SERVER, > pythoncom.IID_ICatRegister > ) > > print 'CLSID_StdComponentCategoriesMgr', > pythoncom.CLSID_StdComponentCategoriesMgr print 'CLSCTX_INPROC_SERVER', > pythoncom.CLSCTX_INPROC_SERVER print 'IID_ICatRegister', > pythoncom.IID_ICatRegister print _cat_registrar() > > > C:\ReportLab>\tmp\dingo.py > CLSID_StdComponentCategoriesMgr > CLSCTX_INPROC_SERVER 1 > IID_ICatRegister > Traceback (most recent call last): > File "C:\tmp\dingo.py", line 13, in ? > print _cat_registrar() > File "C:\tmp\dingo.py", line 7, in _cat_registrar > pythoncom.IID_ICatRegister > pywintypes.com_error: (-2147221164, 'Class not registered', None, None) > > > this is on an NT4 system that has no python/pythonwin etc. Any ideas > what I'm missing/haven't registered? You seem to be asking for INPROC_SERVER. That means COM loads pythoncomXX.dll which (implicitly) loads pythonXX.dll. There's no chance for the import hooks to get installed. Unless you upgrade to release 5. -- Gordon http://www.mcmillan-inc.com/ From mhammond at skippinet.com.au Fri Jan 4 06:37:35 2002 From: mhammond at skippinet.com.au (Mark Hammond) Date: Fri, 04 Jan 2002 05:37:35 GMT Subject: frozen win32com problem References: Message-ID: <3C353FA8.1010409@skippinet.com.au> Gordon McMillan wrote: > Robin Becker wrote: >>def _cat_registrar(): >> return pythoncom.CoCreateInstance( >> pythoncom.CLSID_StdComponentCategoriesMgr, >> None, >> pythoncom.CLSCTX_INPROC_SERVER, >> pythoncom.IID_ICatRegister >> ) ... >> >>this is on an NT4 system that has no python/pythonwin etc. Any ideas >>what I'm missing/haven't registered? >> > > You seem to be asking for INPROC_SERVER. That means COM loads > pythoncomXX.dll which (implicitly) loads pythonXX.dll. There's no chance for > the import hooks to get installed. Actually, the code is only trying to get a reference to a standard COM object, not a Python implemented one. I assume that the test program works OK when not frozen, or is this only on a single machine "in the field"? Mark. From robin at jessikat.fsnet.co.uk Fri Jan 4 12:30:36 2002 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 4 Jan 2002 11:30:36 +0000 Subject: frozen win32com problem References: <3C353FA8.1010409@skippinet.com.au> Message-ID: In article <3C353FA8.1010409 at skippinet.com.au>, Mark Hammond writes ..... > >Actually, the code is only trying to get a reference to a standard COM >object, not a Python implemented one. I assume that the test program >works OK when not frozen, or is this only on a single machine "in the >field"? > >Mark. > yes this works fine on the win2k build system, but not on my test NT4 machine. Could it be that I need some extra library/pyd on the target. On the build system the frozen python.exe seems to be able to register stuff correctly and it looks like it's only using stuff from the frozen distribution, but it has python & win32all installed so maybe it can see stuff via the registry. -- Robin Becker From SSchukat at dspace.de Fri Jan 4 12:50:01 2002 From: SSchukat at dspace.de (Stefan Schukat) Date: Fri, 4 Jan 2002 12:50:01 +0100 Subject: frozen win32com problem Message-ID: <84257D042AA7D411B3F700D0B7DB9B7C13AFD5@PDC-DSPACE> It could also be that the component category manager is not registered right on yout NT system. Try this RegSvr32.Exe \ComCat.DLL on your NT machine and look if it helps. Stefan > -----Original Message----- > From: Robin Becker [mailto:robin at jessikat.fsnet.co.uk] > Sent: Friday, January 04, 2002 12:31 PM > To: python-list at python.org > Subject: Re: frozen win32com problem > > > In article <3C353FA8.1010409 at skippinet.com.au>, Mark Hammond > writes > ..... > > > >Actually, the code is only trying to get a reference to a > standard COM > >object, not a Python implemented one. I assume that the > test program > >works OK when not frozen, or is this only on a single > machine "in the > >field"? > > > >Mark. > > > yes this works fine on the win2k build system, but not on my test NT4 > machine. Could it be that I need some extra library/pyd on the target. > On the build system the frozen python.exe seems to be able to register > stuff correctly and it looks like it's only using stuff from > the frozen > distribution, but it has python & win32all installed so maybe > it can see > stuff via the registry. > -- > Robin Becker > -- > http://mail.python.org/mailman/listinfo/python-list > From robin at jessikat.fsnet.co.uk Fri Jan 4 14:58:17 2002 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Fri, 4 Jan 2002 13:58:17 +0000 Subject: frozen win32com problem References: Message-ID: In article , Stefan Schukat writes >It could also be that the component category manager is not >registered right on yout NT system. Try this > >RegSvr32.Exe \ComCat.DLL > >on your NT machine and look if it helps. > > Stefan ..... thanks I'll try that. -- Robin Becker From robin at jessikat.fsnet.co.uk Wed Jan 9 12:23:17 2002 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 9 Jan 2002 11:23:17 +0000 Subject: frozen win32com problem References: Message-ID: In article , Stefan Schukat writes >It could also be that the component category manager is not >registered right on yout NT system. Try this > >RegSvr32.Exe \ComCat.DLL > >on your NT machine and look if it helps. > > Stefan ..... OK that's the problem. It seems that a standard bare bones install of NT4 is not required to have Comcat.dll at all. Checking with google I see that there are very large numbers of problems associated with comcat.dll (mainly versioning and non-registration). I have a vague understanding that comcat.dll implements the "Component Categories Manager" required for controls, but not for com objects. I have set _reg_disable_pycomcat_ = 1 in my com class, but even so it seems that the win32com/server/register.py module contains an unconditional attempt to register the "Python COM Server" category. This is a bit restrictive. -- Robin Becker From mhammond at skippinet.com.au Thu Jan 10 05:35:21 2002 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 10 Jan 2002 04:35:21 GMT Subject: frozen win32com problem References: Message-ID: <3C3D1A21.6030609@skippinet.com.au> Robin Becker wrote: > In article , Stefan > Schukat writes > I have a vague understanding that comcat.dll implements the "Component > Categories Manager" required for controls, but not for com objects. I > have set _reg_disable_pycomcat_ = 1 in my com class, but even so it > seems that the win32com/server/register.py module contains an > unconditional attempt to register the "Python COM Server" category. > > This is a bit restrictive. I agree, but I can't see why this would happen. Please have a quick look at RegisterServer and the use of 'addPyComCat', and if you can see the problem send me a patch. Thanks, Mark. From mhammond at skippinet.com.au Thu Jan 10 05:46:27 2002 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 10 Jan 2002 04:46:27 GMT Subject: frozen win32com problem References: Message-ID: <3C3D1CBB.5040000@skippinet.com.au> Robin Becker wrote: Actually, I could see how this happens. I just checked in the following patch. RCS file: /home/cvsroot/PyWin32/com/win32com/server/register.py,v retrieving revision 1.4 retrieving revision 1.5 diff -r1.4 -r1.5 12a13 > import win32com 420c421,424 < RegisterPyComCategory() --- > try: > RegisterPyComCategory() > except win32com.error: # Error with the COM category manager - oh well. > pass Mark. From robin at jessikat.fsnet.co.uk Thu Jan 10 09:48:15 2002 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 10 Jan 2002 08:48:15 +0000 Subject: frozen win32com problem References: <3C3D1CBB.5040000@skippinet.com.au> Message-ID: In article <3C3D1CBB.5040000 at skippinet.com.au>, Mark Hammond writes >Robin Becker wrote: > >Actually, I could see how this happens. I just checked in the following >patch. > >RCS file: /home/cvsroot/PyWin32/com/win32com/server/register.py,v >retrieving revision 1.4 >retrieving revision 1.5 >diff -r1.4 -r1.5 >12a13 >> import win32com >420c421,424 >< RegisterPyComCategory() >--- >> try: >> RegisterPyComCategory() >> except win32com.error: # Error with the COM category manager - oh well. >> pass > > >Mark. > Actually I think I tried something like this, but the registration was slightly wrong afterwards (I think the localserver was wrong). I'll have a go on the test NT machine again to check. -- Robin Becker From robin at jessikat.fsnet.co.uk Thu Jan 10 11:34:20 2002 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 10 Jan 2002 10:34:20 +0000 Subject: frozen win32com problem References: <3C3D1CBB.5040000@skippinet.com.au> Message-ID: In article <3C3D1CBB.5040000 at skippinet.com.au>, Mark Hammond writes >Robin Becker wrote: > >Actually, I could see how this happens. I just checked in the following >patch. > >RCS file: /home/cvsroot/PyWin32/com/win32com/server/register.py,v >retrieving revision 1.4 >retrieving revision 1.5 >diff -r1.4 -r1.5 >12a13 >> import win32com >420c421,424 >< RegisterPyComCategory() >--- >> try: >> RegisterPyComCategory() >> except win32com.error: # Error with the COM category manager - oh well. >> pass > > >Mark. > OK I tries this and got a complaint about win32com.error I used instead try: win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT, 'Component Categories\\%s' % CATID_PythonCOMServer) except win32api.error: import pywintypes try: RegisterPyComCategory() except pywintypes.com_error: # Error with the COM category manager - oh well. pass and then things went well. I did interp.py --register interp.py --test and things worked. so my patch (presumably against 1.4) was, *** register.py.orig Fri Aug 04 18:29:16 2000 --- register.py Thu Jan 10 10:29:32 2002 *************** *** 417,421 **** win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT, 'Component Categories\\%s' % CATID_PythonCOMServer) except win32api.error: ! RegisterPyComCategory() ! --- 417,424 ---- win32api.RegQueryValue(win32con.HKEY_CLASSES_ROOT, 'Component Categories\\%s' % CATID_PythonCOMServer) except win32api.error: ! import pywintypes ! try: ! RegisterPyComCategory() ! except pywintypes.com_error: # Error with the COM category manager - oh well. ! pass -- Robin Becker From mhammond at skippinet.com.au Fri Jan 11 00:17:12 2002 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 10 Jan 2002 23:17:12 GMT Subject: frozen win32com problem References: <3C3D1CBB.5040000@skippinet.com.au> Message-ID: <3C3E2112.2000605@skippinet.com.au> Robin Becker wrote: > In article <3C3D1CBB.5040000 at skippinet.com.au>, Mark Hammond writes > >>Robin Becker wrote: >> >>Actually, I could see how this happens. I just checked in the following >>patch. >> >>RCS file: /home/cvsroot/PyWin32/com/win32com/server/register.py,v >>retrieving revision 1.4 >>retrieving revision 1.5 >>diff -r1.4 -r1.5 >>12a13 >> >>>import win32com >>> >>420c421,424 >>< RegisterPyComCategory() >>--- >> >>> try: >>> RegisterPyComCategory() >>> except win32com.error: # Error with the COM category manager - oh well. >>> pass >>> > OK I tries this and got a complaint about win32com.error It looks like you missed a line of my patch: >>diff -r1.4 -r1.5 >>12a13 >> >>>import win32com This should setup win32com correctly so win32com.error can be found. Mark. From robin at jessikat.fsnet.co.uk Fri Jan 11 00:58:40 2002 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 10 Jan 2002 23:58:40 +0000 Subject: frozen win32com problem References: <3C3D1CBB.5040000@skippinet.com.au> <3C3E2112.2000605@skippinet.com.au> Message-ID: <4W+PyLAwqiP8EwXj@jessikat.fsnet.co.uk> In article <3C3E2112.2000605 at skippinet.com.au>, Mark Hammond writes ... >>>>import win32com > > >This should setup win32com correctly so win32com.error can be found. > >Mark. > no I tried directly to import etc and failed PythonWin 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (MarkH at ActiveState.com) - see 'Help/About PythonWin' for further copyright information. >>> import win32com >>> raise win32com.error Traceback (most recent call last): File "", line 1, in ? AttributeError: 'win32com' module has no attribute 'error' >>> -- Robin Becker From mhammond at skippinet.com.au Mon Jan 14 03:05:37 2002 From: mhammond at skippinet.com.au (Mark Hammond) Date: Mon, 14 Jan 2002 02:05:37 GMT Subject: frozen win32com problem References: <3C3D1CBB.5040000@skippinet.com.au> <3C3E2112.2000605@skippinet.com.au> <4W+PyLAwqiP8EwXj@jessikat.fsnet.co.uk> Message-ID: <3C423D12.9040606@skippinet.com.au> Robin Becker wrote: > In article <3C3E2112.2000605 at skippinet.com.au>, Mark Hammond writes > ... > >>>>>import win32com >>>>> >> >>This should setup win32com correctly so win32com.error can be found. >> >>Mark. >> >> > no I tried directly to import etc and failed > > PythonWin 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on win32. > Portions Copyright 1994-2001 Mark Hammond (MarkH at ActiveState.com) - see 'Help/About PythonWin' for further > copyright information. > >>>>import win32com >>>>raise win32com.error Oops - my mistake :( I meant 'pythoncom'. Sorry. Mark. From goller at tttech.com Wed Jan 23 15:19:26 2002 From: goller at tttech.com (Alois Goller) Date: Wed, 23 Jan 2002 15:19:26 +0100 Subject: win32api --with-pymalloc References: <3C3D1CBB.5040000@skippinet.com.au> <3C3E2112.2000605@skippinet.com.au> <4W+PyLAwqiP8EwXj@jessikat.fsnet.co.uk> <3C423D12.9040606@skippinet.com.au> Message-ID: <3C4EC66E.B1E616F8@tttech.com> Hi, I try to compile Python 2.1.2 under Windows with WITH_PYMALLOC defined. This works fine, but I read that there might be problems with python extensions. Well, I want to use win32api and win32con in my code, too. Neil Schemenauer wrote: > Using pymalloc with threads should be safe as long as you don't have > extensions that call pymalloc without the big lock held. How do I see whether "the big lock" is held? Can I use Mark Hammond's win32 extensions together with WITH_PYMALLOC ? Alois From mhammond at skippinet.com.au Thu Jan 24 04:42:17 2002 From: mhammond at skippinet.com.au (Mark Hammond) Date: Thu, 24 Jan 2002 03:42:17 GMT Subject: win32api --with-pymalloc References: <3C3D1CBB.5040000@skippinet.com.au> <3C3E2112.2000605@skippinet.com.au> <4W+PyLAwqiP8EwXj@jessikat.fsnet.co.uk> <3C423D12.9040606@skippinet.com.au> <3C4EC66E.B1E616F8@tttech.com> Message-ID: <3C4F82D1.9070505@skippinet.com.au> Alois Goller wrote: > Hi, > > I try to compile Python 2.1.2 under Windows with WITH_PYMALLOC defined. This > works fine, but I read that there might be problems with python extensions. > Well, I want to use win32api and win32con in my code, too. I've never tried, but would be interested to hear any results. I can't be bothered rebuilding my entire world just to try :) > Neil Schemenauer wrote: > >>Using pymalloc with threads should be safe as long as you don't have >>extensions that call pymalloc without the big lock held. >> > > How do I see whether "the big lock" is held? Can I use Mark Hammond's win32 > extensions together with WITH_PYMALLOC ? The win32 extensions *should* work fine here. They generally grab the lock before doing much at all. Further, a quick look at PyMalloc shows it doesn't attempt to redefine any non-Python memory allocators (such as global new or free) so should be perfectly fine. However, the way I see it, that would make PyMalloc just as thread-safe as Python itself; the GIL should be held before calling any Python functions, including explicit or implicit object creation or destruction. Mark. From writeson at earthlink.net Thu Jan 3 18:31:30 2002 From: writeson at earthlink.net (Doug Farrell) Date: 3 Jan 2002 09:31:30 -0800 Subject: Moving Python between machines Message-ID: <88bc63c6.0201030931.ac371f@posting.google.com> Hi, I've downloaded, compiled and installed Python-2.2 on one of my Solaris 2.6 Sparc machines and it is working fine. I'd like to move that installation over to another Solaris 2.6 Sparc machine so I can use Python2.2 over there, how can I do this easily? I don't have all of the development tools on the second machine, so I can't configure/make/install again. I just want to copy what's necessary from the first machine to the second to get Python2.2 running. Any help or suggestions would be most appreciated. Thanks, Doug Farrell From shalehperry at attbi.com Thu Jan 3 18:45:59 2002 From: shalehperry at attbi.com (Sean 'Shaleh' Perry) Date: Thu, 03 Jan 2002 09:45:59 -0800 (PST) Subject: Moving Python between machines In-Reply-To: <88bc63c6.0201030931.ac371f@posting.google.com> Message-ID: On 03-Jan-2002 Doug Farrell wrote: > Hi, > > I've downloaded, compiled and installed Python-2.2 on one of my > Solaris 2.6 Sparc machines and it is working fine. I'd like to move > that installation over to another Solaris 2.6 Sparc machine so I can > use Python2.2 over there, how can I do this easily? I don't have all > of the development tools on the second machine, so I can't > configure/make/install again. I just want to copy what's necessary > from the first machine to the second to get Python2.2 running. Any > help or suggestions would be most appreciated. > The way many package creation tools do it is by passing a DESTDIR option to the make install. This will install into DESTDIR as if it were the root (/). Then you just tar it up, copy to the new system and untar into that systems root (/). mkdir /tmp/python-install make install DESTDIR=/tmp/python-install cd /tmp tar cvf python-2.2.install.tar From loewis at informatik.hu-berlin.de Thu Jan 3 19:19:19 2002 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Jan 2002 19:19:19 +0100 Subject: Moving Python between machines References: <88bc63c6.0201030931.ac371f@posting.google.com> Message-ID: writeson at earthlink.net (Doug Farrell) writes: > I'd like to move that installation over to another Solaris 2.6 Sparc > machine so I can use Python2.2 over there, how can I do this easily? Copy /bin/python and /lib/python (recursively), to /bin/python and /lib/python. It would be good if prefix and destprefix are the same, but they do not need to be. If they are different, /lib/python should not exist on the target machine. Also, if you use extension modules, I'd recommend to compile them into the Python binary (using Modules/Setup). If they use further libraries (like tclxy.so), I also recommend to link those libraries statically; this, together, will reduce the dependencies of the installation on additional shared libraries (which you otherwise would need to copy as well). HTH, Martin From s.schwarzer at ndh.net Thu Jan 3 20:24:27 2002 From: s.schwarzer at ndh.net (Stefan Schwarzer) Date: Thu, 03 Jan 2002 20:24:27 +0100 Subject: Moving Python between machines References: <88bc63c6.0201030931.ac371f@posting.google.com> Message-ID: <3C34AFEB.61A2B7F9@ndh.net> Hello Doug Martin von Loewis wrote: > > I'd like to move that installation over to another Solaris 2.6 Sparc > > machine so I can use Python2.2 over there, how can I do this easily? > > Copy /bin/python and /lib/python > (recursively), to /bin/python and > /lib/python. > > It would be good if prefix and destprefix are the same, but they do > not need to be. If they are different, /lib/python > should not exist on the target machine. I think if the prefixes differ, you will have to set PYTHONHOME to the new prefix and PYTHONPATH to a list of the paths where the modules are now located. Stefan From tlatoure at systemarts.com Thu Jan 3 18:52:12 2002 From: tlatoure at systemarts.com (Tom) Date: 3 Jan 2002 09:52:12 -0800 Subject: Need Dynamic Menu Code Message-ID: How can you create dynamic menus in Python? Imagine 2 pull-down menus, one for Country, the other for Language. Your selection of Country establishes the choices/values on the Languages menu (consisting of either native language of selected country or English). We can do this easily in ASP. But how can we do it in Python? Advice and input would be greatly appreciated... Thanks From gerson.kurz at t-online.de Thu Jan 3 19:48:57 2002 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Thu, 03 Jan 2002 18:48:57 GMT Subject: Need Dynamic Menu Code References: Message-ID: <3c34a524.20734109@news.t-online.de> On 3 Jan 2002 09:52:12 -0800, tlatoure at systemarts.com (Tom) wrote: >How can you create dynamic menus in Python? Imagine 2 pull-down >menus, one for Country, the other for Language. Your selection of >Country establishes the choices/values on the Languages menu >(consisting of either native language of selected country or English). > >We can do this easily in ASP. But how can we do it in Python? Advice >and input would be greatly appreciated... Disclaimer: I'm not much of an ASP fan. ASP is just HTML with special VB Script between <% and %>. So you're probably talking about (D)HTML menus and not "GUI" menus. ASP is a server-side technique, which allows you to use a language that makes perl shine syntaxwise to generate HTML. Whatever the client sees is only HTML, therefor you can generate it in any language you like. [You could do server-side scripting in Brainfuck if so you desired (see http://esoteric.sange.fi/brainfuck/utils/mod_bf-0.2/) and have the most annoying proprietary tags be generated by programs that look like this: http://esoteric.sange.fi/brainfuck/bf-source/prog/HELLOBF2.BF) If you generate a Menu in ASP, you generate HTML tags. The HTML tags are just strings. So, if the user chooses one thing, some strings are printed, if the user chooses another string, something else gets printed. Its not only simple in ASP, its simple in most programming languages (but not in Brainfuck). What you need to know is a) The choice the user has made b) What HTML tags to display depending upon the choice of the user. The thing about webprogramming is that there are so many alternatives use. I don't know if you use - a python CGI - a mod_python script - a python script that just generates static HTML for khttpd ;) - Client-Side Scripting with Python (IE only) - Server-Side Scripting with Python (IIS only) - your homegrown webserver based on the SocketServer class - a java applet that embedds jython - a java applet that embedds jython which runs a python-powered brainfuck interpreter (http://p-nand-q.com/bf/bf-py.txt) - a python interpreter written in mod_bf etc... All mechanisms differ in - how data is transfered from the user (the webbrowser) to the application (the webserver / the client in case d) - how HTML tags are generated. They do NOT differ in the fact that "a dynamic menu" is just a string that gets generated based on user choice. If you can detail which one of the methods above you want to use, I can perhaps give you an example of generating different HTML tags based on user choice. Here is a very elaborate CGI for dynamic menus in python: ------------------------------------------------------------- #!/usr/bin/python -u # print "language menu" print '''Content-type: text/html

The users choice is either english or german.

''' import cgi form = cgi.FieldStorage() # get the users choice cmd = None if form.has_key('cmd'): cmd = form['cmd'].value # display the various "menus" if cmd == 'english': print '

This is the fancy english menu

' elif cmd == 'german': print '

Das ist das alberne Deutschmenue

' else: print '

The user has not decided on a language yet.

' -------------------------------------------------------------- From tlatoure at systemarts.com Fri Jan 4 17:15:32 2002 From: tlatoure at systemarts.com (Tom) Date: 4 Jan 2002 08:15:32 -0800 Subject: Need Dynamic Menu Code References: <3c34a524.20734109@news.t-online.de> Message-ID: THANK YOU for your detailed reply. We are using server-side scripting with Python on IIS. Would you still recommend the "elaborate CGI for dynamic menus in python" code you so kindly provided us, or would you recommend something else? Thanks again for all your help. gerson.kurz at t-online.de (Gerson Kurz) wrote in message news:<3c34a524.20734109 at news.t-online.de>... > On 3 Jan 2002 09:52:12 -0800, tlatoure at systemarts.com (Tom) wrote: > > >How can you create dynamic menus in Python? Imagine 2 pull-down > >menus, one for Country, the other for Language. Your selection of > >Country establishes the choices/values on the Languages menu > >(consisting of either native language of selected country or English). > > > >We can do this easily in ASP. But how can we do it in Python? Advice > >and input would be greatly appreciated... > > Disclaimer: I'm not much of an ASP fan. > > ASP is just HTML with special VB Script between <% and %>. So you're > probably talking about (D)HTML menus and not "GUI" menus. ASP is a > server-side technique, which allows you to use a language that makes > perl shine syntaxwise to generate HTML. Whatever the client sees is > only HTML, therefor you can generate it in any language you like. [You > could do server-side scripting in Brainfuck if so you desired (see > http://esoteric.sange.fi/brainfuck/utils/mod_bf-0.2/) and have the > most annoying proprietary tags be generated by programs that look like > this: http://esoteric.sange.fi/brainfuck/bf-source/prog/HELLOBF2.BF) > > If you generate a Menu in ASP, you generate HTML tags. The HTML tags > are just strings. So, if the user chooses one thing, some strings are > printed, if the user chooses another string, something else gets > printed. Its not only simple in ASP, its simple in most programming > languages (but not in Brainfuck). What you need to know is > > a) The choice the user has made > b) What HTML tags to display depending upon the choice of the user. > > The thing about webprogramming is that there are so many alternatives > use. I don't know if you use > > - a python CGI > - a mod_python script > - a python script that just generates static HTML for khttpd ;) > - Client-Side Scripting with Python (IE only) > - Server-Side Scripting with Python (IIS only) > - your homegrown webserver based on the SocketServer class > - a java applet that embedds jython > - a java applet that embedds jython which runs a python-powered > brainfuck interpreter (http://p-nand-q.com/bf/bf-py.txt) > - a python interpreter written in mod_bf > etc... > > All mechanisms differ in > > - how data is transfered from the user (the webbrowser) to the > application (the webserver / the client in case d) > - how HTML tags are generated. > > They do NOT differ in the fact that "a dynamic menu" is just a string > that gets generated based on user choice. If you can detail which one > of the methods above you want to use, I can perhaps give you an > example of generating different HTML tags based on user choice. > > Here is a very elaborate CGI for dynamic menus in python: > ------------------------------------------------------------- > #!/usr/bin/python -u > > # print "language menu" > print '''Content-type: text/html > >

The users choice is either > english or > german.

> ''' > > import cgi > form = cgi.FieldStorage() > > # get the users choice > cmd = None > if form.has_key('cmd'): > cmd = form['cmd'].value > > # display the various "menus" > if cmd == 'english': > print '

This is the fancy english menu

' > elif cmd == 'german': > print '

Das ist das alberne Deutschmenue

' > else: > print '

The user has not decided on a language yet.

' > -------------------------------------------------------------- From jim at publishingresources.com Fri Jan 4 20:25:06 2002 From: jim at publishingresources.com (Jim Abrams) Date: Fri, 04 Jan 2002 19:25:06 -0000 Subject: Need Dynamic Menu Code References: <3c34a524.20734109@news.t-online.de> Message-ID: tlatoure at systemarts.com (Tom) wrote in news:d7175e2e.0201040815.72296f6d at posting.google.com: > THANK YOU for your detailed reply. We are using server-side scripting > with Python on IIS. Would you still recommend the "elaborate CGI for > dynamic menus in python" code you so kindly provided us, or would you > recommend something else? > > Thanks again for all your help. If you're forced to use IIS (such as I am), glad to see you went with Python! You should be aware of how to jump between pages with information, a simple form post. But, if you want a DHTML solution, here's a simple ex. (Careful of newsreader wrapping) <%@LANGUAGE="Python"%> <% menu1 = ('stooges', 'colors', 'langs') submenus = { 'stooges': ('moe', 'larry', 'curly'), 'colors': ('blue', 'green', 'red'), 'langs': ('python', 'ruby', 'scheme') } %>


=============== From mlh at vier.idi.ntnu.no Thu Jan 3 19:05:02 2002 From: mlh at vier.idi.ntnu.no (Magnus Lie Hetland) Date: Thu, 3 Jan 2002 18:05:02 +0000 (UTC) Subject: Minimal diffs in difflib? Message-ID: When asking about using difflib to implement version control, I was pointed to the get_opcodes method of SequenceMatcher by Tim Peters, and that was indeed helpful. And after looking a bit at difflib, I think the "intuitive" deltas computed are very nice for showing users the difference between one revision and the previous one. However, I think it would be nice to be able to compute minimal deltas too, to increase the compression of the repository, and so I started wondering... Would it be interesting to include the Levenshtein algorithm in difflib as well? (Or possibly add a separate module or something?) The basic algorithm is very small/simple[1], so adding it wouldn't be much of a burden to the standard lib, would it? (And PHP has it, so why shouldn't we? ) On the other hand, even though this might be a useful/natural algorithm to have in a diff lib, I may not save that much space with it... I guess I had better do some experimenting. Perhaps using zlib or gzlib is better [1] http://www.hetland.org/python/distance.py Note: This implementation only computes the distance, not the delta, but the change needed is minimal. -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.org From tim.one at home.com Thu Jan 3 19:59:12 2002 From: tim.one at home.com (Tim Peters) Date: Thu, 3 Jan 2002 13:59:12 -0500 Subject: Minimal diffs in difflib? In-Reply-To: Message-ID: [Magnus Lie Hetland] > When asking about using difflib to implement version control, I was > pointed to the get_opcodes method of SequenceMatcher by Tim Peters, > and that was indeed helpful. And after looking a bit at difflib, I > think the "intuitive" deltas computed are very nice for showing users > the difference between one revision and the previous one. Indeed, I dreamt up the SequenceMatcher algorithm in the early 80's *for* a source-control system, precisely because "minimal diffs" were too often unintuitive: patches are read more often by people than by source control systems, and saving a few bytes wasn't worth it even back then. > However, I think it would be nice to be able to compute minimal deltas > too, to increase the compression of the repository, and so I started > wondering... Quantify first. Except in pathological cases, SequenceMatcher diffs are usually size-competitive with minimal diffs, they simply don't synch up on ridiculously accidental matches. In non-pathological cases, a synch tool generally has *many* potential matches to choose from, and most equally good in the end (wrt total diff size); SequenceMatcher strives to pick the pair with maximal matching local context, which very often corresponds to how the source was actually edited. > Would it be interesting to include the Levenshtein algorithm in difflib > as well? Not to me . > (Or possibly add a separate module or something?) difflib may turn into a pkg someday, if enough stuff gets added to it. In the meantime, other diff methods "belong" there. > The basic algorithm is very small/simple[1], so adding it > wouldn't be much of a burden to the standard lib, would it? (And PHP > has it, so why shouldn't we? ) An industrial-strength version isn't small or simple -- study your Unix diff source code for why. From david at dataovation.com Thu Jan 3 19:41:46 2002 From: david at dataovation.com (David A McInnis) Date: Thu, 3 Jan 2002 10:41:46 -0800 Subject: regex ? Message-ID: When title has an ' or " this appears to crash. re.compile(r"(.*)", re.I) Any ideas? David -------------- next part -------------- An HTML attachment was scrubbed... URL: From infinitystwin.SPAM at IS.BAD.yahoo.com Thu Jan 3 21:23:52 2002 From: infinitystwin.SPAM at IS.BAD.yahoo.com (Greg Krohn) Date: Thu, 3 Jan 2002 14:23:52 -0600 Subject: regex ? References: Message-ID: <3c34bcc9$0$79560$6e49188b@news.goldengate.net> "David A McInnis" wrote in message news:mailman.1010083385.12710.python-list at python.org... > When title has an ' or " this appears to crash. > > re.compile(r"(.*)", re.I) > > Any ideas? > > David Works for me: import re sampleData = "Spam, spam, ham. " \ + "Here's lookin' at you, kid. " \ + "Say no more." pat = re.compile(r"(.*)", re.I) match = pat.search(sampleData) if match: print match.groups() else: print "No matches" >>> ("Here's lookin' at you, kid.",) From cmbchris at mac.com Thu Jan 10 20:09:46 2002 From: cmbchris at mac.com (Chris Dutton) Date: Thu, 10 Jan 2002 14:09:46 -0500 Subject: regex ? References: <3c34bcc9$0$79560$6e49188b@news.goldengate.net> Message-ID: in article 3c34bcc9$0$79560$6e49188b at news.goldengate.net, Greg Krohn at infinitystwin.SPAM at IS.BAD.yahoo.com wrote on 1/3/02 3:23 PM: > pat = re.compile(r"(.*)", re.I) Or just in case somebody puts two set of titles in one document, for whatever reason... pat = re.compile(r"([^]+)", re.I) From aleax at aleax.it Fri Jan 11 15:47:30 2002 From: aleax at aleax.it (Alex Martelli) Date: Fri, 11 Jan 2002 15:47:30 +0100 Subject: regex ? References: <3c34bcc9$0$79560$6e49188b@news.goldengate.net> Message-ID: "Chris Dutton" wrote in message news:B8635129.1A6C%cmbchris at mac.com... > in article 3c34bcc9$0$79560$6e49188b at news.goldengate.net, Greg Krohn at > infinitystwin.SPAM at IS.BAD.yahoo.com wrote on 1/3/02 3:23 PM: > > > pat = re.compile(r"(.*)", re.I) > > Or just in case somebody puts two set of titles in one document, for > whatever reason... > > pat = re.compile(r"([^]+)", re.I) No!!! The part [^] excludes any of the CHARACTERS lessthan, slash, t, i, l, e, and greaterthan, from being accepted as part of a title. This is VERY unlikely indeed to be what one would want. Alex From s.schwarzer at ndh.net Thu Jan 3 19:45:02 2002 From: s.schwarzer at ndh.net (Stefan Schwarzer) Date: Thu, 03 Jan 2002 19:45:02 +0100 Subject: Style for overwritten methods of abstract classes Message-ID: <3C34A6AE.4293E82C@ndh.net> Hello all :) As an example, I have an abstract base class CacheBase which provides an interface to a persistent storage. All methods _could_ be either overwritten (__init__, __del__) or _have to_ be provided (__getitem__, __setitem__). Initially, I wrote class CacheBase: '''Represents an abstract interface for the URL/value storage. Overwrite __init__, __getitem__, __setitem__, and __del__ to customize the class.''' def __init__(self): pass def __getitem__(self, url): '''Return an abstract value from the cache for the given URL. Return None if the URL is not in the cache.''' return None def __setitem__(self, url, value): '''Set an abstract value (usable for comparisons with a remote URL) for the URL.''' pass def __del__(self): '''Clean up.''' pass I personally like this as an overview of which methods should be defined in derived classes. On the other hand, it may be considered verbose to write all of the above given that the methods would have to be overwritten anyway. Another aspect is that the "noop implementations" of __getitem__ and __setitem__ could actually obscure bugs if somebody forgets to overwrite the methods in derived classes. So I can think of three different approaches: 1. write the code as above 2. merely describe the implementation/interfaces (e. g. in the class docstring or in a comment); write no code 3. use code but let the abstract methods raise NotImplementedError instead of providing a default behaviour which might be useless (4. Are there others?) In the light of 2., __del__ might be a special case because it may be very important for clean-up and at the same time might go unnoticed for a while because Python will use its default behaviour regardless if __del__ had been defined in the abstract class or not. Which approach would you prefer and why? Can you think of criteria/cases where you would use one approach and in another case another approach? Thanks in advance for your replies. Stefan From cliechti at gmx.net Thu Jan 3 22:21:44 2002 From: cliechti at gmx.net (Chris Liechti) Date: 3 Jan 2002 22:21:44 +0100 Subject: Style for overwritten methods of abstract classes References: <3C34A6AE.4293E82C@ndh.net> Message-ID: Stefan Schwarzer wrote in news:3C34A6AE.4293E82C at ndh.net: [snip example interface] > > I personally like this as an overview of which methods should be > defined in derived classes. On the other hand, it may be considered > verbose to write all of the above given that the methods would have > to be overwritten anyway. > > Another aspect is that the "noop implementations" of __getitem__ and > __setitem__ could actually obscure bugs if somebody forgets to overwrite > the methods in derived classes. > > So I can think of three different approaches: > 1. write the code as above [with pass/return None] i would do this only for methods where a noop is save > 2. merely describe the implementation/interfaces (e. g. in the class > docstring or in a comment); write no code you get an exception for some methods, but not for __init__ or __del__ raising an explicit NYI exception seems cleaner to me. > 3. use code but let the abstract methods raise NotImplementedError > instead of providing a default behaviour which might be useless i prefer this one. this way you can't forget to implement something. this comes close to javas or c++ "abstract". things like __init__ or __del__ can use "pass" or just documentation, because some implementation may work with empty methods for them. (if __init__ must take some arguments i would go for "pass") > (4. Are there others?) > > In the light of 2., __del__ might be a special case because it may be > very important for clean-up and at the same time might go unnoticed > for a while because Python will use its default behaviour regardless > if __del__ had been defined in the abstract class or not. most classes don't need a __del__ as python has a good memory management. you _must have_ it only when you allocate external recources (e.g. files are closed if all references to them are deleted, but if you open a serial port as file it will be closed but the original settings are not restored.). > > Which approach would you prefer and why? Can you think of criteria/cases > where you would use one approach and in another case another approach? > > Thanks in advance for your replies. > > Stefan > -- Chris From graz at mindless.com Thu Jan 3 22:50:45 2002 From: graz at mindless.com (Graham Ashton) Date: Thu, 03 Jan 2002 21:50:45 +0000 Subject: Style for overwritten methods of abstract classes References: <3C34A6AE.4293E82C@ndh.net> Message-ID: In article <3C34A6AE.4293E82C at ndh.net>, "Stefan Schwarzer" wrote: > class CacheBase: > '''Represents an abstract interface for the URL/value storage. > > Overwrite __init__, __getitem__, __setitem__, and __del__ to > customize the class.''' > > def __init__(self): > pass > > def __getitem__(self, url): > '''Return an abstract value from the cache for the given URL. > Return None if the URL is not in the cache.''' return None > [snip] I suspect that what you've got above is only a little more useful than documentation on it's own. Atleast it's more likely to get updated if the interface changes. Whenever I need to do this I always go for your third option (raise an exception). I also tend to use that trick when I'm fleshing out an interface and think I'm being too lazy to write all my unit tests up front; it's like an extra safety net, even if I don't need to overwrite stuff later. A bit like an in-line post-it note, telling me exactly where to come back to implement the next bit of functionality. > 3. use code but let the abstract methods raise NotImplementedError > instead of providing a default behaviour which might be useless I also like it to tell me exactly what was missed (okay, you can find it in the traceback, but I find this slows down my edit/run cycle less): def spam(self): raise NotImplementedError, "%s has not implemented spam()" % \ self.__class__ --- Graham From aleax at aleax.it Fri Jan 4 17:49:25 2002 From: aleax at aleax.it (Alex Martelli) Date: Fri, 4 Jan 2002 17:49:25 +0100 Subject: Style for overwritten methods of abstract classes References: <3C34A6AE.4293E82C@ndh.net> Message-ID: "Stefan Schwarzer" wrote in message news:3C34A6AE.4293E82C at ndh.net... > Hello all :) > > As an example, I have an abstract base class CacheBase which provides > an interface to a persistent storage. All methods _could_ be either > overwritten (__init__, __del__) or _have to_ be provided (__getitem__, > __setitem__). Initially, I wrote ... > So I can think of three different approaches: > 1. write the code as above > 2. merely describe the implementation/interfaces (e. g. in the class > docstring or in a comment); write no code > 3. use code but let the abstract methods raise NotImplementedError > instead of providing a default behaviour which might be useless > (4. Are there others?) Yes, there are. You could have a metaclass that does ensure the behavior you desire, and specify specialmethods that MAY or MUST be provided in class-attributes. It's easier in 2.2, of course, where you can make your metaclass just by inheriting from type and tweaking it slightly, so, for example, here's a metaclass to implement "must-checking", only: class AbstractionError(Exception): pass class me(type): def __init__(self, name, bases, classdict): type.__init__(self, name, bases, classdict) if bases == (): missing = self.__must_methods = classdict.get('_must_methods_',()) else: missing = [] for x in self.__must_methods: if not hasattr(self, x): missing.append(x) if missing: errmsg = "Can't instantiate (%s), missing methods (%s)" % ( name, ' '.join(missing)) class dontcallme(me): def __call__(*args, **kwds): raise AbstractionError, errmsg self.__class__ = dontcallme else: class callme(me): __call__ = type.__call__ self.__class__ = callme def tryMaking(klass): try: x = klass() except AbstractionError, noway: print noway else: print "made", x class AbstractBase: __metaclass__ = me _must_methods_ = '__getitem__ __setitem__'.split() tryMaking(AbstractBase) class SemiConcrete(AbstractBase): def __getitem__(self, index): pass tryMaking(SemiConcrete) class ConcreteClass(SemiConcrete): def __setitem__(self, index, value): pass tryMaking(ConcreteClass) Of course, you may choose to be even more thorough in your checks, e.g., check for compatibility of signature rather than just for equal names. Adding the "may" (raising errors if a class using me as its meta ever dares define a class-attribute not in an allowed-list) is left as an exercise to the reader -- it's not hard, of course. The (tiny) advantage of this approach, just like for any "declaration", is that you get your error at the earliest possible moment -- when a class that doesn't define all methods you "know" it MUST define (thus, an abstract class) is *instantiated*. If you didn't want to allow partial definition such as in SemiConcrete, you could get the error at the time such a class is *defined*, of course. You pay the price in terms of runtime only when a class is defined -- that's when me.__init__ runs. The larger price is exactly in the extra checks that this approach lets you do... That price is hefty indeed. Now, suddenly, even if you never use nor need (e.g.) __getitem__, it becomes an error not to have it: you're not within Python's wonderfully-smooth world of signature based polymorphism anymore. But, to each its own. Python gives you all the power you need to shoot yourself in the foot, in this and several other ways. While still not the best language for "Bondage and Discipline Programming", Python does enjoy the advantage (?) that you may easily devise and implement your own cruel and unusual punishments for yourself along these lines. Alex From s.schwarzer at ndh.net Sun Jan 6 17:05:15 2002 From: s.schwarzer at ndh.net (Stefan Schwarzer) Date: Sun, 06 Jan 2002 17:05:15 +0100 Subject: class "type" and metaclasses (was Re: Style for overwritten methods of abstract classes) References: <3C34A6AE.4293E82C@ndh.net> Message-ID: <3C3875BB.34B46CC@ndh.net> Hello Alex thank you for the long answer. Here's mine. :-) Alex Martelli wrote: > > So I can think of three different approaches: > > 1. write the code as above > > 2. merely describe the implementation/interfaces (e. g. in the class > > docstring or in a comment); write no code > > 3. use code but let the abstract methods raise NotImplementedError > > instead of providing a default behaviour which might be useless > > (4. Are there others?) > > Yes, there are. You could have a metaclass that does ensure the > behavior you desire, and specify specialmethods that MAY or MUST > be provided in class-attributes. > > It's easier in 2.2, of course, where you can make your metaclass > just by inheriting from type and tweaking it slightly, so, for > example, here's a metaclass to implement "must-checking", only: [Interesting code example of metaclass snipped] To be honest, I haven't understood everything of this but it inspired my curiosity regarding the "type" class. I didn't find anything about it in the Python 2.2 docs (though I won't say it's not there ;-) ). However, I discovered something via >>> help(type) (and then using the HTTP "version" of pydoc). The PEPs 252 and 253 seemed rather to be aimed at C programmers who want to define their own types. The most useful document (for me) seems to be the tutorial "Unifying types and classes in Python 2.2" at http://www.python.org/2.2/descrintro.html . If I haven't overlooked it that also doesn't mention the type class, does it? There are some more questions open (for me): - Where can I find more information on metaclass programming in Python? - (How) are the built-in function type and the class named "type" (that didn't exist prior to Python 2.2?) related? - Should I be very concerned with metaclass programming? I can't really estimate how useful they are. On the other hand, I suppose that would not have been added to Python if it weren't useful (contrasted to beeing merely "nice"). Are metaclasses rather for experts? > But, to each its own. Python gives you all the power you need to > shoot yourself in the foot, in this and several other ways. While > still not the best language for "Bondage and Discipline Programming", > Python does enjoy the advantage (?) that you may easily devise and > implement your own cruel and unusual punishments for yourself > along these lines. No, I don't like B&D programming. If I would, I probably wouldn't use Python but rather C++ or Java. ;-) My question aimed more at a simple or elegant approach. (Please don't be upset if you consider your suggestion simple and/or elegant. To be more specifically: the usage of the so defined class may be simple but its implementation not so. ;-) ). Stefan From loewis at informatik.hu-berlin.de Sun Jan 6 17:58:03 2002 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 06 Jan 2002 17:58:03 +0100 Subject: class "type" and metaclasses (was Re: Style for overwritten methods of abstract classes) References: <3C34A6AE.4293E82C@ndh.net> <3C3875BB.34B46CC@ndh.net> Message-ID: Stefan Schwarzer writes: > To be honest, I haven't understood everything of this but it inspired > my curiosity regarding the "type" class. I didn't find anything about > it in the Python 2.2 docs (though I won't say it's not there ;-) ). The type class is just what used to be the type type in earlier Python versions, i.e. , see http://www.python.org/doc/current/lib/bltin-type-objects.html It is just that the builtin type() function is not a function anymore, but the type object itself. > The PEPs 252 and 253 seemed rather to be aimed at C programmers who > want to define their own types. The most useful document (for me) seems > to be the tutorial "Unifying types and classes in Python 2.2" at > http://www.python.org/2.2/descrintro.html . If I haven't overlooked it > that also doesn't mention the type class, does it? The type class is nothing new in Python, it was always there. > - Where can I find more information on metaclass programming in Python? At the moment: Use the source, Luke. Volunteers to write documentation are highly encouraged to do so. > - (How) are the built-in function type and the class named "type" (that > didn't exist prior to Python 2.2?) related? The builtin is not a function anymore, it is a type. It existed before, as types.TypeType. Since types are callable now, many builtins have changed from functions to types (like int, float, str). > - Should I be very concerned with metaclass programming? No. > On the other hand, I suppose that would not have been added to > Python if it weren't useful (contrasted to beeing merely > "nice"). Are metaclasses rather for experts? The prime rationale for adding them was the ability to have types implemented in C to be used as base classes for Python-defined classes; this was not possible before. The prime rationale for that, in turn, was the desire to get rid of the ExtensionClasses infrastructure, in particular inside Zope. So unless you have written ExtensionClasses before, you don't need to worry about meta-programming. If you have written extension classes, you should consider moving to 2.2 style types/classes ASAP, to let us better understand how usable the existing API is. Please expect that many things will change in the future in this area; there is a desire to add "proper syntax" for many of the features which are currently done through conventions only (e.g. __slots__, __metaclass__). Regards, Martin From aleax at aleax.it Sun Jan 6 18:37:27 2002 From: aleax at aleax.it (Alex Martelli) Date: Sun, 06 Jan 2002 17:37:27 GMT Subject: class "type" and metaclasses (was Re: Style for overwritten methods of abstract classes) References: <3C34A6AE.4293E82C@ndh.net> <3C3875BB.34B46CC@ndh.net> Message-ID: Stefan Schwarzer wrote: ... > [Interesting code example of metaclass snipped] > > To be honest, I haven't understood everything of this but it inspired > my curiosity regarding the "type" class. I didn't find anything about > it in the Python 2.2 docs (though I won't say it's not there ;-) ). I don't think the type type is yet covered in the docs -- I see it still mentioned there as a built-in function (which it isn't any more; try: [alex at lancelot cb4ok]$ python Python 2.2 (#1, Dec 23 2001, 20:09:01) [GCC 2.96 20000731 (Mandrake Linux 8.1 2.96-0.62mdk)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> type(type) >>> > to be the tutorial "Unifying types and classes in Python 2.2" at > http://www.python.org/2.2/descrintro.html . If I haven't overlooked it > that also doesn't mention the type class, does it? http://www.python.org/2.2/descrintro.html#metaclasses "The built-in 'type' is the most common metaclass; it is the metaclass of all built-in types." > - Where can I find more information on metaclass programming in Python? http://www.python.org/doc/essays/metaclasses/ but it's not really recommended -- in 2.2, things are simpler, as explained in the above-referenced paragraph of the descrintro.html. > - (How) are the built-in function type and the class named "type" (that > didn't exist prior to Python 2.2?) related? Many entities that were built-in functions (acting as factories) up to 2.1 have become types in 2.2. type, int, str ... > - Should I be very concerned with metaclass programming? I can't really > estimate how useful they are. On the other hand, I suppose that would > not have been added to Python if it weren't useful (contrasted to beeing > merely "nice"). Are metaclasses rather for experts? Yes, they're still intended for experts, although they've become much easier to use with 2.2 wrt 2.1. I've never felt the need for actual use of metaclasses in production code, myself... yet. Most of what you can accomplish with a metaclass, you can also do with clever metaprogramming in __getattr__ and friends. However, doing it in a metaclass has potential advantages: the magic happens at class-construction time, rather than on each attribute access -- so, errors may be diagnosed earlier (making them easier to ferret out in tests, and easier to correlate with what's actually wrong with the code) and performance overhead may be less. However, rather than thinking of them as something that's been added to Python, I see them as part of Python's general stance that *the underlying mechanics are exposed* -- you don't HAVE to mess with them, but, if you want, you can... they're very instructive to study and experiment with, although using them in production code may not be appropriate. Back when I was a motorcycle enthusiast, I carefully studied every detail of my machine's "low-level" behavior. I never actually needed to do any serious maintenance myself (excellent motorcycle mechanics are not scarce in the hometown of Ducati &c:-), but I felt the understanding and familiarity with the "underlying mechanisms" made me a better driver anyway, besides getting me ready should an emergency ever call for detailed knowledge. To be honest, these days I drive a Honda Civic (or, more often, just ride a bus:-) and I have very vague ideas about what exactly keeps it ticking in fine detail, just like most drivers (and bus passengers). But should I ever be bitten by the motorcycle bug again, I think that once again I will appreciate having all underlying mechanisms detailed and exposed... it's just a different mindset. Not all bikers share it, mind you -- it's optional. You CAN approach a motorbike, just like you approach a car, as a "black box" -- it's a very convenient and practical vehicle even then, after all. But, you do have the option of going deeper. > No, I don't like B&D programming. If I would, I probably wouldn't use > Python but rather C++ or Java. ;-) My question aimed more at a simple > or elegant approach. (Please don't be upset if you consider your > suggestion simple and/or elegant. To be more specifically: the usage > of the so defined class may be simple but its implementation not so. > ;-) ). I make no claims about the quality of the solution I proposed (actually hacked together somewhat fast) and wouldn't be surprised if it could be substantially improved. The fundamental idea however does seem quite simple to me. When a class statement executes, the metaclass is instantiated, so the metaclass's __init__ executes. At that time, I want this metaclass-instance (this class) to become callable (with the normal semantics, that of producing class-instances) if and only if no abstract methods are left; otherwise, calling the class must raise an exception with a suitable error-message about what methods have not been overridden (have remained abstract). All I do in that metaclass is try to enforce this idea, in order to parallel or mimic the "abstract classes" (non-instantiable classes) of certain other languages. The whole setup seems reasonably elegant to me within the specified mindset of "must override" and "may override". How else is a class going to be able to constrain its subclasses regarding what may or may not, must or must not, be overridden? I think the mindset itself is at fault, and the normal Pythonic approach (let anybody override whatever, diagnose problems at runtime only if conflicts arise) far superior. But the ability to constrain the 'may' and 'must' was the very essence of the thread, no? One case where I think a similar use of metaclasses might be _productive_ is to emulate Haskell's typeclass construct. In a Haskell typeclass, 'abstract' methods may be specified in apparently mutually-recursive terms, for example (in Python syntax): class OneOrMany: def doOne(self, one): self.doMany([one]) def doMany(self, many): for one in many: self.doOne(one) To implement a typeclass into an instantiable class, you have to override some subset of its methods so that all dependency cycles are broken. Here, you might override either or both of doOne and doMany, otherwise the class would not be implementable. Now THIS is what I consider elegant: it clearly specifies the intended semantic dependencies between the methods, and doesn't arbitrarily define one as more fundamental than others, when they're actually all on the same plane. To translate this into a Python metaclass, you'd have to automatically or explicitly identify the dependencies (doOne->doMany, doMany->doOne), notice which dependencies are broken by subclassing (overriding some subsets of the methods), and check if the resulting dependency graph is acyclic -- otherwise, keep the class non-instantiable until by further subclassing the graph does become acyclic. Alex From s.schwarzer at ndh.net Mon Jan 7 00:05:20 2002 From: s.schwarzer at ndh.net (Stefan Schwarzer) Date: Mon, 07 Jan 2002 00:05:20 +0100 Subject: class "type" and metaclasses (was Re: Style for overwritten methods of abstract classes) References: <3C34A6AE.4293E82C@ndh.net> <3C3875BB.34B46CC@ndh.net> Message-ID: <3C38D830.43278623@ndh.net> Hello Alex Alex Martelli wrote: > > - (How) are the built-in function type and the class named "type" (that > > didn't exist prior to Python 2.2?) related? > > Many entities that were built-in functions (acting as factories) up to 2.1 > have become types in 2.2. type, int, str ... I don't know if this question is related but it appeared to me some weeks ago: I can define __int__ etc. in my classes to provide an "opportunity" for int() to "convert" an instance of my class into an int. I have not seen something like this for e. g. __list__, so I could write something like class ACollection: #... def __list__(self): '''Return a list object representing the contents of this object.''' # ... obj = ACollection() # do something with obj L = list(obj) Is it anyhow possible? Or, first, is it desirable and/or why was/is it omitted from Python? (It's not that it hurts me, but to me it's an asymmetry.) > > No, I don't like B&D programming. If I would, I probably wouldn't use > > Python but rather C++ or Java. ;-) My question aimed more at a simple > > or elegant approach. (Please don't be upset if you consider your > > suggestion simple and/or elegant. To be more specifically: the usage > > of the so defined class may be simple but its implementation not so. > > ;-) ). > > I make no claims about the quality of the solution I proposed (actually > hacked together somewhat fast) and wouldn't be surprised if it could be > substantially improved. > > The fundamental idea however does seem quite simple to me. When a class > statement executes, the metaclass is instantiated, so the metaclass's > __init__ executes. At that time, I want this metaclass-instance (this > class) to become callable (with the normal semantics, that of producing > class-instances) if and only if no abstract methods are left; otherwise, > calling the class must raise an exception with a suitable error-message > about what methods have not been overridden (have remained abstract). All > I do in that metaclass is try to enforce this idea, in order to parallel or > mimic the "abstract classes" (non-instantiable classes) of certain other > languages. > > The whole setup seems reasonably elegant to me within the specified mindset > of "must override" and "may override". How else is a class going to be > able to constrain its subclasses regarding what may or may not, must or > must not, be overridden? I think the mindset itself is at fault, and the > normal Pythonic approach (let anybody override whatever, diagnose problems > at runtime only if conflicts arise) far superior. But the ability to > constrain the 'may' and 'must' was the very essence of the thread, no? Don't worry. :-) I did understand this from your previous posting. I just could not figure out the details of the implementation. If I hadn't understood your goals or your approach, I wouldn't have found so much interest in it that I had asked those questions in response. :-) > One case where I think a similar use of metaclasses might be _productive_ > is to emulate Haskell's typeclass construct. In a Haskell typeclass, > 'abstract' methods may be specified in apparently mutually-recursive terms, > for example (in Python syntax): > > class OneOrMany: > def doOne(self, one): > self.doMany([one]) > def doMany(self, many): > for one in many: > self.doOne(one) > > To implement a typeclass into an instantiable class, you have to override > some subset of its methods so that all dependency cycles are broken. Here, > you might override either or both of doOne and doMany, otherwise the class > would not be implementable. Now THIS is what I consider elegant: it > clearly specifies the intended semantic dependencies between the methods, > and doesn't arbitrarily define one as more fundamental than others, when > they're actually all on the same plane. To translate this into a Python > metaclass, you'd have to automatically or explicitly identify the > dependencies (doOne->doMany, doMany->doOne), notice which dependencies are > broken by subclassing (overriding some subsets of the methods), and check > if the resulting dependency graph is acyclic -- otherwise, keep the class > non-instantiable until by further subclassing the graph does become acyclic. Yes, I think I understand. :-) On the other hand, I don't know if I would really like it. C++ does so many things automatically that it's not so easy to keep all these rules in mind and consider them when it's necessary. I like the simplicity of Python. :-) Stefan From jason at jorendorff.com Mon Jan 7 06:19:22 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Sun, 6 Jan 2002 23:19:22 -0600 Subject: __list__ (was: class "type" and metaclasses) In-Reply-To: <3C38D830.43278623@ndh.net> Message-ID: > I don't know if this question is related but it appeared to me some > weeks ago: I can define __int__ etc. in my classes to provide an > "opportunity" for int() to "convert" an instance of my class into an > int. I have not seen something like this for e. g. __list__, so I could > write something like > > [...sample omitted...] > > Is it anyhow possible? Well, yes... If you implement __getitem__() or __iter__(), then list() and dict() will use those. For example, import os class Dir: def __init__(self, path): self.path = path def __iter__(self): return iter(os.listdir(self.path)) d = Dir("c:\\") x = list(d) print x Of course, hypothetical __list__() or __dict__() methods would have been another possible design. But I think the existing behavior is precisely what you'd normally want. I've never used __int__() or __float__(); I use __str__() all the time, but mostly for debug reasons. ## Jason Orendorff http://www.jorendorff.com/ From s.schwarzer at ndh.net Mon Jan 7 20:55:44 2002 From: s.schwarzer at ndh.net (Stefan Schwarzer) Date: Mon, 07 Jan 2002 20:55:44 +0100 Subject: __list__ (was: class "type" and metaclasses) References: Message-ID: <3C39FD40.7C874207@ndh.net> Hello Jason thanks for this reply. Jason Orendorff wrote: > Well, yes... If you implement __getitem__() or __iter__(), > then list() and dict() will use those. For example, > > import os > > class Dir: > def __init__(self, path): > self.path = path > def __iter__(self): > return iter(os.listdir(self.path)) > > d = Dir("c:\\") > x = list(d) > print x > > Of course, hypothetical __list__() or __dict__() methods > would have been another possible design. But I think the > existing behavior is precisely what you'd normally want. yes > I've never used __int__() or __float__(); I use __str__() > all the time, but mostly for debug reasons. I think __int__ and __float__ are mostly for numeric types as the docs suggest. I use __str__ for "nice" "human-readable" output and __repr__ for debug output. Stefan From aleax at aleax.it Mon Jan 7 09:56:36 2002 From: aleax at aleax.it (Alex Martelli) Date: Mon, 7 Jan 2002 09:56:36 +0100 Subject: class "type" and metaclasses (was Re: Style for overwritten methods of abstract classes) References: <3C34A6AE.4293E82C@ndh.net> <3C3875BB.34B46CC@ndh.net> <3C38D830.43278623@ndh.net> Message-ID: "Stefan Schwarzer" wrote in message news:3C38D830.43278623 at ndh.net... ... > I don't know if this question is related but it appeared to me some > weeks ago: I can define __int__ etc. in my classes to provide an > "opportunity" for int() to "convert" an instance of my class into an > int. I have not seen something like this for e. g. __list__, so I could Define __iter__ instead: that's what list(x) calls, as well as any "for item in x" loops. It makes no difference for list(), but, for loops, it may be a crucial saving of resources to be able to generate the items one by one, each only as needed, rather than having to build the whole list in memory at the same time. > On the other hand, I don't know if I would really like it. C++ does so > many things automatically that it's not so easy to keep all these rules > in mind and consider them when it's necessary. I like the simplicity of > Python. :-) I agree that C++'s utter complexity is C++'s key defect, and that much of the complexity comes from the desire to offer "convenient" automatic/default behavior in so many different and slightly overlapping cases. And I share your appreciation for the simplicity achieved with Python. But I don't see how these consideration apply to Haskell-ish typeclasses (which are not offered in C++, anyway). Isn't their superiority over C++'s "abstract classes" rather obvious? And what diminution of simplicity do you see in Haskell typeclasses when compared to C++ abstract classes? In a C++ abstract class you basically *have* to over-constrain -- decide at abstract-class-design time which methods are "more fundamental" than others, when in fact there may be no such constraint in the abstract system you're modeling. Where's the simplicity gain in this? Alex From s.schwarzer at ndh.net Mon Jan 7 20:36:09 2002 From: s.schwarzer at ndh.net (Stefan Schwarzer) Date: Mon, 07 Jan 2002 20:36:09 +0100 Subject: class "type" and metaclasses (was Re: Style for overwritten methods of abstract classes) References: <3C34A6AE.4293E82C@ndh.net> <3C3875BB.34B46CC@ndh.net> <3C38D830.43278623@ndh.net> Message-ID: <3C39F8A9.C87BC795@ndh.net> Hi Alex Alex Martelli wrote: ["substitute" for non-existing __list__] > Define __iter__ instead: that's what list(x) calls, as well as any > "for item in x" loops. It makes no difference for list(), but, for > loops, it may be a crucial saving of resources to be able to generate > the items one by one, each only as needed, rather than having to > build the whole list in memory at the same time. hm, rather flexible :-) > But I don't see how these consideration apply to Haskell-ish typeclasses > (which are not offered in C++, anyway). Isn't their superiority over C++'s > "abstract classes" rather obvious? And what diminution of simplicity do > you see in Haskell typeclasses when compared to C++ abstract classes? I didn't want to compare Haskell with C++. Indeed, I know nothing about Haskell. It might have been an unconscious reflex to "compare" them because of the association by doing things implicitly. Since I do know practically nothing about Haskell, I clearly can't judge about it. :-) The interaction of the method-for-one and the method-for-many though is really interesting because the two are often (or often enough to trigger a feeling of familarity) needed both. Stefan From aleaxit at yahoo.com Mon Jan 7 22:40:51 2002 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 7 Jan 2002 22:40:51 +0100 Subject: class "type" and metaclasses (was Re: Style for overwritten methods of abstract classes) References: <3C34A6AE.4293E82C@ndh.net> <3C3875BB.34B46CC@ndh.net> <3C38D830.43278623@ndh.net> <3C39F8A9.C87BC795@ndh.net> Message-ID: Stefan Schwarzer wrote: ... > ["substitute" for non-existing __list__] >> Define __iter__ instead: that's what list(x) calls, as well as any >> "for item in x" loops. It makes no difference for list(), but, for ... > hm, rather flexible :-) Yep, iterators are. > I didn't want to compare Haskell with C++. Indeed, I know nothing about > Haskell. It might have been an unconscious reflex to "compare" them > because of the association by doing things implicitly. Since I do know > practically nothing about Haskell, I clearly can't judge about it. :-) The only substantial "thing done implicitly" (optionally) in Haskell (and not in C++) is that types can be inferred by the compiler on your behalf -- you don't have to declare them, although you may (it's probably more idiomatic Haskell to declare them anyway). > The interaction of the method-for-one and the method-for-many though is > really interesting because the two are often (or often enough to trigger > a feeling of familarity) needed both. I agree, and that's why I like to use this as a toy example of a typeclass rather than the probably more canonical ones using arithmetic. Alex From issac at myfirstlink.net Thu Jan 3 20:26:48 2002 From: issac at myfirstlink.net (Issac) Date: Thu, 3 Jan 2002 13:26:48 -0600 Subject: Starship / PSA Message-ID: <006d01c1948c$9839c660$6401a8c0@mojave> I'd like to put the Python programs I've written up on Starship Python, but I don't know how to do this. How can the Starship require a PSA membership when the PSA doesn't exist anymore, having been replaced with the exclusive PSF? http://starship.python.net/ http://www.python.org/psa/ http://zope.python.org/psf/about/ Issac From aahz at panix.com Fri Jan 4 06:42:54 2002 From: aahz at panix.com (Aahz Maruch) Date: 3 Jan 2002 21:42:54 -0800 Subject: Starship / PSA References: Message-ID: In article , Issac wrote: > >I'd like to put the Python programs I've written up on Starship Python, >but I don't know how to do this. How can the Starship require a PSA >membership when the PSA doesn't exist anymore, having been replaced >with the exclusive PSF? It's yet another documentation wart. Write to webmaster at starship.python.net explaining why you want a Starship account and you'll probably get it. -- --- Aahz <*> (Copyright 2002 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista Pretty soon, cell phones will be so small we won't know who's crazy. From peter.milliken at gtech.com Thu Jan 3 20:52:38 2002 From: peter.milliken at gtech.com (Peter Milliken) Date: Fri, 4 Jan 2002 06:52:38 +1100 Subject: REPOST: Book Royalties (was: win32all-141 for Python 2.2) References: <3C2D4676.5060700@skippinet.com.au> <3C2D49E6.39FD96BE@earthlink.net> <3C2E5508.7B5455C0@engcorp.com> <5$--$$_----__-$_%$@news.noc.cabal.int> Message-ID: "Bruce Eckel" wrote in message news:5$--$$_----__-$_%$@news.noc.cabal.int... > You can get a rough estimate with these numbers: > > A computer book author typically gets between 10-15% royalties. > Let's be positive and say it's 15%. But that's 15% of what the > publisher gets, which is roughly half of what the bookseller > charges (retail, in general, doubles their cost, which sounds like > a lot but retail is still a very difficult business). My copy of > Mark's book says $35 on the back, although this is often > discounted. So let's say the publisher gets $17.50, then Mark gets > about $2.00 per book. > > It looks like the publisher gets an inordinate share here, but less > than 10% of books that most publishers put out make back their > investment -- that is, break even. About 1% are actually > successful. The successful books must pay for all the publisher's > mistakes, thus the low royalty rate. I believe that most publishers > look at this and say "to be successful, we must pump out lots of > books to increase the number that the 1% represents." Maybe they > don't say this explicitly, but there is pressure in that direction. > I think O'Reilly has been successful because it has said "instead > of always hunting for the blockbusters, let's try to make every > book something that people will want." An excellent business model, > it would seem, but one that I suspect will only work in a > privately-held company, as the constant-growth imperative of the > publicly-held corporation pressures everyone to abandon quality for > percentages. > > Just my 2%. > > Bruce Interesting - but where is the incentive for the author i.e. $2 per book isn't going to make you a millionaire anytime soon (500,000 books? :-)). Even a reasonable income of say $100K per year requires 50,000 books at that rate. I can understand things from the publishers side and don't in anyway blame them for the setup. But surely these figues would argue for a lot of pressure for an author to publish electronically and directly - hence getting far more than $2 per book i.e. from what I have seen of your Python jottings recently, I would happily pay $20 for an electronic copy of the book (10:1 improvement on your income :-)). If you follow the model of making it cheap enough people are less likely to pirate the book i.e. copy the electronic version illegally. Binding books doesn't guarantee an income - people can always ask their local library to buy it in - and they "share", so you'll never get volume sales! :-). One of the biggest problems/practics that businesses follow is "what will the audience pay", rather than "what is a reasonable price that everyone will pay" - I pass up on buying lots of items because they have obviously priced for what they think the market will bear (and they got in wrong in my case :-)) rather than attempting to sell for volume - hence they lose *some* potential profit in a sale to me - I suspect many people fall into this category and hence sales are lost. Books here in Australia - especially technical books, suffer badly from the exchange rate, we are current sitting at roughly 2:1 on the US dollar. This means that a $49.95 US book will cost me somewhere in the vicinity of $100+ AUS, and yet I earn the same salary in AUS dollars as I would if I worked in the US (which I have :-)). The exchange rate doesn't reflect any realistic standard of living or costs etc just the desires of the international monetary community in investing. Of course Australia isn't a big market at the best of times compared with the US market, so many publishers can just ignore it (population ratio is over 10:1). But these kind of numbers have driven me to my local library for fictional books (standard Science Fiction book is around $17.95 - $19.95 at the moment), I will be shortly requesting technical book buy-ins the same way. Then the sales are lost because people will find the book in their library and not have to purchase it directly. Just some of my thoughts - we don't have 1 and 2 cent pieces anymore, the smallest is a 5 cent piece :-). Peter > > *********** REPLY SEPARATOR *********** > > On 12/29/01 at 6:43 PM Peter Hansen wrote: > > >Ron Stephens wrote: > >> > >> Thanks, Mark. I really appreciate your efforts. I also suggest > that > >> *anyone* and everyone* using Python and Windows rush out and buy > your > >> book, Python Programming on Win32. Do you have any other book > projects in > >> mind? > > > >From what I understand of how book publishing works, > >Mark probably makes about 10 cents on each sale. ;-) > >It would be better to just send him a cheque! > > > >-- > >---------------------- > >Peter Hansen, P.Eng. > >peter at engcorp.com > >-- > >http://mail.python.org/mailman/listinfo/python-list > > > > Most current information can be found at: > http://www.mindview.net/Etc/notes.html > =================== > Bruce Eckel http://www.BruceEckel.com > Contains free electronic books: "Thinking in Java 2e" & "Thinking > in C++ 2e" > Please subscribe to my free newsletter -- just send any email to: > join-eckel-oo-programming at earth.lyris.net > My schedule can be found at: > http://www.mindview.net/Calendar > =================== > > ========= WAS CANCELLED BY =======: > Path: news.sol.net!spool1-nwblwi.newsops.execpc.com!newsfeeds.sol.net!newspump.sol .net!news.maxwell.syr.edu!feeder.kornet.net!news1.kornet.net!ua4canc3ll3r > From: "Bruce Eckel" > Newsgroups: comp.lang.python > Subject: cmsg cancel > Control: cancel > Date: Mon, 31 Dec 2001 01:46:53 GMT > Organization: A poorly-installed InterNetNews site > Lines: 2 > Message-ID: > NNTP-Posting-Host: 211.57.49.2 > X-Trace: news2.kornet.net 1009774147 27193 211.57.49.2 (31 Dec 2001 04:49:07 GMT) > X-Complaints-To: usenet at news2.kornet.net > NNTP-Posting-Date: Mon, 31 Dec 2001 04:49:07 +0000 (UTC) > X-No-Archive: yes > X-Unac4ncel: yes > X-Commentary: I love NewsAgent 1.10 and the Sandblaster Cancel Engine Build 74 (19 March 1999) > > This message was cancelled from within Mozilla. From aahz at panix.com Fri Jan 4 06:46:42 2002 From: aahz at panix.com (Aahz Maruch) Date: 3 Jan 2002 21:46:42 -0800 Subject: Book Royalties (was: win32all-141 for Python 2.2) References: <3C2D4676.5060700@skippinet.com.au> <3C2E5508.7B5455C0@engcorp.com> <5$--$$_----__-$_%$@news.noc.cabal.int> Message-ID: In article , Peter Milliken wrote: > >Interesting - but where is the incentive for the author i.e. $2 per book >isn't going to make you a millionaire anytime soon (500,000 books? :-)). The incentive for most authors lies in charging $1000-$5000/day for running training classes (being the author of a well-known book increases either or both of the pay scale and opportunities for training) or in the egoboo (ego-boosting) of being a published author. That's about it. -- --- Aahz <*> (Copyright 2002 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista Pretty soon, cell phones will be so small we won't know who's crazy. From mats at laplaza.org Mon Jan 7 19:00:12 2002 From: mats at laplaza.org (Mats Wichmann) Date: Mon, 07 Jan 2002 18:00:12 GMT Subject: Book Royalties (was: win32all-141 for Python 2.2) References: <3C2D4676.5060700@skippinet.com.au> <3C2E5508.7B5455C0@engcorp.com> <5$--$$_----__-$_%$@news.noc.cabal.int> Message-ID: <3c39e22a.1996971@news.laplaza.org> On 3 Jan 2002 21:46:42 -0800, aahz at panix.com (Aahz Maruch) wrote: :In article , :Peter Milliken wrote: :> :>Interesting - but where is the incentive for the author i.e. $2 per book :>isn't going to make you a millionaire anytime soon (500,000 books? :-)). : :The incentive for most authors lies in charging $1000-$5000/day for :running training classes (being the author of a well-known book increases :either or both of the pay scale and opportunities for training) or in the :egoboo (ego-boosting) of being a published author. That's about it. It's more than just training. At least for consultants (and training can be considered "consulting" in this space), consider writing a book as a marketing expense. Mats Wichmann From navead at hotmail.com Thu Jan 3 21:07:09 2002 From: navead at hotmail.com (navead) Date: 3 Jan 2002 12:07:09 -0800 Subject: Displaying X11 on Tk Message-ID: Hi, I currently have a program which is written in python using Tk, and also I have a program written in C/C++ which uses X11, what I want to do is in the C program rather than display to X11, I would like to have it display on my Tk winddow... I am thinking I probably have to write a wrapper for the Xlib, so that it calls Tk functions, but this can be a hassle. if anyone knows about any package which may already exist, or maybe another method of getting around this problem, I would greatly appreciate it if you would email me. thanks, Navead From martin at v.loewis.de Fri Jan 4 03:19:24 2002 From: martin at v.loewis.de (Martin v. Loewis) Date: 04 Jan 2002 03:19:24 +0100 Subject: Displaying X11 on Tk References: Message-ID: navead at hotmail.com (navead) writes: > Hi, I currently have a program which is written in python using Tk, > and also I have a program written in C/C++ which uses X11, what I > want to do is in the C program rather than display to X11, I would > like to have it display on my Tk winddow... I am thinking I probably > have to write a wrapper for the Xlib, so that it calls Tk functions, > but this can be a hassle. Not at all. Create a Toplevel or Frame widget with the container=1 resource, then use winfo_id to find out the Window ID of the window. Pass that ID to your C++ program, and give the Window ID to XCreateWindow. If you want to have it the other way around (i.e. Tk embedding itself into some other application), create a Toplevel widget with the use=WindowID resource. HTH, Martin From russell_turpin at hotmail.com Thu Jan 3 21:27:40 2002 From: russell_turpin at hotmail.com (Russell Turpin) Date: 3 Jan 2002 12:27:40 -0800 Subject: Who wants a Python programming job in Austin, Texas ? Message-ID: <8a12e538.0201031227.7cb64e8b@posting.google.com> First, let me apologize for getting anyone's hopes up. I do NOT have a job for you. For now, I'm just trying to get a sense of the availability of Python programmers in central Texas. Send me an email, and I will report the tally back here, in case others are interested in this. Here are the relevant questions: Are you looking for a job as a software developer? How long have you been a software engineer? How long have you been programming in Python? From cearnold at dallas.net Fri Jan 4 06:45:28 2002 From: cearnold at dallas.net (Charley Arnold) Date: Thu, 03 Jan 2002 23:45:28 -0600 Subject: Who wants a Python programming job in Austin, Texas ? References: <8a12e538.0201031227.7cb64e8b@posting.google.com> Message-ID: <3C354178.3050207@dallas.net> Russell Turpin wrote: > First, let me apologize for getting anyone's hopes up. I > do NOT have a job for you. For now, I'm just trying to > get a sense of the availability of Python programmers in > central Texas. Send me an email, and I will report the > tally back here, in case others are interested in this. > Here are the relevant questions: > > Are you looking for a job as a software developer? Yes - I moved to Dallas with my wife when she got transfered. Just in time for the bottom to fall out of the programmers job market. > > How long have you been a software engineer? 14+ years, mostly C and Perl (plus some older stuff no longer relevant) > > How long have you been programming in Python? I am now learning Python and C++ (QT/KDE, picking up emacs, exploring the grittier details of CVS)- got lots of time on my hands. If it were a temporary contract I could commute Austin to Dallas for a few months... > -Arnold, C. E. From syver-en+usenet at online.no Thu Jan 3 21:39:32 2002 From: syver-en+usenet at online.no (Syver Enstad) Date: 03 Jan 2002 21:39:32 +0100 Subject: Problem: PyXML 0.7 PrettyPrinting HTML, latin-1 in comments. Message-ID: Running this code : reader = dom.ext.reader.HtmlLib.Reader() domObject = reader.fromUri( os.path.expanduser('~/kode/pythonscript/index.html')) htmlDom = dom.ext.StripHtml(domObject) dom.ext.PrettyPrint(domObject) On this file: Min side p? whole note Works fine. But on this file: Min side p? whole note It says: File "D:\devtools\Python21\_xmlplus\dom\ext\Printer.py", line 356, in visitComment self._write('' % (node.data)) File "D:\devtools\Python21\_xmlplus\dom\ext\Printer.py", line 146, in _write obj = utf8_to_code(text, self.encoding) File "D:\devtools\Python21\_xmlplus\dom\ext\Printer.py", line 45, in utf8_to_code text = unicode(text, "utf-8") UnicodeError: UTF-8 decoding error: invalid data Notice that the ? character that trips up the call to PrettyPrint also exists in the a tag without causing trouble. And that in the printed output when it succeeds the ? in the a tag is substituted for an å escape or whatever it's called. My question is: What should I do to successfully print html files that are latin-1 encoded with PyXML? Is it possible? -- Vennlig hilsen Syver Enstad From joshm at taconic.net Thu Jan 3 22:28:05 2002 From: joshm at taconic.net (Joshua Muskovitz) Date: Thu, 3 Jan 2002 16:28:05 -0500 Subject: generating canonical list of tuples? Message-ID: <3c34cafa_2@corp.newsgroups.com> Here's what I'm trying to do... create "magicFunction(limit, dimension)" to return a list of tuples. Each tuple contains exactly "dimension" elements, all positive integers. The sum of these elements must be less than or equal to "limit". for example, magicFunction(5,3) should return: [ (1,1,1), (1,1,2), (1,1,3), (1,2,1), (1,2,2), (1,3,1), (2,1,1), (2,1,2), (2,2,1), (3,1,1) ] The order of the resulting tuples is unimportant. If "dimension" is a fixed number, this is easy. In the case where dimension is 3, this can be written as: [ (a,b,c) for a in range(1,4) for b in range (1,5-a) for c in range(1,6-a-b) ] But (and here is the REAL question)... how does one do this when dimension is a variable? Option 1: Recursion. Recursion will cause a memory explosion when the limit and dimension begin to grow, and so this isn't a good solution. Option 2: Exec. Construct a line of python code dynamically based on the above example, and exec it. Would this be considered a good solution? Option 3: ??? Is there a pythonic way of doing this? -- josh -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From sholden at holdenweb.com Thu Jan 3 22:43:32 2002 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 3 Jan 2002 16:43:32 -0500 Subject: generating canonical list of tuples? References: <3c34cafa_2@corp.newsgroups.com> Message-ID: "Joshua Muskovitz" wrote in message news:3c34cafa_2 at corp.newsgroups.com... > Here's what I'm trying to do... > > create "magicFunction(limit, dimension)" to return a list of tuples. Each > tuple contains exactly "dimension" elements, all positive integers. The sum > of these elements must be less than or equal to "limit". > > for example, magicFunction(5,3) should return: > [ (1,1,1), (1,1,2), (1,1,3), (1,2,1), (1,2,2), (1,3,1), (2,1,1), (2,1,2), > (2,2,1), (3,1,1) ] > > The order of the resulting tuples is unimportant. > > If "dimension" is a fixed number, this is easy. In the case where dimension > is 3, this can be written as: > > [ (a,b,c) for a in range(1,4) for b in range (1,5-a) for c in > range(1,6-a-b) ] > > But (and here is the REAL question)... how does one do this when dimension > is a variable? > > Option 1: Recursion. Recursion will cause a memory explosion when the > limit and dimension begin to grow, and so this isn't a good solution. I don't see why you make this assertion. Surely an exhaustive search for dimension 32 could be performed with no more than 33 active calls. Of course the space required to store the list will increase as limit increases, but since you want to return the list that's a given anyway. > Option 2: Exec. Construct a line of python code dynamically based on the > above example, and exec it. Would this be considered a good solution? Perhpas by some, but my own feeling is that exec (and to a lesser extent eval(), which might be another choice for this problem) should be reserved as an absolute last resort. > Option 3: ??? > I note that you regard (1,1,2) as different from (1,2,1) and (2,1,1), so ordering is clearly important. This makes it quite a knotty problem. > Is there a pythonic way of doing this? > Go for recursion! regards Steve -- http://www.holdenweb.com/ From joshm at taconic.net Fri Jan 4 08:24:19 2002 From: joshm at taconic.net (Joshua Muskovitz) Date: Fri, 4 Jan 2002 02:24:19 -0500 Subject: generating canonical list of tuples? References: <3c34cafa_2@corp.newsgroups.com> Message-ID: <3c3556b9_4@corp.newsgroups.com> > Option 1: Recursion. Recursion will cause a memory explosion when the > limit and dimension begin to grow, and so this isn't a good solution. > Option 2: Exec. Construct a line of python code dynamically based on the > above example, and exec it. Would this be considered a good solution? > Option 3: ??? Ok, so I've tried a function which brute force cranks out the tuples by adding one to the last element, carrying it over, etc. And I wrote the exec method. And I wrote the recursion method. The exec runs at least six times faster than the brute force method. Recursion causes memory to dump even sooner, since there are tons of redundant lists to gc. The code for the exec method is as follows: def genWhiteTuples(total, blocks): # produce the set of all tuples with "blocks" elements, where # the sum of the elements is less than or equal to "total" # for example, genWhiteTuples(5,3) returns # [ (1,1,1), (1,1,2), (1,1,3), (1,2,1), (1,2,2), # (1,3,1), (2,1,1), (2,1,2), (2,2,1), (3,1,1) ] # create an evil list comprehension to compute... # [ (x1,x2,x3,...) for x1 in range(1,f+1) for x2 in range(1,f+2-x1) # for x3 in range(1,f+3-x1-x2) ... ] # where f is the max value of the first element of the tuple f = total - blocks + 1 sub = '' elements = [] clauses = [] for i in range(1, blocks + 1): elements.append('x%d' % i) clauses.append('for x%d in range(1, f+%d%s)' % (i,i,sub) ) sub = '%s-x%d' % (sub, i) if len(elements) == 1: tup = '(%s,)' % elements[0] else: tup = '(' + ','.join(elements) + ')' cmd = 'good = [ %s %s ]' % (tup, ' '.join(clauses) ) exec(cmd) return good This is pretty cool, but also pretty unmaintainable. Is there a better solution? By the way, trying to compute genWhiteTuples(39, 6) caused my machine to run out of paging space after burning about 500MB. :-) I'm still working on a better algorithm than this, since even with making this run better, it'll still consume the same RAM. -- j -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From jason at jorendorff.com Fri Jan 4 09:56:24 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Fri, 4 Jan 2002 02:56:24 -0600 Subject: generating canonical list of tuples? In-Reply-To: <3c3556b9_4@corp.newsgroups.com> Message-ID: > Ok, so I've tried a function which brute force cranks out the tuples by > adding one to the last element, carrying it over, etc. And I > wrote the exec method. And I wrote the recursion method. The exec > runs at least six times faster than the brute force method. I haven't been following this thread; perhaps someone already suggested using a generator for this. # Python 2.2 only from __future__ import generators def genWhiteTuples(total, blocks): """ The 'brute force' method, as a generator. """ if total < blocks: # Trivial case return result = [1] * blocks running_total = blocks while 1: yield tuple(result) while running_total < total: # Easy. Just increment the rightmost number. result[-1] += 1 running_total += 1 yield tuple(result) # Look for an element to reset. index = blocks - 1 while index > 0: if result[index] > 1: # We found an element to reset. # (Must also increment the element to its left.) running_total = running_total - result[index] + 2 result[index] = 1 result[index-1] += 1 break index -= 1 else: # This means we're done. return You can use a generator in a for statement, just as you would use a list. for x1, x2, x3 in genWhiteTuples(10, 3): do_something(x1, x2, x3) In this case, RAM consumption is low, because the tuples are generated one at a time, as needed, instead of generating them all at once and putting them in a list. In fact, I can even: n = 0 for t in genWhiteTuples(39, 6): n += 1 # count how many results print n It runs in about 10 seconds on my machine, and doesn't use much RAM. The result is 3262623. If you *must* have a list, the syntax is pretty simple: L = list(genWhiteTuples(20, 10)) On my machine, this runs about as fast as your exec-based version, and uses about the same amount of memory. ## Jason Orendorff http://www.jorendorff.com/ From phr-n2002a at nightsong.com Fri Jan 4 09:06:51 2002 From: phr-n2002a at nightsong.com (Paul Rubin) Date: 04 Jan 2002 00:06:51 -0800 Subject: generating canonical list of tuples? References: <3c34cafa_2@corp.newsgroups.com> Message-ID: <7xd70qtu90.fsf@ruckus.brouhaha.com> "Joshua Muskovitz" writes: > Option 1: Recursion. Recursion will cause a memory explosion when the > limit and dimension begin to grow, and so this isn't a good solution. There will be a memory explosion as the limit and dimension grow whether you use recursion or not, because the size of the output list will grow very rapidly. From joshm at taconic.net Fri Jan 4 09:48:11 2002 From: joshm at taconic.net (Joshua Muskovitz) Date: Fri, 4 Jan 2002 03:48:11 -0500 Subject: generating canonical list of tuples? References: <3c34cafa_2@corp.newsgroups.com> <7xd70qtu90.fsf@ruckus.brouhaha.com> Message-ID: <3c356a62_1@corp.newsgroups.com> > There will be a memory explosion as the limit and dimension grow > whether you use recursion or not, because the size of the output list > will grow very rapidly. Yes, this occurred to me -- that regardless of algorithm, the resulting data is identical, and expands very quickly as the dimension grows. I'm working on solving that issue separately from optimizing this mechanism. I'm also trying to understand some of the subtleties of Python 2.x and this is a good way to ferret some of them out. -- j -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From aleax at aleax.it Fri Jan 4 15:02:19 2002 From: aleax at aleax.it (Alex Martelli) Date: Fri, 4 Jan 2002 15:02:19 +0100 Subject: generating canonical list of tuples? References: <3c34cafa_2@corp.newsgroups.com> Message-ID: "Joshua Muskovitz" wrote in message news:3c34cafa_2 at corp.newsgroups.com... > Here's what I'm trying to do... > > create "magicFunction(limit, dimension)" to return a list of tuples. Each > tuple contains exactly "dimension" elements, all positive integers. The sum > of these elements must be less than or equal to "limit". > > for example, magicFunction(5,3) should return: > [ (1,1,1), (1,1,2), (1,1,3), (1,2,1), (1,2,2), (1,3,1), (2,1,1), (2,1,2), > (2,2,1), (3,1,1) ] > > The order of the resulting tuples is unimportant. OK, quite clear. > If "dimension" is a fixed number, this is easy. In the case where dimension ... > But (and here is the REAL question)... how does one do this when dimension > is a variable? Think "counting in a variable base" -- it's often a good mindset in such 'enumeration problems'. In counting we increment each digit as far as possible, then when the digit would overflow we reset it to the minimum value and proceed to the next most significant digit. Here, a 'digit overflows' when the total reaches the limit, so...: def magicFunction(limit, dimension): if limit < dimension: return [] current = [1]*dimension results = [tuple(current)] def total(current): import operator return reduce(operator.add, current) while 1: index = 0 while index < dimension: if total(current) < limit: current[index] += 1 results.append(tuple(current)) break # exit inner loop, continue outer loop elif current[index] > 1: current[index] = 1 index += 1 else: return results Rather than recomputing the total() each time, you could also maintain it incrementally. This also looks like a good candidate to make into a simple-generator, by just changing the .append (and the first assiment to results) into yield statements and making the return statements expressionless -- but that, obviously, wouldn't change the algorithm, just package it up in a potentially more usable way. Alex From joshm at taconic.net Fri Jan 4 17:58:07 2002 From: joshm at taconic.net (Joshua Muskovitz) Date: Fri, 4 Jan 2002 11:58:07 -0500 Subject: generating canonical list of tuples? References: <3c34cafa_2@corp.newsgroups.com> Message-ID: <3c35dd37_3@corp.newsgroups.com> Yes, as Alex and Jason both correctly point out, the concept I was missing is that of using a generator. This was something I read about in the new docs, but didn't fully grok. This is an excellent example of how and why to use them. In retrospect, the use of the word "generating" in my subject line should have tipped me off! :-) I'm hoping to give this idea a spin later today! Thanks for all the help. Hire-me-dammit-ly yrs, -- josh -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From craigesmith at hotmail.com Thu Jan 3 22:33:22 2002 From: craigesmith at hotmail.com (Craig E. Smith) Date: 3 Jan 2002 13:33:22 -0800 Subject: Code explanation please Message-ID: <90cdb005.0201031333.66b89874@posting.google.com> The piece of code below is taken from the Myp3 project. Can someone explain to me the need/reason for the flush() call after each write() to pin? Thanks in advance. def play(self, filename): # play a file self.initvars() self.debug("PLAY " + filename) self.state = "play" # stop the player, then flush to send the command if self.state == "play": self.pin.write("stop\012") self.pin.flush() # as long as the file is present, then open the file, and start to play it if (len(filename) > 0): self.pin.write("input_open " + filename + "\012play\012") #between commenting this and the timeout value of 0.1 in handle_audio (see below) #considerable speedups and timer accuracy can be had #self.pin.write("input_position_range 1\012") self.pin.flush() From jpt.d at rogers.com Thu Jan 3 22:43:26 2002 From: jpt.d at rogers.com (Jeffrey Drake) Date: Thu, 03 Jan 2002 21:43:26 GMT Subject: Code explanation please References: <90cdb005.0201031333.66b89874@posting.google.com> Message-ID: <3c34d025.40409065@nntp> I believe the most reasonable explaination (a guess) would be the same reason you use glFlush() in opengl. To feed a buffer. Whether or not that applies I do not know. Regards, jptd On 3 Jan 2002 13:33:22 -0800, craigesmith at hotmail.com (Craig E. Smith) wrote: >The piece of code below is taken from the Myp3 project. Can someone >explain to me the need/reason for the flush() call after each write() >to pin? Thanks in advance. > > > >def play(self, filename): > # play a file > > self.initvars() > > self.debug("PLAY " + filename) > > self.state = "play" > > # stop the player, then flush to send the command > if self.state == "play": > self.pin.write("stop\012") > self.pin.flush() > > > # as long as the file is present, then open the file, and start to >play it > if (len(filename) > 0): > self.pin.write("input_open " + filename + "\012play\012") > > #between commenting this and the timeout value of 0.1 in >handle_audio (see below) > #considerable speedups and timer accuracy can be had > #self.pin.write("input_position_range 1\012") > self.pin.flush() From tim at vegeta.ath.cx Fri Jan 4 04:01:52 2002 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Fri, 04 Jan 2002 03:01:52 GMT Subject: Code explanation please References: <90cdb005.0201031333.66b89874@posting.google.com> Message-ID: Craig E. Smith graced us by uttering: > The piece of code below is taken from the Myp3 project. Can someone > explain to me the need/reason for the flush() call after each write() > to pin? Pipes, sockets, and physical files on the filesystem have a buffering behavior for performance reasons. For example, they flush automatically only at, say, EOL, EOF, or after a certain number of bytes. The flush call flushes the buffer explicitly. HTH Tim Hammerquist -- E Pluribus Unix From bernd at effonix.de Thu Jan 3 22:46:01 2002 From: bernd at effonix.de (Bernd Jakob) Date: Thu, 3 Jan 2002 22:46:01 +0100 Subject: REPOST: win32all-141 for Python 2.2 References: <0$--$$_----_-%$_$$@news.noc.cabal.int> Message-ID: "Mark Hammond" wrote: > I have made a new win32all release for Python 2.2. > > Hrmm - it seems I can't login to starship :( So I have temporarily > placed it at: > > http://users.bigpond.net.au/mhammond/win32all-141.exe > I could not download it from there. Can somebody tell me where I can find it now? Thanks Bernd Jakob From jpt.d at rogers.com Thu Jan 3 22:53:28 2002 From: jpt.d at rogers.com (Jeffrey Drake) Date: Thu, 03 Jan 2002 21:53:28 GMT Subject: A Python IDE idea - looking for input Message-ID: <3c34d15e.40722565@nntp> This is no guarantee such a product would be started, just looking for input on a potential future product. The model of the ide would come directly from Visual Basic. This includes such things as project manager on the side. The project manager would be such that you could do advanced things like in MSVC. It would support such things as 'Make EXE file' using py2exe, support debugging just like vb does - example, put break points on valid lines. Have auto list members. Support an immediate window where you can put together python statements almost like you can in the interpreter now. With exception that it would also allow you to perform operations within the scope of the paused program (assuming this is possible). Differences from vb would include no form editor (i don't see one needed to begin with). The language I would think of using for such a project would be c++ with wxWindows. Another feature that might work well is to allow this program to be used as an editor for python code like vb allows for msoffice apps (and other apps that buy vba). Any ideas welcome, Regards, Jeffrey Drake From logiplexsoftware at earthlink.net Thu Jan 3 22:58:48 2002 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Thu, 3 Jan 2002 13:58:48 -0800 Subject: A Python IDE idea - looking for input In-Reply-To: <3c34d15e.40722565@nntp> References: <3c34d15e.40722565@nntp> Message-ID: <20020103135848.315c5f04.logiplexsoftware@earthlink.net> On Thu, 03 Jan 2002 21:53:28 GMT jpt.d at rogers.com (Jeffrey Drake) wrote: > > The language I would think of using for such a project would be c++ > with wxWindows. Why not Python with wxPython? -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From sholden at holdenweb.com Thu Jan 3 23:33:16 2002 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 3 Jan 2002 17:33:16 -0500 Subject: A Python IDE idea - looking for input References: <3c34d15e.40722565@nntp> Message-ID: <615Z7.66809$a56.41934@atlpnn01.usenetserver.com> "Jeffrey Drake" wrote ... > This is no guarantee such a product would be started, just looking for > input on a potential future product. > > The model of the ide would come directly from Visual Basic. This > includes such things as project manager on the side. The project > manager would be such that you could do advanced things like in MSVC. "Advanced things" is a somewhat vague concept. Still, let's include it along with apple pie and motherhood, two other features that Americans wouldn't want to be without :-) > It would support such things as 'Make EXE file' using py2exe, support > debugging just like vb does - example, put break points on valid > lines. Have auto list members. Support an immediate window where you > can put together python statements almost like you can in the > interpreter now. With exception that it would also allow you to > perform operations within the scope of the paused program (assuming > this is possible). > Sounds a bit like PythonWin, BlackAdder, Archeopteryx, wxDesigner, ActiveState's Mozilla-based product that does Python and Perl, and PythonWorks. These are some current projects you should be aware of to begin thinking about development for this market. PythonWin, for example, has some quite advanced debugging features. Come to think of it, you could do much worse that hire Mark Hammond (PythonWin's author) to consult on this design. I seem to remember he has some time available currently. > Differences from vb would include no form editor (i don't see one > needed to begin with). > Besides which there's a confusing selection of GUIs to choose from, as witness the immense debates that occur periodically when a newbie innocently asks "which GUI should I use". > The language I would think of using for such a project would be c++ > with wxWindows. > Erm, wouldn't Python be a faster alternative? Once the initial implementation was complete you could optimise the really slow bits (if there were any) in C or C++. > Another feature that might work well is to allow this program to be > used as an editor for python code like vb allows for msoffice apps > (and other apps that buy vba). > Except that you'd need apps that "buy" Python to use such a feature. > Any ideas welcome, Keep up the thinking, but examine the current landscape. A variety of tools are available, but at present there's no refactoring browser, for example (unless PythonWorks now includes it, I only just got round to downloading a demo copy). Rather than trying to emulate what's been done with other languages it might be more fruitful to aim at what Python programmers really need. Just my two penn'orth. Good luck. regards Steve -- http://www.holdenweb.com/ From jpt.d at rogers.com Thu Jan 3 23:52:14 2002 From: jpt.d at rogers.com (Jeffrey Drake) Date: Thu, 03 Jan 2002 22:52:14 GMT Subject: A Python IDE idea - looking for input References: <3c34d15e.40722565@nntp> <615Z7.66809$a56.41934@atlpnn01.usenetserver.com> Message-ID: <3c34dd7f.43827240@nntp> On Thu, 3 Jan 2002 17:33:16 -0500, "Steve Holden" wrote: >"Jeffrey Drake" wrote ... >> This is no guarantee such a product would be started, just looking for >> input on a potential future product. >> >> The model of the ide would come directly from Visual Basic. This >> includes such things as project manager on the side. The project >> manager would be such that you could do advanced things like in MSVC. > >"Advanced things" is a somewhat vague concept. Still, let's include it along >with apple pie and motherhood, two other features that Americans wouldn't >want to be without :-) Advanced things is just meant as a statement saying that vb's project manager is wildly too simple. > >> It would support such things as 'Make EXE file' using py2exe, support >> debugging just like vb does - example, put break points on valid >> lines. Have auto list members. Support an immediate window where you >> can put together python statements almost like you can in the >> interpreter now. With exception that it would also allow you to >> perform operations within the scope of the paused program (assuming >> this is possible). >> >Sounds a bit like PythonWin, BlackAdder, Archeopteryx, wxDesigner, >ActiveState's Mozilla-based product that does Python and Perl, and >PythonWorks. These are some current projects you should be aware of to begin >thinking about development for this market. PythonWin, for example, has some >quite advanced debugging features. Come to think of it, you could do much >worse that hire Mark Hammond (PythonWin's author) to consult on this design. >I seem to remember he has some time available currently. All but one of those ides require payment. PythonWin's debugger likes to freeze a lot when developing code. pygame code I believe I was debugging. I didn't like any of the other products I tried. Komodo is slow, and when running applications they are always put under debug mode I believe. WingIDE (http://archaeopteryx.com/wingide/) I can't say much about. I tried PythonWorks and I don't care for it. It looks and acts a little wierd to me. (http://www.pythonware.com/products/works). I am not trying to make a commercial product. > >> Differences from vb would include no form editor (i don't see one >> needed to begin with). >> >Besides which there's a confusing selection of GUIs to choose from, as >witness the immense debates that occur periodically when a newbie innocently >asks "which GUI should I use". Easy choice, wxWindows :-) *let the religious war begin!* > >> The language I would think of using for such a project would be c++ >> with wxWindows. >> >Erm, wouldn't Python be a faster alternative? Once the initial >implementation was complete you could optimise the really slow bits (if >there were any) in C or C++. I like the idea of controlling python from another language with a product like this an enticing idea. I am also turned off at using an interpreted bytecode language to write an IDE for the same language. My problems with this source from java ides which are infamously slow. > >> Another feature that might work well is to allow this program to be >> used as an editor for python code like vb allows for msoffice apps >> (and other apps that buy vba). >> >Except that you'd need apps that "buy" Python to use such a feature. What do you mean by that? > >> Any ideas welcome, > >Keep up the thinking, but examine the current landscape. A variety of tools >are available, but at present there's no refactoring browser, for example >(unless PythonWorks now includes it, I only just got round to downloading a >demo copy). Rather than trying to emulate what's been done with other >languages it might be more fruitful to aim at what Python programmers really >need. What they really need is something that this post is about. Free tools are needed more than commercial ones IMO. > >Just my two penn'orth. Good luck. > >regards > Steve >-- >http://www.holdenweb.com/ > > > > > From nhodgson at bigpond.net.au Fri Jan 4 01:48:16 2002 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Fri, 04 Jan 2002 00:48:16 GMT Subject: A Python IDE idea - looking for input References: <3c34d15e.40722565@nntp> <615Z7.66809$a56.41934@atlpnn01.usenetserver.com> <3c34dd7f.43827240@nntp> Message-ID: Jeffrey Drake: > All but one of those ides require payment. PythonWin's debugger likes > to freeze a lot when developing code. pygame code I believe I was > debugging. I didn't like any of the other products I tried. If you are talking about hard hangs due to UI contention then one way to go is to run the target code in a separate process and use some probe code in that process to communicate with the IDE process. I believe most of the commercial IDEs do this although there are some performance implications. If the issue is responsiveness of PythonWin then I'm sure more work can be done to improve this. One IDE not mentioned by Steve is Boa Constructor which is very (perhaps overly) ambitious. It is not that active at the moment as Riaan is busy. http://boa-constructor.sourceforge.net/ > I am also turned off at using an interpreted bytecode language to > write an IDE for the same language. My problems with this source from > java ides which are infamously slow. It depends on the level at which you bridge between the low level code and the high level. If you write lots of detail level code (such as a lexer) in Python then there may be perfromance concerns but using Python as a supervisor over low level code written in C works very well. Some of the mentioned IDEs use the Scintilla widget I wrote in C++ to provide text editing. While Python gets hooked into Scintilla text events, most of the processing is done in C++ leading to acceptable performance I hope. Think through the features you need in an IDE and about how they can be implemented. The heaviest feature I see is watch points where you need to evaluate Python expressions after every executed instruction or if you are clever after every instruction that can change a watch point expression. This requires running the interpreter over the expression and I would guess (anyone know?) that this would equal or dominate over the IDE framework code here, so changing the framework to C would not achieve that much. Maybe watc hing the instruction counter tick from Python would be slow compared to doing it from C, but you can always write a small piece of C that performs the loop and then returns to Python when an interesting event occurs. Much of the code bulk in IDEs is UI guff that is better written in Python. Neil From ungrzr2 at ubatxbat.pbz Fri Jan 4 03:52:36 2002 From: ungrzr2 at ubatxbat.pbz ({-- Rot13 - Hateme) Date: 4 Jan 2002 02:52:36 GMT Subject: A Python IDE idea - looking for input References: <3c34d15e.40722565@nntp> <615Z7.66809$a56.41934@atlpnn01.usenetserver.com> Message-ID: "Steve Holden" wrote in news:615Z7.66809$a56.41934 at atlpnn01.usenetserver.com: > >> The language I would think of using for such a project would be c++ >> with wxWindows. >> > Erm, wouldn't Python be a faster alternative? Once the initial > implementation was complete you could optimise the really slow bits > (if there were any) in C or C++. > I really hate this step. Why cannot python be faster? I choose python because it is easier to program with. Now if I want to write a good program, I have to use 2 languages which is not easier anymore. Interpreter can be made to run fast. Why python cannot? Asking people to optimize with C is just an lame excuse. Of couse, python is free (as beer and freedem), so it is natural there are no people want to work on a faster python at this moment. Still the C excuse sucks. From gh_pythonlist at gmx.de Fri Jan 4 04:25:29 2002 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-15?Q?H=E4ring?=) Date: Fri, 4 Jan 2002 04:25:29 +0100 Subject: A Python IDE idea - looking for input In-Reply-To: References: <3c34d15e.40722565@nntp> <615Z7.66809$a56.41934@atlpnn01.usenetserver.com> Message-ID: <20020104032528.GA9352@lilith.hqd-internal> Le 04/01/02 ? 02:52, {-- Rot13 - Hateme ?crivit: > "Steve Holden" wrote in > news:615Z7.66809$a56.41934 at atlpnn01.usenetserver.com: > > > > >> The language I would think of using for such a project would be c++ > >> with wxWindows. > >> > > Erm, wouldn't Python be a faster alternative? Once the initial > > implementation was complete you could optimise the really slow bits > > (if there were any) in C or C++. ^^^^^^^^^^^^^^^^^^^ > > > > I really hate this step. Why cannot python be faster? > I choose python because it is easier to program with. > Now if I want to write a good program, I have > to use 2 languages which is not easier anymore. > > Interpreter can be made to run fast. Why python cannot? > Asking people to optimize with C is just an lame excuse. > > Of couse, python is free (as beer and freedem), so > it is natural there are no people want to work on > a faster python at this moment. Still the C excuse sucks. Yup. But note the "if there were any". I've never needed to optimize Python code myself, except for interfacing OS stuff or for interfacing existing C libraries. I've also quickly looked at some alternatives like OCaml, which do offer an interactive interpreter *and* and a very good native code compiler which is equal to C compilers performance-wise, but the library support was by far worse than Python's. Also the language Ocaml itself doesn't offer many advantages for everyday programming IMHO. Harcore FP'lers will disagree, of course. If you want to be disillusioned about the performance increasements of native code, just look at what compiled Java offers nowadays. If you're lucky, it's even faster that Hotspot in JDK 1.4, with the only difference that you paid 1000s of $ ;-) Then, introduce some introspection (makes Java dynamic, like Python is by default) and watch the performance of the so-called native code go down. I once created a primitive benchmark myself and was *really* impressed by the Oracle Java runtime, it was almost as good as the code created by Visual C++ and on par with gcc for my primitive sieve-of-Erathostenes benchmark. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From anthony at interlink.com.au Fri Jan 4 05:07:28 2002 From: anthony at interlink.com.au (Anthony Baxter) Date: Fri, 04 Jan 2002 15:07:28 +1100 Subject: A Python IDE idea - looking for input In-Reply-To: Message from Gerhard =?iso-8859-15?Q?H=E4ring?= of "Fri, 04 Jan 2002 04:25:29 BST." <20020104032528.GA9352@lilith.hqd-internal> Message-ID: <200201040407.g0447SM07626@mbuna.arbhome.com.au> >>> Gerhard =?iso-8859-15?Q?H=E4ring?= wrote > If you want to be disillusioned about the performance increasements of > native code, just look at what compiled Java offers nowadays. If you're > lucky, it's even faster that Hotspot in JDK 1.4, with the only > difference that you paid 1000s of $ ;-) I think psyco shows that it's _possible_ to get some speedups from native code in python. It doesn't, however, show that anyone's prepared to invest the considerable amount of time or money to make it a reality. Anthony From roy at panix.com Fri Jan 4 05:10:01 2002 From: roy at panix.com (Roy Smith) Date: Thu, 03 Jan 2002 23:10:01 -0500 Subject: A Python IDE idea - looking for input References: <3c34d15e.40722565@nntp> <615Z7.66809$a56.41934@atlpnn01.usenetserver.com> Message-ID: Gerhard H?ring wrote: > I've never needed to optimize Python code myself, except for > interfacing OS stuff or for interfacing existing C libraries. A fair amount of the python I write these days is reimplementing functionality which was previously done in perl. Almost without excpetion, the perl version runs several times faster, which is a strong incentive to find ways to optimize my python code :-) Usually, it's not hard to get a factor of 2 speedup with a little optimization. The profiler will usually point you to the right places to start looking. You will often find that a small handfull of lines of code represent 3/4 of the CPU time of your program (this is the ancient 80/20 rule which has had remarkable longevity since the days of hand-coded assembler). From aleax at aleax.it Fri Jan 4 11:39:26 2002 From: aleax at aleax.it (Alex Martelli) Date: Fri, 4 Jan 2002 11:39:26 +0100 Subject: A Python IDE idea - looking for input References: <3c34d15e.40722565@nntp> <615Z7.66809$a56.41934@atlpnn01.usenetserver.com> Message-ID: "Gerhard H?ring" wrote in message news:mailman.1010114767.18995.python-list at python.org... ... > was by far worse than Python's. Also the language Ocaml itself doesn't > offer many advantages for everyday programming IMHO. Harcore FP'lers > will disagree, of course. I'm a "soft-core" FP'er and I'm more fascinated by Haskell and Erlang than by any ML, and O'CaML in particular. O'Caml looks like a highly multi-paradigm language with lots of pieces stuck to it and excellent implementation performance. But, do I really want ANOTHER C++...??? > > If you want to be disillusioned about the performance increasements of > native code, just look at what compiled Java offers nowadays. If you're > lucky, it's even faster that Hotspot in JDK 1.4, with the only > difference that you paid 1000s of $ ;-) I get native-compiled Java from gcc 3.* and I haven't paid a PENNY for it. Haven't done any benchmarking, either (not even tried JDK 1.4 yet, though I will since I head that introspection in particular is speedier enough to make a real difference with Jython). Alex From sholden at holdenweb.com Fri Jan 4 07:49:26 2002 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 4 Jan 2002 01:49:26 -0500 Subject: A Python IDE idea - looking for input References: <3c34d15e.40722565@nntp> <615Z7.66809$a56.41934@atlpnn01.usenetserver.com> Message-ID: "{-- Rot13 - Hateme" wrote in message news:Xns918C6E68EFB1DYouAreNotMeYouKnow at 218.102.23.34... > "Steve Holden" wrote in > news:615Z7.66809$a56.41934 at atlpnn01.usenetserver.com: > > > > >> The language I would think of using for such a project would be c++ > >> with wxWindows. > >> > > Erm, wouldn't Python be a faster alternative? Once the initial > > implementation was complete you could optimise the really slow bits > > (if there were any) in C or C++. > > > > I really hate this step. Why cannot python be faster? > I choose python because it is easier to program with. > Now if I want to write a good program, I have > to use 2 languages which is not easier anymore. > Presumably "good" == "fast" in your opinion? The "(if there were any)" was there precisely because my personal experience tends to be with problems for which Python is currently quite fast enough. If this isn't the case for you, thenperhaps you ought to think about doing something about it (though I realise moaning on a news group os much easier :-) > Interpreter can be made to run fast. Why python cannot? > Asking people to optimize with C is just an lame excuse. > I wasn't asking anybody to do anything. Python will be optimized just as soon as it's worth somebody's effort to do it. This is the open source world, wake up. If it isn't fast enough, make it run faster. > Of couse, python is free (as beer and freedem), so > it is natural there are no people want to work on > a faster python at this moment. Still the C excuse sucks. > Yup. Free as in "freeloader" if you never put anything back in. regards Steve -- http://www.holdenweb.com/ From bkc at Murkworks.com Thu Jan 3 23:43:04 2002 From: bkc at Murkworks.com (Brad Clements) Date: Thu, 3 Jan 2002 17:43:04 -0500 Subject: A Python IDE idea - looking for input References: <3c34d15e.40722565@nntp> Message-ID: <3c34df14$1_1@news.newsgroups.com> Check out open source Software Development IDE Eclipse. http://www.eclipse.org (maybe stuff from jedit would be useful here) -- Brad Clements, DevNet Sysop 5 Developer Network Sysop Team -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! Check out our new Unlimited Server. No Download or Time Limits! -----== Over 80,000 Newsgroups - 19 Different Servers! ==----- From altis at semi-retired.com Fri Jan 4 01:09:20 2002 From: altis at semi-retired.com (Kevin Altis) Date: Thu, 3 Jan 2002 16:09:20 -0800 Subject: A Python IDE idea - looking for input References: <3c34d15e.40722565@nntp> Message-ID: Funny you should mention such a beast. Here's where PythonCard http://pythoncard.sourceforge.net/ stands as of release 0.6.1 PythonCard uses wxPython 2.3.2 or higher and Python 2.0 or higher. PythonCard includes the following runtime tools: Logging, Message Watcher, Namespace Viewer, Property Editor, and Shell (Python interactive prompt on steroids). The layout editor (resourceEditor sample): Simple, but works reasonably well under Windows. I'm currently chasing down a mouse event bug under GTK that prevents the resizing handles from working correctly, but you can still resize a control via the Property Editor under GTK. A Menu Editor is included. The resourceEditor is written as a PythonCard app with some "raw" wxPython thrown in where needed. I don't think you need to program an IDE in C++. Source code is still decoupled from layouts, so you can edit source in any editor you want (vi, vim, emacs, Pythonwin, IDLE, etc.). Event handlers in PythonCard look like: on_commandName_command or on_widgetName_eventName more examples... def on_menuFileExit_select(self, menu, event): def on_btnColor_mouseClick(self, target, event): def on_bufOff_mouseDrag(self, target, event): So, it looks very similar to VB handler names. The resourceEditor has a Run command so you can quickly test your layout while still editing your source in another program. So, what we have today is part of the puzzle of doing a full IDE for PythonCard. We can always use more developers if you're interested. ka "Jeffrey Drake" wrote in message news:3c34d15e.40722565 at nntp... > This is no guarantee such a product would be started, just looking for > input on a potential future product. > > The model of the ide would come directly from Visual Basic. This > includes such things as project manager on the side. The project > manager would be such that you could do advanced things like in MSVC. > It would support such things as 'Make EXE file' using py2exe, support > debugging just like vb does - example, put break points on valid > lines. Have auto list members. Support an immediate window where you > can put together python statements almost like you can in the > interpreter now. With exception that it would also allow you to > perform operations within the scope of the paused program (assuming > this is possible). > > Differences from vb would include no form editor (i don't see one > needed to begin with). > > The language I would think of using for such a project would be c++ > with wxWindows. > > Another feature that might work well is to allow this program to be > used as an editor for python code like vb allows for msoffice apps > (and other apps that buy vba). > > Any ideas welcome, > Regards, > Jeffrey Drake From larrwright at thewrightshome.com Fri Jan 4 01:46:46 2002 From: larrwright at thewrightshome.com (Larry Wright) Date: Fri, 04 Jan 2002 00:46:46 GMT Subject: A Python IDE idea - looking for input References: <3c34d15e.40722565@nntp> Message-ID: Cliff Wells wrote: > On Thu, 03 Jan 2002 21:53:28 GMT > jpt.d at rogers.com (Jeffrey Drake) wrote: >> >> The language I would think of using for such a project would be c++ >> with wxWindows. > > Why not Python with wxPython? > Or PyQT. I've done some work with it lately and it seems to not have any performance issues. the core bits are in C++ so it's much faster than Java for example. From bbollenbach at home.com Fri Jan 4 03:31:26 2002 From: bbollenbach at home.com (Brad Bollenbach) Date: Fri, 04 Jan 2002 02:31:26 GMT Subject: A Python IDE idea - looking for input References: <3c34d15e.40722565@nntp> Message-ID: <2u8Z7.24814$L4.2838063@news2.calgary.shaw.ca> "Jeffrey Drake" wrote in message news:3c34d15e.40722565 at nntp... > This is no guarantee such a product would be started, just looking for > input on a potential future product. > > The model of the ide would come directly from Visual Basic. This [snip the words of another ambitious open source hacker wanting to reproduce VB's IDE for Python] There are really only two things in VB's IDE that are worth trying to reproduce: the form designer, and the debugger. Everything else that VB does can be handled by common sense (like "project managers"), and a decent text editor (for a good laugh, compare vim to VB's editor). Further, a form designer is only useful for those whose problems involve GUI's, and a debugger is only really useful to those who don't find the one included with Python to be useful and who don't think the simplicity of the language itself greatly reduces the need for a debugger to begin with. My suggestion is this: decide which of the above purposes you find to be a most pressing issue. If it's the requirement for a faster way to design a GUI in Python, then look at something like Glade: http://glade.gnome.org/ or wxDesigner: http://www.roebling.de/ or Black Adder: http://www.thekompany.com/products/blackadder/ or Boa Constructor: http://boa-constructor.sourceforge.net/ because they already solve the problem, and if they don't, you'd likely do better to give your effort to making them better rather than starting all the way from scratch. Software evolves, and these programs are growing up, and could use another parent or two to steer them in the right direction. Writing a form designer that doesn't suck is a monumentous task (which you'll learn shortly after the inspiration that caused you to write this thread wears off :), so you're likely better off to work on what's there, than spending the next 3 years trying to get to where some of the above programs are right now (and some have been around as long or longer than that). If the debugger is something you use often, and you think that Python's builtin debugger is bad, then first read the documentation to make sure you're using it correctly, and if it's not working right ask yourself what you don't like about it, and how hard it would be to make it work the way you think it should. Have fun, Brad From paul at boddie.net Fri Jan 4 12:46:05 2002 From: paul at boddie.net (Paul Boddie) Date: 4 Jan 2002 03:46:05 -0800 Subject: A Python IDE idea - looking for input References: <3c34d15e.40722565@nntp> <2u8Z7.24814$L4.2838063@news2.calgary.shaw.ca> Message-ID: <23891c90.0201040346.49ccf30f@posting.google.com> "Brad Bollenbach" wrote in message news:<2u8Z7.24814$L4.2838063 at news2.calgary.shaw.ca>... > > There are really only two things in VB's IDE that are worth trying to > reproduce: the form designer, and the debugger. Everything else that VB does > can be handled by common sense (like "project managers"), and a decent text > editor (for a good laugh, compare vim to VB's editor). For me, tight integration with CVS would be a requirement - there would be no needless "declaring" of files in projects in my ideal IDE. > Further, a form designer is only useful for those whose problems involve > GUI's, and a debugger is only really useful to those who don't find the one > included with Python to be useful and who don't think the simplicity of the > language itself greatly reduces the need for a debugger to begin with. While debuggers are useful - very useful for programs written in C, for example - the simplistic trace statement approach works well in Python, especially if one has done a fair amount of testing on various program components before putting them together. I heard that certain IDEs for Java are now increasing their support for unit testing, and this would be nice for any ideal Python IDE. Of course, the GUI-centric nature of some IDEs is part of a much larger "turn off" for many developers: can the IDE support development in widely varying environments, such as Web or application server modules/components? Not everyone is writing graphical client software, but that is surely the emphasis of VB. I think many people approach the "what there should be in an IDE" issue from a very narrow mindset, imposed by the variety (or similarity) of existing IDEs. One only has to look at screenshots of almost any commercial or open source IDE to see the blatant similarities of them all - indeed, it's usually possible to predict what an IDE will look like before clicking on the "screenshots" link on any given Web site promoting an IDE. A more interesting IDE-like project would support new developers and scale up to being generally useful for experts. I can imagine having visual representations of Python data types with instances of those types showing their contents in a window (or frame) representing the current namespace, and such representations alone would be a powerful replacement for the archaic spreadsheet concept. Users would be able to manipulate the contents of the representations directly, or by using the Python prompt, but each manipulation would be reflected in all of the available representations, so that a change to a list element might be reflected in the "Python console" by the appearance of an assignment statement involving that list element. More advanced usage could be supported by letting users change the representations by defining different kinds of views, and this would effectively permit the development of form-based interfaces. One could also be able to determine whether the introduction of a new namespace (due to a function call, for example) would open a new window, or instead affect the contents of an existing window. The challenge in such a project would be to find a good representation for activities rather than data and for abstract data "containers" rather than concrete data items. Of course, one might suggest that textual Python source code is a good enough representation for program tasks, but it would be nice to be able to see how that code manipulates the data, or at least be able to step through running code one line at a time. And that brings us right back to debugging tools... Paul From zeitlin at seth.lpthe.jussieu.fr Fri Jan 4 15:17:20 2002 From: zeitlin at seth.lpthe.jussieu.fr (Vadim Zeitlin) Date: Fri, 4 Jan 2002 14:17:20 +0000 (UTC) Subject: A Python IDE idea - looking for input References: <3c34d15e.40722565@nntp> Message-ID: On Thu, 03 Jan 2002 21:53:28 GMT, Jeffrey Drake wrote: > The model of the ide would come directly from Visual Basic. IMHO, if you want to recreate a Microsoft product, Visual Studio (a.k.a. MSDEV) is a better model than VB. > Differences from vb would include no form editor (i don't see one > needed to begin with). Many people find it a very important tool for GUI program design. > The language I would think of using for such a project would be c++ > with wxWindows. I'm a C++ programmer but it still seems clear to me that you should use [wx]Python for this, not C++. You will need to embed Python interpreter anyhow so why not create the GUI in Python as well? You might have to write some C++ code here and there, of course, but it makes direct sense to use Python for almost everything IMHO. Also, I'd encourage you to join the other existing projects with the similar goals such as Boa or wxWorkshop (especially if you insist on using C++!). A good IDE is a lot of work and it would be very difficult to write one alone. Good luck! VZ -- GCS/GM d? H+ s++:-- p2 au--- a- w+ v C+++ UBLS+++ P- L++ N++ E--- W++++ M? V-- -po+ R++ G`` !tv b+++ D--- e++++ u++ h--- f+ r++ n- y? From rxg218 at psu.edu Fri Jan 4 00:06:28 2002 From: rxg218 at psu.edu (Rajarshi Guha) Date: Thu, 03 Jan 2002 18:06:28 -0500 Subject: a few more questions on XML and python Message-ID: Hi, thanks for the nice pointers regrding XML and python. I have another newbie question - I'm trying to get information out of a CML (Chemical Markup Language) file which is a subset of XML. My query is that using xml.parsers.expat I can get a loist of tags and values etc. I How can I indicate to the parser that if say it comes upon a tag like it should call a certain handler to process the coordinate data. Or am I supposed to just do the handling by extractin the information provided by expat. If so is there any type of 'hook' system where I can plug in my handlers. I'm a little confused as to how expat is supposed to handle an arbitrary XML file where the tags could be describing anything. As you can see I'm pretty confused :( TIA -- ------------------------------------------------------------------- Rajarshi Guha | email: rajarshi at presidency.com 417 Davey Laboratory | web : www.rajarshi.outputto.com Department of Chemistry | ICQ : 123242928 Pennsylvania State University | AIM : LoverOfPanda ------------------------------------------------------------------- GPG Fingerprint: DCCB 4D1A 5A8B 2F5A B5F6 1F9E CDC4 5574 9017 AF2A Public Key : http://pgp.mit.edu/ ------------------------------------------------------------------- Mathematics consists of proving the most obvious thing in the least obvious way. -- George Polya From martin at v.loewis.de Fri Jan 4 03:38:32 2002 From: martin at v.loewis.de (Martin v. Loewis) Date: 04 Jan 2002 03:38:32 +0100 Subject: a few more questions on XML and python References: Message-ID: Rajarshi Guha writes: > How can I indicate to the parser that if say it comes upon a tag like > it should call a certain handler to process the coordinate > data. > > Or am I supposed to just do the handling by extractin the information > provided by expat. If so is there any type of 'hook' system where I can > plug in my handlers. If you want to use expat directly, you need to get used to the notion of event-based processing. The parser invokes a callback (aka handler) for each chunk of XML input. That callback must perform all the processing. It will invoke the same callback for all opening tags, so inside this callback, you must look at the element name. If it is coordinate, you set a global variable remembering that you have just seen the tag. Each of the other callbacks needs to look at the global variable. If it is set, do everything needed inside the coordinate. If the end-element callback is invoked, and the tag is coordinate, clear the global variable. Alternatively, you may want to look at the DOM API. There, the parser reads the entire document first, and gives you a tree structure. You can then traverse this tree structure as you want. Regards, Martin From rxg218 at psu.edu Fri Jan 4 05:41:51 2002 From: rxg218 at psu.edu (Rajarshi Guha) Date: Thu, 03 Jan 2002 23:41:51 -0500 Subject: a few more questions on XML and python References: Message-ID: On Thursday 03 January 2002 21:38 in comp.lang.python Martin v. Loewis wrote: > Rajarshi Guha writes: > >> Or am I supposed to just do the handling by extractin the information >> provided by expat. If so is there any type of 'hook' system where I can >> plug in my handlers. > [snip] > Alternatively, you may want to look at the DOM API. There, the parser > reads the entire document first, and gives you a tree structure. You > can then traverse this tree structure as you want. Thanks for the pointer regarding DOM - it was very useful. I do have another question - how can I traverse the tree and see what available tags got read in? Where can I look up the methods available and the actual tree structuire? I tried reading the actual .py file but I got all mixed up - is there any reference to the available methods.? TIA, -- ------------------------------------------------------------------- Rajarshi Guha | email: rajarshi at presidency.com 417 Davey Laboratory | web : www.rajarshi.outputto.com Department of Chemistry | ICQ : 123242928 Pennsylvania State University | AIM : LoverOfPanda ------------------------------------------------------------------- GPG Fingerprint: DCCB 4D1A 5A8B 2F5A B5F6 1F9E CDC4 5574 9017 AF2A Public Key : http://pgp.mit.edu/ ------------------------------------------------------------------- A mathematician is a device for turning coffee into theorems. -- P. Erdos From woodsplitter at rocketmail.com Fri Jan 4 12:31:03 2002 From: woodsplitter at rocketmail.com (stalin) Date: 4 Jan 2002 03:31:03 -0800 Subject: a few more questions on XML and python References: Message-ID: <7876a8ea.0201040331.4726429b@posting.google.com> Rajarshi Guha wrote: > Where can I look up the methods available and the actual tree structuire? I > tried reading the actual .py file but I got all mixed up - is there any > reference to the available methods.? The standard library documentation, section 13.6 "xml.dom" describes the library's DOM support and has links to the W3C DOM specification. In particular, 13.6.2 "Objects in the DOM" is probably what you're looking for when you say "reference to the available methods": http://python.org/doc/current/lib/node438.html > I do have another question - how can I traverse the tree and see what > available tags got read in? ------------------------------------------------------------------ from StringIO import StringIO import xml.dom.minidom as dom theXML = """ The Fascist Menace Josef Stalin unclejoe at kremlin.ru Alexei Voloshnikov just-another-tovarisch at kremlin.ru 1941 """ def printTagNames(node, indentationLevel=0): print indentationLevel * ' ' + node.tagName for child in node.childNodes: if child.nodeType == dom.Node.ELEMENT_NODE: printTagNames(child, indentationLevel+4) doc = dom.parse(StringIO(theXML)) print '--- TAG DUMP ---' printTagNames(doc.documentElement) ------------------------------------------------------------------ From woodsplitter at rocketmail.com Fri Jan 4 05:54:22 2002 From: woodsplitter at rocketmail.com (stalin) Date: 3 Jan 2002 20:54:22 -0800 Subject: a few more questions on XML and python References: Message-ID: <7876a8ea.0201032054.7c7268be@posting.google.com> Rajarshi Guha wrote: > As you can see I'm pretty confused :( Why not use DOM instead of SAX? XML is clearly tree-based, so processing it in terms of trees (DOM) tends to be more easily comprehensible than processing it in terms of streams and event handlers (SAX). SAX has definite resource utilization advantages over DOM for read-only XML access, but I daresay that working code can eat a great deal of memory and still perform better than a dysfunctional collection of highly optimized fragments :) At its simplest, DOM parsing consists of setting up a series of nested node iterations to reach the information you want, as in (Python 2.2): -------------------------------------------------------------- from StringIO import StringIO import xml.dom.minidom as dom theXML = """ The Fascist Menace Josef Stalin unclejoe at kremlin.ru Alexei Voloshnikov just-another-tovarisch at kremlin.ru 1941 """ doc = dom.parse(StringIO(theXML)) book = doc.documentElement print 'edition:', book.attributes['edition'].value # It is the first child (a text node) of the title element, # rather than the title element itself, that contains the value. title = book.getElementsByTagName('title')[0].firstChild.nodeValue print 'title:', title authors = book.getElementsByTagName('authors')[0] for author in authors.getElementsByTagName('author'): print "an author's email:", print author.getElementsByTagName('email')[0].firstChild.nodeValue description = book.getElementsByTagName('description')[0].firstChild.nodeValue print "The critics say [well, aside from omygodisthatakgvbofficer?]:", print description -------------------------------------------------------------- Although that code is totally lax about error handling and quite inefficient (overuse of getElementsByTagName, etc.), it's also brief, and hopefully more comprehensible that the SAX you've been trying to write. If you're processing huge data sets, DOM isn't going to cut it. DOM builds an in-memory representation of the entire document, whereas SAX handles a single element at a time. But after you have a bit of Python and XML parsing under your belt, you can always move on to SAX if necessary, eh? From vonWedel at lfpt.rwth-aachen.de Fri Jan 4 09:39:06 2002 From: vonWedel at lfpt.rwth-aachen.de (Lars von Wedel) Date: Fri, 04 Jan 2002 09:39:06 +0100 Subject: a few more questions on XML and python References: <7876a8ea.0201032054.7c7268be@posting.google.com> Message-ID: <3C356A2A.7010608@lfpt.rwth-aachen.de> Hi, > [...] but I daresay that working code can eat > a great deal of memory and still perform better than a dysfunctional > collection of highly optimized fragments :) Sure, in general, but there are a number of things about reading XML that can be performed using a lean SAX-style implementation, e.g. reading rather simple configuration files etc. > If you're processing huge data sets, DOM isn't going to cut it. DOM > builds an in-memory representation of the entire document, whereas SAX > handles a single element at a time. But after you have a bit of > Python and XML parsing under your belt, you can always move on to SAX > if necessary, eh? What I do in order to simplify parsing XML using SAX is the following in a class used as an element handler. These two methods dispatch the calls of startElement/endElement to a bunch of methods called E1_start, E1_end, E2_start, E2_end, ... for each element type (e.g. E1, E2) occurring in the XML file. That saves me a large if-construct. Very simple, but I like to use it a lot. def startElement(self, name, attrs): mth_name = string.lower(name) + '_start' self.attr_st.append(attrs) if hasattr(self, mth_name): method = getattr(self, mth_name) method(attrs) else: if self.verbose: print 'Warning: Start of element %s skipped' % name def endElement(self, name): attrs = self.attr_st.pop() mth_name = string.lower(name) + '_end' if hasattr(self, mth_name): method = getattr(self, mth_name) method(attrs) else: if self.verbose: print 'Warning: End of element %s skipped' % name Lars From woodsplitter at rocketmail.com Fri Jan 4 14:34:59 2002 From: woodsplitter at rocketmail.com (stalin) Date: 4 Jan 2002 05:34:59 -0800 Subject: a few more questions on XML and python References: <7876a8ea.0201032054.7c7268be@posting.google.com> <3C356A2A.7010608@lfpt.rwth-aachen.de> Message-ID: <7876a8ea.0201040534.13b1a1e@posting.google.com> Lars von Wedel wrote: > [...] but I daresay that working code can eat > > a great deal of memory and still perform better than a dysfunctional > > collection of highly optimized fragments :) > > Sure, in general, but there are a number of things about reading XML > that can be performed using a lean SAX-style implementation, e.g. > reading rather simple configuration files etc. Certainly. I wasn't suggesting that SAX should be generally avoided, just that a newbie to both Python and XML parsing should probably start with DOM because it tends to be more easily comprehensible. From aleax at aleax.it Fri Jan 4 14:30:18 2002 From: aleax at aleax.it (Alex Martelli) Date: Fri, 4 Jan 2002 14:30:18 +0100 Subject: a few more questions on XML and python References: Message-ID: "Rajarshi Guha" wrote in message news:a12o76$18va at r02n01.cac.psu.edu... ... > I'm a little confused as to how expat is supposed to handle an arbitrary > XML file where the tags could be describing anything. See http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65248 for a specific example of using expat. However, most often you would instead use the more flexible interface SAX, as per example in http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65127. An excellent general introduction to XML and Python is at http://www.oreilly.com/catalog/pythonxml/chapter/ch01.html (you'll probably want to buy the whole book after reading this superb first chapter). Note that, be it with expat or SAX, the parsing is "event driven". When an opening tag is encountered, what follows it is not known yet. So, what you normally do: in the start-handler for the tag of your interest, you save its attributes (all that's known so far) and prepare containers for embedded tags and text that may be needed; when tags or characters are received after you've seen the open-tag of interest but before the close-tag, you save the relevant information in the containers; at close-handler time, you process the saved information for the tag. Let's take a simple example. Say that an XML-marked-up text, whatever else it may contain, has a tag called 'coordinate', with a mandatory attribute 'name'; between and the corresponding , only character data may be present (no need to worry about other embedded tags, except maybe to diagnose an error and terminate processing). Given such an XML file, you want to output coordinate data only in the form of printing: name -> coordinate data to standard output. OK so far? Here's one possible approach, then: import xml.sax class handler(xml.sax.handler.ContentHandler): def startDocument(self): self.current_data = None self.current_name = None def endDocument(self): assert self.current_data is None assert self.current_name is None def startElement(self, name, attr): assert self.current_data is None assert self.current_name is None if name=='coordinate': self.current_data = [] self.current_name = attr.get('name') def endElement(self, name): if name=='coordinate': assert self.current_data is not None assert self.current_name is not None print "%s -> %s" % (self.current_name, ''.join(self.current_data)) self.current_data = None self.current_name = None def characters(self, content): if self.current_data is not None: self.current_data.append(content) def ignorableWhitespace(self, ws): if self.current_data is not None: self.current_data.append(ws) # and some tiny self-testing...: if __name__=='__main__': x = ''' One 23 45 two three 42 68 four and other tag. ''' flob = open('someinput.xml', 'w') flob.write(x) flob.close() xml.sax.parse('someinput.xml', handler()) Normally, you want to process several different tags, and testing for each case in startElement and endElement is not elegant nor productive. Then, you can dispatch on tag name in each of these methods, in several possible ways -- Python makes it easy to do so via introspection, and that's a common tack to take (by imitation of sgmllib for example). E.g., def startElement(self, name, attr): try: method = getattr(self, 'start_'+name) except AttributeError: pass else: method(attr) def endElement(self, name): try: method = getattr(self, 'end_'+name) except AttributeError: pass else: method(attr) and then you'd code the blocks that in the above example are guarded by the "if name=='coordinate':" clauses into methods def start_coordinate(self, attr): and def end_coordinate(self, attr): But this doesn't deeply change the nature of what's going on. It's still basically a game of preparing object-state in the start-tag methods, enriching it in method characters, and processing the accumulated stuff in the end-tag methods. Alex From mlistbox at yahoo.com Fri Jan 4 00:09:14 2002 From: mlistbox at yahoo.com (Rob Hancock) Date: Thu, 3 Jan 2002 15:09:14 -0800 (PST) Subject: Multiple os.system calls Message-ID: <20020103230914.70436.qmail@web20806.mail.yahoo.com> Hello Everyone, I am trying to send a list of filenames to tar. Right now I'm doing this with multiple calls to os.system, changing the filename each time. Horrible I know, but I haven't figured out how to use the other os fuctions to accomplish this any better. Can someone enlighten me? __________________________________________________ Do You Yahoo!? Send your FREE holiday greetings online! http://greetings.yahoo.com From s.schwarzer at ndh.net Fri Jan 4 01:20:58 2002 From: s.schwarzer at ndh.net (Stefan Schwarzer) Date: Fri, 04 Jan 2002 01:20:58 +0100 Subject: Multiple os.system calls References: Message-ID: <3C34F56A.DA75DFAF@ndh.net> Hello Rob Rob Hancock wrote: > I am trying to send a list of filenames to tar. Right > now I'm doing this with multiple calls to os.system, > changing the filename each time. Horrible I know, but > I haven't figured out how to use the other os fuctions > to accomplish this any better. Can someone enlighten > me? You could use os.popen to feed the filenames to tar via standard input. Stefan From aleax at aleax.it Fri Jan 4 14:05:24 2002 From: aleax at aleax.it (Alex Martelli) Date: Fri, 4 Jan 2002 14:05:24 +0100 Subject: Multiple os.system calls References: Message-ID: "Rob Hancock" wrote in message news:mailman.1010099405.19889.python-list at python.org... > Hello Everyone, > > I am trying to send a list of filenames to tar. Right > now I'm doing this with multiple calls to os.system, > changing the filename each time. Horrible I know, but > I haven't figured out how to use the other os fuctions > to accomplish this any better. Can someone enlighten > me? What about os.system('tar cf result.tar ' + ' '.join(thefilenames))? Assuming that what tar is doing with the filenames is adding them to a tarfile, of course (you don't really make that very clear, at least not to my reading). Alex From joya at foretec.com Fri Jan 4 00:42:36 2002 From: joya at foretec.com (Joya Subudhi) Date: Thu, 03 Jan 2002 18:42:36 -0500 Subject: Python Conference News Message-ID: <3C34EC6C.50594AFE@foretec.com> Python 10 Conference News Python 10 is just around the corner. Register today and save with EARLY BIRD REGISTRATION RATES. This early bird offer ends on January 7, 2002. To register, go to http://www.python10.org/p10-regInfo.html The Python 10 GROUP RATE at the Hilton Alexandria Mark Center is only guaranteed until January 11, 2002. For information on room rates and reservation procedures, please go to http://www.python10.org/p10-hotelInformation.html Feature Presentation: Developers' Day opens with the "State of the Python Union" Address by Guido van Rossum Birds-of-a-Feather: Python 10 is now calling for your Birds-of-a-Feather (BoF) submissions. To propose a BoF, please go to: http://www.python10.org/p10-callBoFs.html The Tenth International Python Conference, February 4 - 7, 2002 The Hilton Alexandria Mark Center, Alexandria, Virginia http://www.python10.org Silver Sponsor: Hostway Corporation: http://www.hostway.com Silver Sponsor: New Riders Publishing: http://www.newriders.com Exhibitor: Archaeopteryx Software: http://www.archaeopteryx.com From sag at hydrosphere.com Fri Jan 4 01:01:27 2002 From: sag at hydrosphere.com (Sue Giller) Date: Thu, 3 Jan 2002 17:01:27 -0700 Subject: Subclassing exceptions Message-ID: <20020103235854150.AAA275@mail.climatedata.com@SUEW2000> I am trying to write an exception class that will pass on info from a previous exception (if any) along with the currently raised exception. This is in Windows (win32all 1.40) I am using sys.exc_info() to get the current state of the exception. According to Beazley, pg 118, exc_info() should return None if no exception is currently being handled. See the end of the message for the subclass. If I catch an exception, and then raise my own Ex exception, things seem ok: (The following prints "Ex: unsupported operand types for +; Raising an exception" which is what I want) try: a = 1 + 'b' except: raise Ex, "Raising an exception However, if I just raise my exception, I don't get None back from exc_info, but rather a win32ui error: There is no active view". The following prints "Ex: There is no active view.;Raising cain". I would expect to get None since no exception has been raised before my exception is raised. raise Ex, "Raising cain" A trace on that shows Traceback (most recent call last): File "C:\Python21\Pythonwin\pywin\framework\intpyapp.py", line 75, in OnCommand v = self.GetActiveView() # Raise an exception if none - good - then we want default handling win32ui: There is no active view. Here is the exception class (test case): It wants to append any input args to any existing text from an exception. import exceptions class Ex(exceptions.Exception): def __init__(self, args=None): import sys info = sys.exc_info() text = "" if not info is None: # always get this! text = "%s" % str(info[1]) if args != None: text = text + "\n\t" + args self.args = text Is there some way to write a subclassed exception that allows me to pass on the text from the last raised exception (if any) plus my subclassed text? This does not happen from the interactive prompt, but will happen from a script. You can have a simple script in PythonWin, with just the lines: import sys print sys.exc_info() and get the same results ('win32ui', 'There is no active view.', ) From cliechti at gmx.net Fri Jan 4 22:58:55 2002 From: cliechti at gmx.net (Chris Liechti) Date: 4 Jan 2002 22:58:55 +0100 Subject: Subclassing exceptions References: Message-ID: sag at hydrosphere.com (Sue Giller) wrote in news:mailman.1010102348.1522.python-list at python.org: > I am trying to write an exception class that will pass on info from a > previous exception (if any) along with the currently raised exception. why do you wanna do this? i often use: ... except: print >>sys.stderr, "Exception in _ComPortThread:" traceback.print_exc(file=sys.stderr) to print a tarceback but continue the program. > Here is the exception class (test case): It wants to append any input > args to any existing text from an exception. > > import exceptions > class Ex(exceptions.Exception): > def __init__(self, args=None): > import sys > info = sys.exc_info() > text = "" > if not info is None: # always get this! > text = "%s" % str(info[1]) > if args != None: > text = text + "\n\t" + args > self.args = text i don't know how secure is it to get exception info during an exception is raised... i would leave my fingers of it... i would process the last exception end then raise the own exception along with the extracted info. > Is there some way to write a subclassed exception that allows me to > pass on the text from the last raised exception (if any) plus my > subclassed text? does this work for you: class MyException(Exception): pass ... try: ... except Exception, msg: raise MyException, msg ... > This does not happen from the interactive prompt, but will happen > from a script. You can have a simple script in PythonWin, with just > the lines: > > import sys > print sys.exc_info() > > and get the same results > > ('win32ui', 'There is no active view.', 0133FF70>) python win uses python too.. so maybe you see an exception that was generated in the GUI. -- Chris From sag at hydrosphere.com Fri Jan 4 23:22:44 2002 From: sag at hydrosphere.com (Sue Giller) Date: Fri, 4 Jan 2002 15:22:44 -0700 Subject: Subclassing exceptions In-Reply-To: <200201042158.g04LwsA06782@mail.swissonline.ch> Message-ID: <20020104222009103.AAA275@mail.climatedata.com@SUEW2000> > why do you wanna do this? Eventually, the exceptions will be passed back thru a COM object. I want to be able to pass information on both the exception that was raised within Python, as well as information on where in my script this exception occured, but I don't want a full trace. I hope to create a general COM error, subclassed for each of my COM objects, that can pass back this info. So I need to handle the case where I have caught an exception, as well as the case where I just want to raise my own exception. As further information, I can run my test script in DOS window and I get the correct results. I haven't tested it yet in a com object, but that is next. I build and test my scripts in PythonWin, so I tend to expect the behaviour shown there to be the same as the behavior I would see running the same script in DOS. So, that is where my puzzlement is coming from. Thanks sue From hoongyu at joins.com Fri Jan 4 01:53:17 2002 From: hoongyu at joins.com (=?ks_c_5601-1987?B?wbbAzLqq?=) Date: Fri, 04 Jan 2002 09:53:17 +0900 Subject: =?ks_c_5601-1987?B?cHl0aG9uLWxpc3S01LKyIDIwMDK/+bXlxMUgx9GxucD8IMa8xM/AxyDH4L/uwLsuLi4=?= Message-ID: <200201040056.g040uFX11009@joins.com> --> (?)??? ?? ? 2002 ?? ???? ??? ? ??? ?? 3??? ?????!!! ??? 3??? ??? ?????? ???? ???? ??? ??? ??? ?????. ????? ?? E-mail ?? ?? ?? E-mail ??? ??? ?? ????? ??? ??????. ????? -------------- next part -------------- An HTML attachment was scrubbed... URL: From bpt at tunes.org Fri Jan 4 01:59:15 2002 From: bpt at tunes.org (Brian P Templeton) Date: Fri, 04 Jan 2002 00:59:15 GMT Subject: Time for a Fresh Scheme Standard: Say Goodbye to the RnRS Relic References: <3218013921984060@naggum.net> <3218081134224960@naggum.net> Message-ID: <87n0zve479.fsf@tunes.org> markj+0111 at cloaked.freeserve.co.uk (MJ Ray) writes: > Erik Naggum wrote: >> Have you thought about how _necessary_ it is for you Scheme freaks to be >> hostile to those who do not agree with you? E.g., where _did_ the stupid >> need to attack Common Lisp now come from? So immature and vindictive! > > Sorry Erik. I attacked you, not Common Lisp. Or are you Common Lisp > itself? > >> [...] so far, we have had a large number of Scheme freaks invade >> Common Lisp fora to tell us how superior Scheme is, while no Common Lisp >> programmers invade Scheme camps to tell you how good Common Lisp is. > > I can only think of one Common Lisp forum, Then you're obviously not thinking very hard, since you just posted to one. :) > CLiki, and it contains little > about Scheme. Maybe you wish to make general Lisp fora "pure" and filled > only with your One True Lisp? > Why do you think that CLiki -- a Wiki devoted to Common Lisp, and for the most part consisting of resources for Common Lisp developers on Unix -- would include Scheme information? CLiki is *specifically* about Common Lisp, not Lisp in general. > I've snipped the rest of your content-free post. Followups set. Followups ignored, since this is also relevant to Common Lisp. -- BPT /"\ ASCII Ribbon Campaign backronym for Linux: \ / No HTML or RTF in mail Linux Is Not Unix X No MS-Word in mail Meme plague ;) ---------> / \ Respect Open Standards From ahamm at programmer.net Fri Jan 4 04:03:13 2002 From: ahamm at programmer.net (Andrew Hamm) Date: Fri, 4 Jan 2002 14:03:13 +1100 Subject: Time for a Fresh Scheme Standard: Say Goodbye to the RnRS Relic References: <3218013921984060@naggum.net><3218081134224960@naggum.net> <87n0zve479.fsf@tunes.org> Message-ID: <3c351b9e$1_2@news.iprimus.com.au> Brian P Templeton wrote... >markj+0111 at cloaked.freeserve.co.uk wrote: >> Erik Naggum wrote: >>>[PROBABLY OTHER PEOPLE HAVE ALSO written:] > [FLAMEY STUFF ABOUT COMMON LISP AND SCHEME] Guys, what makes you think that the rest of the newsgroups care to follow this flame war? Us other language users don't give a damn. In fact, this whole thing looks like a troll for a flame war. If you really must keep flaming each other (and I'm not taking sides since I haven't been following the thread, and I'm not trying to say that flaming isn't fun) then could you please trim the list of newsgroups down to just the lispy ones? Or better still, please arrange to meet behind the Gym building after school and you can have a fist fight to decide which version of Lisp is better. If you are too woosy to have a fist fight, have a pokemon battle on your gameboys. -- Space Corps Directive #997 Work done by an officer's doppleganger in a parallel universe cannot be claimed as overtime. -- Red Dwarf From ahamm at programmer.net Fri Jan 4 05:37:50 2002 From: ahamm at programmer.net (Andrew Hamm) Date: Fri, 4 Jan 2002 15:37:50 +1100 Subject: Time for a Fresh Scheme Standard: Say Goodbye to the RnRS Relic References: <3218013921984060@naggum.net><3218081134224960@naggum.net> <87n0zve479.fsf@tunes.org> <3c351b9e$1_2@news.iprimus.com.au> Message-ID: <3c3531cf_2@news.iprimus.com.au> michael at thelastchurch.org wrote in message ... >On Fri, 4 Jan 2002 14:03:13 +1100, "Andrew Hamm" > wrote: >> If >>you are too woosy to have a fist fight, have a pokemon battle on your >>gameboys. > >Ditto: > "I choose you!!!!" ???? Sorry - couldn't resist. Hopefully all our 6yr old nephews will move onto the next craze very soon and we can all forget about pokemon. What horrors await us then? -- Space Corps Directive #997 Work done by an officer's doppleganger in a parallel universe cannot be claimed as overtime. -- Red Dwarf From markj+0111 at cloaked.freeserve.co.uk Fri Jan 4 04:37:33 2002 From: markj+0111 at cloaked.freeserve.co.uk (MJ Ray) Date: Fri, 04 Jan 2002 03:37:33 GMT Subject: Time for a Fresh Scheme Standard: Say Goodbye to the RnRS Relic References: <3218013921984060@naggum.net> <3218081134224960@naggum.net> <87n0zve479.fsf@tunes.org> Message-ID: Brian P Templeton wrote: >markj+0111 at cloaked.freeserve.co.uk (MJ Ray) writes: >> I can only think of one Common Lisp forum, >Then you're obviously not thinking very hard, since you just posted to >one. :) Sorry, I've looked at the available material about comp.lang.lisp and it appears to be a forum for Lisp, not just Common Lisp. Am I mistaken? Can you justify that? >Why do you think that CLiki [...] would include Scheme information? I don't, as it's the only CL forum I found, which is what I said. Please try to parse in the spirit of the message. ;-) >> I've snipped the rest of your content-free post. Followups set. >Followups ignored, since this is also relevant to Common Lisp. Followups reset, as this has nothing to do with perl, python, or religion. Please be polite, even if you ignore my recommendation. From joe at al.com.au Fri Jan 4 02:40:36 2002 From: joe at al.com.au (Joe Connellan) Date: Fri, 04 Jan 2002 12:40:36 +1100 Subject: PIL Image to PyOpengl glDrawPixels Message-ID: <3C350814.E5F43046@al.com.au> Hi, I'm opening an image using import Image im = Image.open("/tmp/image.bmp") imgData = im.getData() which returns a nested list of integers like this imgData[width*height][3] How do I go about formating this for the following glDrawPixels? glDrawPixels(self.im.size[0], self.im.size[1], GL_RGB, GL_INT, imgData) according to the docs this particular glDrawPixels is suppose to take a sequence of ints but the following code does not work width = 100 height = 100 numChannels = 3 imgData = [100, ] * width * height * numChannels glDrawPixels(100, 100, GL_RGB, GL_INT, imgData) I'm pretty sure glDrawPixels is working ok as the following code works fine (using chars). width = 100 height = 100 numChannels = 3 imgData = chr(100) * width * height * numChannels glDrawPixels(100, 100, GL_RGB, GL_UNSIGNED_BYTE, imgData) Any help would be greatly appreciated. Thanks Joe From mcfletch at rogers.com Fri Jan 4 05:33:18 2002 From: mcfletch at rogers.com (Mike C. Fletcher) Date: Thu, 03 Jan 2002 23:33:18 -0500 Subject: PIL Image to PyOpengl glDrawPixels References: <3C350814.E5F43046@al.com.au> Message-ID: <3C35308E.5090205@rogers.com> You can find a working example of loading an image with PIL and then using it with glDrawPixels here (all one line). http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/pyopengl/OpenGLContext/tests/gldrawpixels.py?rev=1.6&content-type=text/plain Sorry, a bit busy at the moment to go through and figure out what's going on in your code, post if you still have problems after looking at the example. HTH, Mike Joe Connellan wrote: > Hi, > I'm opening an image using ... > How do I go about formating this for the following glDrawPixels? > > glDrawPixels(self.im.size[0], self.im.size[1], GL_RGB, GL_INT, imgData) ... From pete at shinners.org Fri Jan 4 09:34:03 2002 From: pete at shinners.org (Pete Shinners) Date: Fri, 04 Jan 2002 08:34:03 GMT Subject: PIL Image to PyOpengl glDrawPixels References: <3C350814.E5F43046@al.com.au> Message-ID: <3C356951.5070700@shinners.org> Joe Connellan wrote: > I'm opening an image using > > import Image > > im = Image.open("/tmp/image.bmp") > imgData = im.getData() > > which returns a nested list of integers like this > imgData[width*height][3] > > How do I go about formating this for the following glDrawPixels? you'll want to use the 'tostring' function from PIL. this will convert the image into a string of byte-data. that is what you pass to glDrawPixels. also be sure to use the vertical-flip option for tostring, since opengl looks at images bottom to top :] From mertz at gnosis.cx Fri Jan 4 03:31:51 2002 From: mertz at gnosis.cx (Dr. David Mertz) Date: Thu, 03 Jan 2002 21:31:51 -0500 Subject: Book Royalties Message-ID: > A computer book author typically gets between 10-15% royalties.... > Mark's book says $35 on the back, although this is often > discounted. So let's say the publisher gets $17.50, then Mark gets > about $2.00 per book. "Peter Milliken" wrote: |Even a reasonable income of say $100K per year requires 50,000 books at |that rate. Well, US$100k is a bit more "reasonable" than AU$100k. But either way, most computer book authors have day jobs. |But surely these figues would argue for a lot of pressure for an author |to publish electronically and directly - hence getting far more than $2 |per book I happen to be writing a book also, and so spent some time researching and thinking about this (plug: _Text Processing in Python_ :-)). Actually, I started writing the thing for Sybex, then they had some budgetary cutbacks, but decided not to tell me they were cancelling my book for a six weeks of writing (it took some nasty legal-sounding letters to wrestle some due monies out of them). Fortunately, after a delay, I have a new contract to finish it with Addison Wesley, who is really a much better publisher anyway. But for my gap time, I thought really seriously about self-publishing. The electronic vs. paper issue is surprisingly unimportant, actually. You can get a printer to produce a very nice physical book for just a few dollars a copy. I looked at some paper stocks and print process stuff, and for a run of 1000 you can get something just as good looking as what New Riders of O'Reilly publish for less than $4/book. The author needs to find an editor; and either find a typesetter and indexer or do it herself -- but then, I am doing my AW typesetting in exchange for a bit of extra money from them anyway (I wouldn't dream of trying to be my own editor or indexer; authors are blind to certain things in their own books). The real problem with self-publishing is publicity and distribution. It's easy to get an ISBN; and not hard to get your book listed on Amazon and Barnes-and-Noble websites. But to put books on bookstore shelves, a self-published author has a big challenge. The thumb-through-the-shelf shoppers are just simply not going to see your self-published book; and I don't really believe that websites are going to attract all that many potential buyers. Of course, if you can get three or four times the per-book profit, you can sell a third or fourth as many books and get the same income. I don't know how these things balance each other... maybe someone like Bruce Eckel--with more books out there--has a better knowledge of the pros and cons. Yours, David... From tuttledon at mailandnews.com Fri Jan 4 04:10:48 2002 From: tuttledon at mailandnews.com (Don Tuttle) Date: Fri, 04 Jan 2002 03:10:48 GMT Subject: Book Royalties References: Message-ID: "Dr. David Mertz" > I happen to be writing a book also, and so spent some time researching > and thinking about this (plug: _Text Processing in Python_ :-)). Wow. You must be quite a salesman. How many times did you hear, "Why wouldn't I just use Perl?" And what was your response? Don From peter.milliken at gtech.com Fri Jan 4 05:04:14 2002 From: peter.milliken at gtech.com (Peter Milliken) Date: Fri, 4 Jan 2002 15:04:14 +1100 Subject: Book Royalties References: Message-ID: "Dr. David Mertz" wrote in message news:mailman.1010113205.15149.python-list at python.org... > The real problem with self-publishing is publicity and distribution. > It's easy to get an ISBN; and not hard to get your book listed on Amazon > and Barnes-and-Noble websites. But to put books on bookstore shelves, a > self-published author has a big challenge. The thumb-through-the-shelf > shoppers are just simply not going to see your self-published book; and > I don't really believe that websites are going to attract all that many > potential buyers. Of course, if you can get three or four times the > per-book profit, you can sell a third or fourth as many books and get > the same income. I don't know how these things balance each other... > maybe someone like Bruce Eckel--with more books out there--has a better > knowledge of the pros and cons. OK, agreed but how often do you purchase a "specialist" title type book like a computer book by just "thumbing through shelfs"? Perhaps the "generic" books like Software Development in 21 Days or whatever, but the more niche markets like "Thinking in Python" can be advertised quite effectively through the Python newsgroup (the *only* audience is most likely found in comp.lang.python - in which case you run the advert in the news group - there used to be FAQs published regularly in newsgroups - just volunteer to maintain the Python FAQ and make sure there is a section on books! :-)). In your case, you would also have to go after that part of your intended audience through some form of appeal to a newsgroup where you would find people interested in Text Processing. Anyway, just thinking out loud there :-) As I said, the publishing industry is putting itself out of business as far as I am concerned - I will be investigating getting my local library to purchase a copy of "Python Programming Patterns" in the near future :-). Peter From lac at strakt.com Fri Jan 4 13:00:29 2002 From: lac at strakt.com (Laura Creighton) Date: Fri, 04 Jan 2002 13:00:29 +0100 Subject: Book Royalties In-Reply-To: Message from "Peter Milliken" of "Fri, 04 Jan 2002 15:04:14 +1100." References: Message-ID: <200201041200.g04C0Tua032257@ratthing-b246.strakt.com> I disagree with Peter Milliken's assertion that the only audience for "Thinking in Python" is most likely found in comp.lang.python. I think the set of people 'too busy to read newsgroups' is a more significant market segment for Bruce Eckel to target. He has his own newsletter, but I do not know what else he does to try to reach this segment. It is a nasty problem. Laura Creighton From aleax at aleax.it Fri Jan 4 13:12:23 2002 From: aleax at aleax.it (Alex Martelli) Date: Fri, 4 Jan 2002 13:12:23 +0100 Subject: Book Royalties References: Message-ID: "Laura Creighton" wrote in message news:mailman.1010145666.18032.python-list at python.org... > I disagree with Peter Milliken's assertion that the only audience > for "Thinking in Python" is most likely found in comp.lang.python. > I think the set of people 'too busy to read newsgroups' is a more > significant market segment for Bruce Eckel to target. He has his Definitely. > own newsletter, but I do not know what else he does to try to > reach this segment. It is a nasty problem. What about, having Prentice-Hall publish his books? That's what he's done for "Thinking in C++" and "Thinking in Java" (and similarly earlier books too, I think, although it may have been McGraw-Hill -- doesn't change the point, I believe). It seems to me that existing publishers and bookshops (including both online and brick-and-mortar stores) are a reasonably good setup to market and sell books (as well as, at least potentially, helping enormously with editing, production, and so on). No doubt better alternatives may one day emerge, but, so far, I have seen none. Alex From claird at starbase.neosoft.com Fri Jan 4 19:14:29 2002 From: claird at starbase.neosoft.com (Cameron Laird) Date: 4 Jan 2002 12:14:29 -0600 Subject: Book Royalties References: Message-ID: <725D989D4EABAA23.7E7330ECA11138F5.060A7A10105DAABD@lp.airnews.net> In article , Alex Martelli wrote: . . . >It seems to me that existing publishers and bookshops (including >both online and brick-and-mortar stores) are a reasonably good setup >to market and sell books (as well as, at least potentially, helping >enormously with editing, production, and so on). No doubt better >alternatives may one day emerge, but, so far, I have seen none. . . . Distribution and marketing--those are the reasons, and pre- dominantly the former. Tim O'Reilly writes frequently on this subject, both in public and elsewhere. In principle, publishers add value in the editorial process, but that has become secondary or even tertiary for most. Distribution's the key thing, though: publishers (when they're doing their job) get inventory out on display shelves where modestly-motivated prospective consumers are liable to exercise their impulses. Most of the other publishing functions are fungible. In particular, self-publishing can work out great for people, such as Bruce, who are in front of their audiences a lot. Apart from a few elephant-generators (the original Dummy authors, ...), some of the best livings among authors are those made by trainers or seminar speakers who capture the dollars in the pockets of their listeners. I second Alex: while 'twould appear that more efficient social forms will appear some day, it's not obvious what beats a traditional book right now. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From claird at starbase.neosoft.com Fri Jan 4 19:04:50 2002 From: claird at starbase.neosoft.com (Cameron Laird) Date: 4 Jan 2002 12:04:50 -0600 Subject: Book Royalties References: Message-ID: In article , Laura Creighton wrote: >I disagree with Peter Milliken's assertion that the only audience >for "Thinking in Python" is most likely found in comp.lang.python. >I think the set of people 'too busy to read newsgroups' is a more >significant market segment for Bruce Eckel to target. He has his >own newsletter, but I do not know what else he does to try to >reach this segment. It is a nasty problem. > >Laura Creighton > Many people who aren't even aware of newsgroups bought previous Eckel works. Yes, marketing remains a challenge. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From scott at coyotegulch.com Fri Jan 4 05:57:15 2002 From: scott at coyotegulch.com (Scott Robert Ladd) Date: Fri, 04 Jan 2002 04:57:15 GMT Subject: Book Royalties References: Message-ID: Well, I've written 17 books since 1990, mostly on C++ and Java, and made a "decent" living when writing was my full-time professional. With three kids now and other responsibilities, I went back into industry, when I make more than double my best annual "book" income. > Actually, I started writing the thing for Sybex, then they had some > budgetary cutbacks, but decided not to tell me they were cancelling my > book for a six weeks of writing (it took some nasty legal-sounding > letters to wrestle some due monies out of them). Fortunately, after a > delay, I have a new contract to finish it with Addison Wesley, who is > really a much better publisher anyway. I've had some bad luck with publishers, too -- they get sold (M&T), or decide to "change direction" and abandon a finished book project (Cambridge and O'Reilly, in my case). It's a rough business. And I've told a couple of publishers to take a hike after they treated me like dirt... the bigger the publisher, the more they'll try to railroad a writer into giving up copyright or modifying a book for some political agenda (as in MS Press messing up my Visual J++ book in '97). > But for my gap time, I thought really seriously about self-publishing. > The electronic vs. paper issue is surprisingly unimportant, actually. > You can get a printer to produce a very nice physical book for just a > few dollars a copy. I looked at some paper stocks and print process > stuff, and for a run of 1000 you can get something just as good looking > as what New Riders of O'Reilly publish for less than $4/book. Does electronic self-publishing work? Well, it all depends on whether people are willing to pay. Even Stephen King didn't make much money from his experiments in e-books; only about 2/3rds of people were willing to pay for what they downloaded. It's impossible (or at least highly impractical) to publish in a format that can't be "shared", thus it is difficult to enforce any sort of payment for one's work. Once an electronic book is "in the wild", it's likely to be available from web sites around the world. > An author needs to find an editor; and either find a typesetter and indexer > or do it herself -- but then, I am doing my AW typesetting in exchange > for a bit of extra money from them anyway (I wouldn't dream of trying to > be my own editor or indexer; authors are blind to certain things in > their own books). Excellent advice. I'm a lousy proofreader of my own work; I like having an editor. I tried indexing one of my own books; some publishers pay out of their pocket to index books, while others ask the author to pay for it. > The real problem with self-publishing is publicity and distribution. > It's easy to get an ISBN; and not hard to get your book listed on Amazon > and Barnes-and-Noble websites. But to put books on bookstore shelves, a > self-published author has a big challenge. Once again, great advice. This is where self-publishing falls down for me; I'm just not very effective at marketing. The market is flooded with books from "big name" publishers, and the web is inundated with free material (mostly bad) that leaves today's younger developers wondering why they should pay US$20-60 for a dead tree book (or even $5 for a PDF!). I wish Bruce Eckel well; I hope he can pull off a profit from his online books. Oh, I'm still working on books; I've just taken a couple of years to have real benefits, a steady paycheck, and to get myself reoriented in practical practice. Writing computer books is *not* the path to riches and fame, but I still love doing it... so back into the fire I go, with the naive belief that *somehow*, someday, I'll make enough money to quit my "real" job... ;) -- Scott Robert Ladd Master of Complexity, Destroyer of Order and Chaos Visit CoyoteGulch at http://www.coyotegulch.com No ads -- just info, algorithms, and very free code. From drt-usenet-2002 at un.bewaff.net Tue Jan 8 18:01:46 2002 From: drt-usenet-2002 at un.bewaff.net (Doobee R. Tzeck) Date: 08 Jan 2002 18:01:46 +0100 Subject: Book Royalties References: Message-ID: <878zb822v9.fsf@c0re.bewaff.net> "Dr. David Mertz" writes: > |But surely these figues would argue for a lot of pressure for an author > |to publish electronically and directly - hence getting far more than $2 > |per book > > I happen to be writing a book also, and so spent some time researching > and thinking about this (plug: _Text Processing in Python_ :-)). http://philip.greenspun.com/wtr/dead-trees/story.html has a very entertaining article about the writing and publishing the book "Database-backed Web Sites" drt -- teenage mutant ninja hero coders from da c0re - http://c0re.jp/ me - http://koeln.ccc.de/~drt/ From NOSPAM.opengeometry at yahoo.ca Tue Jan 8 20:27:10 2002 From: NOSPAM.opengeometry at yahoo.ca (William Park) Date: Tue, 08 Jan 2002 19:27:10 GMT Subject: Book Royalties References: Message-ID: Dr. David Mertz wrote: > But for my gap time, I thought really seriously about self-publishing. > The electronic vs. paper issue is surprisingly unimportant, actually. > You can get a printer to produce a very nice physical book for just a > few dollars a copy. I looked at some paper stocks and print process > stuff, and for a run of 1000 you can get something just as good looking > as what New Riders of O'Reilly publish for less than $4/book. The > author needs to find an editor; and either find a typesetter and indexer > or do it herself -- but then, I am doing my AW typesetting in exchange > for a bit of extra money from them anyway (I wouldn't dream of trying to > be my own editor or indexer; authors are blind to certain things in > their own books). > > The real problem with self-publishing is publicity and distribution. > It's easy to get an ISBN; and not hard to get your book listed on Amazon > and Barnes-and-Noble websites. But to put books on bookstore shelves, a > self-published author has a big challenge. The thumb-through-the-shelf > shoppers are just simply not going to see your self-published book; and > I don't really believe that websites are going to attract all that many > potential buyers. Of course, if you can get three or four times the > per-book profit, you can sell a third or fourth as many books and get > the same income. I don't know how these things balance each other... > maybe someone like Bruce Eckel--with more books out there--has a better > knowledge of the pros and cons. Hi David, I'm also an aspiring author, looking at 5% (retail) royalty. I would like to ask few questions... 1. Of the printers that you looked at, how were their binding? Were the binding comparable to those books that you see on bookstores? I can do my own typesetting and all, but can't do binding. 2. In your dealing with publishers, have you comes across any who will do the marketing and distribution only, and leave the printing to the author? I figure most publisher already outsource the printing to offset shops. Yours truly, -- William Park, Open Geometry Consulting, . 8 CPU cluster, NAS, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Tin From kragen at pobox.com Thu Jan 24 00:56:14 2002 From: kragen at pobox.com (Kragen Sitaker) Date: 23 Jan 2002 18:56:14 -0500 Subject: Book Royalties References: Message-ID: <83hepck4f5.fsf@panacea.canonical.org> William Park writes: > 1. Of the printers that you looked at, how were their binding? Were the > binding comparable to those books that you see on bookstores? I can do > my own typesetting and all, but can't do binding. Most of the bright-orange-doorstop school of computer books are bound by a process known as "perfect binding", which consists of hot-gluing the edges of the pages to the spine. This is really cheap, but it results in spines that crack, pages that fall out, and books that don't open flat, especially if they get hot (my copy of "Philip and Alex's guide to Web Publishing" got left open in my car one summer Ohio day, and the spine had peeled away from the pages when I got off work). You can get perfect binding done at Kinko's fairly cheaply. Actual sewn-signature binding, like hardcover books and O'Reilly use, I imagine to be more expensive; but I haven't tried it. The Velobind process results in sturdier books than perfect binding, and can actually be applied to previously perfect-bound books. It involves punching holes through the pages near the edge, sticking plastic rods through the holes, and melting the plastic rods onto plastic strips on the outside of the book. (Somewhat simplified.) It costs a couple bucks at Kinko's, but only works for books up to an inch or so thick. I have a question. How can a self-publisher find a decent editor and indexer? Those are fairly specialized skills, and the editors and indexers used by most of the books I've liked in the past are employees of book publishers, so I don't expect that they are available for freelance work --- right? From phr-n2002a at nightsong.com Thu Jan 24 03:08:19 2002 From: phr-n2002a at nightsong.com (Paul Rubin) Date: 23 Jan 2002 18:08:19 -0800 Subject: Book Royalties References: <83hepck4f5.fsf@panacea.canonical.org> Message-ID: <7x7kq8lcvg.fsf@ruckus.brouhaha.com> Kragen Sitaker writes: > I have a question. How can a self-publisher find a decent editor and > indexer? Those are fairly specialized skills, and the editors and > indexers used by most of the books I've liked in the past are > employees of book publishers, so I don't expect that they are > available for freelance work --- right? I don't know about indexing but there's bazillions of freelance editors out there hungry for work. From kragen at pobox.com Thu Jan 24 07:25:45 2002 From: kragen at pobox.com (Kragen Sitaker) Date: 24 Jan 2002 01:25:45 -0500 Subject: Book Royalties References: <83hepck4f5.fsf@panacea.canonical.org> <7x7kq8lcvg.fsf@ruckus.brouhaha.com> Message-ID: <83665sjmdy.fsf@panacea.canonical.org> Paul Rubin writes: > Kragen Sitaker writes: > > I have a question. How can a self-publisher find a decent editor and > > indexer? Those are fairly specialized skills, and the editors and > > indexers used by most of the books I've liked in the past are > > employees of book publishers, so I don't expect that they are > > available for freelance work --- right? > > I don't know about indexing but there's bazillions of freelance > editors out there hungry for work. How do you know which ones are any good? From mertz at gnosis.cx Thu Jan 24 08:26:31 2002 From: mertz at gnosis.cx (Dr. David Mertz) Date: Thu, 24 Jan 2002 02:26:31 -0500 Subject: Book Royalties References: <83hepck4f5.fsf@panacea.canonical.org> <7x7kq8lcvg.fsf@ruckus.brouhaha.com> <83665sjmdy.fsf@panacea.canonical.org> Message-ID: Kragen Sitaker wrote previously: |> I don't know about indexing but there's bazillions of freelance |> editors out there hungry for work. |How do you know which ones are any good? I know a couple editors whose work I have been pleased with, who would probably be interested in doing freelance work on books or articles. I haven't been in a relationship with either that involved me paying them directly, so I honestly cannot say what sort of rates they would want for a project like that. But if anyone wants to write me off-list, I'll let you know contact information--and also the exact details of my knowledge about said editors. Of course, I happen to know a couple whom I would recommend... everyone else who has written books and articles has their own good and bad experiences... adding up to exactly one bazillion editors in all. Of those, only a few jillion are looking for freelance work, and only (let's say) 30% of those are in the good category. Yours, David... -- mertz@ _/_/_/_/ THIS MESSAGE WAS BROUGHT TO YOU BY: \_\_\_\_ n o gnosis _/_/ Postmodern Enterprises \_\_ .cx _/_/ \_\_ d o _/_/_/ IN A WORLD W/O WALLS, THERE WOULD BE NO GATES \_\_\_ z e From jadestar at idiom.com Sun Jan 27 04:52:20 2002 From: jadestar at idiom.com (James T. Dennis) Date: 27 Jan 2002 03:52:20 GMT Subject: Book Royalties References: <83hepck4f5.fsf@panacea.canonical.org> <7x7kq8lcvg.fsf@ruckus.brouhaha.com> Message-ID: Paul Rubin wrote: > Kragen Sitaker writes: >> I have a question. How can a self-publisher find a decent editor and >> indexer? Those are fairly specialized skills, and the editors and >> indexers used by most of the books I've liked in the past are >> employees of book publishers, so I don't expect that they are >> available for freelance work --- right? > I don't know about indexing but there's bazillions of freelance > editors out there hungry for work. I started my book (_Linux_System_Administration_, New Riders) in LaTeX and did most of my own indexing. As I added a couple of co-authors they taught themselves enough LaTeX to use my macros and those macros did most of the indexing, except for things we wanted to add "by hand." We convinced our publishers/editors to hire a TeXnician to create a stylesheet to fit our LaTeX sources into their printing r