From printers at sendme.cz Sat Jan 18 07:53:20 2003 From: printers at sendme.cz (A) Date: Sat, 18 Jan 2003 13:53:20 +0100 Subject: Cookies module Message-ID: <3E295C50.29055.554F41B@localhost> Hi all, Is there a cookie module that handles cookies on a client side and would work with httplib module? For example: Server returns the following cookies: Set-Cookie: compid=1342; expires= Set-Cookie: password=BMA; expires= Set-Cookie: company=BMA TRADING s.r.o.; expires= Set-Cookie: email=export at send.com; expires=Fri, 02-Dec-50 00:00:00 GMT Set-Cookie: temppassword=; expires=Thu, 01-Jan-1970 00:00:00 GMT I have a procedure that can create compid=1342;password=BMA;company=BMA TRADING s.r.o.;email=export at send.com but the right is email=export at send.com; compid=1342; password=BMA; company=BMA TRADING s.r.o Please note the order. And this is only one type of returned cookies. I do not know how difficult it would be to think about all varieties e.g. if Path is present. Thanks for help. Ladislav From bokr at oz.net Sun Jan 12 22:15:41 2003 From: bokr at oz.net (Bengt Richter) Date: 13 Jan 2003 03:15:41 GMT Subject: map() question... References: <3E222975.F176575D@alcyone.com> Message-ID: On Sun, 12 Jan 2003 18:50:29 -0800, Erik Max Francis wrote: >Mike Meyer wrote: > >> "Kevin Ethridge" writes: >> >> > Why doesn't map() work with the print function? >> > ie map(print, ['Have', 'a', 'great', 'day.']) >> >> Because print isn't a function, it's a statement. It will work with >> sys.stdout.write. > >Only if wrapped in a lambda. Don't forget that trailing newline that's >implicit in a print statement (one with no trailing comma, anyway): > > lambda x: sys.stdout.write(x + '\n') > And then there's softspace ;-) Regards, Bengt Richter From mwh at python.net Wed Jan 29 07:14:36 2003 From: mwh at python.net (Michael Hudson) Date: Wed, 29 Jan 2003 12:14:36 GMT Subject: Python vs. C++ Builder - speed of development References: <3e36d04e_2@news.vo.lu> Message-ID: <7h3el6w17cp.fsf@pc150.maths.bris.ac.uk> Laura Creighton writes: > Typing 400 words a minute helps as well. I cannot do that yet, but > one person here at Strakt can. Utterly awesome. I thought that > 200 words was good.... I think I can guess who that is :) Cheers, M. -- > So what does "abc" / "ab" equal? cheese -- Steve Holden defends obscure semantics on comp.lang.python From vvainio at tp.spt.fi Mon Jan 20 04:11:23 2003 From: vvainio at tp.spt.fi (Ville Vainio) Date: 20 Jan 2003 01:11:23 -0800 Subject: comprehensions was Re: Switch statements again References: Message-ID: Tim Peters wrote in message news:... > At the time, lexical nesting didn't yet exist in Python either. The case > for "magically local" bindings has gotten stronger since lexical nesting was > added, but now we've got a backwards compatibility burden too. Backwards compatibility would be less of a burden if it was flagged as "possibly unsupported in the future" in the documentation. At least it would do a bit to alleviate the embarrassment felt when explaining the feature to colleagues, 5 minutes after touting how well designed python is ;-). From mis6 at pitt.edu Thu Jan 9 11:37:56 2003 From: mis6 at pitt.edu (Michele Simionato) Date: 9 Jan 2003 08:37:56 -0800 Subject: Do pythons like sugar? References: <6u6q1vk7dgjps43t0uuk8eut1ghlgnoc71@4ax.com> Message-ID: <2259b0e2.0301090837.2bcdf1d8@posting.google.com> Afanasiy wrote in message news:<6u6q1vk7dgjps43t0uuk8eut1ghlgnoc71 at 4ax.com>... > I've written this method for a text formatting class... > But it's ugly as sin. With all those self's I consider > it much less readable than it could be... > > A few languages provide syntax sugar for dealing with > this by allowing you to localize the class scope. > > Does Python? eg. `with self do:` > > def format( self, width=80 ): > self.lines = [''] > i = 0 > for word in self.text.split(): > if self.textwidth(self.lines[i]) + self.textwidth(word) <= width: > if self.textwidth(self.lines[i]) > 0: > self.lines[i] += ' ' > self.lines[i] += word > else: > i += 1 > self.lines.append(word) You may get rid of self with dirty tricks. I have posted few days ago a solution involving metaclasses which allows Python to recognize _x as a shortcut for self.x. For instance your code would read from noself import Noself class D(Noself): text='Hello world!' #put here your text def textwidth(self,x): #put here your textwidth function return len(x) def format( self, width=80 ): _lines = [''] i = 0 for word in _text.split(): if _textwidth(_lines[i]) + _textwidth(word) <= width: if _textwidth(_lines[i]) > 0: _lines[i] += ' ' _lines[i] += word else: i += 1 _lines.append(word) d=D() d.format() print d.lines I don't know if this is elegant enough for you. It works with Python 2.2, but it has some limitations (for instance you cannot use methods defined trough lambda functions). Moreover, in the present form, _x is replaced with self.x even inside strings, which is bad. Finally, you will break pre-existing code using variables of kind "_x". Nevertheless, I send the script to you to show that a solution is possible, but not recommended, since you would confused all Pythonistas if you use that instead of self. --- begin noself.py --- import re,inspect def selfexpand(cls): """Given a class, looks in its methods and expands identifiers starting with _ to self. For instance, _x --> self.x. Identifiers starting with __ are expanded as __x --> self._classname__x. Identifiers of the form __something__ are ignored. This first version is very stupid and does the replacement in comments (no big harm) and strings (potentially big harm!) too.""" __id__=r'(\b__\w+?__\b)' #first, look at this kind of identifier __id =r'\b__(\w*)' #then, at this kind _id =r'\b_([a-zA-Z_]\w*)' #then, at this kind regexp=re.compile('|'.join([__id__,__id,_id])) def sub(match): i=match.lastindex; g=match.group(i) if i==1: return g # do nothing elif i==2: return 'self._%s__%s' % (cls.__name__,g) elif i==3: return 'self.%s' % g def kill_initial_spaces(text): lines=text.splitlines(); firstline=lines[0] spaces=len(firstline)-len(firstline.lstrip()) if not spaces: return text else: return '\n'.join([line[spaces:] for line in lines]) def modify(method): source=kill_initial_spaces(inspect.getsource(method)) code=regexp.sub(sub,source) # print code d={}; exec code+'\n' in d setattr(cls,method.__name__,d[method.__name__]) for key,val in cls.__dict__.items(): if inspect.isroutine(val): modify(val) class Noself: class __metaclass__(type): "Classes who inherit from Noself automagically call selfexpand" def __init__(cls,name,bases,dic): selfexpand(cls) --- end noself.py --- From chris_mk at hotmail.com Thu Jan 2 18:26:25 2003 From: chris_mk at hotmail.com (Christopher) Date: 2 Jan 2003 15:26:25 -0800 Subject: How do I initialize a list please? References: <3E12178B.2060107@tismer.com> <3E121E42.1000504@rogers.com> Message-ID: Christian Tismer wrote in message news:... > > Absolutely, Mike, I agree. > > I just could not extend to this, since an obvious > one-liner must live in a short message, or it > will miss its desired effect. > I was waiting for this, thanks for chiming in. > > the-opposite-would-require-a-deep-multiply- > -operator-and-happy-new-year-ly y'rs - chris Just curious again, what, exactly, is the desired effect? It must have been lost on me. ;-) From andrew-pythonlist at puzzling.org Thu Jan 30 08:23:35 2003 From: andrew-pythonlist at puzzling.org (Andrew Bennetts) Date: Fri, 31 Jan 2003 00:23:35 +1100 Subject: OO design and multiple local sockets In-Reply-To: <26200000.1043930172@localhost.localdomain> References: <26200000.1043930172@localhost.localdomain> Message-ID: <20030130132335.GA13850@frobozz.local> On Fri, Jan 31, 2003 at 01:36:12AM +1300, Andrew McGregor wrote: > I've got an awful case of writer's block on this one :-( > > Problem: I'm writing an app (an implementation of HIP, see > www.hip4inter.net) that uses raw sockets in a big way. It needs to bind > local sockets to each IP address on the system so it can transmit packets > with each source address. It also needs to know which address packets were > received on, and from where. So far, so good. It's threaded (pretty much > necessarily). There are two pools of sockets for two different protocols > that have to interact. > > Just the code for the protocol transforms and state machines is about 7k > lines, including tests, and works, but with only a single unbound local > socket, so some features I can't do yet. > > What I can't figure out is what a clean OO design for the socket handling > looks like, managing the various queues and worker threads without getting > really hairy. Can anyone help? For OO design inspiration for socket programming, I suggest looking at Twisted -- although admittedly it is rather different to your design (being single-threaded asynchronous rather than multi-threaded). In particular its Factory and Protocol classes may be of interest. In fact, I'd really tempted to use Twisted for this -- have you looked at it? I've found it excels for writing servers that involve multiple protocols. (Not that being a developer of Twisted makes me biased or anything...) -Andrew. From clifford.wells at attbi.com Sat Jan 4 14:27:13 2003 From: clifford.wells at attbi.com (Cliff Wells) Date: 04 Jan 2003 11:27:13 -0800 Subject: new years resolutions In-Reply-To: <60FB8BB7F0EFC7409B75EEEC13E2019201BFDE7C@admin56.narex.com> References: <60FB8BB7F0EFC7409B75EEEC13E2019201BFDE7C@admin56.narex.com> Message-ID: <1041708433.6001.63.camel@x1-6-00-04-5a-64-c4-03> On Sat, 2003-01-04 at 08:46, Bjorn Pettersen wrote: > > From: andy [mailto:andy at eastonwest.co.uk] > [...] > > On a purely personal level, I *feel* that programming, to me, > > is solving a problem by the use of a computer-programming > > language. To me, HTML coding doesn't *feel* like that, but > > maybe that's because I'm not very *good* at it... I think > > its because of the lack of control structures (I am trying to > > self-analyse to figure out what I mean)... having said that, > > I suppose tables, for instance resemble control structures... > [...] > > I told myself I wasn't going to keep this thread alive anymore, but then > who said I was either principled or consistent . Probably many people who responded to this thread told themselves the same thing, so you're at least consistent with them (myself included) > I think the above is the crux of the problem however. Ask yourself (i) > would I write HTML pages differently if I considered it programming?, > (ii) would I write Python programs differently if I considered writing > HTML programming?, (iii) would I view people writing HTML differently if > they were allowed to call it programming?, and finally, (iv) do I think > other people would view me differently if writing HTML was also > considered programming? > > My personal answers are no, no, no, and I don't care. Wheter writing > HTML is programming makes no difference to anything I'm doing, nor do I > expect, does it to any of our web designers. It's a fact of life that I > couldn't do their work, and they couldn't do mine -- and I don't have > enough hubris to suggest that my work is either harder, more important, > or more meaningful (I'm having a hard time seeing another reason for > making a distinction... i.e. tell my _why_ you want do make a > distinction and the "how" should be much easier). Besides, even I end up > writing a lot of HTML (aka documentation) -- should I change my title to > "Software Architect/HTML writer" ? (As an experiment, try telling > your boss you don't want to write documentation, in HTML, since you're a > _programmer_ ). > > Finally, it seems rather silly to try to define set membership (is HTML > in the set of programming languages?) as a all or nothing (function > returning either 0 or 1) when (a) you don't have a concrete definition, > (b) it seems to rely on a combination of factors in varying degrees, and > (c) a good number of the people interested all but define it as the > intent _they're_ having when _they're_ writing HTML ("HTML is something > I use for documentation, for my _real_ work I use X".) For a much better > (or at least more interesting) approach google for "Russel's paradox" > and "fuzzy logic". I think the thing that gave this thread its energy was because it was started by someone flaming a newbie over a fairly trivial and offhand remark. That tends to get people's hackles up and the lines get drawn fairly quickly. Once people have announced their positions they are reluctant to withdraw from that position and yet are too polite (thank you) to invoke the Hitler clause bringing the thread to its logical conclusion and yet can't quite stop arguing. > ok-I'll-shut-up-now'ly y'rs *Sure* you will : self.consistency -= 1 Arguments-are-the-crack-pipe-of-usenet'ly yrs, -- Cliff Wells From gerhard.haering at opus-gmbh.net Wed Jan 15 07:34:40 2003 From: gerhard.haering at opus-gmbh.net (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: 15 Jan 2003 12:34:40 GMT Subject: Using list_dbs() and list_tables function of MySQLDB with python References: <12fcb4be.0301150422.336d00a4@posting.google.com> Message-ID: sonu wrote: > dear friends, > > i m using list_dbs() and list_tables() function in my application but > finding a problem in running this code successfully. > > The code i m using is: > # !/usr/bin/Python > import MySQLdb > hostname = "192.168.0.11" > username = "root" Using the root user like this is a very bad idea. > password = "" With an empty password even more so. > database = "test" > conn = MySQLdb.connect (hostname, username, password, database) > for db in conn.list_dbs(): > for tbl in conn.list_tables(db[0]): You can't use SQL functions like this (using methods on the connection object). Instead use something like: cursor = conn.cursor() cursor.execute("select list_dbs()") for db_row in cursor.fetchall(): cursor.execute("select list_tables(%s)", (db_row[0],)) for table_row in cursor.fetchall(): # ... Note the use of DB-API parameter binding. > [...] Please help me in solving the problem. You should consider reading some more about the Python DB-API. URLs of interest are: http://www.python.org/peps/pep-0249.html http://www.amk.ca/python/writing/DB-API.html Gerhard -- Gerhard H?ring OPUS GmbH M?nchen Tel.: +49 89 - 889 49 7 - 32 http://www.opus-gmbh.net/ From tim.one at comcast.net Wed Jan 22 20:42:42 2003 From: tim.one at comcast.net (Tim Peters) Date: Wed, 22 Jan 2003 20:42:42 -0500 Subject: logging module missing in 2.3a1 In-Reply-To: Message-ID: [Janto Dreijer] > Python 2.3a1 (#38, Dec 31 2002, 17:53:59) [MSC v.1200 32 bit > (Intel)] on win32 ^^^^^^^^ > Type "copyright", "credits" or "license" for more information. > IDLE 0.8 -- press F1 for help > >>> import logging > Traceback (most recent call last): > File "", line 1, in ? > import logging > ImportError: No module named logging > >>> > > Eh? Is there something I'm missing? > Or is the actual code a bit behind wrt the documentation? The Windows installer wasn't updated to include this new package. It's been fixed (for 2.3a2). From aleax at aleax.it Wed Jan 29 10:08:14 2003 From: aleax at aleax.it (Alex Martelli) Date: Wed, 29 Jan 2003 15:08:14 GMT Subject: Dumb Q #1 References: <3e35fde8_3@corp.newsgroups.com> <3e36afd5$0$26195$a1866201@newsreader.visi.com> Message-ID: Grant Edwards wrote: > In article , Andy Jewell > wrote: > >> for record in records[:]: >> >> 2) Rewrite the records list back to the file. Modifying the records >> /list/ merely changes the copy in memory. > > Writing to a file like /etc/passwd is generally considered "A > Bad Thing". When you want to change a critical (and "live") > file whose corruption will render your system inoperable, > always use a temporary file and then rename it. Incidentally, module fileinput can do that for you -- when you specify the parameter requesting "inline rewrite" of the files being processed, what fileinput does under the cover is exactly this -- write to temporary files and replace the input files with the temporary ones when each is done. So...: import fileinput for line in fileinput.input('/etc/passwd', inplace=1): fields = line.split(':') if fields[3] == "200": fields[3] = 199 line = ':'.join(fields) print line, Alex From andrew-pythonlist at puzzling.org Thu Jan 9 08:21:43 2003 From: andrew-pythonlist at puzzling.org (Andrew Bennetts) Date: Fri, 10 Jan 2003 00:21:43 +1100 Subject: Do pythons like sugar? In-Reply-To: <28sq1v881mp1jki155gal6mtsqt59ujtqt@4ax.com> References: <6u6q1vk7dgjps43t0uuk8eut1ghlgnoc71@4ax.com> <28sq1v881mp1jki155gal6mtsqt59ujtqt@4ax.com> Message-ID: <20030109132143.GB31993@frobozz.local> On Thu, Jan 09, 2003 at 12:54:24PM +0000, Afanasiy wrote: > On Thu, 9 Jan 2003 22:29:33 +1100, Andrew Bennetts > wrote: > >> > >> You don't know what I am doing. My design is perfect. > > > >What is good design for one language isn't necessarily good design for > >another. Python offers different features to, say, C++, and is best used in > >different ways. I would recommend that you try to understand the pythonic > >world-view better, rather than insisting on imposing your preconceptions on > >us... my experience agrees with Andrew Dalke's; explicit self is much better > >than the alternatives. > > If the "pythonic world-view" is that code which would look better with > implicit self is "poor implementation", then no, I do not agree with it. The pythonic world-view on this particular issue is that "Explicit is better than implicit", yes. > Please note I am not complaining out about the lack of this possibility. > I only have a problem with the condescending tones. I guess it's normal. In my experience, people who find this sort of thing about Python annoying aren't using Python optimally. My recommendation is to trust us, show us your whole class, and invite constructive criticism on its design. This may sound condescending, but this newsgroup is filled with experienced Python programmers, and I would be very surprised if you considered yourself better at writing Python than them. -Andrew. From karsten at rohrbach.de Sat Jan 4 04:48:28 2003 From: karsten at rohrbach.de (Karsten W. Rohrbach) Date: 4 Jan 2003 09:48:28 GMT Subject: Simple Zope Photo Album References: <74977d59.0301031118.75afd76d@posting.google.com> Message-ID: mlorfeld wrote: [...] > image, python script, wiki). So basically I'm looking for a Q&D > pytyhon/dtml/html code snippit that will dynamically create a photo > album. Any suggestions? - Install ImageMagick locally - Create a work directory hierarchy $ mkdir work $ mkdir work/img $ mkdir work/thumb - Put all images into ./work - run ImageMagick over them to create jpg and thumbnails (presented script is from my work dir wich contains only PNG images, I publish JPEG pictures) #!/bin/sh for i in *.png do FNAME=`echo -n ${i} | sed s/.png$//` echo ${FNAME} convert ${i} ./img/${FNAME}.jpeg convert ${i} -geometry 96x96 ./thumb/${FNAME}.jpeg done - Now FTP to your Zope server and upload the two directories relative to you gallery container object (Folder) - I use NcFTP for that (recursive put) - on the Zope side you can install a simple DTML method which creates a 5 by somewhat table of thumbnails. [1]

( Photos)

The beneift is, that you won't need any additional Zope products. The drawback is the hackish generation of URLs (which produces relative URLs that might lead to acqusition problems, depending on where you put the DTML method). Regards, /k [1] http://www.rohrbach.de/Content/Karsten/Pics From -$P-W$- at verence.demon.co.uk Mon Jan 13 15:07:45 2003 From: -$P-W$- at verence.demon.co.uk (Paul Wright) Date: Mon, 13 Jan 2003 20:07:45 +0000 (UTC) Subject: OT: spam filtering idea References: <7xr8bhhy0n.fsf@ruckus.brouhaha.com> Message-ID: In article <7xr8bhhy0n.fsf at ruckus.brouhaha.com>, Paul Rubin wrote: >The next step is to collect the frequency statistics at various >honeypots around the net, automatically combining them and transfering >them to public databases. Your filter can then retrieve new >statistics over the net every few hours. Any spam you receive will >probably also hit a honeypot at about the same time that you get it. >So since the statistics you've retrieved are weighted for the latest >and freshest spam, you should be able to kill it very effectively. I thought the point of Bayesian filtering was that it learned about your spam and your legitimate email, so that learning what other people considered spam wouldn't be as effective. I'm no expert on this, though. I expect Tim Peters will be along in a minute :-) argues that human malice can and will defeat Bayesian filters, and that widespread adoption of them will end up making spam harder to recognize by hand. I'm a little concerned that the author of the article overestimates the intelligence of spammers, but I suppose there's a selection pressure on them to get more cunning as time goes on. The people who successfully spam my Hotmail spam trap these days are certainly getting cleverer, presumably in response to Brightmail filtering. A system which works by reporting mail to honeypots would be better off reporting hashes of message bodies to something like Vipul's Razor or the Distributed Checksum Clearinghouse. That said, the obvious spammer response when people do that is to make messages which are more and more dissimilar for each recipient, again something where human malice can probably defeat automated attempts to find similar messages. The DCC's creator has said that he thinks that it will eventually be most useful against "mainsleaze", that is, spam from big businesses who will not want to use the sort of filter-evading tactics which are popular with the "enlarge your naked cheerleaders"[1] crowd. [1] How many boneheaded keyword filters will now bounce this post when it goes out as mail on the python list, I wonder? There's an awful lot of snake oil out there being sold as spam filters. -- Paul Wright | http://pobox.com/~pw201 | From martin at v.loewis.de Fri Jan 3 15:37:55 2003 From: martin at v.loewis.de (Martin v. =?iso-8859-15?q?L=F6wis?=) Date: 03 Jan 2003 21:37:55 +0100 Subject: Leakage vs Cyclops References: Message-ID: Robin Becker writes: > With upper limit of 900 pages the peak working set is 15M with 2700 > it rises to 45M. This seems to be a real leak, but how can I track > it down? I'd use some of the more recent checking facilities: 1. set the gc debug flags to gc.DEBUG_STATS, then invoke gc.collect(), then check how many new objects where collected. 2. check gc.garbage to make sure you don't have cycles with finalizers. 3. invoke gc.get_objects from time to time, and print its length, to see the total number of container objects. Verify that it is indeed growing over time. 4. count the list of container objects by type, print the number of objects per type, to find what new objects you are allocating. If these are instance objects, further divide them by class. 5. Once you have an object which keeps a lot of other objects alive, and which should have been released, use gc.get_referrers to find out why it is still alive itself. HTH, Martin From max at alcyone.com Mon Jan 6 23:21:34 2003 From: max at alcyone.com (Erik Max Francis) Date: Mon, 06 Jan 2003 20:21:34 -0800 Subject: Comments on base52 encoder/decoder ? References: Message-ID: <3E1A55CE.59A4BAE0@alcyone.com> Bengt Richter wrote: > What it boils down to is that there are enough codes for two sets > of encodings plus 9023 special codes. You can think of it as a single > bit attribute for arbitrary subsequences of binary bytes with no extra > encoding characters vs doing them separately as before, and 9023 > integer > codes can be inserted also at a cost of 3 code characters apiece. You > can think of them as available escape codes. My initial, gut reaction to this is that you're getting too fancy for your own good. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE / \ Can I walk with you / Through your life \__/ India Arie Bosskey.net: Quake III Arena / http://www.bosskey.net/q3a/ A personal guide to Quake III Arena. From wilk-spamout at flibuste.net Sat Jan 25 15:42:32 2003 From: wilk-spamout at flibuste.net (William) Date: 25 Jan 2003 21:42:32 +0100 Subject: December 2002 comp.lang.* stats References: <877kct1tgk.fsf@flibuste.net> Message-ID: <87znppx8p3.fsf@flibuste.net> thanks to Aaron K. Johnson : the french stats (december 2002) i'v added the total of messages and the % of messages by author fr.comp.lang.php 1231 4661 3.79 fr.comp.lang.java 974 3541 3.64 fr.comp.lang.c++ 644 6074 9.43 fr.comp.lang.c 577 4240 7.35 fr.comp.lang.javascript 536 2221 4.14 fr.comp.lang.perl 359 1234 3.44 fr.comp.lang.basic 351 1001 2.85 fr.comp.lang.pascal 167 495 2.96 fr.comp.lang.general 156 357 2.29 fr.comp.lang.python 154 753 4.89 fr.comp.lang.ada 113 408 3.61 fr.comp.lang.tcl 76 304 4.00 fr.comp.lang.caml 68 355 5.22 fr.comp.lang.lisp 46 77 1.67 fr.comp.lang.postscript 26 39 1.50 :((( i go to post this stats on the french newsgroup, it will be one more for the next month ! I want to interpret this like that: python is so easy that we don't need to post any question on newsgroup. > In message <877kct1tgk.fsf at flibuste.net>, William wrote: > > Aaron K. Johnson writes: > > > > > Ok. > > > > > > I've finally taken into account the objections raised herein, and > > modified my > > > usenet query algorithms. > > > > > > What you see below are pure and simple the number of unique posters to > > each > > > comp.lang.whatever hierarchy in December 2002. > > > > can you give us your script ? i would like to compare with fr.comp.lang.* > > William, I'll send you a private email with the script. > > Anyone else who wants it, I'll send it to you, with the caveat that any > improvements you make to it, you send back to me, or uses you put it to, you > give me the output to...... > > > > > > > Thanks, > > > Aaron. > > > > > > comp.lang.java 5347 > > > comp.lang.c++ 3075 > > > comp.lang.perl 2136 > > > comp.lang.javascript 2130 > > > comp.lang.python 1996 > > > comp.lang.basic 1758 > > > comp.lang.c 1670 > > > comp.lang.labview 958 > > > comp.lang.clipper 922 > > > comp.lang.tcl 853 > > > comp.lang.pascal 805 > > > comp.lang.ruby 767 > > > comp.lang.clarion 707 > > > comp.lang.lisp 587 > > > comp.lang.fortran 517 > > > comp.lang.smalltalk 391 > > > comp.lang.asm 386 > > > comp.lang.cobol 382 > > > comp.lang.ada 376 > > > comp.lang.vhdl 370 > > > comp.lang.scheme 349 > > > comp.lang.postscript 319 > > > comp.lang.prolog 243 > > > comp.lang.functional 237 > > > comp.lang.idl-pvwave 230 > > > comp.lang.forth 226 > > > comp.lang.verilog 223 > > > comp.lang.awk 211 > > > comp.lang.vrml 153 > > > comp.lang.rexx 147 > > > comp.lang.apl 142 > > > comp.lang.mumps 126 > > > comp.lang.pl1 121 > > > comp.lang.misc 115 > > > comp.lang.objective-c 108 > > > comp.lang.eiffel 101 > > > comp.lang.logo 80 > > > comp.lang.ml 73 > > > comp.lang.asm370 65 > > > comp.lang.dylan 38 > > > comp.lang.modula3 30 > > > comp.lang.oberon 26 > > > comp.lang.modula2 23 > > > comp.lang.pop 22 > > > comp.lang.icon 17 > > > comp.lang.idl 15 > > > comp.lang.limbo 5 > > > comp.lang.clos 4 > > > comp.lang.prograph 2 > > > comp.lang.clu 2 > > > > > > > -- William Dode - http://flibuste.net From throwaway at mit.edu Thu Jan 30 14:53:41 2003 From: throwaway at mit.edu (Alex Coventry) Date: 30 Jan 2003 14:53:41 -0500 Subject: Segmentation fault?? References: <3E39794D.8030203@nipltd.com> Message-ID: <87u1fqs9bu.fsf@mit.edu> you may want to check that your memory is still good. alex. From bokr at oz.net Wed Jan 8 19:53:16 2003 From: bokr at oz.net (Bengt Richter) Date: 9 Jan 2003 00:53:16 GMT Subject: Comments on base52 encoder/decoder ? References: <7x4r8jbui3.fsf@ruckus.brouhaha.com> <7xhecjsea0.fsf@ruckus.brouhaha.com> Message-ID: On Wed, 08 Jan 2003 17:08:21 -0700, Andrew Dalke wrote: [...] > >BTW, I do line folding somewhat often, and wouldn't mind having a >function or string method which did that. Not enough to push for >it though, since it is easy to write. And some people who want >folds also want a continutation character, like a "\" at the end >or a ">" at the start, but having a library function which supports >those is too much. > >Bah, I'll stick with writing bio/chem software instead of worrying >about all of this. :) > How about one that does this: BTW, I do line folding somewhat often, and wouldn't mind having a function or string method which did that. Not enough to push for it though, since it is easy to write. And some people who want folds also want a continutation character, like a "" at the end or a ">" at the start, but having a library function which supports those is too much. Bah, I'll stick with writing bio/chem software instead of worrying about all of this. :) Or this: BTW, I do line folding the end or a ">" at the somewhat often, and start, but having a wouldn't mind having a library function which function or string method supports those is too which did that. Not much. enough to push for it though, since it is easy Bah, I'll stick with to write. And some people writing bio/chem software who want folds also want instead of worrying about a continutation all of this. :) character, like a "" at I posted a string subclass doing the above, but nobody noticed ;-) Regards, Bengt Richter From bruce at hoult.org Wed Jan 1 02:49:05 2003 From: bruce at hoult.org (Bruce Hoult) Date: Wed, 01 Jan 2003 20:49:05 +1300 Subject: No macros in Python References: <20021215204402.861.55351.Mailman@mail.python.org> <3DFD5BC2.CF5175E6@engcorp.com> <3dfdd4ab$0$71707$edfadb0f@dread11.news.tele.dk> Message-ID: In article , Mike Meyer wrote: > "Anders J. Munch" writes: > > > "Mike Meyer" wrote: > > > Macros are a general-purpose mechanism. There are lots of things they > > > let you do. Lazy evaluation, infinite lists, CLOS, short-circuit > > > booleans, and so on. > > No, s-expressions buy you those things, not macros. Macros don't > > provide expressiveness, they provide speed and some convenience, say > > to let you write: > > Since I can do those things with macros and without s-expressions, I > disagree. Well, maybe not CLOS. Dylan does a version of CLOS (and all the others listed) with macros and without S-expressions. -- Bruce From cnetzer at mail.arc.nasa.gov Mon Jan 13 17:00:47 2003 From: cnetzer at mail.arc.nasa.gov (Chad Netzer) Date: Mon, 13 Jan 2003 14:00:47 -0800 Subject: Elegant copy-by-value In-Reply-To: References: <87n0m7urz4.fsf@gvdnet.dk> Message-ID: <200301132200.OAA19047@mail.arc.nasa.gov> On Saturday 11 January 2003 19:51, Carl Banks wrote: > For example, lists (and Numeric > arrays) can do this: > > a = b[:] Just to be pedantic, Numeric arrays (ie, from the Numeric module) do NOT copy when you slice them. They return views into the slice. This break from Python semantics was done early on as a performance enhancement, and can cause no end of confusion (unfortunately). You copy Numeric arrays with the .copy() method. I think the 'numarray' people (who are building a replacement for Numeric) have gone back and forth over whether to keep the slices-are-views-not-copies feature, and have decided (for compatibility w/ Numeric) to keep it as is. But regardless, since it may matter, Numeric slices do not produce copies, but views (or aliases). -- Bay Area Python Interest Group - http://www.baypiggies.net/ Chad Netzer cnetzer at mail.arc.nasa.gov From eddie at holyrood.ed.ac.uk Fri Jan 10 12:15:36 2003 From: eddie at holyrood.ed.ac.uk (Eddie Corns) Date: Fri, 10 Jan 2003 17:15:36 +0000 (UTC) Subject: telnetlib References: Message-ID: "Dickerson, Dee" writes: >Below is telnet code that I am trying to get going. I am going from a Windows2000 machine to a Redhat Linux machine; the ls command will not run as I can tell; it does not return any output. > >I need to be able to execute other commands such as ps with options such as > >ps -eda -format pid,command |grep legion-server,,,,, etc| > >I would appreciate any help that anyone could offer. > > >import telnetlib >import sys >from hostlistdee import hostlistdee > >user='legion' >pw='*******' > >for host in hostlistdee: > try: > tn=telnetlib.Telnet(host) > tn.read_until("login: ") > tn.write(user+'\n') > tn.read_until('Password: ') > tn.write(pw+'\n') > tn.write('ls\n') > tn.write('exit\n') > tn.read_all() > tn.close() > print 'started ',host > except: > print 'failed ',host > # end try ># end def 2 things. How do you know there's no output if you don't print the results from tn.read_*? and secondly you should never close a telnet connection until you've safely read all outstanding data because closing the connection flushes all outstanding data and you don't see it. The 'exit' command, I think, will cause the far end to close the connection. From p-abel at t-online.de Tue Jan 21 15:52:20 2003 From: p-abel at t-online.de (Peter Abel) Date: 21 Jan 2003 12:52:20 -0800 Subject: max() of a list of tuples References: <3e2d27c6$1_1@news.uni-bielefeld.de> Message-ID: <13a533e8.0301211252.187ffeb9@posting.google.com> Terry Hancock wrote in message news:... > Mario Wehbrink wrote: > > i have a list of tuples that look like: > > [(1,3,5), (8,16,2), (2,56,4)] > > > > what i am interested, in is the tuple with the greatest value in pos 3. > > So in this case it would be (1,3,5). Is there a way to tell > > max(mylistoftuples) to only look at the last position of the tuples? > > Don't know if this is the most elegant solution, but it does work: > > l = [(1, 3, 5), (8, 16, 2), (2, 56, 4)] > z = zip(*l) > z # prints [(1, 8, 2), (3, 16, 56), (5, 2, 4)] > l[list(z[2]).index(max(z[2]))] # prints (1, 3, 5) > > Ugly, but: > > * zip combines sequences into a list of tuples > * one of these contains the sequence you want to test > * we find the maximum and what its index in the sequence is > * we use that to look up the index in the original list > > Maybe someone will have a more elegant solution. > > Cheers, > Terry Silly me!!! The correct code is: >>> l = [(1, 3, 5), (8, 16, 2), (2, 56, 4)] >>> reduce(lambda y,x:y[2]>x[2] and y or x,l,(-1.e16,-1.e16,-1.e16)) (1, 3, 5) And it works also with: >>> l = [(1, 3, -5), (8, 16, -2), (2, 56, -4)] >>> reduce(lambda y,x:y[2]>x[2] and y or x,l,(-1.e16,-1.e16,-1.e16)) (8, 16, -2) Or with: >> l = [(1, 3, -5), (8, 16, -200), (2, 56, -4)] >>> reduce(lambda y,x:y[2]>x[2] and y or x,l,(-1.e16,-1.e16,-1.e16)) (2, 56, -4) >>> Sorry Peter From tjg at craigelachie.org Wed Jan 29 01:44:43 2003 From: tjg at craigelachie.org (Timothy Grant) Date: Tue, 28 Jan 2003 22:44:43 -0800 Subject: [Q] Customizable text editor based on Python? In-Reply-To: <3E372422.30E3AEAB@engcorp.com> References: <1fpidub.1nl29qx1bozn22N%eRrEiMcOgVoErMrE@cox.net> <3E372422.30E3AEAB@engcorp.com> Message-ID: <200301282244.44719.tjg@craigelachie.org> > Eric wrote: > I was wondering if people could point me to a text editor which can be > extended using Python, similar to how Emacs can be extended via LISP and > Alpha can be extended via TCL/TK. Vim with Python compiled in. Glimmer (http://glimmer.sourceforge.net). Scite -- Stand Fast, tjg. Timothy Grant www.craigelachie.org From mwilson at the-wire.com Sat Jan 25 10:47:41 2003 From: mwilson at the-wire.com (Mel Wilson) Date: Sat, 25 Jan 2003 10:47:41 -0500 Subject: Illegal literal or not? References: <_RfY9.862$d66.98244@newsread1.prod.itd.earthlink.net> Message-ID: In article <_RfY9.862$d66.98244 at newsread1.prod.itd.earthlink.net>, "LJ & MT Lareau" wrote: >Is it possible to have Python produce the following literal output in the >interactive mode. >'"Let's try this!", they said.' >If so what is the Python statement. I've tried several ways >and can't seem to produce it. Thanks for the help. Just for weirdness' sake (there have been better answers)... print "'" + '"' + "Let's try this!" + '"' + ', they said.' + "'" print ''.join (["'", '"', "Let's try this!", '"', ', they said.', "'"]) Regards. Mel. From pyth at devel.trillke.net Mon Jan 13 13:49:15 2003 From: pyth at devel.trillke.net (holger krekel) Date: Mon, 13 Jan 2003 19:49:15 +0100 Subject: Seeking Minimal Python Project Name (was: [pypy-dev] Re: [ann] MinimalPython project) In-Reply-To: ; from Dick.Zantow@lexisnexis.com on Mon, Jan 13, 2003 at 01:19:08PM -0500 References: <7xr8bjgz4x.fsf@ruckus.brouhaha.com> <7x4r8ej1r9.fsf@ruckus.brouhaha.com> <7x8yxqduco.fsf@ruckus.brouhaha.com> <5.0.2.1.1.20030112185911.00a7a6d0@mail.oz.net> <3E222FC1.40908@tismer.com> Message-ID: <20030113194915.B349@prim.han.de> rzed wrote: > holger krekel wrote: > > [Christian Tismer Mon, Jan 13, 2003 at 04:17:21AM +0100] > >> Bengt Richter wrote: > >>> At 03:39 2003-01-13 +0100, Christian Tismer wrote: > >>> [...] > >>> > >>>> At the same time, as much as possible should become > >>>> pluggable. It will be possible to have MiniPy > >>> > >>> [...] > >>> > >>> Is "MiniPy" the official name ? > >> > >> No. > >> There is no official name, yet. > > > > I suggest we use 'pypy' and/or 'Minimal Python' for > > the time before the sprint. > > > > On one of the sprint evenings we should discuss and > > decide (vote) on the eventual name. [1] > > > > Without code you can't vote :-) > > > > cheers, > > > > holger > > > > > > [1] FWIW, Currently I think that i will propose P > > (courtesy of Tim Churches). > > Oh no!! Then we'd be writing P-code! > > And, at least in America, "coding in P" sounds like urine over your > head. (Not you, holger, but I mean ... ) i guess i just forget about naming until the sprint, then :-) holger From jbperez808 at yahoo.com Fri Jan 17 03:54:04 2003 From: jbperez808 at yahoo.com (Jonathan P.) Date: 17 Jan 2003 00:54:04 -0800 Subject: iterating in reverse References: Message-ID: Chad Netzer wrote in message news:... > FWIW. list.reverse() is often not too bad since it only has to do the > work of reversing the list indices in memory, not copying the actual > objects themselves. Iterating backwards does save an O(N) operation, > but for small lists, list.reverse() is likely faster. I need to iterate using for in both the original order and in reverse depending on the situation. The main thing that bugs me is that I have to choose between storing 2 copies of the same data (one reversed, the other not) or I have to do a couple of reverse()s each time (to undo the transformation) I need to access the list in reverse. The former is wasteful of space, the latter of performance. From peter at engcorp.com Thu Jan 2 22:22:42 2003 From: peter at engcorp.com (Peter Hansen) Date: Thu, 02 Jan 2003 22:22:42 -0500 Subject: new years resolutions References: Message-ID: <3E150202.4CB9A9B2@engcorp.com> Dennis Lee Bieber wrote: > > eltronic at juno.com fed this fish to the penguins on Thursday 02 January > 2003 03:34 pm: > > > > > HTML is a programming language, why else would I have to debug it? > > > Then news posts and email are programming languages too, as I have to > debug (spell-check) them I see the grin, but note that this is exactly why those are *not* programming languages, while HTML definitely is. If you write the wrong HTML, the computer does not do what it is supposed to do, while if you put the wrong content in your email or news post, only humans mind. Telling a computer (even a mechanical one) what to do is programming, pure and simple. -Peter From CousinStanley at HotMail.com Sat Jan 11 09:06:52 2003 From: CousinStanley at HotMail.com (Cousin Stanley) Date: Sat, 11 Jan 2003 07:06:52 -0700 Subject: How to change colors of console window? References: <3e1ab443_1@corp.newsgroups.com> <3e1e153c_3@corp.newsgroups.com> Message-ID: || Can you give an example of using an escape sequence || to change the DOS windows to, say blue on white ? Bill ... According to the documentation I've found, the following ANSI Escape Sequence SHOULD produce blue foreground / white background from a BAT file ... echo ; However, on my Win98 system it comes out blue on silver ... I also can't seem to produce a yellow background and the blink sequence doesn't blink on my machine ... Following is a BAT file with a few more examples ... Cousin Stanley ----------------------------------------------------- :: aColors.bat @echo off cls echo. echo  %0.bat echo. echo  Ansi.Sys Foreground Colors echo. echo  0 : Light on Dark { Default } echo  7 : Dark on Light { Inverse }  echo  30 : Black echo  31 : Red echo  32 : Green echo  33 : Yellow echo  34 : Blue echo  35 : Magenta echo  36 : Cyan echo  37 : White echo  echo. echo  Ansi.Sys Background Colors echo. echo  40 : Black  echo  41 : Red  echo  42 : Green  echo  43 : Yellow ???  echo  44 : Blue  echo  45 : Magenta  echo  46 : Cyan  echo  47 : Light  echo  7 : Dark on Light  echo  echo. echo  Blink This echo. echo  Ansi Escape Sequence echo  From sasDOTepsylon at wanadoo.fr Mon Jan 13 07:57:46 2003 From: sasDOTepsylon at wanadoo.fr (EpSyLOn) Date: Mon, 13 Jan 2003 13:57:46 +0100 Subject: Seeking Minimal Python Project Name References: Message-ID: On Mon, 13 Jan 2003 03:21:44 -0800, Kow K wrote: > > >Lighthon (sounds lighter and smaller ...) Two "h", it's kind of confusing... >Lython (variation of the above) I love this one. It's a lighter Python (and it's very close to Python because only one letter changes). -- .-. EpSyLOn sasepsylonwanadoofr oo| faq fclc: http://www.isty-info.uvsq.fr/~rumeau/fclc /`'\ Usenet : http://www.usenet-fr.net (\_;/) "Quand le sage montre la lune, l'imb?cile regarde le doigt" From akjmicro at yahoo.com Sat Jan 25 17:40:05 2003 From: akjmicro at yahoo.com (Aaron K. Johnson) Date: Sat, 25 Jan 2003 16:40:05 -0600 Subject: usenet statistics script....happy hacking!!! Message-ID: If anyone improves this, repost to the community, please. ######## start here ####### newsdata, by Aaron K. Johnson #!/PUT/YOUR/PYTHON/PATH/HERE from nntplib import * from string import find,split,join ########## change the data output file below: outfile=open('put_your_data_file_here','w') ########## change the news server: s=NNTP('news.whatever.whatever') newsgroups=['comp.lang.ada', 'comp.lang.apl', 'comp.lang.asm.x86', 'comp.lang.asm370', 'comp.lang.awk', 'comp.lang.basic.misc', 'comp.lang.basic.powerbasic', 'comp.lang.basic.realbasic', 'comp.lang.basic.visual.3rdparty', 'comp.lang.basic.visual.announce', 'comp.lang.basic.visual.database', 'comp.lang.basic.visual.misc', 'comp.lang.beta', 'comp.lang.c', 'comp.lang.c.moderated','comp.lang.c++', 'comp.lang.c++.leda', 'comp.lang.c++.moderated', 'comp.lang.clarion', 'comp.lang.clipper', 'comp.lang.clipper.visual-objects', 'comp.lang.clos', 'comp.lang.clu', 'comp.lang.cobol', 'comp.lang.dylan', 'comp.lang.eiffel', 'comp.lang.forth', 'comp.lang.forth.mac', 'comp.lang.fortran', 'comp.lang.functional', 'comp.lang.hermes', 'comp.lang.icon', 'comp.lang.idl', 'comp.lang.idl-pvwave', 'comp.lang.java.advocacy', 'comp.lang.java.announce', 'comp.lang.java.beans', 'comp.lang.java.corba', 'comp.lang.java.databases', 'comp.lang.java.gui', 'comp.lang.java.help', 'comp.lang.java.machine', 'comp.lang.java.programmer', 'comp.lang.java.security', 'comp.lang.java.softwaretools', 'comp.lang.javascript', 'comp.lang.labview', 'comp.lang.limbo', 'comp.lang.lisp', 'comp.lang.lisp.franz', 'comp.lang.lisp.mcl', 'comp.lang.lisp.x', 'comp.lang.logo', 'comp.lang.misc', 'comp.lang.ml', 'comp.lang.modula2', 'comp.lang.modula3', 'comp.lang.mumps', 'comp.lang.oberon', 'comp.lang.objective-c', 'comp.lang.pascal.ansi-iso', 'comp.lang.pascal.borland', 'comp.lang.pascal.delphi.advocacy', 'comp.lang.pascal.delphi.announce', 'comp.lang.pascal.delphi.components.misc', 'comp.lang.pascal.delphi.components.usage', 'comp.lang.pascal.delphi.components.writing', 'comp.lang.pascal.delphi.databases', 'comp.lang.pascal.delphi.misc', 'comp.lang.pascal.mac', 'comp.lang.pascal.misc', 'comp.lang.perl.announce', 'comp.lang.perl.misc', 'comp.lang.perl.moderated', 'comp.lang.perl.modules', 'comp.lang.perl.tk', 'comp.lang.pl1', 'comp.lang.php', 'comp.lang.pop', 'comp.lang.postscript', 'comp.lang.prograph', 'comp.lang.prolog', 'comp.lang.python', 'comp.lang.python.announce', 'comp.lang.rexx', 'comp.lang.ruby', 'comp.lang.sather', 'comp.lang.scheme', 'comp.lang.scheme.c', 'comp.lang.scheme.scsh', 'comp.lang.smalltalk', 'comp.lang.tcl', 'comp.lang.tcl.announce', 'comp.lang.verilog', 'comp.lang.vhdl', 'comp.lang.visual', 'comp.lang.vrml'] oldbasename='' ####### for comp.lang.* hierarchies virgin=1 authors=[] data=[] ########### main loop for newsgroup in newsgroups: basename=join(newsgroup.split('.')[:3],'.') gr=s.group(newsgroup) ############### flush data to data array, and empty author pool, ############### if new basename detected, ############### and we've done at least one already..... if basename != oldbasename and not virgin: print "total users: ", len(authors) data.append([len(authors), oldbasename]) authors=[] print 'group is', newsgroup print 'basename is', basename pool=s.xhdr('date','-') ####### give me all you've got on the server date_pool=[] for date in pool[1]: ######## filter out all those not Dec 2002 ########### enter date below: if date[1].find('Dec 2002') != -1: date_pool.append(date[0]) try: ######## ignore if empty, try next newsgroup first=date_pool[0] last=date_pool[-1] image=first + '-' + last except: continue array=s.xhdr('from', image) ############################## for article in array[1]: author=article[1] if not author in authors: authors.append(author) ########### output: oldbasename=basename virgin=0 ##### final flush after exiting for loop: print "total users: ", len(authors) data.append([len(authors), oldbasename]) ####### now we sort: data.sort() data.reverse() for item in data: outfile.write("%s %s\n" % (item[1],item[0])) outfile.close() From peter at engcorp.com Tue Jan 28 19:49:04 2003 From: peter at engcorp.com (Peter Hansen) Date: Tue, 28 Jan 2003 19:49:04 -0500 Subject: Python vs. C++ Builder - speed of development References: <3e36d04e_2@news.vo.lu> Message-ID: <3E3724FF.8358506E@engcorp.com> Brandon Van Every wrote: > > Python is a "glue" language, ... Just checking here :-)... you're not saying Python is *only* a glue language, right? Just that it *can be* used as a glue language when you need such a thing? -Peter From maxm at mxm.dk Tue Jan 21 06:25:58 2003 From: maxm at mxm.dk (Max M) Date: Tue, 21 Jan 2003 12:25:58 +0100 Subject: max() of a list of tuples In-Reply-To: <3e2d27c6$1_1@news.uni-bielefeld.de> References: <3e2d27c6$1_1@news.uni-bielefeld.de> Message-ID: <3E2D2E46.6060104@mxm.dk> Mario Wehbrink wrote: > i have a list of tuples that look like: > [(1,3,5), (8,16,2), (2,56,4)] > > what i am interested, in is the tuple with the greatest value in pos 3. > So in this case it would be (1,3,5). Is there a way to tell > max(mylistoftuples) to only look at the last position of the tuples? l = [(1,3,5), (8,16,2), (2,56,4)] print max([(i[-1],i) for i in l])[1] >>> (1,3,5) -- hilsen/regards Max M http://www.futureport.dk/ Fremtiden, videnskab, skeptiscisme og transhumanisme From ark at gmx.net Tue Jan 28 18:32:54 2003 From: ark at gmx.net (Arne Koewing) Date: Wed, 29 Jan 2003 00:32:54 +0100 Subject: patching of python: tabs make me seek of python References: Message-ID: "Terry Reedy" writes: ... > Warning: if you keep using Python another month or two, you might > instead start thinking about patching C/C++ to recognize block indents > in addition to braces. It has happened to other people. > > Terry J. Reedy > > This hapened more than once: cugar: syntactical sugar for C++ http://www.boswa.com/misc/ Cugar makes C++ look a lot like Python Cython: http://www.algonet.se/~jsjogren/oscar/cython/ Cython a preprocessor that lets you code C and C++ with a more Pythonish synthax (it's written in Perl ;-) From nagylzs at freemail.hu Tue Jan 28 16:21:02 2003 From: nagylzs at freemail.hu (=?ISO-8859-1?Q?Nagy_L=E1szl=F3?=) Date: Tue, 28 Jan 2003 22:21:02 +0100 Subject: Generating Unique Keys References: <7xy956jf5j.fsf@ruckus.brouhaha.com> <47e891f1.0301281237.16079102@posting.google.com> <7xvg09c8bi.fsf@ruckus.brouhaha.com> Message-ID: <3E36F43E.1090803@freemail.hu> > > >If you've got a source of good random numbers, you can just use them >directly as tokens and not need this hashing stuff. > There are whole books about what are the "good" (pseudo) random numbers. The perfect answer is this: depends on what you want to do with them. If you want to use them to create session keys, you will surely need to use a hash function. The PRNG algorithm can be explored in almost all cases (especially when using /dev/random), and this is a security risk. A "good" PRNG ("good" depends on the application) is measured by statistical properties (both theoretical and empirical). But most "good" PRNGs are not tested aganist invertion. You can conclude PRNG state information from a random number sequence. Not so easy, but much more easy than invert a hash function like SHA1. :-) IMHO you should use a hash function (why not?) Laci 1.0 p.s.: Sorry for my broken English From sschwarzer at sschwarzer.net Thu Jan 23 15:35:32 2003 From: sschwarzer at sschwarzer.net (Stefan Schwarzer) Date: Thu, 23 Jan 2003 21:35:32 +0100 Subject: UML and Python References: Message-ID: Terry Hancock wrote: > Would I be wasting my time to use UML? And if I do use it, should I > concentrate on being rigorously correct or just use quick, simplified > representations? It depends. :-) In my opinion, any diagrams shouldn't be an end in itself but rather a means to help designing and explaining the code. So, I use UML only when it helps me to design or explain something which would be more difficult without UML (see also http://www.agilemodeling.com/ ). Consequently, I use UML rather seldom (though I like it), mostly when designing frameworks or discussing a design with colleague. > I'm using "dia" to do this. I created some reverse-engineered drawings > using happydoc, but I'm actually moving towards just doing new design from > scratch, because the automatically generated drawing is kind of a pain to > work with. So far, I've mostly used Poseidon from Gentleware ( http://www.gentleware.com/ ) and I like it. Stefan From wouterm at spammers-unite-here.com Tue Jan 28 23:01:12 2003 From: wouterm at spammers-unite-here.com (Wouter van Marle) Date: Wed, 29 Jan 2003 12:01:12 +0800 Subject: Installer for Python software (Linux) Message-ID: Hi All! At the moment I am developing a piece of software that is targeted at the office market, my ambition is in future to make it part of Gnome Office, or at least easily compatible with that project. Now the software is developing pretty well, and it is time to start thinking of the installation. What I am looking for is an installation procedure like this: - user downloads program - user runs program, program asks for root password for general installation (if no root password: user installation) - program copies *.py to correct dir, and compiles the *.py to *.pyc. - user has to give some settings for the program to run properly Now the major problems I see here are: - how to go to root mode? (and when asking the password: how to change the users keystrokes to *'s on the fly??) - how do I compile the *.py to *.pyc without running the program? (I guess this is trivial, and yes I am lazy so add this to the questions as well). Any other things that I have to beware of? Wouter. From abelikov72 at hotmail.com Tue Jan 7 07:57:26 2003 From: abelikov72 at hotmail.com (Afanasiy) Date: Tue, 07 Jan 2003 12:57:26 GMT Subject: best python editor/ide for windows References: Message-ID: On 5 Jan 2003 07:14:14 -0800, grayshade at libero.it (Domenico) wrote: >have your say... Someone suggested crimsoneditor(.com), which I never tried until now. I just wanted to let you know I've changed my best editors list for the first time in years, adding it just under ultraedit. ;-) 1. ultraedit 2. crimsoneditor 3. editplus 4. zeus It seems to try to feel like ultraedit more than any other. If it had at least an archaic method of displaying hex and a column selection/editing mode, it might topple ultraedit. ( these modes are toggled via ctrl-h & alt-c in ultraedit ) ultraedit is old and ugly, and I choose to use 8.x on purpose, but nothing else has all the same features. This is about where I wish the crimsoneditor author would charge for his product so that he could make time to add some necessary features. P.S. I use Hex Workshop for real hex based editing as needed, but having a hex mode in my text editor is very often useful. From riccardo at Togli_Quest0sideralis.net Sat Jan 25 13:16:19 2003 From: riccardo at Togli_Quest0sideralis.net (Riccardo Galli) Date: Sat, 25 Jan 2003 19:16:19 +0100 Subject: Illegal literal or not? References: <_RfY9.862$d66.98244@newsread1.prod.itd.earthlink.net> Message-ID: On Fri, 24 Jan 2003 18:46:18 +0000, LJ & MT Lareau wrote: > Is it possible to have Python produce the following literal output in the > interactive mode. > '"Let's try this!", they said.' Another way (other than Morris's) is print r''''"Let's try this",they said' ''' -- -=Riccardo Galli=- _,e. s~ `` ~@. ideralis Programs . ol `**~ http://www.sideralis.net From samj at eisa.net.au Fri Jan 31 19:03:26 2003 From: samj at eisa.net.au (samphdauto) Date: 31 Jan 2003 16:03:26 -0800 Subject: will Python do me good? Message-ID: <65050d4c.0301311603.4eb79a85@posting.google.com> Hello every one.. Well, this is the first time I post here since I am thinking of learning Python... my background is VB and wanting to find a better language in order to build my project and not sure if Python is my best option. So your input is greatly appreciated. My project will need to extract and re-organize information form the web into my Access database under W2K. The info could be text, data, files, images, sound files, listings, HTML parsing, sound parsing and whathaveyou. So if I give it a list of websites. I will need to write the code to get specific info from that site or page. So it may need to drill down to get to the info. I am not sure if I am making enough sense to you. I hope I am. Thanks Sam From richard_water61 at hotmail.com Wed Jan 22 04:40:39 2003 From: richard_water61 at hotmail.com (Richard Waters) Date: 22 Jan 2003 01:40:39 -0800 Subject: Outlook Express and COM References: Message-ID: <20c262a1.0301220140.228f0ba5@posting.google.com> "Tim Peters" wrote in message news:... > AFAIK, OE has no programming interface at all, neither COM nor anything else > (unlike big brother Outlook, which has several programming interfaces -- > some of which even appear to work, sometimes <0.9 wink>). Slightly off the original topic; one thing to watch with Outlook (2000, maybe later versions also). There are 2 ways to install it. I don't remember the exact terminology, but one way gives you an internet-only version (very similar to OE), the other gives you the full, corporate Outlook package. The former has fewer automation interfaces available than the latter so be careful when you write code to automate it; may not work for everyone! - Richard From kevin at cazabon.com Thu Jan 2 20:40:07 2003 From: kevin at cazabon.com (Kevin@Cazabon.com) Date: Fri, 03 Jan 2003 01:40:07 GMT Subject: Announcement: ICC color management for PIL, pyCMS Message-ID: FYI, I've released a module for PIL that implements ICC Color Management functionality for PIL (the Python Imaging Library). It consists of a DLL and a matching Python interface. It uses the LGPL "littleCMS" library for the ICC functionality. Full source code and documentation are available for download too, along with a pre-build Windows binary. http://www.cazabon.com/pyCMS Enjoy, and please send feedback and updates/bug reports if you find any... your help in testing is appreciated! Also, I'm looking for pre-built binaries to post from other platforms/Python builds. Kevin Cazabon. From aka at mvps.org Tue Jan 14 18:08:22 2003 From: aka at mvps.org (Alex K. Angelopoulos) Date: Tue, 14 Jan 2003 18:08:22 -0500 Subject: ActivePython on Windows: References Question References: Message-ID: Thanks for all the info. I have some notes below, inline. wrote in message news:mailman.1042579468.2572.python-list at python.org... > > On Mon, 13 Jan 2003 14:19:12 -0500 "Alex K. Angelopoulos" > the script engine is not installed by default and > there is some incomplete and or out of date docs... > ...unfortunately most of the scripts in the demo dir don't work for me. I've noticed issues with many Python scripts not working when run from wscript/cscript, and part of it does seem to be core engine implementation. I suspect the major problem is the lack of a lot of interest in this hosting model. If the Python core was much more widely distributed as an Active Scripting engine, it would make sense, but in my experience most Windows users who install Python actually use the entire language natively - you get access to a lot of fully-wrapped functionality that way. > Mark Hammond seems to be the single source for all the win32 extensions he also is the author of one of the few other Active Scripting engines available in source form, a "Forthish" example available for download from MSKB. > example of scripting outloook > http://www.boddie.org.uk/python/COM.html The problem with Python COM examples is that even the ones which claim to be "WSH examples", is that they usually aren't. They are usually demos of accessing COM objects installed _with_ WSH, but hosted by Python itself. This is fine for the usual role of native use, but can produce problems when used as examples for someone working from WSH-hosted Python. From cnetzer at mail.arc.nasa.gov Thu Jan 30 21:09:37 2003 From: cnetzer at mail.arc.nasa.gov (Chad Netzer) Date: 30 Jan 2003 18:09:37 -0800 Subject: Which exception has been used? (was: Which exception to use?) In-Reply-To: References: <7h3y954ywdw.fsf@pc150.maths.bris.ac.uk> Message-ID: <1043978977.679.17.camel@sayge.arc.nasa.gov> On Thu, 2003-01-30 at 16:10, Gon?alo Rodrigues wrote: > Does this solve your problem? > > >>> try: > ... raise TypeError("This is a whacky example!") > ... except Exception, e: > ... print e > ... > This is a whacky example! Well, I think Cameron's point is that one can have exceptions that are NOT derived from Exception (although it is very bad style; but you may not have to be prepared to handle other people's code). Also, string exceptions are still (and at least pychecker wil report that as a warning) This is an example of the kind of problem one might have to be on the lookout for: output: caught MyException caught Exception caught non-standard exception __main__.MyDumbException <__main__.MyDumbException instance at 0x815d2c4> caught non-standard exception eggs None code: """ import sys class MyException( Exception ): pass class MyDumbException: pass for exception in (MyException, Exception, MyDumbException, "eggs"): try: raise exception except MyException, e: print 'caught MyException', e except Exception, e: print 'caught Exception', e except: name, e, traceback = sys.exc_info() print 'caught non-standard exception', str( name ), e """ -- Bay Area Python Interest Group - http://www.baypiggies.net/ Chad Netzer (any opinion expressed is my own and not NASA's or my employer's) From tjreedy at udel.edu Tue Jan 21 08:06:02 2003 From: tjreedy at udel.edu (Terry Reedy) Date: Tue, 21 Jan 2003 08:06:02 -0500 Subject: How to get the types of the parents of an object ? References: <3E2D3C3C.8010800@novagrid.com> Message-ID: <-z6dnZeKDKnC1bCjXTWcqA@comcast.com> > Now my_class is a child of my_super_class. And I want to check if > my_object is an instance of my_super_class. Is this what you are looking for? >>> class mysuper(object): pass ... >>> class myclass(mysuper): pass ... >>> myobject=myclass() >>> isinstance(myobject,mysuper) 1 Terry J. Reedy From mh at pixar.com Fri Jan 31 13:33:34 2003 From: mh at pixar.com (Mark Harrison) Date: Fri, 31 Jan 2003 18:33:34 GMT Subject: converting data to hex References: Message-ID: <2kz_9.909$Fc3.97669323@newssvr21.news.prodigy.com> Geoff Gerrietts wrote: > value = tuple(map(ord,md5.new(myStr).digest())) Most excellent... It was only the ord that I originally thought I needed, but tuple/map is so slick that now I don't feel guilty about asking such a dumb question. Thanks, Mark -- Mark Harrison Pixar Animation Studios From paul at boddie.net Tue Jan 21 06:34:28 2003 From: paul at boddie.net (Paul Boddie) Date: 21 Jan 2003 03:34:28 -0800 Subject: Python web development, really References: Message-ID: <23891c90.0301210334.6d719987@posting.google.com> Afanasiy wrote in message news:... > I would love to use Python instead of PHP for web development, but > I have so far been confused by the options, or perhaps lack thereof, > given my strict requirements. I would appreciate suggestions. First of all, take a look at the PythonInfo Wiki: http://www.python.org/cgi-bin/moinmoin/WebProgramming This site is being updated and covers a lot more than the Web Frameworks Overview. Certainly, the aim is to be able to help people in situations like yours. [...] > Possible solutions should do 99% of the following : > > * Run on the same hardware I use currently > > * Be as fast or faster than Apache+PHP > (I'm sorry to say Zope/Roxen are not) > (This might mean it must use Apache) Neither of these should be an issue. > * Use a similar amount of memory > (ie. not Java/.NET related) Yes, we don't want the lights to dim when that application server starts up. ;-) > * Provide a fairly equivalent framework w/ sessions, cookies, get, post > (Described in http://www.boddie.org.uk/python/web_frameworks.html) > (eg. I should not have to write code to parse query strings, etc.) > (PHP is somewhat unique in the ways it can bring in post variables) I'm not familiar with PHP, but with most Python frameworks you don't need to parse the raw HTTP inputs, and with many frameworks you have convenient interfaces to those inputs. Webware provides a servlet-like interface, although it's much more "sane" than the Java Servlet API (in case you were wondering). As for the "unique" aspects of PHP's variable handling, are you referring to something like this...? http://www.php.net/manual/en/security.registerglobals.php > * Allow all errors to be caught and handled so users never see them > (I currently send them to an email address) > (Users are notified an error occurred and a developer contacted) I've been thinking rather seriously about better solutions than "we'll just log the error and send an e-mail"; it seems to me that most people don't have enough time to sift through lengthy log files, and when e-mails arrive I'm sure most developers just want to delete them. > * Allow sending of email Python provides a number of ways of doing this, although an integrated approach to application communications would be a lot more attractive than firing up sendmail. I'm not sure of the state of Python frameworks in this respect, although I suspect that Twisted integrates the different communications "channels" better than most. > * Allow sending of raw binary data, for restricted file downloading > (eg. http://example.com/sendfile.php?id=A6DE12FAB3...etc) > (This requires header manipulation, specifically the mime type) > (That sort of thing should be part of the framework 3 bullets up) You mean full control over headers and the ability to bypass the templating system? > * Allow SSL secured authorize.net credit card processing > (I currently use PHP's libcurl+ssl module) This is presumably where your application connects out to another application - some kind of back-end integration. This should be possible, yes, but I'm not aware of any components for it that just plug into a Python framework or application server, although there could be a product available for Zope. Meanwhile, various Webware people may have experience with this kind of thing even though the Webware framework doesn't have a "checkbox feature" entitled "credit card processing". > * Allow similarly powerful regex capabilities > (I currently use PHP's pcre module) Python's re module should suffice. > * Big plus, but optional, auto prepend/append files > (eg. Apache+PHP has .htaccess directives like this ) > ( php_value auto_prepend_file "_header.php" ) > ( php_value auto_append_file "_footer.php" ) > (granular down to the directory That's an Apache thing, surely, so you might want to check to see whether various frameworks and templating systems are open to such external content manipulation - ie. that they generate page fragments rather than full pages. I would guess that most systems are. > * Finally, very optional plus, global application scoped variables > (PHP does NOT allow this, but I know why) > (I do not want to hear why you think this is bad) > (I know why it is good, I know why it can be bad) If you're not talking about the various exploitable PHP features, but are actually referring to "shared data" or "singletons" which are available to all requests running within a given application, there are various means of achieving this in the different frameworks. It would surprise me if the Webware Wiki didn't cover this topic, for example. Paul From jordan at krushen.com Fri Jan 24 18:16:18 2003 From: jordan at krushen.com (Jordan Krushen) Date: Fri, 24 Jan 2003 23:16:18 GMT Subject: Looking for CORBA examples, or something better References: Message-ID: <6PjY9.107141$Yo4.5235832@news1.calgary.shaw.ca> Grzegorz Adam Hankiewicz wrote: > CORBA is usually more code verbose than Java's RMI, because RMI > knows it's talking to another Java. Is there something similar > in Python? Something easier to write than CORBA but restricted to > python. Maybe YAMI? > > Please point me towards the juicy documentation (huh, google is > unreachable from my end now) Check out Pyro (Python Remote Objects) for something Python-specific: http://pyro.sf.net/ J. From kevinethridge at yahoo.com Sun Jan 12 22:59:27 2003 From: kevinethridge at yahoo.com (Kevin Ethridge) Date: Mon, 13 Jan 2003 03:59:27 GMT Subject: map() question... References: Message-ID: Thanks for the responses to my question. "Kevin Ethridge" wrote in message news:ubnU9.50476$DN6.1535465 at twister.austin.rr.com... > Why doesn't map() work with the print function? > ie map(print, ['Have', 'a', 'great', 'day.']) > > From giles_brown at hotmail.com Tue Jan 14 13:15:27 2003 From: giles_brown at hotmail.com (Giles Brown) Date: 14 Jan 2003 10:15:27 -0800 Subject: [OT] Seeking Minimal Python Project Name References: <3e22b7f7@news.swissonline.ch> Message-ID: <57de9986.0301141015.30a66906@posting.google.com> "F. GEIGER" wrote in message news:<3e22b7f7 at news.swissonline.ch>... > Seems somebody has started a competition in finding names for Minimal > Python. > > Minimal Python -> Mython. > > Children's Python (this kind of pythons really exists, German: > Zwergpython) -> Chython > > Small Python -> Smython > > Dwarf + Python -> Dwython Taking a similar approach you could have: (s)elf (h)osting (py)thon -> shpy (to be pronounced like spy by someone doing a bad sean connery impression.) Giles Brown From bdash at gmx.net Sun Jan 5 07:58:37 2003 From: bdash at gmx.net (Mark Rowe) Date: Mon, 06 Jan 2003 01:58:37 +1300 Subject: lambda semantics in for loop In-Reply-To: <280e901b.0301050436.b4e501d@posting.google.com> Message-ID: <67E9D2B0-20AD-11D7-BF53-00039344A992@gmx.net> On Monday, January 6, 2003, at 01:36 AM, Henk Punt wrote: > Hi, > > When I have the following bit of python code: > >>>> l = [] >>>> for i in range(10): > ... l.append(lambda x: x + i) > > I would expect: > > l[0](0) = 0 > l[1](0) = 1 > > l[0](1) = 1 > l[1](1) = 2 > > etc. > > instead > > l[0](0) = 9 > l[1](0) = 9 > > l[0](1) = 10 > l[1](1) = 10 > > It seems that the 'i' in the lambda binds to the last value of i in the > for loop. > Is this because 'i' is really a pointer and not the value of 'i' > itself?. > Please enlighten me!, > > How do I modify the example so that I would get my expected semantics. > Should I copy 'i' to force the creation of a new object?, If so how > would > this work in the case where i is a string. I've tried to coerce python > into making a deepcopy of a string so that id(s) != id(copy(s)) but > I've > not been able to do that also. > > Thanx already, > > Henk Punt. From the Python Reference manuals section on Naming on Binding (http://www.python.org/doc/current/ref/naming.html): If a name is bound in a block, it is a local variable of that block. If a name is bound at the module level, it is a global variable. (The variables of the module code block are local and global.) If a variable is used in a code block but not defined there, it is a free variable . In your case, the variable i is bound at module level and is therefore treated as a global variable. This means that its value when you call the lambda functions is used. To get around this you can make i local to the lambda by passing it as a default argument like so: >>> l = [] >>> for i in range(10): ... l.append(lambda x, i=i: x + i) ... >>> l[0](0) 0 >>> l[1](0) 1 >>> l[9](0) 9 >>> l[5](5) 10 >>> -- Mark Rowe bdash at clear.net.nz From reageer.in at de.nieuwsgroep Thu Jan 16 09:24:37 2003 From: reageer.in at de.nieuwsgroep (Rene Pijlman) Date: Thu, 16 Jan 2003 15:24:37 +0100 Subject: reading from a zipped file References: Message-ID: Lance: >I have a zip file [...] Is there a Python module that will help? http://www.python.org/doc/current/lib/module-zipfile.html -- Ren? Pijlman Wat wil jij leren? http://www.leren.nl From tmoyer at talk.com Thu Jan 30 12:06:37 2003 From: tmoyer at talk.com (Todd Moyer) Date: 30 Jan 2003 09:06:37 -0800 Subject: Jython TagLibs in JSP Message-ID: <6437096f.0301300906.6db26790@posting.google.com> I'm trying to write a JSP TagLib in Jython following the example from Jython for Java Programmers (pages 407-408). It's being found by the app server (Orion in this case), but the methods aren't matching up correctly. Anyone out there have any success doing this? Cheers, Todd Moyer From theller at python.net Wed Jan 22 02:49:41 2003 From: theller at python.net (Thomas Heller) Date: 22 Jan 2003 08:49:41 +0100 Subject: Easiest way to include C libraries References: <4378fa6f.0301211616.3b353722@posting.google.com> <3E2DEF9F.A8596B23@engcorp.com> Message-ID: Peter Hansen writes: > Marc wrote: > > > > Basically I have to include a bunch of header files (.h for C) or .dll > > files (for Tcl) and be able to access them from Python code. These > > files are quite large, so any manual intervention will be time > > consuming. The new release of Python mentioned some new ways of > > extending it, but I'm not sure how many people have used these new > > functions or what problems they might have. > > > Look into "calldll" or the newer potential replacement ... uh.. dang! > What was the name of that thing? Why didn't I bookmark it. :-( > > (No doubt some kind soul will post the name and save us the trouble > of searching futilely for it... so far Google hasn't helped me.) ctypes. http://starship.python.net/crew/theller/ctypes.html Thomas From wyojustin at hotmail.com Tue Jan 21 21:27:04 2003 From: wyojustin at hotmail.com (Justin Shaw) Date: Tue, 21 Jan 2003 21:27:04 -0500 Subject: 1-line idiom to replace if blocks References: <3e2cf624@post.usenet.com> <3E2D0318.B792D649@alcyone.com> Message-ID: > And, of course, if you really want short-circuiting, you can write this: > > result=[lambda:value-if-false, lambda:value-if-true][condition]() > I like it except I'd add "[not not condition]" to ensure a 0 or a 1. Justin Shaw From adalke at mindspring.com Fri Jan 10 12:36:54 2003 From: adalke at mindspring.com (Andrew Dalke) Date: Fri, 10 Jan 2003 10:36:54 -0700 Subject: YAI: syntax for preset locals without using dummy args with defaults In-Reply-To: References: Message-ID: Bengt Richter wrote: > def foo(x, y=default, z=some_expression): > ... > > where the purpose is not to have three parameters, but two > plus a local binding (z) in foo to the value of some_expression > evaluated in the def-time environment. z may bind something not > accessible later at call time, or it may be just to avoid recalculating > an expensive expression at each function call. I offer the following to be able to compare this proposal with what I've done to solve this problem def _foo(x, y, z = some_expresssion): .... def foo(x, y = default): _foo(x, y) However, I do this only rarely (mostly for recursive functions) since it doesn't gain all that much over _default_z = some_expression def foo(x, y = default): z = _default_z ... Andrew ' dalke at dalkescientific.com From claird at lairds.com Tue Jan 28 10:22:32 2003 From: claird at lairds.com (Cameron Laird) Date: Tue, 28 Jan 2003 15:22:32 -0000 Subject: How can I avoid running a python script multiple times? References: <3E3677E5.5070901@Linux.ie> Message-ID: In article <3E3677E5.5070901 at Linux.ie>, wrote: >Grzegorz Adam Hankiewicz wrote: >> Hi. >> >> Using the concurrency jargon, I'm trying to mark python scripts as >> 'critical processes' which are not allowed to be run more than one >> at the same time (I'm constrained to unix environments, BTW). To >> do so, and following the logic of a bash script I had, I've created >> a function which is passed the real entry point of the script. > >[snip] > >> def run_if_possible(entry_point): >> """Given a function, it is called if there's no previous process >running""" >> permission = 0 >> lock_path = "%s.lock" % os.path.realpath(sys.argv[0]) >> if os.path.isfile(lock_path): >> file = open(lock_path, "rt") > >what does t do in "rt" ? >Hmm this didn't give an error for me: file = open(lock_path, "wqst") >So unrecognised options must be ignored. I tried x also, but this >seemed to set the exclusive bit? Where are these documented? >Ah, OK on Linux (glibc): > info libc "Opening Streams" >This shows that the x is glibc specific and sets O_EXCL >on the subsequent open() call (which is what you want). > >You could just do os.system("sematree ...") as I've worked >this out already: http://www.pixelbeat.org/sematree/ > >Note a simple atomic locking mechanism could be to >try and create a directory, which should work over >NFS etc. Might be simpler that messing with exclusive >bits on files? > >Note also sockets would be troublesome as you'll >have issues with SO_REUSEADDR for one thing. > >P?draig. > For Unix, or multiple platforms centered on Unix, my favorite singleton resource manager pertinent to this discussion is the socket service. has a discussion that's easily adapted to Python. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://phaseit.net/claird/home.html From woetzel at gmd.de Wed Jan 8 10:01:45 2003 From: woetzel at gmd.de (Gerd Woetzel) Date: 8 Jan 2003 16:01:45 +0100 Subject: "%s" vs unicode References: <1GtMGLAYnyG+Ew34@jessikat.demon.co.uk> Message-ID: <3e1c3d59$1@news.fhg.de> martin at v.loewis.de (Martin v. Loewis) writes: >It follows the general principle that, when combining byte strings and >Unicode strings, the byte string will be converted to Unicode, not >vice versa. Unfortunately the "general principle" is wrong. There is a canonical embedding of Unicode strings into byte strings (which is UTF-8) but no canonical embedding of byte strings into Unicode strings. Hence it should be vice versa. Its a real shame that I have no acces to the bvd's time machine :-) Regards, Gerd From wilk-spamout at flibuste.net Sun Jan 12 13:58:25 2003 From: wilk-spamout at flibuste.net (William) Date: 12 Jan 2003 19:58:25 +0100 Subject: Python for CGI is dead? References: Message-ID: <87fzryyz3i.fsf@flibuste.net> hwlgw at hotmail.com (Will Stuyvesant) writes: > I am spending rather much time trying to build a project using CGI > scripts written in Python. But am I wasting my time? I could not > find much Python hosting, and none free (except a french one that I > can not register into) for Python CGI scripts! If you want a french hosting, look at http://wikipython.tuxfamily.org/moin.cgi/HebergeursWeb For the others, I think the problem come with RH who provide python2 by default only in the last release. -- William Dode - http://flibuste.net From Kyler at news.Lairds.org Fri Jan 10 22:25:59 2003 From: Kyler at news.Lairds.org (Kyler Laird) Date: Sat, 11 Jan 2003 03:25:59 GMT Subject: How do I get to *all* of the groups of an re search? References: Message-ID: Andrew Dalke writes: >> As it is, I am resigned to understanding that Python's re >> module makes an arbitrary and undocumented decision to return >> the last instance of a match for a group. I'm embarrassed. >It is documented, and behaves as documented. Ah! It's documented in multiple places. The quote I gave before did not mention any further restrictions to "the contents of a group can be retrieved after a match has been performed," >http://www.python.org/doc/current/lib/match-objects.html Thank you. Any idea how I should have know to find that from here? http://www.python.org/doc/current/lib/re-syntax.html >] If a group number is negative or larger than the number of >] groups defined in the pattern, an IndexError exception is >] raised. If a group is contained in a part of the pattern that did not >] match, the corresponding result is None. If a group is contained >] in a part of the pattern that matched multiple times, the last >] match is returned. >As far as my research went, no standard regexp library could provide >that sort of information. They only give the last group which >matched a pattern. Yes, and that surprises me. It seems so obvious that it should return all matched pieces and so arbitrary that it only returns the last one. >I ended up writing my own regexp engine (!), Martel, which is at >http://www.dalkescientific.com/Martel/ and based on mxTextTools. Hmmmm...that's tempting. I try to limit myself to built-in tools when I can, but it's still tempting. I appreciate the reference. >> At the very least, the documentation should be changed to say >> that only the last match of a group will be returned. Better >> still would be an explanation of why the last one was chosen >> and how that makes Python's behavior more predictable. >It is documented. It's not documented where a user is likely to look for the RE syntax. The RE syntax page gives what appears to be a very straightforward explanation of groups. I don't know why a beginning Python user would think to look elsewhere for some strange behavior. >And it is consistent with other regexp libs, I'm not as concerned about Python being like lots of other languages as I am with it behaving the way a new programmer might expect it to work after reading what appears to be a canonical explanation. >eg, I know Perl's works that way. I have 2nd ed. of Friedl's >regexp book, but I haven't read it yet and I can't find where >he talks about it. Still, this behaviour is highly consistent >with the other regexp packages. Regardless, do you find it useful? Can you think of any time when you want to match a bunch of things and just end up with the last one? >You can also solve this without regexps. I can solve it lots of ways. I went for what I thought was going to be an elegant solution. I'd like to have a tool that works the way I expected the re module to work. >Show me a module besides Martel which lets you get access to >the parse tree. I looked at about a dozen packages, read >through Friedl's 1st edition book, and posted to various newsgroups >looking for one. I'm not at all interested in how popular the solution is. --kyler From jbperez808 at yahoo.com Fri Jan 17 03:23:04 2003 From: jbperez808 at yahoo.com (Jonathan P.) Date: 17 Jan 2003 00:23:04 -0800 Subject: iterating in reverse References: Message-ID: > Get the Python 2.3 alpha, and it's really easy :) > > >>> l = [1,2,3,4,5] > >>> for i in l[::-1]: > ... print i > ... > 5 > 4 > 3 > 2 > 1 > > -Andrew. Ach...! That's definitely the easiest on the eyes (wonder about the performance implications though). Still a bit of an eyesore... but we Python programmers are really too spoiled. ;-D From andy at eastonwest.co.uk Fri Jan 17 18:27:43 2003 From: andy at eastonwest.co.uk (andy) Date: Fri, 17 Jan 2003 23:27:43 +0000 Subject: Coding standard: Prefixing variables to indicate datatype In-Reply-To: <3E274C99.F8E2453B@alcyone.com> References: <0BuV9.11459$CG6.203654@news4.e.nsc.no> <6ee58e07.0301161523.65f3343b@posting.google.com> <3E274C99.F8E2453B@alcyone.com> Message-ID: <200301172327.43334.andy@eastonwest.co.uk> I tried a bit of Novell NDS client programming, a while back, with Delphi. Their Delphi API is RIDDLED with 'elongated' hungarian prefixes; instead of just c for char, s for string, i for integer and so on, they have developed a 'system' of long 3-5 character prefixes for each data type. Sometimes, you need to convert from, say, a Delphi Object string, to a zero-delimited string, and then pass the *pointer* to this to the API, like this: strUserName: string; stzUserName: array [128] of char; lpstzUserName: pointer to char; Ugly as sin, and it makes justabout any half-line equation three times as long, and utterly indistinguishable. With Python, I generally only use any form of hint if I'm converting from one data type to another, and it's not a 'throw-away' assignment. I'd do this sort of thing (dubious contrived example): x=getanum() # x now contains a number xstr=str(x) # do stuff with xstr As most people have said, it's not normally necessary, and just adds to the complication (and thus detracts from the readability) of your code. I feel that using a suffix is less likely to obsure the purpose of a variable than a prefix, but even then, if the code begins to get too unwieldy, I'd hack the suffix off to get control back! regards, -andyj From ajs at ix.netcom.com Sun Jan 19 19:08:31 2003 From: ajs at ix.netcom.com (Arthur) Date: Sun, 19 Jan 2003 19:08:31 -0500 Subject: license Message-ID: <000901c2c018$121cca60$c560f6d1@Arts> Tim writes- >Not for that alone: the PSF license explicitly grants permission to make >modifications and distribute derived works. Every OSI-certified license >does, since freedom to make derived works is part of the Open Source >definition (point 3 at ). While >I am not a lawyer, it was intended that it be *hard* to violate the Python >license. The license does require that derivative works include "a brief >summary of the changes made to Python 2.3". But understand, if he was redistributing Python with some notification that what one is receiving is modified from Python2.3, there is not an issue. The facts here - One has a standard Python installation. That is assumed by the third party distribution. And with no warning that it intends to do so, that the 3rd party package you download modifies the standard installation, and gives no notification that it did so. And the modification does not even reverse itself if you uninstall that package. I think that's quite ugly. And thought someone might agree. its refreshing to know I'm *never* right. Art From hanzac at cmmail.com Wed Jan 15 20:56:17 2003 From: hanzac at cmmail.com (hanzac) Date: 15 Jan 2003 17:56:17 -0800 Subject: How can I call the functions in a DLL Message-ID: HI, I once used win32api.LoadLibrary("xxx.dll") and stored the HANDLE in d and used win32api.GetProcAddress(a, "xxx") and it returned a int value of the function address. But how can I call the function? Can someone guide me? Thanks first.:-) From phr-n2003b at NOSPAMnightsong.com Fri Jan 17 18:38:39 2003 From: phr-n2003b at NOSPAMnightsong.com (Paul Rubin) Date: 17 Jan 2003 15:38:39 -0800 Subject: iterating in reverse References: <3E274D34.8F0C4348@alcyone.com> Message-ID: <7xadhz1h4w.fsf@ruckus.brouhaha.com> Nick Vargish