From joconnor at cybermesa.com Thu Dec 21 13:42:20 2000 From: joconnor at cybermesa.com (Jay O'Connor) Date: Thu, 21 Dec 2000 18:42:20 +0000 Subject: while (thread.alive()): Message-ID: <3A424F0C.A57C155@cybermesa.com> >> I'm continuously amused that people try to take language design >> forward and still drag obsolete ideas along for the ride. >Like having a print command that doesn't, by default, send output >to the printer... :o) Good example -- Jay O'Connor joconnor at cybermesa.com http://www.cybermesa.com/~joconnor "God himself plays the bass strings first when He tunes the soul" From syver at NOSPAMcyberwatcher.com Wed Dec 13 14:22:51 2000 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Wed, 13 Dec 2000 20:22:51 +0100 Subject: Source Code Management References: <918711$meh$1@reader1.imaginet.fr> Message-ID: <918ifa$rg8$1@troll.powertech.no> "Dale Strickland-Clark" wrote in message news:prff3tc59qtv0qr9afj16dali3jv789c7u at 4ax.com... > I've just dug CVS out and downloaded it but I discover that the NT version appears to require a > mounted volume. > > That's a disappointment. Nah, you just have to set up the environment properly. set the cvs root or something. From hs at paradise.nirvananet Mon Dec 25 10:18:25 2000 From: hs at paradise.nirvananet (Hartmann Schaffer) Date: 25 Dec 2000 10:18:25 -0500 Subject: One Python 2.1 idea References: <925baq$5sj$1@nnrp1.deja.com> <925tak01tpu@news1.newsguy.com> <926ici$vi9$1@nnrp1.deja.com> Message-ID: <927og1$66v$1@paradise.nirvananet> In article <926ici$vi9$1 at nnrp1.deja.com>, wrote: > ... >responsibilities. Application programmers should use the >abstractions that best solve their problem, functionally, >assuming that these are implemented well. Language >implementors should strive to make sure that the >implementation for an abstraction performs well in all >the ways it is used. This route provides significant gains >in productivity. But it only works if BOTH groups take up >their mantle. unfortunately, that simply doesn't work in practice. programmer tend to develop a style that is dictated by the implementation they are using. if a particularly abstraction performs lousy in the implementation i'm using and my users are screaming that they are falling asleep while waiting for a particular result, telling them that it might get better with the next release of the compiler won't cut it. if i expect something like that to happen, i won't wait for the complaints to come in, but write the code so that they won't, i.e. avoid the abstraction > ... >I think this approach is misguided. A listBuffer, as >far as I can tell, is functionally identical to a >sequence. We've cluttered the language with another >abstraction, whose only purpose is to help the compiler >decide an implementation. Now, everyone learning Python >has to learn about listBuffers, in order to read your >code. This same mistake has been made already with >xrange(). Given enough time, we'll have to teach >programmers about a dozen different things that all >behave like Python sequences. Blech! > >In my mind, the ideal is very different. The Python >implementation should have a dozen or more ways of >implementing sequences, depending on how they are >constructed, what kinds of objects are put into them, >the contexts in which they are indexed, whether they >are used for iteration, etc. The vast majority of the >time, these things can be determined at compile time. >There shouldn't be a different language abstraction >for sequences that are not stored. xrange() is an >abomination. The compiler should simply use this >implementation when it fits. > >ONLY ONE SEQUENCE ABSTRACTION SHOULD BE EXPOSED TO THE >APPLICATION PROGRAMMER. It would be a mistake -- a BIG >mistake -- to continue the process of cluttering up >the language with new abstractions, merely to give >implementation directive to the compiler. I vote we noble thought, but i see at least two objections here: 1. the compiler can only find the best way to implement a general abstraction iff it can see all uses of a particular instance. in a language that has seperate modules that come together at execution time this often is not the case 2. the programmer should be able to communicate to the compiler all the relevant information about the particular instance of an abstraction he uses that s/he is aware of. whether you use extra language features or annotations is irrelevant, and i would argue that for all practical purposes the annotations are as much part of the language as some special construct, only that it uses a different syntax. if the implementation improves, the compiler is as much free to map different source constructs into identical internal constructs, as it is free to ignore annotations > ... hs From sab at NOSPAM.freeuk.com Thu Dec 21 15:45:18 2000 From: sab at NOSPAM.freeuk.com (G. Willoughby) Date: Thu, 21 Dec 2000 20:45:18 -0000 Subject: 2 question from a python newbie! References: <91tl43$rko$1@neptunium.btinternet.com> Message-ID: <91tq58$cq6$1@uranium.btinternet.com> Thanks mate, i'm not a total programming newbie just a python newbie :) ill check out that site and them, thar books. ta G. Willoughby P.S. so python is really used as a scripting language and nothing more? "Remco Gerlich" wrote in message news:slrn944q0t.919.scarblac at pino.selwerd.nl... > G. Willoughby wrote in comp.lang.python: > > 1). Can python scripts be compiled to 'stand alone' .exe files? > > Sort of. There is a utility ('Freeze') that packs your program and Python > itself into one big .exe, and it's stand alone then. But that's not the > usual way to use Python. > > > 2). What's the best book/s available for learning python from a total > > beginers point of view? > > There are several options. Alan Gauld has a nice website for total > programming newbies at http://www.crosswinds.net/~agauld/ . He's also > often helpful at the tutor mailing list. He has a book out now, called > "Learn to program using Python". It's brand new and I haven't seen any > reviews yet, but you can try his page first and buy the book if you want > to have an extended version printed on dead trees. > > Other options are for instance "Teach Yourself Python in 24 Hours" and > "The Quick Python Book". There are also more tutorials online, see the > Documentation link on http://www.python.org . > > -- > Remco Gerlich From sholden at holdenweb.com Thu Dec 14 10:38:21 2000 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 14 Dec 2000 10:38:21 -0500 Subject: MS + Python = help??? References: <91an5e$qfm$1@nnrp1.deja.com> Message-ID: Arint? wrote in message news:91an5e$qfm$1 at nnrp1.deja.com... > What is the address of the webpage that had the python help in the form > of one of the new micrsoft html help format things. > > tia > Go to http://alldunn.com/python/ and use the py2docs.zip link at the top of the page. regards Steve From sh at ttsoftware.co.uk Fri Dec 15 10:41:05 2000 From: sh at ttsoftware.co.uk (Steve Horne) Date: Fri, 15 Dec 2000 15:41:05 +0000 Subject: what is a closure? References: <3a39033b@news.xtml.co.uk> Message-ID: <8nck3tocsg8kp1u2g1du6nd3lt9gfeckr2@4ax.com> On Thu, 14 Dec 2000 18:09:54 GMT, "Fredrik Lundh" wrote: >In the following example, the "a=a" default argument binding >binds add's local name "a" to the value of the "a" argument >from make_adder. > > def make_adder(a): > def add(b, a=a): > return a + b > return add > > >>> m = make_adder(10) > >>> m(20) > 30 Are you sure that's a closure? - It looks closer to currying to me. And the definition seemed pretty close to the definition of an object - a collection of related data and methods. Currying, in functional languages, is the process of specialising a function by specifying one or more of its parameters to produce a function with fewer parameters than the original. The notation in Python is OK, but not very convenient... If fn_name has two parameters, you could apply currying to derive a single-parameter function as follows... lambda p1 : fn_name (p1, 10) # only works for literals lambda p1, p2=whatever : fn_name (p1, p2) Because the second form is a bit wordy, sometimes it is easier to have a currying function such as... def curry_p2_of_2 (fn, p2) : return lambda p1, fn=fn, p2=p2 : fn (p1, p2) This is clearly similar to your example. I was reading a book about developing compilers recently (Modern Compiler Design, by Dick Grune, Henri Bal, Ceriel Jacobs and Koen Langendoen), and something that was presented in it was a 'closure algorithm'. This took a collection of data and some related expressions, and repeatedly evaluated the expressions using both original and previously derived data until all the data it was possible to derive was fully derived. The thing that made it a closure algorithm seemed to be the fact that the expressions were applied repeatedly on an accumulating set of data until no further data could be derived - the closure being the complete collection of data. An example would be that given the expressions A = int + (int + int), you could represent it as two simple expressions... A = int + = int + int And then, given an expression to determine result types from the parameter types for the '+' operator, the closure algorithm would work as follows... Step 1 - it is not possible to determine A from A = int + B, as is not yet known. Step 2 - = int + int, therefore = int Step 3 - A = int + , therefore A = int + int Step 4 - A = int + int, therefore A = int. Step 5 - Unable to find any expressions to apply for which the inputs are known, yet the output is unknown, so terminate. I don't claim to be an expert on this. I would simply appreciate it if someone could clear up my confusion! -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From ben.hutchings at roundpoint.com Tue Dec 5 11:05:28 2000 From: ben.hutchings at roundpoint.com (Ben Hutchings) Date: 05 Dec 2000 16:05:28 +0000 Subject: os.rmdir() and os.removedirs() only work on empty directories? References: <8v1p27$7d7$1@nnrp1.deja.com> Message-ID: jschmitt at vmlabs.com writes: > I was a bit surprised to find that os.rmdir() and os.removedirs() both > complained if I tried to delete a directory that was not empty. Is > that expected? POSIX says the rmdir call should only remove an empty directory, so it doesn't surprise me that os.rmdir behaves this way. I have yet to see what os.removedirs is for. > I guess shutil.rmtree() is the tool to use if I really want to > recursively delete a directory hierarchy that is non-empty. I hadn't seen that one - I wrote this function myself when I wanted recursive deletion: def rmdir_recursive(dir): """Remove a directory, and all its contents if it is not already empty.""" for name in os.listdir(dir): full_name = os.path.join(dir, name) # on Windows, if we don't have write permission we can't remove # the file/directory either, so turn that on if not os.access(full_name, os.W_OK): os.chmod(full_name, 0600) if os.path.isdir(full_name): rmdir_recursive(full_name) else: os.remove(full_name) os.rmdir(dir) > I don't quite understand this part of the documentation os.removedirs(): > '...if the leaf directory is successfully removed, directories > corresponding to rightmost path segments will be pruned way until > either the whole path is consumed...' I believe that this means it will remove successive parent directories referred to in the given path if they have become empty - so if you have the following directory structure: . (current directory) | +--a/ | | | +--b/ | | | | | +--c/ | | | | | +--d/ | | | +--e/ | +--f and you call os.removedirs('a/b/c/d'), it will remove directories a/b/c/d, a/b/c and a/b (assuming the process is permitted to do so). It will attempt to remove a, fail because a is not empty, and then stop. -- Any opinions expressed are my own and not necessarily those of Roundpoint. From fredp at mygale.org.nospam Wed Dec 13 03:35:30 2000 From: fredp at mygale.org.nospam (Fred Pacquier) Date: 13 Dec 2000 08:35:30 GMT Subject: Thank you, Fredrik. (was Re: Label-Value) References: <914v6l02ouv@news2.newsguy.com> Message-ID: <9009628F0PaCmAnRDLM@161.48.76.20> katz at Glue.umd.edu (Roy Katz) said : >On Tue, 12 Dec 2000, Fredrik Lundh wrote: >> Sigh. The problem is that you keep using terms that mean >> something for you, whether or not they apply to the current >> situation. [snip] >> If you want to learn something new, you have to stop doing >> that. [snip] >> Here's how it's done in Python: >> [wonderful explanation snipped] > >Thank you very much, I understand now more or less how this works. >Furthermore I appreciate your thoughtful, measured, and flame-free tone. Seconded. I'm sure it's been useful to many other people who have been "doing" Python for as long as you have (including me) without an understanding that deep, whether they will admit to it or not. As Fredrik says, this info certainly exists elsewhere and could be pieced together from existing material. But having it summed up clearly and in few words in one place can be a revelation, so this definitely needs to go in python-snippets or FAQTS or somewhere... Thanks /F ! -- YAFAP : http://www.multimania.com/fredp/ From paulp at ActiveState.com Fri Dec 8 11:52:34 2000 From: paulp at ActiveState.com (Paul Prescod) Date: Fri, 08 Dec 2000 08:52:34 -0800 Subject: xml.dom References: <90q292$k9k$1@merlin.rembrandtstr.bocholt.de> Message-ID: <3A3111D2.5C236D22@ActiveState.com> Magnus Heino wrote: > > Hi. > > How do I build an xmldocument using something in xml.dom? I'm not sure what you are asking. Here's a potential answer if the question is: "How do I parse an XML document into a DOM using the DOM implementation that ships with Python 2.0." >>> from xml.dom import minidom >>> dom = minidom.Parse("c:\\temp\\test.xml") Paul Prescod From lvirden at cas.org Sat Dec 30 07:22:17 2000 From: lvirden at cas.org (lvirden at cas.org) Date: 30 Dec 2000 12:22:17 GMT Subject: Python legalities References: <3A2FC63D.652101A@accessone.com> Message-ID: <92kk1p$c65$1@srv38.cas.org> According to Helen Dawson : :The legal department at my company is a bit nervous ... :They are concerned about the :risks of using software that may inadvertently contain fragments :of patented or copyrighted code, without anyone who can indemnify :us against this risk. It's good to worry about this. However, how do you handle the situation when dealing with software you've written on site? I would think that passing the free software through the same reviews as the inhouse procedures should be sufficient... -- -- "See, he's not just anyone ... he's my son." Mark Schultz Even if explicitly stated to the contrary, nothing in this posting From fredrik at effbot.org Fri Dec 8 05:51:26 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 08 Dec 2000 10:51:26 GMT Subject: "**" operator in method/function interfaces ?? References: <90qdi3$ar6$1@reader1.imaginet.fr> Message-ID: Gilles Lenfant wrote: > What's the use of "**" in such a construct ? > > ... > class MyClass: > def __init__(self, adata, **anotherdata) > ... > > > I found such construct in some examples of the Tkinter tutorial at > pythonware, and in some other documents. > I have gone around all books and web language tutorial I know and did not > find anything about it. http://www.python.org/doc/current/ref/function.html If the form "*identifier'' is present, it is initialized to a tuple receiving any excess positional parameters, defaulting to the empty tuple. If the form "**identifier'' is present, it is initialized to a new dictionary receiving any excess keyword arguments, defaulting to a new empty dictionary. or, in other words: >>> def func(*args, **kwargs): ... print args, kwargs ... >>> func(1, 2, 3, a=4, b=5, c=6) (1, 2, 3) {'b': 5, 'c': 6, 'a': 4} From aleaxit at yahoo.com Tue Dec 12 04:12:56 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Dec 2000 10:12:56 +0100 Subject: 3rd argument to os.path.walk(): Why? References: <912gdb$1oqr$1@news.idiom.com> <912nj60ccr@news2.newsguy.com> Message-ID: <914q6v02l3p@news2.newsguy.com> "Rob Hooft" wrote in message news:m2vgsqw1k2.fsf at hooft.net... > > AM> E.g., say you want to _count_ the files: > > AM> import os > > AM> class Counter: > AM> def __init__(self): > AM> self.count = 0 > AM> def inc(self, n=1): > AM> self.count += n > > AM> def count_names(count, dir, flist): > AM> count.inc(len(flist)) > > AM> count = Counter() > AM> os.path.walk("/", count_names, count) > > AM> print count.count,"files in all" > > If you'd do this, why not make "count_names" a method of the Counter > class? As things stand here, "Counter" is a completely general-purpose class, which has no knowledge whatsoever of files, their names, and path-walking -- it's completely decoupled from all of these concerns, a low-level "utility class" that is reusable in all sorts of contexts. Strictly coupling a generic counter-class to specific things it could be counting doesn't seem like an elegant design at all. If anything, one might *derive* from Counter a NamesCounter subclass, or *contain and delegate-to* a Counter from a wrapper class -- assuming os.path.walk takes any callable (specifically, a bound method is what we would pass here) even though the docs specifically say it takes a *function* instead (the docs are often too-restrictive regarding object-types expected by core Python functions...). Once that is feasible, then both idioms for setting callbacks are equally elegant: 1. the classical procedural set-callback idiom, where you provide a function (typically not carrying state) and the state to be passed to it as an argument when the calling-back does happen; 2. the strongly object-oriented set-callback idiom, where you provide a callable object which entirely takes care of its own state issues. The tradeoffs between these two design approaches are, more or less, 'the usual suspects'. One way to frame [1] is strictly object-oriented terms is as an application of the "Memento" design-pattern -- the 'function' might still be a more-general 'callable', but some part of its state is objectified as a separate 'memento' object that is explicitly handled back to it as needed. "Memento" is one of many important ways in which issues of object-identity and object-state can be decoupled, and thereby handled more explicitly, with finer-grained control. (One doesn't always _want_ to control things on a fine-grained level, which is why it's nice to have different idioms available in the language/framework:-). Alex From aleaxit at yahoo.com Wed Dec 27 15:53:34 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 27 Dec 2000 21:53:34 +0100 Subject: Python and Napster References: <000c01c06fe3$efc29520$102b2bc1@cadlab.it>, <92ap0g12b6r@news1.newsguy.com>, <20001227164900.DF7E6A84F@darjeeling.zadka.site.co.il> Message-ID: <92dptl11vqa@news2.newsguy.com> "Moshe Zadka" wrote in message news:mailman.977910196.13387.python-list at python.org... > On Wed, 27 Dec 2000, "Alex Martelli" wrote: > > > HTTP (and the Python tools around it) is great for file transfer (and > > suchlike) but it's not oriented to peer-to-peer at all. > > Well, yeah, you'd have to implement the low-level part of peer-to-peer. > But the HTTP infrastructure is usually enough for that: broadcast by > performing a GET /?file=name to say you have a file called "name" > and the nameing service turns out to be composed of 302 redirects. I'll have to trust you on that. A '302 redirect' is somehow broadcast to...? > > I think that actually transferring a file's data and metadata, once > > you have a proxy for a remote object, is no big issue. It seems to > > me that naming, exceptions, resuming transfer (not supported by HTTP, > > is it?) > > You have insulted the prophet: your punishment shall be cruel indeed! > Of course HTTP supports resuming transfer. SimpleHTTPServer doesn't > though. I don't think it should be hard to add, though. I guess I'm stuck back in HTTP 1.0 times. What's the transfer-resumption transaction, then? > An advantage of HTTP is that it will be possible to use the protocol > with clients not written in Python. If what he wants is simple file > exchange, there is no reason to be limited to Python at the protocol > level. If cross-language and cross-platform operation is desired, Corba would seem most appropriate to me. I saw no indication of such desire in the original post, though -- cross-platform, yes, but the idea seemed to be to have a single Python app that would handle it all. Alex From fidelman at world.std.com Thu Dec 7 07:36:21 2000 From: fidelman at world.std.com (Miles R. Fidelman) Date: Thu, 7 Dec 2000 12:36:21 GMT Subject: Python Origins References: <90k3pq$50p$1@nnrp1.deja.com> <3A2EE2AF.AD8A51E2@caltech.edu> <976153091.257544@clam-ext> Message-ID: Mark, Mark Hadfield (m.hadfield at niwa.cri.nz) wrote: : "Nathan Gray" wrote in message : > What a rude response to a polite and legitimate question. : Well I think a more legitimate question would have been: : "I want to know about Pythons origins. I've looked in the obvious places, : i.e. www.python.org, and read the stuff there but I want to know more about : this: ..." What a great way of summarizing things - this says it all. Miles Fidelman From sdm7g at virginia.edu Thu Dec 21 13:26:29 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Thu, 21 Dec 2000 13:26:29 -0500 (EST) Subject: Python in "math through programming" curriculum In-Reply-To: References: <2g2t3t06r2agrrjmfnr41eu4lc2u39a8qi@4ax.com> <3A3EFF47.67DE69CF@gte.net> <91n9i30pr7@news2.newsguy.com> <91qa3r01m78@news2.newsguy.com> Message-ID: On 21 Dec 2000, Neelakantan Krishnaswami wrote: > > Yes -- the reference to Knuth's _Concrete Mathematics_ made me think > that an introduction to CS was envisioned. For things like graphing > and statistics, there's no reason not to use Python, since it has good > graphing and statistical libraries. Static typechecking doesn't help > here, I don't think, and in Haskell's case it becomes a positive > nuisance (because of all the IO). > XlispStat -- a free Lisp variant with extensions for statictics, vector math and object-oriented interactive graphics -- is another good choice. There's a good textbook by Luke Tierney available. The graphics and statistics support is quite a bit more mature than what's available in Python, and the graphics is better integrated and easier to use. ( That maturity and integration, however, is one of the current problems: for example, the 3-D graphics predates the wide availability of OpenGL libraries -- it would be nice to be able to extend some of it's graphics abilities but the current graphics model is pretty tightly tied. That's where Python's not being tied to any one graphics model is an advantage. ) See: You might also check out StarLogo from MIT's media lab -- a special version of Logo designed to handle thousands of independent "turtle" agents in parallel: | StarLogo is a programmable modeling environment for exploring the | workings of decentralized systems -- systems that are organized without | an organizer, coordinated without a coordinator. With StarLogo, you can | model (and gain insights into) many real-life phenomena, such as bird | flocks, traffic jams, ant colonies, and market economies. -- Steve Majewski From aleaxit at yahoo.com Tue Dec 19 04:59:56 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 19 Dec 2000 10:59:56 +0100 Subject: Need Help sorting alphabetically. References: <3A3F1A91.A7ED9182@araidesign.com> Message-ID: <91nbjl0rj3@news2.newsguy.com> "Chris Arai" wrote in message news:3A3F1A91.A7ED9182 at araidesign.com... > Hi, > > This seems like it should be obvious, but it is evading me! > > I would like to sort alphabetically (I'm not sure that is the correct > term) so that strings of alpha numerics sort alphabetically instead of > by ASCII order. > > eg: > >>> m=['Pg95_100.GIF', > 'Pg9_100.GIF','Pg95A_100.gif','Pg9A_100.gif','Pg10_100.gif'] > >>> m.sort() > >>> m > ['Pg10_100.gif', 'Pg95A_100.gif', 'Pg95_100.GIF', 'Pg9A_100.gif', > 'Pg9_100.GIF'] > > > I would like the order to be > ['Pg9_100.GIF', 'Pg9A_100.gif', 'Pg10_100.gif, 'Pg95_100.GIF', > Pg95A_100.gif' ] > > What is the obvious answer?? First: you have to *precisely* define, for each string, what 'data equivalent to it' you ARE comparing for your sorting purposes. This is no doubt the major task you face. For your specific example, e.g., it would seem that the 'equivalent data' to each string is an integer made up from the digits between a leading 'Pg' prefix and some following non-digits, then the following non-digits if any up to but not including a '_', then the rest - but your criteria might well be very different. First of all, nail down those criteria. Extraction of 'equivalent data' can be done by using regular expressions, or in other ways. RE's can be very compact and pretty fast, but there may be other simpler ways, depending on what exactly you're doing. Assuming RE's, then, for example: import re cre = re.compile('(\D*)(\d+)([^_]*)_(.*)') We match 4 parenthesized groups: 0 or more non-digits (the prefix), 1 or more digits (the number), 0 or more non-underlines, whatever comes after the underling Of these, the second field needs to be converted to an int, the other will remain strings. def eqv1(astring): mo = cre.match(astring) if not mo: raise ValueError, "no match: %r"%astring groups = mo.groups() return (groups[0], int(groups[1])) + groups[2:] if __name__=='__main__': for s in m: print s, eqv1(s) Running this will confirm we're extracting the right 'equivalent' data: D:\PySym>python ccc.py Pg95_100.GIF ('Pg', 95, '', '100.GIF') Pg9_100.GIF ('Pg', 9, '', '100.GIF') Pg95A_100.gif ('Pg', 95, 'A', '100.gif') Pg9A_100.gif ('Pg', 9, 'A', '100.gif') Pg10_100.gif ('Pg', 10, '', '100.gif') D:\PySym> Actually, you'll probably want to lowercase some of this, too, always for comparison purposes -- I suspect you want it to be irrelevant to the sort whether a string ends in '.GIF' or '.gif', for example, or whether the prefix is spelled mixed, upper, lowercase. So, you could change the last line in eqv1 (after also changing the import to import re, string of course), to: return (groups[0].lower(), int(groups[1]) ) + tuple(map(string.lower,groups[2:])) and now the test would emit: D:\PySym>python ccc.py Pg95_100.GIF ('pg', 95, '', '100.gif') Pg9_100.GIF ('pg', 9, '', '100.gif') Pg95A_100.gif ('pg', 95, 'a', '100.gif') Pg9A_100.gif ('pg', 9, 'a', '100.gif') Pg10_100.gif ('pg', 10, '', '100.gif') D:\PySym> more likely to be right. Anyway, use this kind of exploratory approach to make sure you have the right 'equivalence extraction' function for your purposes; be sure to test quite extensively on data which IS representative of the scenarios you will want to handle! Once you *DO* have a good 'eqv' function for your purposes -- one that, applied to any string you may be sorting, returns the correct 'equivalent' tuple you want to use for comparison -- there are basically two approaches to using it. One involves passing a comparison-function to the sort method, and I would not advise it -- if the extraction function does anything 'heavy', sorting lists of substantial length can be quite slow this way. A better approach (which I _think_ should be called 'Schwartzian transform', from the name of its inventor, but there is anything but consensus on this group regarding the name, or the priority of Randall Schwartz' "invention" of this...!): def richSort(aList, eqv): auxList = [ (eqv(x), x) for x in aList ] auxList.sort() return [ x for (junk, x) in auxList ] Changing the unit-test at the end of the module to: if __name__=='__main__': for s in m: print s, eqv1(s) x = richSort(m, eqv1) print x we now have the following test-output when just running the module: D:\PySym>python ccc.py Pg95_100.GIF ('pg', 95, '', '100.gif') Pg9_100.GIF ('pg', 9, '', '100.gif') Pg95A_100.gif ('pg', 95, 'a', '100.gif') Pg9A_100.gif ('pg', 9, 'a', '100.gif') Pg10_100.gif ('pg', 10, '', '100.gif') ['Pg9_100.GIF', 'Pg9A_100.gif', 'Pg10_100.gif', 'Pg95_100.GIF', 'Pg95A_100.gif'] D:\PySym> which seems a good match for the required functionality. Function richSort is not complex. It build an auxiliary list, where each item's "sorting-equivalent" is prepended to the item itself; sorts the auxiliary-lists with its own sort method, which ('lexicographically'...:-) will consider the comparison of the 'sorting-equivalents' to have precedence; extract the results by junking all the sorting-equivalents previously prepended. It's much clearer and more concise to express this in Python, of course, as above done, than in English, at least my personal, somewhat verbose idiolect of it:-). If you *had* to do it with comparison-function-argument- to-sort, it could be, for example: def richSortAlternate(aList, eqv): def compare(a, b, eqv=eqv): return cmp(eqv(a), eqv(b)) aList.sort(compare) return aList and it would operate in-place. But I would strongly advise the other approach...! In any case, developing the 'eqv' data-extraction is the key step, and also the one depending strongly on the specific problems you want to solve, while the ways you apply that function to the sorting tasks are general-purpose Python patterns/idioms. Alex From gregj at pobox.com Sun Dec 31 00:02:22 2000 From: gregj at pobox.com (Greg Jorgensen) Date: Sun, 31 Dec 2000 05:02:22 GMT Subject: HTML Parser References: Message-ID: "Greg Jorgensen" wrote: > rx = re.compile('(<.*?>)', re.MULTILINE) Oops -- that should be: rx = re.compile('(<.*?>)', re.DOTALL) That makes the . match the newlines. You need that because HTML tags can span lines. -- Greg Jorgensen PDXperts Portland, Oregon, USA gregj at pobox.com From Bjoern.Giesler at gmx.de Thu Dec 14 10:11:01 2000 From: Bjoern.Giesler at gmx.de (Bjoern Giesler) Date: 14 Dec 2000 15:11:01 GMT Subject: Why no shared libpython by default? Message-ID: <91anu5$bmd$1@news.rz.uni-karlsruhe.de> Hi, why isn't libpython built as a shared library by default? Yes, I know how to set it up as a shared library, and it's not that much of a hassle, but why not as standard? Regards, --Bj?rn From michael at stroeder.com Sun Dec 31 08:36:49 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Sun, 31 Dec 2000 14:36:49 +0100 Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> Message-ID: <3A4F3671.AAA18BFF@stroeder.com> Steve Lamb wrote: > > Whatever. *plonk* While you're at it: Can you please *plonk* me too? We might disagree in the future and we can avoid flame wars in advance and save work. And it's a great honor for me to be in the same kill-file as the Eff-bot. Your cooperation by *plonking* me is highly appreciated. Thank you. Ciao, Michael. From dsh8290 at rit.edu Tue Dec 12 19:22:26 2000 From: dsh8290 at rit.edu (D-Man) Date: Tue, 12 Dec 2000 19:22:26 -0500 Subject: DangerousExceptions (was Re[2]: [Q] Are Exceptions used that much in practice?) In-Reply-To: <196647430.20001213004339@vega.bg>; from spahievi@vega.bg on Tue, Dec 12, 2000 at 17:43:39 -0500 References: <3A35D546.A4731B5B@enteract.com> <914mfd02ibt@news2.newsguy.com> <196647430.20001213004339@vega.bg> Message-ID: <20001212192226.E16853@westsidecnc.rh.rit.edu> That might be nice sometime. Java has it. -D On Tue, 12 Dec 2000 17:43:39 Niki Spahiev wrote: | 12.12.2000, 21:34:08, Rainer Deyke wrote: | | RD> "Alex Martelli" wrote in message | RD> news:914mfd02ibt at news2.newsguy.com... | >> (Some might prefer a wider 'except: return 0' clause, but | >> most often it's better to be specific in catching exceptions). | | RD> I would go further and say that 'except: return 0' should never be used, | RD> since it would catch and ignore MemoryError, KeyboardInterrupt, | SystemExit, | RD> ComputerExplodingError, or any number of other exceptions that are | totally | RD> unrelated to the issue at hand and require careful handling and/or | program | RD> termination. | | While at this i always wished that Exception has two subclasses: | "NormalException" and "DangerousException" so one can use | | except NormalException: return 0 | | and not worry about MemoryError, KeyboardInterrupt, SystemExit, | ComputerExplodingError :) being improperly handled. | | | -- | Best regards, | Niki Spahiev | From scj at mcom.mcom.fr Wed Dec 6 06:36:12 2000 From: scj at mcom.mcom.fr (Alfred) Date: Wed, 06 Dec 2000 11:36:12 GMT Subject: Sort References: Message-ID: Merci beaucoup !!!! (Thank you !!!!) Greg From leejor at my-deja.com Tue Dec 12 18:19:26 2000 From: leejor at my-deja.com (leejor at my-deja.com) Date: Tue, 12 Dec 2000 23:19:26 GMT Subject: Spinning off time intensive procedures to speed CGI Message-ID: <916bpn$a6i$1@nnrp1.deja.com> I have a variety of time consuming proceedures that slow the response time of my CGI scripts. These are proceedures that do not send any information back to the web browser. I want to spin off these proceedures to allow the original program to imediately continue. Examples of these proceedures include: saving to Log files, sending emails, or caching database queries. How do I accomplish this? I have played with fork() and os.system(), but have not achieved the results I need. In my searches of the documentation and online forums, I have only found methods that _wait_ for the spun off proceedures to return a result. I don't want to wait. Thanks! -- Lee A. Joramo ljoramo at nickads.com The Nickel Want Ads www.nickads.com Internet Manager 970-242-5555 Sent via Deja.com http://www.deja.com/ From teyc at bigfoot.com Wed Dec 13 22:28:21 2000 From: teyc at bigfoot.com (Chui Tey) Date: Thu, 14 Dec 2000 13:28:21 +1000 Subject: Python for REAL Projects ? References: <3a380d1e.409238@bendigo.news.origin.net.au> Message-ID: <919erq$tsr$1@bunyip.cc.uq.edu.au> Delphi is a development environment and you should really compare Python vs Pascal, Delphi vs PythonWorks, WingIDE From loewis at informatik.hu-berlin.de Fri Dec 8 14:46:00 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 08 Dec 2000 20:46:00 +0100 Subject: SAX2 XML validating? References: <3A2BF45A.246B757F@marge.hologic.com> <90ih81$hj9$1@reader1.imaginet.fr> Message-ID: "Gilles Lenfant" writes: > AFAIK, the only one XML validating parser for Python (100% python) is Lars > Marius Garshol's xmlproc > http://www.stud.ifi.uio.no/~lmariusg/download/python/xml/ Indeed. It is also available as part of PyXML, http://sourceforge.net/projects/pyxml, which can be safely installed on top of Python 2. Regards, Martin From krussell4 at home.com Tue Dec 5 22:33:25 2000 From: krussell4 at home.com (Kevin Russell) Date: Wed, 06 Dec 2000 03:33:25 GMT Subject: mp3 module References: <3A2BB89B.D4C30300@ira.uka.de> Message-ID: <3A2DB330.64D341AD@home.com> Markus von Ehr wrote: > > Hi, > > is there a module to play mp3 files with python? > > Thanks for answers, > There are a few different modules that can read and play MP3 files (I'd recommend Snack, but I'm biased) or that offer very nice front-ends to existing MP3 players on various platforms. Check out the Sound/Audio section of the Vaults of Parnassus: http://www.vex.net/parnassus/ -- Kevin From jakobsen at home.com Fri Dec 29 23:54:48 2000 From: jakobsen at home.com (Peder Jakobsen) Date: Sat, 30 Dec 2000 04:54:48 GMT Subject: Is 100,000 entries big for a dictionary? References: <92iug4$vqb$1@nnrp1.deja.com> <92j54s$t0i$1@reader1.imaginet.fr> Message-ID: Now try print megadict and see how long that takes ;) "Gilles Lenfant" wrote in message news:92j54s$t0i$1 at reader1.imaginet.fr... > Not for my desktop Sun 4500 with 16 Gb RAM 8)) > For your machine: > > megadict = {} > for x in xrange(0, 100000): > megadict[str(x)] = 'depends on the stuff you put in the dict' > > So what's the result ? > > a ?crit dans le message news: > 92iug4$vqb$1 at nnrp1.deja.com... > > I'm in the process of architecting an application with medium sized data > > sets. Python dictionaries are tempting as part of the representation > > mechanism. How do they perform when they have 100,000 entries? Can you > > offer any other experience with this size data set in Python? > > > > > > Sent via Deja.com > > http://www.deja.com/ > From hzzhang at hotmail.com Fri Dec 8 11:56:55 2000 From: hzzhang at hotmail.com (Hongzhen Zhang) Date: Fri, 08 Dec 2000 11:56:55 -0500 Subject: Jpython not work in Win2000 Message-ID: <3A3112D7.20504@hotmail.com> Hi, I just installed Jpython on Windows 2000. After successful installation, under dos prompt, I type: jpython it complains that 'jpython' is not recognized as an internal or external command, operable program or batch file. The jpython is a executable jar file, according to the file property. How can that happen? But it works in Windows NT. Any suggestions and recommendations are highly welcome. zhang From peter at engcorp.com Tue Dec 12 23:49:54 2000 From: peter at engcorp.com (Peter Hansen) Date: Tue, 12 Dec 2000 23:49:54 -0500 Subject: How can I use printer port in python?... References: <90vnol$l5p$1@news1-2.kornet.net> <3A33C429.FE4EF79C@engcorp.com> <912l22$gv$1@news1-2.kornet.net> Message-ID: <3A36FFF2.CDED9271@engcorp.com> Seo ji won wrote: > > "Peter Hansen" wrote: > > We could assume you mean a parallel port, and that you are on Windows, > > and that you don't actually plan to talk to a printer here, but then > > again we could be wrong. Help us out! > > Oh, I'm using Win2k(server..) and using python 2.0, > and want to use parallel port... > > I looked at those archives which you suggested, but there's no direct > answer.. Quite true, but it gave us the needed shared reference for a discussion. :) > -- or I don't know if its answer :) > > Do I have to use c code to use parallel port on windows?.. > > If I have to use c, just give me brief sample for it... ;-) > > if not, tell me how can I deal with parallel port with python... Unfortunately, you haven't quite answered the question fully: do you plan to talk to a printer or some other kind of device where you want directly to control the pins in the parallel port? If the latter, what kind of control do you need? Just the eight data pins? Any of the handshaking pins? Are you transferring data in and out (bidirectional) or just controlling some device without feedback? All these things are rather relevant in providing a correct answer to the question. In any case, your use of W2K is probably a big problem if you want the latter. As with NT (and I'm assuming here, since I've never used W2K and hope not to), you cannot directly control the hardware. You would have to go through the operating system's API or use a driver and wrap that with appropriate code (quite possibly with C code, depending on what you really want here). All these areas quickly go beyond any experience I've had, so I doubt I can "help" further... From erno-news at erno.iki.fi Tue Dec 26 13:02:48 2000 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 26 Dec 2000 20:02:48 +0200 Subject: python telnet script for openvms host References: <92ainp$jab$1@nnrp1.deja.com> Message-ID: Ennis Rosamond writes: | tn.read_until('[c') #last char of session hearder | tn.write('$ dir\r') | #following this, I receive back the sequence: | #recv '\377\373\001' | #IAC WILL 251 | #recv '\377\373\003' | #IAC WILL 251 | #recv '\003\\\033Z' | # | #which I don't know how to interpret. that looks like telnet option negotiation, telnetlib should take care of all that automaticalyl for you. i suspect the above is just some debug output from telnetlib. are you sure you are seeing it after your last .write call, and not at the start of the telnet connection? -- erno From josh at open.com Tue Dec 5 01:40:17 2000 From: josh at open.com (Joshua Muskovitz) Date: Tue, 5 Dec 2000 01:40:17 -0500 Subject: Calculating factorial References: <3a2a9496.647995@uutiset.nic.fi> Message-ID: <3a2c8c2a_3@corp.newsfeeds.com> What about using xrange() instead of range() to support *really* large numbers? -- 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 rodsenra at correionet.com.br Sat Dec 9 08:40:16 2000 From: rodsenra at correionet.com.br (Rodrigo Senra) Date: Sat, 09 Dec 2000 11:40:16 -0200 Subject: About Search engines References: Message-ID: <3A323640.65FBBE3B@correionet.com.br> Tim May wrote: > > Don't be misled by this claim. While it is claimed that Metacrawler > searches N different other search engines, it often (usually) returns > fewer results than Google does. > In any case, the moral is to try many different engines... I recommend trying HuskySearch (http://huskysearch.cs.washington.edu) It uses different search engines (including google) with a smart result combination strategy. HTH Rod BTW, I know this is not related to Pyhton. But since the issue came up in the thread 'simmulated annealing' in this list, I thought this info would benefit the majority. -- Rodrigo Senra Computer Engineer (GPr Sistemas Ltda) rodsenra at correionet.com.br MSc Student of Reflection (IC- UNICAMP) Rodrigo.Senra at ic.unicamp.br http://www.ic.unicamp.br/~921234 (see also http://www.gpr.com.br) From cjensen at bioeng.ucsd.edu Fri Dec 8 16:26:16 2000 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Fri, 08 Dec 2000 13:26:16 -0800 Subject: Parallel Computing References: <3A300B1D.223630F3@bioeng.ucsd.edu> Message-ID: <3A3151F8.7149AE05@bioeng.ucsd.edu> Konrad Hinsen wrote: > > Curtis Jensen writes: > > > I haven't had much luck on finding anything about parallel computing via > > Python. Does Python support this? Or do we just need to write a C > > module to run parallel code? Thanks. > > It depends on what you mean exactly by "parallel code", but I suppose > that for most interpretations the answer is that you can do it in > Python using existing modules. > > I'll limit myself to the kind of parallel computing that I do myself, > which is algorithm parallelization implemented via MPI. Version 2.1 of > ScientificPython (available at > ftp://dirac.cnrs-orleans.fr/ScientificPython/) contains an interface > to the most commonly used MPI functions plus the necessary > infrastructure to make Python run as an MPI application, and to permit > C extension modules to use MPI as well without linking to it > (important if you use dynamic libraries). With this package, you can > use MPI in Python in exactly the same way you would do in C or > Fortran. The data objects that can be passed between processes are > NumPy arrays and strings. > > However, most real-life parallel code will also contain C code for > speed; you wouldn't use a parallel machine if speed weren't important. > But you can end up with an efficient program in which most code is > Python. For an example, see the development releases (2.1.x) of the > Molecular Modelling Toolkit (available at > ftp://dirac.cnrs-orleans.fr/MMTK/). > Sorry I suppose I should have been more specific in what I was asking. I was looking for something like what Mr. Hinsen suggested. Though, I am also interested in RPC; I didn't expect to get responces about that. Glad I did. bye the way, the above links are a bit off. I believe they should be: ftp://dirac.cnrs-orleans.fr/pub/ScientificPython/ and ftp://dirac.cnrs-orleans.fr/pub/MMTK/ Thanks. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From thomas at xs4all.net Mon Dec 4 12:03:54 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Mon, 4 Dec 2000 18:03:54 +0100 Subject: Python mailing list/usenet bridge. In-Reply-To: <200012041005.EAA23178@x56.deja.com>; from sbrunning@bigfoot.com on Mon, Dec 04, 2000 at 10:05:53AM +0000 References: <8vt9t4$r0f$1@nnrp1.deja.com> <900365$fp6$1@nnrp1.deja.com> <905t5s$6ef$1@nnrp1.deja.com> <200012041005.EAA23178@x56.deja.com> Message-ID: <20001204180354.C4396@xs4all.nl> On Mon, Dec 04, 2000 at 10:05:53AM +0000, Simon B. wrote: > *Still* nothing. This is getting a bit irritating - deja is horrid. > *Please*, anyone know who I can nag to get this sorted? Noone. The only people we can nag to have been nagged to already, and they can't fix it (except in the long term, which is what Barry *is* fixing.) If you want read-access, though, you can use 'tyrannewsaurus.xs4all.nl' as your newsserver. It's the publically accessible newsserver my company hosts, as a test-bed. We don't charge, we don't expect you to fill in forms, and we don't use your ipadress for anything. My first posting that said this attracted 500+ concurrent connections, so I'm wondering howmuch more this one is going to attract :-) -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From aahz at panix.com Thu Dec 28 12:40:27 2000 From: aahz at panix.com (Aahz Maruch) Date: 28 Dec 2000 09:40:27 -0800 Subject: Q: Is there any good documentation on MAPI using Python References: Message-ID: <92ftub$lev$1@panix3.panix.com> In article , Grant Edwards wrote: > >I'm using a Python program to fetch e-mail messages (and >associated attachements) via MAPI. You're welcome to it: > > ftp://ftp.visi.com/users/grante/python/mfetch.py So how's the BOFH these days? (For those walking in late, Grant wrote that program when his BOFH shut down POP3 access to the Exchange Server and then shut down HTTP access (or was it the other way around?).) -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Ninth Virtual Anniversary: 3 days and counting From schliep at Octopussy.MI.Uni-Koeln.DE Sun Dec 10 08:59:41 2000 From: schliep at Octopussy.MI.Uni-Koeln.DE (Alexander Schliep) Date: 10 Dec 2000 14:59:41 +0100 Subject: Dijkstra's Shortest Path algorithm References: Message-ID: Roy Katz writes: > I was wondering if Python (or Numerical Python) has anything like this > (a Graph module??). If there isn't, perhaps I should post my class at There is a Graph class among a lot of other things in Gato (graph animation toolbox), see . Gato allows you to implement algorithms and have their action visualized. BFS/DFS algorithms are bundled. You can easily code your own algorithms complete with visualization. Next year there will be a Springer textbook bundled with Gato, although Gato itself is released freely under the LGPL. Yours, Alexander PS: I am the principal author of Gato -- Alexander Schliep schliep at zpr.uni-koeln.de ZPR/ZAIK Tel: +49-221-470-6040 (w) University of Cologne FAX: +49-221-470-5160 Weyertal 80 http://www.zpr.uni-koeln.de/~schliep 50931 Cologne, Germany From at home.com Sat Dec 23 00:58:10 2000 From: at home.com (John Q. Public) Date: Sat, 23 Dec 2000 05:58:10 GMT Subject: PythonWin Question Message-ID: <3A443EF1.125426ED@home.com> While trying to add a journaling mechanism to python, I came across an odd behavior from PythonWin when I tried to override sys.stdout. For both the console and IDLE versions of the interpreter, I can override sys.stdout, but not for PythonWin. IDLE: >>> import journal >>> sys.stdout >>> journal.Open("My_Journal.txt") >>> sys.stdout >>> journal.Close() >>> sys.stdout console: >>> import journal >>> sys.stdout ', mode 'w' at 00762C80> >>> journal.Open("My_Journal.txt") >>> sys.stdout >>> journal.Close() >>> sys.stdout ', mode 'w' at 00762C80> PythonWin: >>> import journal >>> sys.stdout >>> journal.Open("My_Journal.txt") >>> sys.stdout >>> journal.Close() No open journals! >>> sys.stdout Any thoughts on how I can get PythonWin to "behave?" Thanks! Jonathan Polley jwpolley(a)collins(d)rockwell(d)com From pbjorn at uswest.net Fri Dec 22 13:40:06 2000 From: pbjorn at uswest.net (Bjorn Pettersen) Date: Fri, 22 Dec 2000 11:40:06 -0700 Subject: ANNOUNCE: soundex.py References: <3A4119C3.2E5E54E1@uswest.net> Message-ID: <3A43A006.F2CCC36@uswest.net> If we could get the soundex.py as part of the standard library, this would definitely get my vote. -- bjorn "A.M. Kuchling" wrote: > Does this mean that Modules/soundex.c can be dropped from the Python > CVS tree? > > --amk From erno-news at erno.iki.fi Sun Dec 24 02:26:36 2000 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 24 Dec 2000 09:26:36 +0200 Subject: Some Python 2.1 ideas References: Message-ID: >>>>> "Bob" == Bob Alexander writes: [snip] | ---- String method to remove trailing newline i think it would be prettier and more useful to have methods to remove a given prefix/suffix from the beginning or the end of a string. maybe add optional arguments for lstrip/rstrip, or introduce new methods rtrim/ltrim? -- erno From moshez at zadka.site.co.il Tue Dec 12 10:17:32 2000 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Tue, 12 Dec 2000 17:17:32 +0200 (IST) Subject: Inheriting the @ sign from Ruby Message-ID: <20001212151732.5D5A2A82E@darjeeling.zadka.site.co.il> On Tue, 12 Dec 2000, Roy Katz wrote: > Why not bind @ to the first argument of method definitions? Consider: > > > class X: > > def __init__( self, x ): > > @bind(x) # binds to 'self', because > # 'self' is the first argument to __init__ > > def bind(myself, x): > @x = x # equivalent to myself.x If you're requiring the "@" anyway, why not write the self. and be maximally obvious? Explicit is better then implicit. -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From rjroy at takingcontrol.com Mon Dec 4 17:39:17 2000 From: rjroy at takingcontrol.com (Robert Roy) Date: Mon, 04 Dec 2000 22:39:17 GMT Subject: Dividing the screen in text mode? References: <90eh84$3u0$1@bob.news.rcn.net> <90ehc9$50p$1@bob.news.rcn.net> Message-ID: <3a2c1cc3.417918375@news1.on.sympatico.ca> On Sun, 3 Dec 2000 17:27:24 -0500, "Z 3 Penguin" wrote: >oh yeah, i'm using py2.0 in win32. > >From an annoucement by Fredrik a couple of weeks ago: The Console module is a simple console driver, currently available for Windows 9X/NT/2000. This module provides cursor-addressable text output, plus full support for mouse and keyboard input. The 001114 release comes with source code, prebuilt binaries for Python 1.5 and 2.0, documentation, and a Python-style license. Get your copy from: http://effbot.org/efflib/console enjoy /F From MarkH at ActiveState.com Tue Dec 5 00:05:50 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Tue, 05 Dec 2000 05:05:50 GMT Subject: Python And MS Word Com Server References: <90bc4c$rhr$02$1@news.t-online.com> <90g54c$chj$1@news.inet.tele.dk> Message-ID: <3A2C7661.7010404@ActiveState.com> Jesper Hertel wrote: > I have exactly the same problem, but no solution, unfortunately. > At the top of the generated file makepy creates, you will find: # The following 3 lines may need tweaking for the particular server # Candidates are pythoncom.Missing and pythoncom.Empty defaultNamedOptArg=pythoncom.Missing defaultNamedNotOptArg=pythoncom.Missing defaultUnnamedArg=pythoncom.Missing Try changing those 3 lines to "Empty" Mark. From aleaxit at yahoo.com Tue Dec 12 07:05:37 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 12 Dec 2000 13:05:37 +0100 Subject: Print whithout \n References: Message-ID: <9154aq02st0@news2.newsguy.com> "Henrik M?rtensson" wrote in message news:aboZ5.3538$Kd1.410322 at newsb.telia.net... > Hi > > How do you print a string whithout a linefeed in the end. With a trailing comma on the print statement: print "no linefeed here", print "nor here","here neither", Alex From cbarker at jps.net Tue Dec 26 19:11:00 2000 From: cbarker at jps.net (cbarker at jps.net) Date: Wed, 27 Dec 2000 00:11:00 GMT Subject: Homogeneous Sequences in Python? Message-ID: <92bc2i$72n$1@nnrp1.deja.com> Homogeneous Sequences in Python? It seems that we have recently has yet another discussion about what kind of performance improvements might be made to the Python interpreter. It seems that there is some consensus that there are perhaps a lot of little things that could be done for special cases, but the big "bang for the buck" stuff has been done. For the most part, I find that Python is fast enough as it stands for most of my needs, but that it does fall down flat for a lot of what I do: numerical computing. A lot of the performance hit comes from what it know to be a limitation of virtually all interpreted languages: slow looping. While this is true, I think Python suffers more because of it's extreme dynamicism. The classic answer to why Python cannot be easily made faster, even if it were compiled, is that because of Python's dynamic nature, an expression like "x = a + b" cannot be compiled, because it is not known until runtime what types a and b are, and what it means to __add__ them. I am a BIG fan of Python's dynamic nature, so I would not like to see any of that flexibility go away. I have seen proposals for "optional static typing" that would address this issue (I believe Guido is talking about it for Py3k). That would certainly help, but it could be somewhat ugly as well. What occurs to me are two observations: 1) the occasional staticly typed integer is not going to make much difference. What would make a difference is a large collection of integers, for example 2) More often than not, when I build a large sequence, it is homogeneous, that is a large list (or tuple, whatever) of the same type: maybe a list of strings ( file.readlines() ), a list of integers (range(n) ), or even a list of lists. So, what we need to speed things up is to have a way for Python to process large sequences of the same type without having to type check each item in the sequence. The simple way to implement this is to have an optionally static type declaration for sequence: list.is_list_of_integers, or something like that. Then when this list is processed, the interpreter would know what it was dealing with. It then struck me that it could certainly be done automatically, on-the-fly: Every time an item was added to a sequence, it's type would be checked, and some kind of "homogeneous flag" would be set: a = [] # type unknown a.append(4) # homogeneous list of integers a.append(56) # still a homogeneous list of integers a.append(4.5) # Not homogeneous I have not idea how much this would slow append operations, but I suspect much less than the potential speed up of know that a list is homogeneous when it is. A plus of doing this automatically, is that it would take NO changes to existing code to take advantage of the new feature. Would this really speed up Python code much, even for large homogeneous sequences? I have no idea. I am in no way qualified to make that judgment, I'd like to hear what folks think. I suspect that it won't speed up straight, run-through-the-interpreter code enough to make it worth it, but it could have some real benefits in three places: 1) some of the sequence oriented operations that are being introduced: list comprehensions, and the possible future Elementwise/Objectwise Operators (see PEP # 225) 2) Py2c, the Python to C translator. I think a really important element of Python's future may be Py2C (and perhaps eventually a Python compiler or JIT compiler). It seems that has been the direction of number of interpreted languages. With optional static typing and compilation, LISP can be as fast (or faster) that C++ for numerics. MATLAB now has a translator to C++ that can create faster code and fully compiled stand alone applications. That has almost eliminated the need to write external functions in C. Py2C can only be so fast without some kind of static typing. I think homogeneous sequences could do it. Right now Py2C can convert "for i in range(1000)" into a fast C loop, but can't do anything with "for i in list_of_integers", If it had a way of knowing that it was a list of integers, it could be highly optimized. 3) Extensions that you have to pass a lot of data to. An example is wxPython. In order to draw a polyline with a couple of thousand points, for example, you have to pass a list of 2-tuples of integers of the coordinates of the points. The extension has to do a type check on every one of the numbers in every one of the tuples in the list. Frankly, this is still pretty fast, but not as fast as it could be. My goal is to be able to write applications that contain some numerically intensive code (or other repetitious simple processing) and not to have to use anything but Python. I'm going to have to keep writing C for a large amount of the core code if something isn't done a little differently. What about Numeric? NumPy provides the Multiarray object, which does provide what I am talking about, a homogeneous sequence ( at least of numbers, which is mostly what I need). As a result, it can implement very fast array oriented operations that eliminate the need for a large amount of hand coded C extensions. The problem is that core Python has no idea that it is a homogeneous sequence, so when you have to do some looping, things slow WAY down. As an example, I recently wrote a function that had to loop through a NumPy array of 1000 items, a list of 200 Numpy arrays, and each row in each of the Arrays in that list. The result was a triple nested loop, and a very slow run time. I probably could have avoided one of those loops using array oriented computation, but there was no way to get rid of all of them. I wrote the functions in the inner part of the loop in C, and got about a 25% speed up. I then wrote the entire thing in C, and got a 100X speed up. what had taken 100 seconds, now took 1 second. This was going to get done a lot, so I needed to do that. Having been working almost entirely in Python lately, I really didn't enjoy writing the C ! How this could be implemented: I am not qualified to talk about the actual code in the Python interpreter, but what I am envisioning is that the concept of the homogeneous sequence would be get into the Python code, and hopefully some optimizations of list comprehensions and the like could be done. In the short term, I would imagine little other benefit, but once it was in there, it could be used to great advantage in Py2C, and used by extension writers to really make things easier. In the long term, homogeneous sequences might provide a basis for the high performance Python compiler of the future. My questions: Is this even a remotely good idea, or have I just gotten carried away? Could it be useful to dynamically test for homogeneous sequences, or would they have to be statically defined? Looking at some of the stuff on the Web about Guido's ideas about static typing, I see a way to do homogeneous sequences, but no mention of the concept itself. Is it there somewhere? What are all the other flaws in my ideas that I haven't come up with yet? Sent via Deja.com http://www.deja.com/ From jp at ulgo.koti.com.pl Tue Dec 26 10:08:35 2000 From: jp at ulgo.koti.com.pl (Jacek =?iso-8859-2?Q?Pop=B3awski?=) Date: 26 Dec 2000 15:08:35 GMT Subject: ~Python ? References: <3a4833f8.346848@news.t-online.de> Message-ID: Gerson Kurz wrote: >You can have real fun if you try to deleting an >actual directory named ~ on Linux, boy. hmm... without -rf it's not dangerous... is it? anyway - you can use \~ or file manager (mc for example) -- They'll take your diamonds, and then give you steel You'll be caught in the middle of the madness Just lost like them "All The Fools Sailed Away" And part of all the pain that they feel - Ronnie James Dio From SBrunning at trisystems.co.uk Wed Dec 6 12:48:27 2000 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Wed, 6 Dec 2000 17:48:27 -0000 Subject: parsing and searching big text files Message-ID: <31575A892FF6D1118F5800600846864D5B155D@intrepid> > From: Gabor Gludovatz [SMTP:ggabor at sopron.hu] > I have a big text file which contains 3 variable lenght columns with > names. I have to search this file for names in either column and have to > show to other 2 names, and I have to do this very fast! > > The text file is about 3 megs long. Does someone know a method to do this > quickly? > > Which is the faster, should I read to whole text file into the memory and > parse and search it there, or should I read it from the disk line by line > and parse it..? > the last seemed to be very slow. > > Here is an example line from this text file: > Foo Bar:John Doe:Bill > > If I look for, for example, John Doe, the function should return Foo Bar > and Bill and all the other records which contain John Doe. > > Again: I have to do it very fast. Try this (untested): def scanGaborsFile(file, scanFor='John Doe', seperator=':'): result = [] try: lines = file.read().splitlines() except AttributeError: lines = open(file, 'r').read().splitlines() for line in lines: fields = line.split(seperator) if scanFor in fields: fields.pop(fields.index(scanFor)) result.append(fields) return result To answer your specific question, reading in the whole file will be by far the fastest way of doing it, unless you run out of memory. Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From gherman at darwin.in-berlin.de Tue Dec 19 09:27:21 2000 From: gherman at darwin.in-berlin.de (Dinu C. Gherman) Date: Tue, 19 Dec 2000 15:27:21 +0100 Subject: UN/EDIFACT related packages References: <91lg8h$2mo$1@reader1.imaginet.fr> Message-ID: <3A3F7049.29CCAC24@darwin.in-berlin.de> Gilles Lenfant wrote: > > I'm looking for packages related to UN/EDIFACT EDI messages. > Yes we got business partners who did not make the XML jump. > I'm 100% newbie in the EDIFACT field, so if some of you have > useful related packages/tooks, thei're welcome. > I did not find throug usual Python related search engines :( I know that Cees de Groot did some work in that field, resulting in a package called "ema". Hopefully he will listen and speak up. Long ago I wrote some toy implementation, which will not be very helpful, I guess, as my need for this did almost immediately evaporate after I started to get interested in EDIFACT. As you mention, the world goes for XML now! Dinu -- Dinu C. Gherman ................................................................ "The only possible values [for quality] are 'excellent' and 'in- sanely excellent', depending on whether lives are at stake or not. Otherwise you don't enjoy your work, you don't work well, and the project goes down the drain." (Kent Beck, "Extreme Programming Explained") From junaftnoon at nospamplzyahoo.com Thu Dec 28 12:36:44 2000 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Fri, 29 Dec 2000 02:36:44 +0900 Subject: sniffing btw my web browser and a server References: <92aush$rhc$1@news.nuri.net> <92fs3l$5gg$01$1@news.t-online.com> Message-ID: <92ftpn$e2j$1@news.nuri.net> "Eduard Hiti" wrote : [snip] > > There's also a Python only solution: 'WebDebug'. It also acts as a proxy, > logging all transfers and generating a nice and comprehensive HTML report. > > The URL: http://www.cyberclip.com/webdebug/download.html This one's what I've been looking for, but the link seems broken. Does anyone have it or know alternative links? Best regards, June From News at Titanic.co.uk Wed Dec 27 09:59:13 2000 From: News at Titanic.co.uk (Simon Faulkner) Date: Wed, 27 Dec 2000 14:59:13 GMT Subject: Controlling the Parallel Port References: Message-ID: <1q0k4t41id4d0nii3sofvbbchm44dllfp9@4ax.com> Having read the previous messages I note that this has been discussed on the Win platform but I am interested in the Linux (RH7) platform. I have the Jan Axelson Parallel Port Complete book but I am not sure how to write the port from Python. Any code snippets gratefully stolen... Simon On Wed, 27 Dec 2000 14:33:36 GMT, Simon Faulkner wrote: >Is it easy to control (read/write) the Parallel Port in linux using >Python? > >I am hoping to use it to drive some simple electronics > >(Usual disclaimer understood - If it smokes then you probably got the >wiring wrong!) > > >Simon >Simon Faulkner Simon Faulkner From alan at littleford.net Wed Dec 20 01:06:03 2000 From: alan at littleford.net (Alan Littleford) Date: Tue, 19 Dec 2000 22:06:03 -0800 Subject: Jython stability and JITs Message-ID: <3A404C4B.CBCA036D@littleford.net> I am thinking of using Jython for a project -- I know it is Alpha and do not have too much trouble with that. However the FAQ seems to go to great length implying that Jython and JITs spell trouble (because of "non-standard" JVM code that Jython emits) -- indeed it basically says turn off your JIT if you want to sleep easy at night. Is this indeed the case -- have people had trouble with JITs and Jython, or is this a left over warning from earlier (JPython) days ? Thanks Alanl From fhorch at ecoaccess.org Mon Dec 18 13:04:12 2000 From: fhorch at ecoaccess.org (Fred Wilson Horch) Date: Mon, 18 Dec 2000 13:04:12 -0500 Subject: Volunteer internship for Python programmers Message-ID: <3A3E519C.37004BB7@ecoaccess.org> Dear colleague, If you are * interested in Python programming or already a programmer, * looking for a volunteer opportunity or an independent study project, * eager to publish code and work on a development team, and * able to invest a few hours a week between January and May 2001 reading, writing and documenting open source object-oriented web application software (specifically Java, C and Python code for Zope running on Linux), you may be interested in the attached announcement. Thanks for the bandwidth, Fred Wilson Horch mailto:fhorch at ecoaccess.org Executive Director, EcoAccess http://ecoaccess.org/ P.O. Box 2823, Durham, NC 27715-2823 phone: 919.419-8354 -------------- next part -------------- Spring 2001 EcoAccess Technology Associate Internship EcoAccess, a public charity working to enhance public understanding of our natural environment, is offering a volunteer Technology Associate internship program for people seeking the opportunity to enhance their software development skills. Selected Technology Associates will receive a loaner Linux system to allow them to develop free open source software for the EcoAccess database-backed web site. Designed for Associates who have some programming experience, the internship runs from January 8 through May 4. Our software is published on SourceForge and licensed under the General Public License. How to Apply The internship is open to anyone who has any programming experience or training, with preference to those residing in the Triangle area of North Carolina. Apply by e-mail to Fred Wilson Horch, Executive Director internship at ecoaccess.org Please include the following information: * Your name * Preferred e-mail address * A summary of your education and relevant work experience, if any * Your experience with open source software, if any * Your other time commitments between January and May If we are interested in working with you, we will request a code sample before making a decision whether to accept you into the program. More About the Internship Our Technology Associates will learn how to develop for Zope, a leading Open Source web application server. Part of the internship will be devoted to learning and improving Zope itself, including documenting aspects of its interfaces. The other part will be devoted to writing applications in Python, Java and C to support the charitable EcoAccess project. Technology Associates must have at least dial-up Internet connectivity. Four interns who are in the Triangle area of North Carolina (Raleigh-Durham-Chapel Hill) can receive fully-configured development machines for use during the internship. (Associates may also use their own Linux machines if they prefer.) The loaner machines are best described as tomorrow's software running on yesterday's hardware. Our Technology Associates will get hands-on experience building object-oriented transactional web applications. Specifically, our Associates will write programs in Java, C and Python that run on Linux and use PostgreSQL databases. This internship is made possible through the generosity of several members of the Triangle Linux Users Group (TriLUG) who donated the hardware for our loaner machines. We appreciate the help! (Announcement revision 1.0 2000-12-14 10:21) From aleaxit at yahoo.com Mon Dec 4 16:45:56 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 4 Dec 2000 22:45:56 +0100 Subject: Converting Perl Regex to Python! References: <90h0a8$jgm$1@nnrp1.deja.com> Message-ID: <90h3dr0i17@news2.newsguy.com> wrote in message news:90h0a8$jgm$1 at nnrp1.deja.com... > I'm working on porting a program from Perl to Python, and i'm to a > point where I need to convert their Perl regex stuff over to python. > Now, I understand what is going on in the Perl if statement below, but > i haven't seen to many good examples of regex stuff for Python, so i'm > hurting for an translation > > The string i need to grab the info from looks like this: > > MSG notify timecode [00:00:00:00] > > if ($msg =~ /^MSG notify timecode \[(\d\d:\d\d:\d\d):\d\d\]/) { > $cajun->{state_clock}=$1; > } > > So, how exactly do i convert this to python? import re mo = re.match(r'MSG notify timecode \[(\d\d:\d\d:\d\d):\d\d\]', msg) if mo: cajun.state_clock = mo.group(1) Alex From joconnor at cybermesa.com Tue Dec 12 13:24:31 2000 From: joconnor at cybermesa.com (Jay O'Connor) Date: Tue, 12 Dec 2000 18:24:31 +0000 Subject: ooopss... Message-ID: <3A366D5F.CDBAC92F@cybermesa.com> > while (stream.atEnd()): > element = stream.next() > #process element Oops...Of course that won't work. I was translating the normal idiom from Smalltalk, which uses #whileFalse: in such situations instead of #whileTrue: It should read while (! stream.atEnd()): element = stream.next() As an aside, is there a Stream library for Python? Similar to Smalltalk's? I miss the idiom...If not, would anyone be interested in having one? I could probably do it as a side project It's a lot easier to extend a language by adding libraries than by changing the syntax -- Jay O'Connor joconnor at cybermesa.com http://www.cybermesa.com/~joconnor "God himself plays the bass strings first when He tunes the soul" From fredrik at effbot.org Sat Dec 9 05:21:57 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 09 Dec 2000 10:21:57 GMT Subject: PIL binary for Python 2.0 for Windows ? References: <3a2f472f$0$235@hades.is.co.za> Message-ID: <9JnY5.2716$O%.428568@newsc.telia.net> "Richard" wrote: > I have downloaded the dll & the PIL tar file Imaging-1.1.1.tar.gz. > > Please can you tell me where these file should be copied? (My Python 2.0 is > istalled under C:\Python20). put them anywhere on your Python path (if you don't know how Python searches for modules, look it up in the Python docs). also see the updated pil page: http://effbot.org/pil From mksql at my-deja.com Wed Dec 6 15:33:35 2000 From: mksql at my-deja.com (Matt) Date: Wed, 06 Dec 2000 20:33:35 GMT Subject: mxODBC + MSSQL = code -9 error (again) Message-ID: <90m7qv$rj2$1@nnrp1.deja.com> I am just starting to use the mxODBC package, and have come across an issue that has been posted in the newsgroups before, but I have not yet found a solution. I am using ActiveState Python 2.0 "ActivePython 2.0, build 202 (ActiveState Tool Corp.) based on Python 2.0 (#8, Oct 19 2000, 11:30:05) [MSC 32 bit (Intel)] on win32", on a Windows 2000 Professional PC, and attempting to connect to a Microsoft SQL Server 7.0 database, using a simple test script adapted from your documentation. Thes test script, included below, works fine when connecting to an Access database, so I am assuming my installation is valid. But, when I connect to a SQL Server database, and have a result set that includes a Unicode character data (SQLDMO_DTypeUVarchar -9 Variable length) type, I get the "InterfaceError: SQL type (code -9) not implemented" error. This is avoidable since my tables to not use Unicode fields, but apparently some of the SQL Server system tables do. The script below, when run against a MS Access DSN, properly returns a list of tables. But it appears the same call against the MS SQL DSN returns Unicode data in the result set (in c.tables). *** import ODBC db = ODBC.Windows.Connect('SQLTest','sa') c = db.cursor() c.execute('select count(*) from testdata') c.fetchone() c.tables(None,None,None,None) ODBC.print_resultset(c) c.close() db.close() Traceback (most recent call last): File "d:\python20\pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "D:\Python20\Lib\ODBC\Misc\sqltest.py", line 7, in ? ODBC.print_resultset(c) File "d:\python20\lib\ODBC\ODBC.py", line 75, in print_resultset lines = apply(format_resultset,(cursor,headers),kws) File "d:\python20\lib\ODBC\ODBC.py", line 33, in format_resultset rows = cursor.fetchall() InterfaceError: SQL type (code -9) not implemented Sent via Deja.com http://www.deja.com/ Before you buy. From MarkH at ActiveState.com Sat Dec 30 19:14:47 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 31 Dec 2000 00:14:47 GMT Subject: msxml3 and IStream interface References: <3A4D3814.6090201@ActiveState.com> Message-ID: <3A4E7956.5060903@ActiveState.com> David Bolen wrote: > Mark Hammond writes: > In a similar vein (already known interfaces versus not), I'm beginning > to look/work more with the server side of things, and was wondering > how one might go about using win32com to produce a COM server using a > non-IDispatch interface, where that interface wasn't one of the > predefined ones in pythoncom. > > Your book doesn't seem to really touch the construction of > non-IDispatch interfaces - is the most practical approach for me to > build a typelib via standard means (compiling an IDL), then use makepy > to define it for win32com, which then would let me declare it in the > _com_interfaces entry in my class? This will still only allow Python to implement it as (basically) an IDispatch based interface. To implement a true vtable interface like IStream, you really hav 2 choices: * Implement your own extension DLL, like win32comext\*.pyd * Dig into "univgw", a tool that is 85% of the way to being able to implement arbitary vtable interfaces given a TLB definition. > And if I'm intending to use these over DCOM and might involve > non-standard marshaling code, is there a way to make that code > available to win32com? I understood that interfaces registered their own marshalling proxies explicitly in the registry, and that the COM framework itself would use these behind the scenes for you. Of course, you still need to implement that marshalling code. > Book and/or code pointers are fine (I've saved various COM stuff from > you and Alex in the past which I'm still also going through). I'm afraid you are already into "use the source" territory! Mark. From aleaxit at yahoo.com Thu Dec 28 05:01:55 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 28 Dec 2000 11:01:55 +0100 Subject: A Suggestion for Python Colon Syntax References: Message-ID: <92f35001cbf@news1.newsguy.com> "Tim Peters" wrote in message news:mailman.977974330.23639.python-list at python.org... [snip] > despite not understanding much. Thoreau went on to make that principle the > basis of his form of poetry: Isn't Thoreau's poetry a rather minor part of his writings, despite his beautiful "if men read aright, methinks they would never read anything but poems" ... "after all, man is the great poet, and not Homer nor Shakespeare; and our language itself, and the common arts of life, are his work"? I always think of him mainly as a thinker, and writer of essays, rather than a poet. In a way, I think it's thus fortunate that the following snippet: > # Local Variables: > # py-indent-offset: 8 > # End: > # My Captain: Oh, My Captain! if, as you say, it was Thoreau's, ended up inspiring one Walt Whitman instead. Lincoln well deserved such a memorial, after all, and, as a versifier, I think Whitman had it all over Thoreau (which rather appreciated his poems, isn't it?). Alex From steve.waterbury at gsfc.nasa.gov Mon Dec 11 00:31:10 2000 From: steve.waterbury at gsfc.nasa.gov (Steve Waterbury) Date: Mon, 11 Dec 2000 00:31:10 -0500 Subject: NIST meeting: "Defining Standard, Scriptable Objects for CAD/CAE/CAM/PDM" Message-ID: <3A34669E.8FA938D8@gsfc.nasa.gov> "Defining Standard, Scriptable Objects for CAD/CAE/CAM/PDM" Date: December 13th Time: 10:00 AM - 4:00 PM Location: NIST, Building 225, Room A54 -> for directions and maps to NIST, see: http://www.nist.gov/public_affairs/maps/nistmaps.html * If you plan to come, you MUST contact Michael McLay, so that we are sure that the meeting room space is adequate: mailto:mclay at nist.gov - or call 301-975-4099 Background: Roughly, PDM ("Product Data Management") does for CAD/CAE/CAM models and related objects what Zope does for the objects that need to be managed in a typical Web site (HTML docs, etc.). Problem Statement The problem is to find an open architecture for integrating and managing the configuration of computer-aided design, analysis, and manufacturing (CAD/CAE/CAM) tools, models, and data. The purpose of the meeting is to evaluate technologies, try to define an approximate roadmap for building an open architecture, and establish a ROM guess of (1) how much work may be required to implement the architecture components and (2) the cost of developing and maintaining an instance of the architecture for an engineering organization. Agenda: * Engineering Tool/Data Integration Requirements Steve Waterbury/NASA * GenCAM: a Standard API for Electronic Manufacturing Data Michael McLay/NIST * The MEMS Exchange: Python and ZODB for Management of Complex Objects Andrew Kuchling/CNRI * The CADScript/IScript Architecture (and Demo) Doug Cheney/International TechneGroup, Inc. * Python and Zope: Architectures and Directions Barry Warsaw/Python Labs * Group discussion - How to incorporate interfaces to Python and Zope components such as ZODB into a standard PDM architecture - What enhancements to ZODB, ZCatalog, ZPatterns, etc., can address functionality and interfaces needed for general PDM - Which pieces of the architecture make the most sense as open source products, which ones are most logical as commercial products, and what interfaces should be standardized to enable open source and commercial products to interoperate. Cheers, -- Steve Waterbury NASA/Goddard Space Flight Center. oo _\o \/\ \ / ____________________________________________ oo _________________ "Sometimes you're the windshield; sometimes you're the bug." - Knopfler Stephen C. Waterbury Component Technologies Code 562, NASA/GSFC and Radiation Effects Branch Greenbelt, MD 20771 Engineering Web/Database Specialist Tel: 301-286-7557 FAX: 301-286-1695 WWW: http://misspiggy.gsfc.nasa.gov/people/waterbug.html _________________________________________________________________ From tcmay at got.net Sat Dec 9 19:29:45 2000 From: tcmay at got.net (Tim May) Date: Sat, 09 Dec 2000 16:29:45 -0800 Subject: Python Origins References: <90k3pq$50p$1@nnrp1.deja.com> <3A2EE2AF.AD8A51E2@caltech.edu> <90uddk$31f@gap.cco.caltech.edu> Message-ID: In article <90uddk$31f at gap.cco.caltech.edu>, Nathaniel Gray wrote: > Tim May wrote: > > > I did some work on simulated annealing while at Intel, which is why I > > commented in the SA thread. > > Wow. I hadn't even noticed it was the same person. This one's even > worse. > Just out of curiosity, why did you bother to take the time to do a > google > search just to castigate the original poster in that thread? Notice how you're the one fanning the flames in these threads? Like many fuzzy do-gooders, you preach "why can't we all just get along?", but in actuality you spread poison. > He didn't ask you to do a search. He asked if anybody had solved the > problem and would be willing to share their code. He was quite polite, > and > even explicitly stated that he'd already searched dejanews and > python.org. > What exactly did you take issue with? Did he use the wrong search engine > for your tastes? He has expressed happiness that he could find 1200 references, many of them applicable, to Python and simulated annelaing by using a better search engine. I didn't see _you_ providing any help, either in that thread or in this "Python origins" thread. Your role is apparently just to join in later and argue for niceness. You remind me of Alan Dershowitz. --Tim May -- ---------:---------:---------:---------:---------:---------:---------:---- Timothy C. May | Crypto Anarchy: encryption, digital money, ComSec 3DES: 831-728-0152 | anonymous networks, digital pseudonyms, zero W.A.S.T.E.: Corralitos, CA | knowledge, reputations, information markets, "Cyphernomicon" | black markets, collapse of governments. From gerson.kurz at t-online.de Tue Dec 26 01:03:40 2000 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Tue, 26 Dec 2000 06:03:40 GMT Subject: ~Python ? Message-ID: <3a4833f8.346848@news.t-online.de> On Linux, ~ usually refers to the users homedir, but not so in Python (at least, in ActivePython 2.0). I found out the hard way when using a script that issued os.makedirs() relative to ~ - It created an actual directory named ~. You can have real fun if you try to deleting an actual directory named ~ on Linux, boy. I understand that ~ is probably handled by the shell, but if Python doesn't deal with it, its hard to use Python in some kinds of scripts. (I think Perl, Pythons ugly twin-brother, does) From quinn at dinar.ugcs.caltech.edu Sat Dec 16 21:09:26 2000 From: quinn at dinar.ugcs.caltech.edu (Quinn Dunkan) Date: 17 Dec 2000 02:09:26 GMT Subject: Label-Value (was: Re: Inheriting the @ sign from Ruby) References: <914v6l02ouv@news2.newsguy.com> <5jvZ5.3588$Kd1.418770@newsb.telia.net> <3A368E11.20C17E92@san.rr.com> <3A380E4E.8537A0FB@san.rr.com> <91a1vr02b02@news2.newsguy.com> <91bbq102mtk@news1.newsguy.com> <91d5el0me7@news1.newsguy.com> Message-ID: On Fri, 15 Dec 2000 16:38:47 GMT, Rainer Deyke wrote: >Yes, in-place modification should be supported. I had something like this >in mind: > >class UserInt: > def __init__(self, value): > self.data = value > def __add__(self, other): > if isinstance(other, UserInt): > return self.__class__(self.data + other.data) > else: > return self.__class__(self.data + other) > __radd__ = __add__ > def __iadd__(self, other): > if isinstance(other, UserInt): > self.data += other.data > else: > self.data += other > # Repeat for all other operations > >UserInt as written is more properly UserNumber, since it supports longs ints >and floats. Just as a matter of style, would it be superior to add a __coerce__ method that knows how to coerce ints, longs, and floats into UserInts, or make an explicit check on each method? __coerce__ saves a lot of typing, but I'm generally wary of implicit things like coercion. When I implemented a class like this (a vector, actually), I used __coerce__, but after trying to wrap my brain around the control flow, I was thinking maybe I wouldn't next time, even though it seems to work fine. Is this fear unfounded? Is there a better way? From tdelaney at avaya.com Tue Dec 19 18:22:51 2000 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 20 Dec 2000 10:22:51 +1100 Subject: while true: !!! Message-ID: > > > >The idiom is actually > > > > > > > >while 1: > > > > > > > > do something > > > > > > > > if condition: > > > > break > > > > > > > > do something else > [snip] > > I go well out of my way to avoid this idiom, as I feel you > should always > > have the termination condition at one end of the loop, > preferably the top > > I disagree intensely with this stance: I strongly feel that the > loop-exit condition should be *in the most natural place for it*, > which is often the top, but not all that rarely elsewhere. > > Anyway, one doesn't have to go 'well' out of one way to hide > this clean, general loop structure as if it was otherwise -- > one 'status-variable' will suffice, e.g: > > looping = 1 > while looping: > do something > if condition: > looping = 0 > else: > do something else > > I think this is *substantially* less readable than the > clean, natural form: > > while 1: > do something > if condition: break > do something else I don't usually do this either, as it is actually *worse* unless there is a very obvious "thing" which the loop should end on. Instead, I attempt to create a situation where *all* the decision-making is encapsulated in the condition. This may well mean that I define a class or function which does something, supplying me with data and a loop exit condition. Again, the canonical example is reading a file: maybe_buffered_stream = MaybeBufferedFileInputStream(file_object) while maybe_buffered_stream.has_unread_contents: line = maybe_buffered_stream.readline() Tim Delaney Avaya Australia From robin at jessikat.fsnet.co.uk Tue Dec 5 05:15:18 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Tue, 5 Dec 2000 10:15:18 +0000 Subject: PyThreadState_Get error again :( References: <42+P6LAmqiK6Ewl1@jessikat.fsnet.co.uk> <3A2AD10F.8040803@ActiveState.com> <3A2C7488.4040005@ActiveState.com> Message-ID: In article <3A2C7488.4040005 at ActiveState.com>, Mark Hammond writes >Robin Becker wrote: > >> Is there any way to get 135 without reinstalling 2.0 or perhaps there >> has been a fix in that? Is it worth pursuing further? > >135 is available stand alone at >http://www.activestate.com/Products/ActivePython/win32all.html > >I would love to know if it is a problem there, as I can't repro on 98. >Obviously, this is not to suggest that 95 has a problem while 98 doesnt. > I no longer have 95 installed here. > >Mark. ... well the 135 release certainly fixes that problem on the Win95 OSR2 machine. -- Robin Becker From rrasche at dspace.de Thu Dec 7 10:06:28 2000 From: rrasche at dspace.de (Rainer Rasche) Date: Thu, 7 Dec 2000 16:06:28 +0100 Subject: UML and Python Message-ID: <90o91k$eks$1@desperado.vew-telnet.net> Hi, is somebody out there, who is interested in developing python applications with UML-CASE Tools (e. g. ObjectDomain) and wants to exchange some experiences with me? Thanks, Rainer rrasche at dspace.de From gherman at darwin.in-berlin.de Mon Dec 18 06:48:58 2000 From: gherman at darwin.in-berlin.de (Dinu C. Gherman) Date: Mon, 18 Dec 2000 12:48:58 +0100 Subject: Singleton vs Proxies DP (was Re: Solution: Direct access to Printer I/O lines) References: <917k9b$9i9$1@nnrp1.deja.com> <91cnp3$g59$1@nnrp1.deja.com> <91d23f0jk7@news1.newsguy.com> <91gfnp$7r4$1@animus.fel.iae.nl> <91gkh801e49@news2.newsguy.com> <3A3CB83D.45C8775E@darwin.in-berlin.de> <91iu95013ta@news2.newsguy.com> <3A3D1D49.1A453B51@darwin.in-berlin.de> <91kmfd020hp@news1.newsguy.com> Message-ID: <3A3DF9AA.74552346@darwin.in-berlin.de> Alex Martelli wrote: > > [gives well-reasoned explanations] Following your reasoning I do see there is a place for such solutions as you describe them. Luckily, patterns can (and, in fact, should) be tweaked and adapted a lot to the current needs (and "forces") at hand! Actually, I'm pretty sure there is already something like a singleton-like pattern with more of the properties you like. Maybe you should check Linda Rising's "Pattern Almanac" or similar sources? http://www.amazon.com/exec/obidos/ASIN/0201615673 Best regards, Dinu -- Dinu C. Gherman ................................................................ "The only possible values [for quality] are 'excellent' and 'in- sanely excellent', depending on whether lives are at stake or not. Otherwise you don't enjoy your work, you don't work well, and the project goes down the drain." (Kent Beck, "Extreme Programming Explained") From greg at cosc.canterbury.ac.nz Wed Dec 20 19:49:34 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 21 Dec 2000 13:49:34 +1300 Subject: while true: !!! References: <3A4024E5.98843CFC@cosc.canterbury.ac.nz> <91qadb$1di$1@plutonium.compulink.co.uk> Message-ID: <3A41539E.DF6977D6@cosc.canterbury.ac.nz> gbreed at cix.compulink.co.uk wrote: > > Take any type, and if > there's a way of it being nothing, it evaluates false. Hmmm, let's try that out. Is [[]] true or false? It's a list containing a list containing nothing. Since [] is false, a list containing nothing must be nothing. So [[]] is a list containing nothing, which is nothing. Ah, it must be false! :-) Nothing-is-weird-stuff, -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From sholden at holdenweb.com Tue Dec 19 08:29:46 2000 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 19 Dec 2000 08:29:46 -0500 Subject: while true: !!! References: <91nc7h0s0p@news2.newsguy.com> Message-ID: Alex Martelli wrote in message news:91nc7h0s0p at news2.newsguy.com... > "Rainer Deyke" wrote in message > news:KTz%5.48644$x6.22165257 at news2.rdc2.tx.home.com... > > "Steve Lamb" wrote in message > > news:slrn93t7bv.le.grey at teleute.rpglink.com... > > > On Mon, 18 Dec 2000 23:32:23 +0100 (MET), Carsten Geckeler > > > > > wrote: > > > >`while true' would be more readable and clear than `while 1'. By the > > way, > > > >explain a newbie that -1 is true. ;) > > > > > > 0 is true, all else is false. And? :P > > > > 0 is false, None is false, [] is false, () is false, {} is false, and x is > > false where x is a class instance and x.__nonzero__() returns false. > > Everything else is true. I think. > > Another couple of 'false's: a class instance which doesn't define > __nonzero__ but does define __length__ when the latter returns 0; > and, C-implemented user objects, similarly to class instances. > > I don't _think_ there are any more... > > > Alex > Nothing is true. All is permitted. Hassan-i-Sabbah regards Steve From aahz at panix.com Sun Dec 31 11:05:12 2000 From: aahz at panix.com (Aahz Maruch) Date: 31 Dec 2000 08:05:12 -0800 Subject: 2001 Enchancement Wishlist References: Message-ID: <92nlfo$3j5$1@panix3.panix.com> In article , Tim Peters wrote: > >I suggest you're off track in your modeling, confounding roles that should >be distinct: that of Plus as a function and Plus as an object (representing >an only partially evaluated sum). In this case I'd probably have a base >class Expression for all kinds of expresssions (incl. atoms like Symbols), >make Plus a function mapping zero or more Expressions (or subclasses) to an >Expression (or subclass), and make Sum a subclass of Expression that >represents a partially evaluated sum. That's the way I *think* of the >domain, so that's the way I'd want to code it (and, no, I'm not bothered by >having to come up with distinct names for the verb sense (Plus) and the noun >sense (Sum) -- the distinction between nouns and verbs is usually helpful!). Actually, to nitpick a bit, I'd suggest "Add" as the verb. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 Ninth Virtual Anniversary: Tomorrow! From un4e at rzstud1.rz.uni-karlsruhe.de Mon Dec 11 08:52:05 2000 From: un4e at rzstud1.rz.uni-karlsruhe.de (Bjoern Giesler) Date: 11 Dec 2000 13:52:05 GMT Subject: Modifying running code? [HACK ALERT] Message-ID: <912m65$pu1$1@news.rz.uni-karlsruhe.de> Hi, I'm writing a kind of mini runtime environment that lets me debug / correct buggy Python code "on the fly". This is supposed to work as follows: 1) an exception gets thrown by the buggy code and is caught by a toplevel exception handler 2) the toplevel handler figures out the function that caused the exception 3) the function source is loaded into an editor and can be corrected by the user 4) if the code has been saved, it is recompiled and inserted instead of the original function 5) the program is then resumed at the point where the original function had been called Can this be done in Python at all? Can it be done in regular Python or only in Stackless Python (which supports continuations and would therefore, I believe, make step 5 easy)? Is the whole thing complete bull doodoo? Any hints or suggestions? Thanks in advance for any input, --Bj?rn From nospam at caltech.edu Thu Dec 14 04:08:04 2000 From: nospam at caltech.edu (Nathan Gray) Date: Thu, 14 Dec 2000 01:08:04 -0800 Subject: Python Origins References: <90k3pq$50p$1@nnrp1.deja.com> <3A2EE2AF.AD8A51E2@caltech.edu> <90uddk$31f@gap.cco.caltech.edu> Message-ID: <3A388DF4.836440B4@caltech.edu> Tim May wrote: > In article <90uddk$31f at gap.cco.caltech.edu>, Nathaniel Gray > wrote: > > > Just out of curiosity, why did you bother to take the time to do a > > google > > search just to castigate the original poster in that thread? > > Notice how you're the one fanning the flames in these threads? Notice how you're avoiding the question? It's a simple question. Why go to the trouble of doing a search, which you claim is such an imposition on your time, if you're not planning to help out? On second thought, don't answer. The answer's pretty obvious, and this thread has outlived its expiration date. > > He didn't ask you to do a search. He asked if anybody had solved the > > problem and would be willing to share their code. He was quite polite, > > and > > even explicitly stated that he'd already searched dejanews and > > python.org. > > What exactly did you take issue with? Did he use the wrong search engine > > for your tastes? > > He has expressed happiness that he could find 1200 references, many of > them applicable, to Python and simulated annelaing by using a better > search engine. After apologizing profusely under the misguided impression that his question was somehow inappropriate for this newsgroup. For the record, Jochen, your question was just the sort of thing newsgroups were invented for. > I didn't see _you_ providing any help, either in that thread or in this > "Python origins" thread. Your role is apparently just to join in later > and argue for niceness. You're right. I definitely should have given Jochen my python code for simulated annealing. Oh wait, I don't have any -- that's why I didn't reply to his post. See how that works? If he'd asked for Matlab code simulating networks of integrate-and-fire neurons, on the other hand, I would have replied. I would have told him to take it to the Matlab newsgroup, but I also would have shared my code. > You remind me of Alan Dershowitz. So does yer mom! Shall we continue with "I know you are, but what am I," or shall we go straight to obscenities? How about we skip it? Over and out. -n8gray -at -caltech -dot -edu From dsh8290 at rit.edu Thu Dec 28 08:00:04 2000 From: dsh8290 at rit.edu (D-Man) Date: Thu, 28 Dec 2000 08:00:04 -0500 Subject: Is this a BUG? In-Reply-To: <3A4B0C5E.1E7976D2@wielun.dhs.org>; from qdlaty@wielun.dhs.org on Thu, Dec 28, 2000 at 10:48:14AM +0100 References: <3A4B0C5E.1E7976D2@wielun.dhs.org> Message-ID: <20001228080004.A13937@westsidecnc.rh.rit.edu> On Thu, Dec 28, 2000 at 10:48:14AM +0100, QdlatY wrote: > print "!",form["index"].value,"!" > ! 1 ! > ---------------- > ^ ^ > Why the hell there are spaces? index property has value '1'! > not ' 1 '?! This is a result of print trying to be convenient for you. If I write print "abc" , "def" I will get abc def as output. If I write print "abc" + "def" I will get abcdef If you use string concatenation when you print you will only get what you have (no spaces added) plus an EOL at the end. > > Yours > QdlatY -D From michael at stroeder.com Fri Dec 29 10:09:56 2000 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 29 Dec 2000 16:09:56 +0100 Subject: Python vs PHP (& Java?) References: <92f3kp01cqe@news1.newsguy.com> <3A4C8871.DB734376@stroeder.com> Message-ID: <3A4CA944.B02FB62B@stroeder.com> Cameron Laird wrote: > > In article <3A4C8871.DB734376 at stroeder.com>, > Michael =?iso-8859-1?Q?Str=F6der?= wrote: > >Moshe Zadka wrote: > >> > >> Apache modules. Yes, now that we have mod_snake, you > >> can do these things in Python, in theory: but mod_snake is still > >> young, while mod_perl is quite mature. > > > >mod_python? > > Did you intend to supply readers with directions > to ? Mainly I wanted to point out that mod_snake is not the only solution => IMHO the mod_perl argument is not 100% proven to be right. Thanks for adding the URL anyway. ;-) Ciao, Michael. From andreas at andreas-jung.com Wed Dec 20 14:02:34 2000 From: andreas at andreas-jung.com (Andreas Jung) Date: Wed, 20 Dec 2000 20:02:34 +0100 Subject: Problems compiling on Sunos5 In-Reply-To: ; from rvprasad@cis.ksu.edu on Wed, Dec 20, 2000 at 11:34:15AM -0600 References: Message-ID: <20001220200234.A5081@yetix.sz-sb.de> On Wed, Dec 20, 2000 at 11:34:15AM -0600, Venkatesh Prasad Ranganath wrote: > Hi, > > I am trying to compile Python 2.0 on Sunos 5. I am able to compile but many > functions are not being supported. When I execute configure, the list of > functions checked by configure are reported as not supported but all those > functions are available. For example, strftime() is reported as not available. > > Is this a problem with the configure script or something I have to specify when > configuring. My configure command was as follows > > configure --with-threads=/usr/lib --with-cycle-gc --without-libdb Usually you should not care about the functions available or not. When "make" works correctly and you have a running Python interpreter after the termination of "make" ...be happy...and "make install". I have never seen any real problems with the installation of Python under Solaris. Andreas From amk at mira.erols.com Wed Dec 13 20:03:14 2000 From: amk at mira.erols.com (A.M. Kuchling) Date: 14 Dec 2000 01:03:14 GMT Subject: Python-like compiled language References: <913jr3$dmv$1@sylvester.vcn.bc.ca> <3A35835B.AAA92005@bioeng.ucsd.edu> <9163mr02v2t@news1.newsguy.com> <917ipt023tk@news2.newsguy.com> Message-ID: On Wed, 13 Dec 2000 11:24:43 +0100, Alex Martelli wrote: >What about Modula-3, by the way? I gather that one has >similarities, too (having provided some of our BDFL's >inspiration), but don't know much about its compilers' >effectiveness. The Modula-3 compiler is quite elderly, being based on GCC 2.4.5 or something like that. There's an updated version, m3cgc1, that patches against more recent versions, but it doesn't seem to be very well-known. M3 appears to be withering away. Richard Watts, who maintained a now-dead branch of the Modula-3 compiler, wants to design Modula-4: www.modula-4.org, and current discussions in comp.lang.modula3. --amk From dsavitsk at my-deja.com Tue Dec 19 18:09:08 2000 From: dsavitsk at my-deja.com (dsavitsk at my-deja.com) Date: Tue, 19 Dec 2000 23:09:08 GMT Subject: python with VB/Delphi Message-ID: <91opqf$nr7$1@nnrp1.deja.com> the link form python.org to the tutorial on using vb/delphi interfaces to python programs seems to be no longer. does anyone know of a good tutorial on doing this. do people have a preference for one of these (or neither)? thanks doug Sent via Deja.com http://www.deja.com/ From mjackson at wc.eso.mc.xerox.com Tue Dec 5 20:36:15 2000 From: mjackson at wc.eso.mc.xerox.com (Mark Jackson) Date: 6 Dec 2000 01:36:15 GMT Subject: Python Origins References: <90k3pq$50p$1@nnrp1.deja.com> Message-ID: <90k56f$dhc$1@news.wrc.xerox.com> Nigel writes: > I am doing some research and I would be grateful if anybody could give > me some history on the origins of Python. But then you wouldn't really be doing any research, would you? Hint: there's *lots* of material to be found on, or linked from, www.python.org. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson I know nothing about this subject but I do have prejudices, which I am more than happy to share with you. - Leon Botstein From DanielK at aracnet.com Sun Dec 24 13:29:54 2000 From: DanielK at aracnet.com (Daniel Klein) Date: Sun, 24 Dec 2000 10:29:54 -0800 Subject: soundex (revisited) Message-ID: After seeing the post from several days ago on soundex, I gave it whirl to see if I could come up with something different (and possibly better), following the rules laid down by Knuth: def get_soundex(name, digits = 3): soundexcodes = "01230120022455012623010202" # ABCDEFGHIJKLMNOPQRSTUVWXYZ instring = name.upper() soundex = instring[0] last = soundex instring = instring[1:] for char in instring: if 65 <= ord(char) <= 90: sx = soundexcodes[ord(char) - 65] if int(sx) and char != last: soundex += sx last = char if len(soundex) < (digits + 1): soundex = (soundex + ("0" * digits)) return soundex[:digits + 1] As this is one of the first (complete) functions I have created in Python, all comments, suggestions, derogatory remarks :^) are welcome. One question: how is it that this understands the 'upper()' function without explicitly importing the 'string' module? Dan: From aleaxit at yahoo.com Fri Dec 22 03:20:31 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Fri, 22 Dec 2000 09:20:31 +0100 Subject: COM / Variants / VT_BOOL References: Message-ID: <91v2sv01rpp@news2.newsguy.com> "Stefan Migowsky" wrote in message news:mailman.977467384.30398.python-list at python.org... > You do not need to create a VARIANT ! The win32com library automatically > converts almost all Python objects to the corresponding VARIANT type. > Since VT_BOOL is just an int which is transmitted through the COM channel > you can use the simple Python 1 or 0, e.g. > server = win23com.client.Dynamic("XXX") > > server.Enabled = 1 # Set to true > server.Enabled = 0 # Set to false *Almost* right... but not *quite*, and we hit this specific problem quite recently (we weren't driving with Python, but I think that would have made no difference). VARIANT_BOOL (the content of VARIANT's discriminated union when its type-tag is VT_BOOL) is defined as a 16-bit value that is either 0 ('false') or 0xFFFF ('true'); other values are, it seems, "not permitted". Any 'sensible' server would 'of course' take any non-zero here as 'true'... but we just found out you cannot *COUNT* on that. Setting the property .ValidateOnParse of the Xerces XML parser (originally from IBM, now, I believe, from Apache), in its COM setting, to 0 *or* 1, still keeps the parser non-validating; you HAVE to set it to -1 or 65535 to make the parser a validating one. I have not checked the behavior of Microsoft's MSXML, which the packaging of Xerces as a COM server is apparently intended to generally mimic; but, anyway, I suspect the Xerces team will not acknowledge this as a 'bug', whatever MSXML does in the (non-documented, non-supported) case that one sets this 'boolean' property to a non-permitted value -- and, formally, they would, I guess, be right. I have not checked Xerces' sources to confirm this, but I guess that somewhere they're testing the property's value for "== VARIANT_TRUE". *Most* COM servers will happily accept 'server.BoolProp = 1' as setting the property to 'true', but, I suggest, don't count on that; use 'server.BoolProp = -1' and you might be safer. Alex From skip at mojam.com Fri Dec 22 11:57:50 2000 From: skip at mojam.com (Skip Montanaro) Date: Fri, 22 Dec 2000 10:57:50 -0600 (CST) Subject: ANNOUNCE: soundex.py In-Reply-To: <3A414897.D82C953C@gte.net> References: <3A414897.D82C953C@gte.net> Message-ID: <14915.34830.638362.635454@beluga.mojam.com> >>>>> "Steve" == Steve Williams writes: Steve> I've found you can good results with a variable length soundex Steve> string--the more information you give the routine (first names, Steve> middle names, prefixes and suffixes) the better/smaller the Steve> result set. Your wish is my command. The module at http://www.musi-cal.com/~skip/python/soundex.py now computes a variable-length soundex string if you set soundex.NDIGITS to 0: >>> soundex.NDIGITS=0 >>> soundex.get_soundex("montanaro") 'M5356' >>> soundex.get_soundex("merriweather clark") 'M6362462' >>> soundex.get_soundex('van der tamp, albert') 'V5363514163' >>> soundex.get_soundex('van der tamp, albert c, lieutenant colonel, Phd') 'V5363514163243553245413' Skip From fredrik at effbot.org Fri Dec 8 10:50:49 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 08 Dec 2000 15:50:49 GMT Subject: reading directory structure References: <90qtar$eve$1@narses.hrz.tu-chemnitz.de> Message-ID: Alexander Groten wrote: > I'm new in Python. > For a script I need a algorithm, that read a directory to a defined depth. > Similar FIND. > > I have no plan (in the moment). Any suggestions? os.path.walk for some info on how to prevent os.path.walk from traversing the whole disk, see: http://www.deja.com/=dnc/getdoc.xp?AN=695333869 From colaveaj at sirinet.net Fri Dec 8 05:00:27 2000 From: colaveaj at sirinet.net (Tony) Date: Fri, 8 Dec 2000 10:00:27 -0000 Subject: window placement w/ Tkinter Message-ID: I am creating GUI apps and cant figure out how to set the placement on the screen of my frames. I dont see anything in the constructor for it. How is this done? From kragen at dnaco.net Sun Dec 31 08:03:25 2000 From: kragen at dnaco.net (Kragen Sitaker) Date: Sun, 31 Dec 2000 13:03:25 GMT Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <92m9pm$d19$1@nnrp1.deja.com> <3A4EC5B1.8912E571@engcorp.com> Message-ID: In article <3A4EC5B1.8912E571 at engcorp.com>, Peter Hansen wrote: >Kragen Sitaker wrote: >> >> The only time I wish I wasn't subject to Python's indentation rules is >> when I can't outdent my "if finished(): break" statements like I do in >> C. > >But why would you want to outdent it? It's *part* of the loop, not a >following statement. Identation should match the block structure of the >code, and that statement lies _within_ the block. I would want to outdent it because, in my view, it isn't part of the loop body; it's part of the loop structure itself, just like the while 1: at the beginning. It is not within the block of code controlled by the loop. In fact, it comes *between* two blocks of code controlled by the loop, much as else: comes between two blocks of code controlled by an if (or, in Python, a for or while). Indenting it with the rest of the code makes it appear as if there is only one block of code, when in fact there are two basic blocks that will run different numbers of times. -- Kragen Sitaker Perilous to all of us are the devices of an art deeper than we possess ourselves. -- Gandalf the White [J.R.R. Tolkien, "The Two Towers", Bk 3, Ch. XI] From eff at my-deja.com Wed Dec 20 06:00:45 2000 From: eff at my-deja.com (eff at my-deja.com) Date: Wed, 20 Dec 2000 11:00:45 GMT Subject: while true: !!! References: <4bY%5.172261$U46.5444054@news1.sttls1.wa.home.com> Message-ID: <91q3gr$nbr$1@nnrp1.deja.com> Greg Jorgensen wrote: > This thread is a great example of what newsreader filters > are good for. so? this newsgroup is cross-linked with a mailing list. how about showing the people on that list some respect? > Obviously quite a few of us are getting something out of it. lots of new names in the killfile, you mean? Sent via Deja.com http://www.deja.com/ From boud at rempt.xs4all.nl Fri Dec 29 14:46:45 2000 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 29 Dec 2000 19:46:45 GMT Subject: Kanji References: <92dl3u$to0$1@news.idiom.com> <92f3n7$hsf$1@news1.xs4all.nl> Message-ID: <92ipn5$cf4$1@news1.xs4all.nl> Marcin 'Qrczak' Kowalczyk wrote: > 28 Dec 2000 10:12:55 GMT, Boudewijn Rempt pisze: >> And Kura is a language database written entirely in Python and Qt >> which reached feature-complete stage yesterday... > "Kura" means "hen" in Polish BTW. It's Nepali for language - and it's a word in Japanese and Maori, too. I sometimes get hits from people called Kura who're looking for their web presence... By the way, version 0.99 is now on my website, and includes a Pinyin input method for Chinese. I've used to enter a bit of Mencius: http://www.valdyas.org:8000/KURA?command=record?table=lng_text?textnr=17 (Make sure you're using the utf-8 encoding; some browsers don't pick it up from the html.) -- Boudewijn Rempt | http://www.valdyas.org From sill at localhost.kitenet.net Fri Dec 15 16:59:56 2000 From: sill at localhost.kitenet.net (Oldayz) Date: Fri, 15 Dec 2000 21:59:56 GMT Subject: while true: !!! References: <8uthf2$pjh$04$1@news.t-online.com> <8utnqk02rlq@news1.newsguy.com> <8uu44b$4nc$04$1@news.t-online.com> <3A34CEA7.CD9D85AE@yahoo.com> <3A36368C.26AADDDE@yahoo.com> <915jcf0c6o@news2.newsguy.com> <9162p3$7t2$1@animus.fel.iae.nl> <3A397C74.6C8906E1@cosc.canterbury.ac.nz> <91d5520m6j@news1.newsguy.com> Message-ID: On Fri, 15 Dec 2000 14:08:15 +0100, Alex Martelli wrote: >"Greg Ewing" wrote in message >news:3A397C74.6C8906E1 at cosc.canterbury.ac.nz... >> Oldayz wrote: >> > >> > I thought something like forever: would be even more lucid >> >> If there is a break in the loop somewhere, it's >> not really forever, though, is it? >> >> So perhaps it should *really* be >> >> for a while: >> ... >> >> :-) Sarcasm notwithstanding, I think forever: makes sense because the idiom suggests the code will execute forever, unless something (say a break statement) stops it. The question is whether while 1: is common enough to deserve a separate name for it - to be honest, i'm almost certain it does not, even though it's a matter of taste. Hey, how about if you think while 1: looks ugly you do true = 1 somewhere on top and use while true: ? I think it's much more obvious and clean and you don't need to change syntax. Ideally, language should stay fairly close to the way we normally think; in this case it's the difference between thinking 'walk north until the heat death of the universe BUT if you see grocery, get in, buy apple juice and return home' and 'go to grocery, buy apple juice and return home'. I usually think in a latter manner but YMMV ;-). OTOH, i'm a newbie and I can be totally off base here, am I? -- Andrei From dsh8290 at rit.edu Mon Dec 18 15:12:25 2000 From: dsh8290 at rit.edu (D-Man) Date: Mon, 18 Dec 2000 15:12:25 -0500 Subject: while true: !!! In-Reply-To: ; from tim.one@home.com on Mon, Dec 18, 2000 at 01:15:39PM -0500 References: <20001218085229.A10917@westsidecnc.rh.rit.edu> Message-ID: <20001218151225.A12029@westsidecnc.rh.rit.edu> On Mon, Dec 18, 2000 at 01:15:39PM -0500, Tim Peters wrote: > [D-Man] > > I think that some people were confused with this statement. He meant > > that 'true' and 'false' would be constants like in C++ and Java. It > > would be illegal to try > > > > true = false > > ... > > A non-empty string literal is true, and unalterably so, so everyone can be > happy writing: > > while "forever, because stupid Guido won't define 'true'": > wink Yes, true should be defined as a global constant, but this is almost as good : while 'true' : :-) Good point Tim. From qrczak at knm.org.pl Sun Dec 31 05:31:33 2000 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: 31 Dec 2000 10:31:33 GMT Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> Message-ID: Sat, 30 Dec 2000 22:21:12 -0500, Andrew Henshaw pisze: > a) > do: > R=Themistor.ReadResistance() > T=R_to_Temperature(R) > until (T>=25) > If a), then this looks very unPythonic, because the indentation > blocking is backwards. In other words "until (T>=25)" is a control > statement for an indented block that is above it (and it doesn't > have a ":"). do: R=Themistor.ReadResistance() T=R_to_Temperature(R) :until (T>=25) -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZAST?PCZA QRCZAK From kalle at gnupung.net Fri Dec 8 11:19:44 2000 From: kalle at gnupung.net (Kalle Svensson) Date: Fri, 8 Dec 2000 17:19:44 +0100 Subject: Refactoring browser In-Reply-To: <3A31047A.A7E880EF@mail.vega.bg> References: <3A31047A.A7E880EF@mail.vega.bg> Message-ID: On Fri, 8 Dec 2000, Stefan Boiadjiev wrote: > Do in python world exist something similar to Smalltalk Refactoring > browser ? There is a project called Bicycle Repair Man. http://bicyclerepair.sourceforge.net/ Regards, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) Not signed due to logistical difficulties (I'm not at home). If you doubt the authenticity of this message, please tell me. From tim at 2wave.net Wed Dec 20 13:22:14 2000 From: tim at 2wave.net (tim at 2wave.net) Date: Wed, 20 Dec 2000 18:22:14 GMT Subject: DCOracle-1.3.2 makefile problem .er. opportunity? Message-ID: <91qtcd$dic$1@nnrp1.deja.com> Hi I'm no makefile expert, I'm afraid, and am trying to build DCOracle- 1.3.2 in Linux 7 (for Oracle 8.1.6), and not succeeding :-(. I've followed the makefile instructions provided, and get to the problem below. I haven't found any references to others having this problem on comp.lang.python, so I wonder if any of you who have been down this path before recognise the error - and point me in directions which might overcome it! ------------------------------ root> makefile -f Makefile.pre.in boot rm -f *.o *~ rm -f *.a tags TAGS config.c Makefile.pre python sedscript rm -f *.so *.sl so_locations VERSION=`python -c "import sys; print sys.version[:3]"`; installdir=`python -c "import sys; print sys.prefix"`; exec_installdir=`python -c "import sys; print sys.exec_prefix"`; make -f ./Makefile.pre.in VPATH=. srcdir=. VERSION=$VERSION installdir=$installdir exec_installdir=$exec_installdir Makefile make[1]: Entering directory `/home/tim/rpms/DCOracle-1.3.2/src' make[1]: *** No rule to make target'/usr/lib/python1.5/config/Makefile' needed by 'sedscript'. Stop. make[1]: Leaving directory `/home/tim/rpms/DCOracle-1.3.2/src' ------------------------------------------------ Thanks Tim Sent via Deja.com http://www.deja.com/ From root at rainerdeyke.com Fri Dec 15 11:38:47 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 15 Dec 2000 16:38:47 GMT Subject: Label-Value (was: Re: Inheriting the @ sign from Ruby) References: <914v6l02ouv@news2.newsguy.com> <5jvZ5.3588$Kd1.418770@newsb.telia.net> <3A368E11.20C17E92@san.rr.com> <3A380E4E.8537A0FB@san.rr.com> <91a1vr02b02@news2.newsguy.com> <91bbq102mtk@news1.newsguy.com> <91d5el0me7@news1.newsguy.com> Message-ID: "Alex Martelli" wrote in message news:91d5el0me7 at news1.newsguy.com... > "Rainer Deyke" wrote in message > news:rWd_5.26820$x6.14119694 at news2.rdc2.tx.home.com... > [snip] > > > > class MutableInt(UserInt.UserInt): > > > > def set(self, value): > > > > self.data = value > > > > > > UserInt is not in the Python 2 docs, though it's nice to hear it > > exists:-). > > > > Actually it doesn't, but it's trivial (if tedious) to implement. > > But, if UserInt is not a funky metaclass, how will MutableInt live > up to its name? Surely it should at least redefine all of the > in-place methods...: > > x = y = MutableInt(23) > x += 1 Yes, in-place modification should be supported. I had something like this in mind: class UserInt: def __init__(self, value): self.data = value def __add__(self, other): if isinstance(other, UserInt): return self.__class__(self.data + other.data) else: return self.__class__(self.data + other) __radd__ = __add__ def __iadd__(self, other): if isinstance(other, UserInt): self.data += other.data else: self.data += other # Repeat for all other operations UserInt as written is more properly UserNumber, since it supports longs ints and floats. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From Alok_k at infy.com Thu Dec 28 04:12:42 2000 From: Alok_k at infy.com (Alok_k) Date: Thu, 28 Dec 2000 14:42:42 +0530 Subject: python faqs by email Message-ID: <19CC5A519D17D2118E9C0008C7F4327502217AFD@TWRMSG02> Hi list I don't have access to the web but I do have email access. Is it possible to get hold of python faqs thru email? some that will be helpful to a c++ programmer in learning python. Regards, Alok From tim.one at home.com Wed Dec 27 23:32:49 2000 From: tim.one at home.com (Tim Peters) Date: Wed, 27 Dec 2000 23:32:49 -0500 Subject: One Python 2.1 idea In-Reply-To: <20001227104140.F25820@xs4all.nl> Message-ID: [posted & mailed] [Tim] > >>> class Oops: > ... [Thomas Wouters] > Funny, I didn't see that original message. I guess the list is > still a little flabergasted over being moved and Barry apparently > abandoning it (because of his lack of connectivity) ;) Best I can tell, mail->news works great now, in that emails to python-list at python.org show up on local news servers very quickly (minutes). But for reasons not yet understood, the mailing-list version is experiencing random long delays, and this is true of all the mailing lists hosted at mail.python.org. I haven't seen evidence that any msgs are getting lost, but multi-hour delays are common, and I've seen a few delayed by a full day. Barry is indeed whining about his lack of connectivity, as if you need megabit speeds to look at a stinking mail header . About x.foo = x.foo, I never saw anyone suggest that to save time, before this thread. Where it did come up several times over the years was people trying to customize how a method works for a particular instance, rather than make a proper subclass. Since Python made instance.__class__ writable, I don't see any excuse for *that* form of trickery anymore. but-i-guess-whatever-isn't-forbidden-is-mandatory-ly y'rs - tim From aleaxit at yahoo.com Sat Dec 23 03:17:49 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sat, 23 Dec 2000 09:17:49 +0100 Subject: Good introduction to functional programming with Python? References: Message-ID: <921nd205si@news2.newsguy.com> "Tim Peters" wrote in message news:mailman.977553967.26987.python-list at python.org... [snip] We agree on far too much, and dwelling on agreements ain't no fun, so, let's pick on a difference: > If it is, then if FP is "about" anything, it's about the art of using > higher-order functions, and I believe mere mortals *need* a strong static > typing system to keep those straight. Maps returning maps returning maps > ... can get hard to follow real fast. Erlang designers and practitioners seem to disagree: and Erlang is arguably the FP around which most $$$ turn in today's real-world, what with its use in Ericsson and Bluetail's acquisition by a Nortel subsidiary. I have no real experience with it, and thus no solid basis on which to judge it, but, sordid materialist that I am, I _am_ impressed when hundreds of megabucks are in play:-). And Erlang relies on strong dynamic (aka latent) typing, and an emphasis on concurrency in an FP setting, to (allegedly) reach good levels of reliability, performance, ease of learning, programmer productivity. Static typing has its place, but so, it appears, does latent typing, even in FP. > > or Unixoid. (Not that Haskell's and Erlang's implementations > > are any less free, cross-platform, and good-quality, but, IMHO, > > Rice's Scheme has characteristics that make it even better). > > A caution that this depends on how powerful his computer is: DrScheme is > too much a resource hog for a satisfying experience on older Windows boxes > (voice of experience). This is a bit ironic, since Scheme is ported at > least as often as Python to tiny platforms. You pay through the nose for > "all the trimmings" that come with DrScheme. Worth it if you can afford it! Thanks for the warning! The oldest machine on which I had tried Rice Scheme's had a Pentium-133 and 32M RAM, and they seemed to run fine there -- with older boxes yet, a smaller implementation is no doubt better! Alex From rpm at wag.caltech.edu Sun Dec 17 13:36:45 2000 From: rpm at wag.caltech.edu (Richard P. Muller) Date: Sun, 17 Dec 2000 10:36:45 -0800 Subject: Error evaluating numbers starting in zero Message-ID: <3A3D07BD.85EFEB3D@wag.caltech.edu> I'm sure people already know about this, but I just got hit with a really screwy error. I have a python checkbook program that evaluates date strings, such as "01/31/99". Most dates are fine, but if I have a date such as "01/08/99", python runs into an error when it tries to eval("08"). I can see how this might be a feature and not a bug, in that it interprets numbers starting in "O" as octyl. My workaround is the function: def chop_leading_zeros(str): # removes a single leading zero from a string to be evaluated # I think it interprets these numbers as Octyl if str[0] == '0': str = str[1:] return str Does anyone have a simpler or more elegant workaround? From aleaxit at yahoo.com Tue Dec 19 12:11:16 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 19 Dec 2000 18:11:16 +0100 Subject: Events in win32com References: Message-ID: <91o4sk01jdb@news2.newsguy.com> "Paul Moore" wrote in message news:Y1g=Op6IfWSoJn1ISFtOyuvqwBb3 at 4ax.com... > If I create an object using > > obj = win32com.client.Dispatch(progid) > > can I see events from the object? You can, although using DispatchWithEvents may be easier. This is a typical example...: import win32com.client from win32com.client import gencache evmod = gencache.EnsureModule('{D240EC61-B6ED-11D4-9E45-0060B0EB1D67}', 0, 1, 0) class Evhand: def OnOne(self): print "eh: One!" def OnTwo(self): print "eh: Two!" class Other(evmod._IEvGenEvents2): def OnOne(self): print "oh: One!" def OnTwo(self): print "oh: Two!" ob = win32com.client.DispatchWithEvents("evts.EvGen", Evhand) oh = Other(ob) ob.Fire() where progid 'evts.EvGen' refers to a tiny object I built just for the purpose of event-handling tests (it generates events along different sourceinterfaces when you call its Fire method). This shows we can get events separately from DispatchWithEvents (and on a different sourceinterface than the default one, if we know the name of that alternate sourceinterface!). > In WSH the CreateObject method has > an extra parameter which is the prefix for subroutine names which are > called on an event, something like > > ie = WScript.CreateObject("InternetExplorer.Application", "ie_") > > Sub ie_OnQuit() > End Sub > > While I don't like the "specially named subroutine" approach, I do > need to be able to sink events in Python. Is this possible, or should > I resort to using Python via WSH? It's quite possible to avoid WSH, unless you like the services it brings to your script. > (BTW, assuming I can sink events, will Python handle ByRef event > parameters - for example, a Cancel parameter which is set to True in > the handler to stop the event occurring). If your EnsureModule (or equivalent) has been called, so that Python *knows* exactly what's happening, then, yes, [out] and [in,out] parameters will be handled (COM has no 'byref', but that's how VB maps [in,out] -- [out] is a big problem in VB), but of course they'll be handled for events as in other COM Python cases -- that is, they become extra _return values_ of your method. Alex From rapto at arrakis.es Mon Dec 18 14:11:15 2000 From: rapto at arrakis.es (Marcos =?iso-8859-1?Q?S=E1nchez?= Provencio) Date: Mon, 18 Dec 2000 20:11:15 +0100 Subject: More docs in =?iso-8859-1?Q?Spanish=2FM=E1s?= madera References: <5.0.2.1.0.20001218105723.00a232e0@mail.codeit.com> Message-ID: <3A3E6153.CA888DF5@arrakis.es> Julio Flores Schwarzbeck wrote: > > I believe you meant http://pySpanishDoc.sourceforge.net/ > > Probablemente te refieres a: http://pySpanishDoc.sourceforge.net/ > > Saludos, > > At 06:01 PM 12/18/00 +0000, rapto at arrakis.es wrote: > >New files in > >Ficheros nuevos en > >http://pySpanishDoc/sourceforge.net/ > > > > > >Sent via Deja.com > >http://www.deja.com/ > >-- > >http://www.python.org/mailman/listinfo/python-list Indeed. Thank you very much. Corcho, vaya gamba. M?s vale vigilarme. From pearu at cens.ioc.ee Sat Dec 30 03:52:10 2000 From: pearu at cens.ioc.ee (Pearu Peterson) Date: Sat, 30 Dec 2000 10:52:10 +0200 Subject: 2001 Enchancement Wishlist In-Reply-To: <3A4CEACB.220998A0@javanet.com> References: <3A4CEACB.220998A0@javanet.com> Message-ID: On Fri, 29 Dec 2000, Raymond Hettinger wrote: > 3. __init__ is the only special method that doesn't allow a return value. > I think it should continue to return the new object by default but also > allow another return item to be substituted. For example: > > def __init__( self ): > if MyClass.aSingleton == None: > MyClass.aSingleton = self > return MyClass.aSingleton I see that many Python experts are against this proposal but anyway, I would like to support this idea with the following examples. Say, I would like to define class Real: def __init__(self,num): self.num = num class Complex: def __init__(self,real,imag): if imag == 0: return Real(real) self.real,self.imag = real,imag That is, if imaginary part of a Complex number is zero, it's constructor would return Real instance: >>> a = Complex(1,2) >>> b = Complex(1,0) >>> print a.__class__.__name__,b.__class__.__name__ Complex Real Yes, I could cover this example in Python 2.0 by defining: class Complex: def __init__(self,real,imag): if imag == 0: self.__class__ = Real self.real = real else: self.real,self.imag = real,imag but it works only if __init__ should "return" a class instance. For example, the following behavior cannot be handled in Python 2.0: class NonZeroInteger: def __init__(self,num): if num == 0: return 0 self.num = num so that >>> type(NonZeroInteger(2)),type(NonZeroInteger(0)) (, ) Sure, one can write wrapper functions (as some of you already suggested): class _Complex: ... def Complex(real,imag): if imag == 0: return Real(real) return _Complex(real,imag) but I think that this way is actually a very unpythonic one, especially if there is much simpler/cleaner solution available (that is, possible), that is, allowing __init__ return arbitrary object. I have used these number classes only for demonstration, but there are real situations where 'rich' __init__ would be very useful. For example, in PySymbolic there are classes Plus, Symbol, etc and gmpy numbers that are objects. E.g. class Plus represents a sum of its elements (arguments): c = Plus(a,b,c) -> c = a + b + c # c is Plus instance where a,b,c are Symbol instances. Now, if one constructs a Plus instance only with one argument, c = Plus(a) -> c = a # c is Symbol instance ***lots of code*** could be avoided with rich Plus.__init__ that would return in this case Symbol instance a. If the argument to Plus constructor is gmpy number: c = Plus(mpz(3)) -> c = mpz(3) # c is mpz type object then rich Plus.__init__ would return mpz object. So, in my humble opinion, rich __init__ would be very useful feature. Pearu From erno-news at erno.iki.fi Sun Dec 24 14:17:50 2000 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 24 Dec 2000 21:17:50 +0200 Subject: PEP 222 draft References: Message-ID: >>>>> "A" == A M Kuchling writes: | The cgi.py module would be deprecated. (XXX A new module or | package name hasn't been chosen yet: 'web'? 'cgilib'?) i would like it more to add the new stuff to the existing cgi module rather than having old/new modules with slightly different variations of the same name. | XXX open issues: naming convention (studlycaps or | underline-separated?); need to look at the cgi.parse*() functions | and see if they can be simplified, too. StudlyCaps for classes and underline_separated for the rest! | # The Response class borrows most of its methods from Zope's # | HTTPResponse class. | def redirect(self, url): "Redirect the browser to another | URL" pass i think this is spurious, there is the status method already, and you don't know which of the various 30x responses is most appropriate here. | # XXX methods for specific classes of error:serverError, # | badRequest, etc.? i like cacheability, maybe expires/last-modified/vary but maybe that's spurious too. | class Request: | """ Attributes: | XXX should these be dictionaries, or dictionary-like | objects? .headers : dictionary containing HTTP headers .cookies : | dictionary of cookies .fields : data from the form .env : | environment dictionary """ probably dictionary-like, since there can be several occurrences of a single header and the order might matter. [...] | # Should people just use the dictionaries directly? def | getHeader(self, name, default=None): pass "getList" too? | # Possibilities? I don't know if these are worth doing in | the # basic objects. def getBrowser(self): "Returns | Mozilla/IE/Lynx/Opera/whatever" do you mean attempting something more than just returning the user-agent header? that seems highly unwise to me. many browsers (opera, konqueror, msie atleast) lie in the user-agent header and it's not possible to decipher it robustly and future-proofly. and most of the situations where misguided cgi programmers want to do user-agent sniffing is exactly differentiating between these. -- erno From junaftnoon at nospamplzyahoo.com Sat Dec 30 14:29:59 2000 From: junaftnoon at nospamplzyahoo.com (June Kim) Date: Sun, 31 Dec 2000 04:29:59 +0900 Subject: Running Boa Contructor with the latest versions of Python & wxPython Message-ID: <92ld65$4un$1@news.nuri.net> I tried to run BC on my windows machine installed with the lastest versions of Python(2.0) and wxPython(2.2.2) and got the following error. Any roundabout ways to run it besides downgrading the Python and wxPython? Traceback (most recent call last): File "boa.py", line 119, in ? main() File "boa.py", line 112, in main app = BoaApp(0) File "boa.py", line 49, in __init__ wxApp.__init__(self, redirect) File "c:\python20\wxPython\wx.py", line 1646, in __init__ _wxStart(self.OnInit) File "boa.py", line 58, in OnInit self.main = Palette.BoaFrame(None, -1, self) File "Palette.py", line 157, in __init__ wxMenu(), self.componentSB, app)#palettePage.menu File "Editor.py", line 135, in __init__ self.addShellPage() File "Editor.py", line 310, in addShellPage self.tabs.AddPage(ShellEditor.ShellEditor(self.tabs, -1), 'Shell') File "ShellEditor.py", line 26, in __init__ PythonStyledTextCtrlMix.__init__(self, wId, -1) File "Views\StyledTextCtrls.py", line 137, in __init__ self.SetKeywords(0, AttributeError: 'ShellEditor' instance has no attribute 'SetKeywords' From fredrik at effbot.org Fri Dec 29 15:36:23 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Fri, 29 Dec 2000 20:36:23 GMT Subject: Question re: eval() References: <978109654.339714327@news.silcom.com> Message-ID: Clarence Gardner wrote: > I want to eval() an expression, but have some of the variables in it be > lazily evaluated. E.g., > > class D: > def __getitem__(self, name): > if name == 'n': > return 3 > > d = D() > x = eval('n + 1', d) > > but the eval function accepts only a dictionary as the second parameter. > Is there any amazing way to do this? not really "lazy" evaluation, but the following trick lets you figure out what names you need to define before evaluating it: def getvalue(name): # get value of variable "name" print "fetch", name return len(name) myexpr = "a + bb + ccc" # compile expression code = compile(myexpr, "", "eval") # populate dictionary dict = {} for name in code.co_names: dict[name] = getvalue(name) print "result", eval(code, dict) From aahz at panix.com Fri Dec 22 01:31:00 2000 From: aahz at panix.com (Aahz Maruch) Date: 21 Dec 2000 22:31:00 -0800 Subject: Thread time-out in python References: <91m3vv$hfg$1@nnrp1.deja.com> Message-ID: <91usf4$1db$1@panix3.panix.com> In article <91m3vv$hfg$1 at nnrp1.deja.com>, wrote: > >In my application, I spawn a thread and give it some work. Here, I need >to be notified if that thread does not finish the assigned task in >certain time limit. Could anyone suggest me what would be the best >way to do it, if any? You'd probably need a second thread to act as a timer. The problem is that you need a way to notify the first thread to stop working, and that can only happen if the first thread is processing work in small enough chunks that it is easily interruptable. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 I don't really mind a person having the last whine, but I do mind someone else having the last self-righteous whine. --Aahz From dsh8290 at rit.edu Sun Dec 17 23:57:56 2000 From: dsh8290 at rit.edu (D-Man) Date: Sun, 17 Dec 2000 23:57:56 -0500 Subject: while true: !!! In-Reply-To: ; from tdelaney@avaya.com on Mon, Dec 18, 2000 at 11:03:31AM +1100 References: Message-ID: <20001217235756.A9804@westsidecnc.rh.rit.edu> On Mon, Dec 18, 2000 at 11:03:31AM +1100, Delaney, Timothy wrote: > > while 1: > > try to read a line from a file > > if we didn't get a line: > break > > do something with the line > This is precisely where having assigment as an expression (like C/C++) is useful : while ( (line = file.readline()) != None ) : do something with the line Even a do-while loop doesn't solve this idiom ideally, you need to read the line before the loop test and the test must occur before using the line. Maybe adding some sort of peek function to file objects could solve this : while ( file.exists_next_line() ) : line = file.readline() do something with the line -D From aahz at panix.com Thu Dec 7 20:39:30 2000 From: aahz at panix.com (Aahz Maruch) Date: 7 Dec 2000 17:39:30 -0800 Subject: problems with urllib in Python20? References: <90pdir$k7$1@bob.news.rcn.net> Message-ID: <90pe4i$7fk$1@panix6.panix.com> In article <90pdir$k7$1 at bob.news.rcn.net>, Z 3 Penguin wrote: > >whenever i try to use urllib.urlopen() in Python20/Win32, i get this error: >-START- >Fatal Python error: Interpreter not initialized (version mismatch?) By "Win32" do you mean Win 3.1 with Win32 extensions or what? I've used Python20 and urllib on Win98SE with no problems. -- --- Aahz (Copyright 2000 by aahz at pobox.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 What if there were no rhetorical questions? --Aahz From sholden at holdenweb.com Tue Dec 19 08:22:31 2000 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 19 Dec 2000 08:22:31 -0500 Subject: while true: !!! References: Message-ID: Greg Jorgensen wrote in message news:DnD%5.166633$U46.5342944 at news1.sttls1.wa.home.com... > "Blair Lowe" wrote: > [snip] > > You can define true and false yourself, as many C/C++ header files do, but > then you run the risk of stuff like this: > > true = 1 > false = 0 > ... > a = len(s) > if a == true: # fails unless a is 1 > I've always tried to discourage students from comparing a Boolean with a constant, but it can be difficult to get the point over that (a) can evaluate as true even though (a == some_constant) may well evaluate to false. Clearly, if what you have is a Boolean value (i.e. one which can be used as the expression in an "if" statement) then it's adding inefficiency to compare it with something, when what should be used is either if a: or if not a: This works quite nicely in Python: >>> not "forever" 0 >>> not () 1 >>> not(1,2,3) 0 although I have worked in languages where, due to bad semantics, any non-zero value was treated as true, and the "not" operator simply did a bitwise inversion, so (not {something true}) also evaluated true. Be that as it may, I would still argue it's bad pedagogy to suggest that people write "if Boolean == true_constant", since this *should* (but sometimes isn't, in poorly designed languages) be equivalent to "if Boolean". > It's much harder to track this kind of thing down than learning once in your > career what "while 1" means. > > > While "while 1" (pardon the pun) is a standard fixture that anyone > > with any experience knows what is going on, the whole point is to > > make all our code readable so that we, and others can maintain it and > > reuse it easily. > > Exactly--that's why learning idioms is as important as learning syntax. > This is why c.l.p. is so helpful: the idioms are regularly presented. > > Although the definition is cryptic, the resulting code is > > very readable. That is what we want. > > Until it doesn't work. Encountering "while true:" in a program, a newbie may > assume that true is a Python keyword. I remember a C++ programmer I worked > with who though that true and false were keywords until he discovered this > (typical) definition in a header file: > > enum { false = 0, true = -1 }; > Although one could argue that he was using a local idiom. But in general, and especially in a learning environment, cryptic definitions aren't always waht you want. If someone then wants to look "under the hood" they have to reach a new level of understanding. "while 1" isn't really that difficult! regards Steve From bartig at my-deja.com Mon Dec 11 14:15:14 2000 From: bartig at my-deja.com (bartig at my-deja.com) Date: Mon, 11 Dec 2000 19:15:14 GMT Subject: dictionaries thread safe Message-ID: <91393q$opb$1@nnrp1.deja.com> I'm writing a program that passes dictionaries into a function that's being threaded. Are dictionaries thread safe? Sent via Deja.com http://www.deja.com/ Before you buy. From MarkH at ActiveState.com Sat Dec 9 19:50:56 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Sun, 10 Dec 2000 00:50:56 GMT Subject: Implementing IPersistStorage using PythonCOM References: <3A307D8C.10909@ActiveState.com> <3A317651.5000109@ActiveState.com> Message-ID: <3A32D22B.3050901@ActiveState.com> IPersistStorage is pretty badly broken when trying to implement it from Python. A really obvious error in PyGPersistStorage.cpp. I have fixed it here, but not too sure how that helps you - if you are building from sources, then you can simply get a new CVS update and rebuild. If you aren't I could try mailing you a new pythoncom20.dll Mark. From pbjorn at uswest.net Sat Dec 23 12:32:25 2000 From: pbjorn at uswest.net (Bjorn Pettersen) Date: Sat, 23 Dec 2000 10:32:25 -0700 Subject: Some Python 2.1 ideas References: Message-ID: <3A44E1A9.D3A9FC35@uswest.net> Bob Alexander wrote: > Here are some thoughts on possible enhancements to Python. If discussion > shows any positive enthusiasm maybe they could turn into PEPs. > > [assignment expression] This has been discussed to death (at least once a year for the three years I've been here ;-) I happen to think it's a good idea, but I have no illusions of it ever being implemented > [range literals] PEP 204 (http://python.sourceforge.net/peps/pep-0204.html) Allready rejected. > [string.chomp] A platform independent way of doing this (that handles the case where the file doesn't originate on the native platform) would indeed be nice, although I don't think it's a big enough feature to require a PEP (i.e. if you create a patch it might be accepted ;-) -- bjorn From ssthapa at harper.uchicago.edu Fri Dec 15 03:25:30 2000 From: ssthapa at harper.uchicago.edu (Suchandra Thapa) Date: Fri, 15 Dec 2000 08:25:30 GMT Subject: Solution: Direct access to Printer I/O lines References: <917k9b$9i9$1@nnrp1.deja.com> Message-ID: jkndeja at my-deja.com wrote: >CAVEATS: > - It's intended to work under Windows 95 only. It won't work under >NT (you need a kernel-mode driver to access I/O ports under NT, and I >haven't written that yet ;-). I don't know about W98. It won't work >under linux either ;-). I'm happy to write a similar extension for >linux if people are interested - it's good practice for me... It should work in w98 since I've used the same approach you seem to have used in w98. It should also work in windows me. > - to be safe, I have restricted the range over which I/O port >access is allowed. This is currently limited to the address spaces of >the LPT ports: > > 0x278 to 0x27a (LPT1:) > 0x378 to 0x37a (LPT2:) > 0x3bc to 0x3bf (LPT3:) > Actually there is a second range of addresses at base+300(?) that controls ECP/EPP/SPP operations. The specific offset is in the parallel port faq. I don't think people will need much access to this in python except to check to make sure SPP mode is on or to switch to SPP mode. >I assume you know what you're doing... > > - Oh, I built it with Python v1.5.2 (ie. this is the import Library >I used). Does this mean it will need re-building for V2.0? not sure... I believe you need to rebuild due to changes in the interface API. >I haven't even checked yet which of the LPT: port addresses are Read- >only, which are Write only, and which are Read/Write - that's how >tested this is! Track down Ralph Browns Interrupt list for the gen. on >this. It's even worse than this. base+2 is the control register and certain bits are readonly while others are read-write. The status register base+1 has a similar feature. BTW, I'm not sure if I've gotten the addresses for the registers reversed. -- ------------------------------------------------------------------ | Suchandra Thapa | "There are only two kinds of math books. s-thapaNO at SPAMuchicago.edu | Those you cannot read beyond the first | sentence, and those you cannot read | beyond the first page." | -C.N. Yang ------------------------------------------------------------------ From grante at visi.com Wed Dec 6 17:49:37 2000 From: grante at visi.com (Grant Edwards) Date: Wed, 06 Dec 2000 22:49:37 GMT Subject: Python Origins References: <90k3pq$50p$1@nnrp1.deja.com> <3A2DD2CA.14A5D7E2@engcorp.com> <90l3j9$4bn$1@kapsel.intranet> <976139270.161152@clam-ext> Message-ID: <5ozX5.1613$TU6.39593@ptah.visi.com> In article <976139270.161152 at clam-ext>, Mark Hadfield wrote: >"Piotr Kuchta" wrote in message > >> ...Dutchmen are very talented: common Dutchman speaks well two foreign >> languages, English and German. > >Whereas common Australian speaks poorly one foreign language: English. ;) Good on ya, mate! -- Grant Edwards grante Yow! HELLO, everybody, at I'm a HUMAN!! visi.com From jh at web.de Tue Dec 5 15:18:48 2000 From: jh at web.de (Jürgen Hermann) Date: Tue, 5 Dec 2000 21:18:48 +0100 Subject: CGI POST binary file upload? References: <90j8j0$cmt$1@nnrp1.deja.com> Message-ID: <90jij9$j2$07$1@news.t-online.com> "Bill Seitz" schrieb im Newsbeitrag news:90j8j0$cmt$1 at nnrp1.deja.com... > msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) You DO realize that a file upload, seen from the server side, is _INPUT_? ;) From aleaxit at yahoo.com Thu Dec 21 09:43:13 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 21 Dec 2000 15:43:13 +0100 Subject: please help References: <91spce$tc1$1@nnrp1.deja.com> Message-ID: <91t5ir02hc9@news2.newsguy.com> wrote in message news:91spce$tc1$1 at nnrp1.deja.com... > Hi, > I am just thinking about taking Python as my first programming > language for serious learning (after reading "how to become a hacker"), Good idea. > but some distrusts with python's applicability prevent me from fully > applying myself to it. Would you kindly help clear up some of my doubts > about Python? Sure! > 1. I want to use IIS 4.0 for my webserver, can I use scripts compiled > by Python in it? With Mark Hammond's 'win32all' extensions (already bundled in the ActiveState distribution of Python for win32, see www.activestate.com) Python is installed as an 'Active Scripting Language', so you can use it for most any task for which you could use any other Active Scripting language (such as vbscript or jscript). IIS 4.0 is one example of the variety of active script host programs, and chapter 21 "Active Scripting" of Hammond and Robinson's "Python Programming on Win32" book (O'Reilly) specifically deals on how to configure it (virtual directory -> physical directory with the Python ASP's). > 2. What about the ASP? If I want to use ASP, can I use Python to do > such jobs like user authentication? How well can Python be used in Web > programming on Windows platform? See above. 'Yes', and 'Very very well', are the answers. Once you've installed Python (in the ActiveState version, or with the separate win32all extensions that you'll also find on their site applied on top of the standard Python 2 Win32 distribution), and set up the virtual->physical directory, you're all set. You'll start your ASP page with <%@ Language=Python @> and live happily ever after (directing your commands and requests to Application, ObjectContext, Request, Response, Server, just as you would for any other ASP). > 3. I used VB in the past and you can make a '.exe' file after > compiling. But how can I actually execute the Python program in > Windows? It seems that I can not make a .exe file for it to execute. It > is dependent on the interpreter? You can try Gordon McMillan's "installer" at http://www.mcmillan-inc.com/install1.html to bundle the various files a given Python application needs into a single, 'self-unpacking-and-installing', .EXE file. This only matters if you want to distribute applications to others who don't have Python installed, actually. Else, to run a foo.py program, once you have Python installed, you enter at the command prompt (or in a .BAT, or...): python foo.py normally, or pythonw foo.py to execute without a console (stdin/out/err), useful for GUI apps; and/or associate python.exe and/or pythonw.exe to the appropriate file-extensions (.py and .pyw are normally used) so the python file or a shortcut to it can be 'double-clicked' (a single click may actually suffice, with Active Desktop:-). You also have many other options, for example all those connected with Windows Scripting Host (WSH), HTML Applications (HTA), and so on. That YOUR program is not itself an .EXE (except if you package with Installer) matters little. Python itself is mostly a DLL, by the way; python.exe and pythonw.exe are just tiny wrappers to run the code in the DLL -- this matters because it's easy to access the DLL itself from your programs (in C or C++). But on Windows, among the other myriad options, COM shines: with Python (and win32all; or, ActiveState's python) you can build COM objects and instantiate-and-run-them in any way you like from any other program (including Python ones, of course). COM is also how ActiveScripting works, how WSH works, how HTML pages can embed/talk with your objects and be scripted by you, etc, etc -- even how the graphical Shell of Windows is interacted with. > 4. If I really sit my self to Python, does it reward equally for the > same effort in learning C? In the aspect of the quality of programs. Python will let you be orders of magnitude more productive than C at most tasks: the flip side of this is *performance*. Python is a very high-level language, while C is pretty low level, close to the machine and far from the human being. Python thus lets YOU, the human being, be much faster and more productive; while C optimizes the speed with which the *computer* can run your programs. (C++ tries to do both, and _also_ keeps C compatibility; but, as a result, is HUGE and terribly complex, alas). For most tasks these days, by far, human productivity is what matters -- computer power has become incredibly cheap compared to what it was back when C was invented (as the price/performance ratio halves every 18 months or so, in 30 years there have been about 20 halvings -- i.e., a factor of *a million to one* or so...), while human beings are much the same as 30 years ago. Crucial performance aspects, such as choice of good algorithms, are _easier_ in Python, as you can better experiment and try out various things, so you could even end up with a better/faster program...!-) And when the algorithm is settled and you *DO* need to squeeze every last cycle of computation out of your machine, that's where extensions to Python, built in C or C++, enter the picture, *selectively* replacing Python code with much-speedier, lower-level code. You will find a lot of GREAT existing extensions for such things as numerical work ('Numeric') and image processing ('PIL'), the kind of tasks that are computationally very intensive... not to speak of all the existing components which you may access (on Windows) from Python via COM (that lets you reuse/automate such things as Microsoft Excel's engine to handle your computations, for example). You may eventually want to learn C, or C++, yourself, in order to be able to write some little but crucial very high speed component for your own programs -- but that will only be, say, 1/10 or 2/10 of your overall program; most of it can stay in Python, if you wish... Alex From tim.one at home.com Sun Dec 31 17:02:12 2000 From: tim.one at home.com (Tim Peters) Date: Sun, 31 Dec 2000 17:02:12 -0500 Subject: Is 100,000 entries big for a dictionary? In-Reply-To: <92o5cg$ooc$1@panix2.panix.com> Message-ID: [/F] > The implementation limit is currently one billion objects. [Aahz] > It occurs to me, in light of the earlier thread on "is", that the > limit is likely to hit even faster than that, depending on how id() is > implemented. Yes, it will be hit much faster. id() is a 32-bit int on most machines, and is simply the address of the object. Since all Python objects contain at least a refcount and a type pointer, on most machines a PyObject occupies a bare minimum of 8 bytes, so divide your virtual address space by at least 8. If you use nothing but ints, at least 12 . Python also ensures that a hash table is never more than 2/3 occupied. So 60 million is a more realistic-- but still wildly optimistic --upper bound (e.g., on Win32 the user VM space spans 31 bits, not 32, so lose another factor of 2 right there). > ... > Incidentally, I think you were insufficiently pedantic in that thread > when you suggested "id(a) == id(b)". It really should be > > import __builtin__ > if __builtin__.id(a) == __builtin__.id(b): > .... Actually, since __builtin__ is writable, you should really arrange to capture the then-current __builtin__.id at startup time. Watch out for import hooks too: "import" may not do what you expect . the-only-python-program-i'm-sure-about-is-"x=1"-ly y'rs - tim From wolfgang.grafen at marconi.com Tue Dec 5 05:15:55 2000 From: wolfgang.grafen at marconi.com (Wolfgang Grafen) Date: Tue, 05 Dec 2000 11:15:55 +0100 Subject: Using dictionaries References: <3a2c9264.503856587@news-server.bigpond.net.au> Message-ID: <3A2CC05B.DEDE735B@marconi.com> sorular wrote: > > G'day > > I am trying to write a python program where a "configuration.py" will > have all the user entered values in a dictionary format and a > "main.py" which will import these and use it as local parameters. > > But, there are quite a few values in the dictionary > ie > dict = { 'key1':'value1' , ' key2':'value2' , ......'keyN':'value2'} > > and in the "main.py" these will be all renamed with the local names > ie > Val1 = dictionary.dict['key1'] > Val2 = dictionary.dict['key2'] > .... > ValN = dictionary.dict['keyN'] > etc.... > > But overall, I still have a large numbe of values (ValN) to list... ! > > Q1- Is there a more efficient way to do this ? I thought about using a > for loop but that didnt work.... > > Q2 - would it be possible only to list the parameters in first file > (ie dictionary.py > key1 = value1 > key2 = value2 > ..... > keyN = valueN > ) > and inside main.py, do a simple import... > import dictionary * > so that key1 can be used inside main.py as a local parameter? > > thank > > HK What about this? >>> locals().update(dictionary) or >>> globals().update(dictionary) >>> dictionary={"b":3} >>> globals().update(dictionary) >>> b 3 From pyth at relax.dk Thu Dec 7 08:01:06 2000 From: pyth at relax.dk (pyth at relax.dk) Date: Thu, 7 Dec 2000 14:01:06 +0100 (CET) Subject: list -> tuple In-Reply-To: <31575A892FF6D1118F5800600846864D5B1572@intrepid> Message-ID: > > From: pyth at relax.dk [SMTP:pyth at relax.dk] > > My problem is, that I'm getting a list, so I have to convert it to a > > tuple, before I can use it... any easy way to do that > > list2tuble(list,tuple) ? :o) > > tuple(list) > DOH!... thank you very much... I hate when problems gets to complicated... hehe... :o) /Dan Larsen From aleaxit at yahoo.com Mon Dec 25 19:50:29 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 26 Dec 2000 01:50:29 +0100 Subject: One Python 2.1 idea References: <9237md$orm$1@nnrp1.deja.com> <924bjt0e3n@news1.newsguy.com> <925baq$5sj$1@nnrp1.deja.com> <925tak01tpu@news1.newsguy.com> <926ici$vi9$1@nnrp1.deja.com> <92722s0l1f@news1.newsguy.com> <927se2$q7n$1@nnrp1.deja.com> Message-ID: <928q6p02mdu@news1.newsguy.com> wrote in message news:927se2$q7n$1 at nnrp1.deja.com... [snip] > > C++ offers lots of very-low-level constructs AS WELL > > AS pretty high-level ones, and, as I said, the low-level > > parts keep coming up then and again even when one is > > trying to work more abstractly .. > > To me, this is a BIG reason for preferring Python to > C++. Yes, you can implement any abstraction in C++. Nolo contendere: I *do* prefer Python for most tasks. Squeezing the last little bit of performance out of some key hotspot, and interfacing to existing libraries and frameworks that I haven't nicely dressed up yet, being the occasional exceptions. > When you write Python, you keep present in your mind the > memory management strategy for sequences, the lookup, I do keep in mind a few well-known traps that could lead to huge performance problems (building a string by sequentially catenating lots and lots of pieces being the foremost example). Apart from that, I feel no real such need when I _write_ code -- simplicity and clarity being by far more important issues than a few % worth of performance. (Occasionally, when I _tune_ code, I may do a few experiments based on Python's internals being a NON-black box -- I don't just thrash around at random seeing what might make it faster, I do let my knowledge lead me to see what may be worth trying). > point release? If so, I think C++ might be a better > language for you! It may be better *when the ultimate quest for top-notch performance is on*. That is, AT MOST, in 10% of the code I write. > > .. IF I have a semantic constraint about there being > > no deletes on this object, it's a CRUCIAL part of my > > abstraction for it -- I want to state it clearly and > > readably, and let compiler and human readers make of > > my statement what they wish. > > But this is NOT what we are talking about. IF it is > important functionally to some list object that there are > no deletes from it, if deleting from it is an application > error, then you SHOULD create a new type, and build in > this constraint, EVEN IF it imposes a performance penalty > to ensure this constraint. But that is NOT the issue. The Oh yes it is. I want *DECLARATIVE* ways to assert my known semantic constraints: easier for me to write, easier for the human readers to follow, easier for the compiler to insert checking code for OR base inferences for optimization on. A win-win-win-win situation. Hiding declarative knowledge in executable code is a serious design mistake. Are you SERIOUSLY saying that if what I know is "for every item x of X there exists one item y of Y such that foo(x,y)" then I should code at each step: for x in X: for y in Y: if foo(x,y): break else: raise AssertionError, "no foo(x,y) for "+str(x) ...? I want (in my dreams) the COMPILER to generate this code for me based on a DECLARATIVE ASSERTION using quantifiers -- when I throw some switch on it telling to pedantically check out everything it possibly can; and I want my declarative assertion to stand as an interesting tidbit of information to readers AND, who knows, possibly help some future super-duper compiler get some extra optimization too. > issue is the much more common case where it just so > happens that there are no deletes from a list, in the > code as it appears now, and this can be used for > performance optimization. It is NOT part of the > application's semantics, but just a happenstance of > current code. With Python's fluidity and non-encapsulation, 'current code' will have to comprise every last single user typed string whose exec might possibly change this 'happenstance'. Talk about whole-program optimizers... _at the very least_, a declarative assertion about lack of access to 'this list here' "from the outside" is going to be needed for any practical purposes -- "nobody but us chickens is going to mess with X -- feel free to infer everything about X based on this *finite* set of code and/or to hide it from outside". Alex From tim at degree.ath.cx Wed Dec 27 21:07:13 2000 From: tim at degree.ath.cx (Tim Hammerquist) Date: Thu, 28 Dec 2000 02:07:13 GMT Subject: Python vs PHP (& Java?) References: Message-ID: Ben Ocean wrote: > I'm an intermediate-level programmer that's new to Python (via Zope) and I > like it a lot. However, it appears to me that, while Python is a good > replacement for Perl, it cannot replace much of the functionality of PHP, > which can be scripted into HTML (whereas Python, it appears, must be > called). Ok, everyone else made very good points, but this little comment slipped out (not that I'm surprised, honestly) =) There is no "replacement for Perl!" And Python would do a poor job trying to be Perl (and vice versa), nor does anyone here seem to _want_ Python to be/replace Perl. Let me paraphrase: Perl is Perl and should remain Perl. Python is Python and should remain Python. Java is long-winded and...um, "pragmatic" and should be given a fair shot. PHP is crap and should be left to those to don't want control over their scripts. (Ok, this last one was significantly biased; did ya notice?) Just my $.02. =) And Ben: don't leave language choices up to others...unless "others" are your boss, of course. Research the languages, not just hearsay. -- -Tim Hammerquist I am opposed to millionaires, but it would be dangerous to offer me the position. -- Mark Twain From merlyn at stonehenge.com Fri Dec 15 10:46:57 2000 From: merlyn at stonehenge.com (Randal L. Schwartz) Date: 15 Dec 2000 07:46:57 -0800 Subject: Smalltalk and Python References: <3A2FFB8B.2030408@zoologic.com> <915qlh$89fa$1@nntp6.u.washington.edu> <917g5o$qh$1@news.rz.uni-karlsruhe.de> <55ne3t4lqvijv14bt7nj3b53oovmjf9ql0@4ax.com> <917r2b$4n7$1@news.rz.uni-karlsruhe.de> <86d7ewrqat.wl@archon.local.idaemons.org> <918v7a02scn@news1.newsguy.com> <91a1ed02a4j@news2.newsguy.com> <3A389B1A.4F33FFD4@cfmu.eurocontrol.be> <91ae8s02llf@news2.newsguy.com> <3A38CF3E.8BBD2216@cfmu.eurocontrol.be> <91avrn08ql@news2.newsguy.com> <3A39EAB0.1A0528C3@cfmu.eurocontrol.be> Message-ID: >>>>> "Ian" == Ian Wild writes: >> > classes exist only by convention [in Perl] >> >> 'only by convention'!? Have they abrogated the 'bless' >> keyword, now? Ian> My understanding is that 'bless' does some internal Ian> tweakery of a magic array (@INC). If you promise not Ian> to look too hard, you've got classes. Anything that Ian> needs a promise from me I'll regard as convention, not Ian> a language construct. YM, as they say, MV. 'bless' changes a portion of the datastructure holding the object so that it remembers which package it's associated with, which then permits runtime location of a method called against that object. And isn't *everything* a "promise" at some point? I don't see anything less direct about Perl's object structure than say, C++'s version of the same thing. Isn't a C++ object just a struct behind the scenes? You dismiss Perl too easily. As a hybrid (some objects, some not) language, it's a very usable object model. It's not smalltalk, which is a cleaner interface, but it's certainly more usable *and* introspective than C++ (which Larry Wall promised us Perl's OO would *not* emulate {grin}), and more flexible (and therefore useful) than Java's hybrid object model. -- Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095 Perl/Unix/security consulting, Technical writing, Comedy, etc. etc. See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training! From spahievi at vega.bg Tue Dec 5 16:01:24 2000 From: spahievi at vega.bg (Niki Spahiev) Date: Tue, 5 Dec 2000 23:01:24 +0200 Subject: Smalltalk/ROSE-like prog. environment? In-Reply-To: <90j2gg$kpf$1@news.rz.uni-karlsruhe.de> References: <90j2gg$kpf$1@news.rz.uni-karlsruhe.de> Message-ID: <7843403270.20001205230124@vega.bg> 05.12.2000, 17:44:16, Bjoern Giesler wrote: BG> Hi, BG> I have a dream... :-) BG> I'd like to have a programming environment that allows you to do graphical BG> OO design (UML, ROSE-like) with access to all classes a project consists of BG> (Smalltalk-like). This thing would allow the programmer to graphically BG> design class interfaces and interactions, and edit method source code on a BG> per-method basis. I.e. no editing-around in large .py files but working just BG> on the job at hand. BG> This would have a couple of other nifty features: A test mode in which an BG> exception is presented to the user in a dialog box that allows modification BG> of the code _while the program is running_ (this could be done with BG> continuations, I believe) and stuff like that. BG> This is a very hazy notion that has been floating around in my head for a BG> while. I believe that Python would be the ideal language for this kind of BG> application. Does anybody know of such an environment? BG> If not, I'd like to give it a shot. Anybody have any ideas or want to BG> collaborate with me? BG> Regards, BG> --Bj?rn Closest thing to this dream (but not too close) is called SNiFF+. It has personal version for linux and groks Python. -- Best regards, Niki Spahiev From mdtompkins at home.com Fri Dec 15 18:08:29 2000 From: mdtompkins at home.com (Mark Tompkins) Date: Fri, 15 Dec 2000 23:08:29 +0000 Subject: win32wnet.WNetAddConnection2, win32wnet.WNetCancelConnection2 Message-ID: <3A3AA46C.5E1F2F8C@home.com> Hi, Well, the last time I called, I couldn't map a local drive to a remote network share. I was able to solve this problem by assigning the following privileges first to the Administrator group using the user administrator, and then, from within the service itself, changing the privileges of the service process (SYSTEM and LocalSystem are members of the local Administrators group by default, I believe): # SE_TCB_NAME - Act as Part of the Operating System # SE_CHANGE_NOTIFY_NAME - Bypass Traverse Checking (This privilege is granted to all users by default). # SE_ASSIGNPRIMARYTOKEN_NAME - Replace a Process Level Token Next I try to create a connection to a remote share win32wnet.WNetAddConnection2(win32netcon.RESOURCETYPE_DISK,'Y:','\\\\clun1-172\\source',None,'orabatch','orabatch') This works just great. Then, I try to cancel the connection win32wnet.WNetCancelConnection2('Y:',0,1) This fails, with error (the error message gives the pywintypes.api_error information, wrapped by my error message): Unable to delete net file share: Y: + Code: 2250 + Func: WNetCancelConnection2 + descr: This network connection does not exist. I've tried running the service as default (SYSTEM account - a local account only), (LocalSystem account) and orabatch, an account that is a domain account that is enabled to make the connection to the remote share. Why is the current process not owner of the connection that it has just created???? Why can't the current process see the connection that it has just made? What must I do so that when orabatch user creates a connection to a remote share, that the local drive (in this case Y:) can be deleted from within the service? thx Mark From jwbnews at scandaroon.com Wed Dec 6 00:13:46 2000 From: jwbnews at scandaroon.com (John W. Baxter) Date: Tue, 05 Dec 2000 21:13:46 -0800 Subject: Rounding error in Python 2.0 References: <90jscs$uno$1@nnrp1.deja.com> Message-ID: In article , "Fredrik Lundh" wrote: > A. Binary floating point cannot represent decimal fractions > exactly, so some rounding always occurs (even in Python > 1.5.2). Well, 20% of the numbers with a single digit to the right of the decimal, and 4% of the numbers with two digits to the right of the decimal (and so on) are precise. It's only the other 80% or 96% or... which aren't. ;-) --John -- John W. Baxter Port Ludlow, WA USA jwbnews at scandaroon.com From andrew_dot_henshaw_at_earthling_dot_net Tue Dec 19 21:36:49 2000 From: andrew_dot_henshaw_at_earthling_dot_net (Andrew Henshaw) Date: Tue, 19 Dec 2000 21:36:49 -0500 Subject: while true: !!! References: Message-ID: "Steve Holden" wrote in message news:ckJ%5.3097$Yv6.81688 at e420r-atl1.usenetserver.com... ...snip > I've always tried to discourage students from comparing a Boolean with a > constant, but it can be difficult to get the point over that (a) can > evaluate as true even though (a == some_constant) may well evaluate to > false. > > Clearly, if what you have is a Boolean value (i.e. one which can be used as > the expression in an "if" statement) then it's adding inefficiency to > compare it with something, when what should be used is either > > if a: > > or > > if not a: > > This works quite nicely in Python: > > >>> not "forever" > 0 I had never thought of this before, but it is kind of interesting that not 'this is a true string' doesn't produce '' but instead produces 0. Similarly, not [0, 1, 2] could produce [] . In fact, I could see where that might be useful. On the other hand (to be consistent), what would not [] produce? :) Also, shouldn't false == false ? '' == [] returns 0. :) Well, at least (not '') == (not []) returns 1. Andrew Henshaw From sill at localhost.kitenet.net Tue Dec 5 17:54:33 2000 From: sill at localhost.kitenet.net (Oldayz) Date: Tue, 05 Dec 2000 22:54:33 GMT Subject: Newbie question on 'cmpfiles': References: <90i074$d73$1@nnrp1.deja.com> Message-ID: On Tue, 05 Dec 2000 05:59:02 GMT, harisri at my-deja.com wrote: >Hello, > >I am a newbie user to python 2.0 > >Can someone help me by explaining 'cmpfiles' function with a simple >example? > >I am trying to compare 2 directories, but not sure about the syntaxof >this function. The "Python Reference Library" did not help me on this. > >[What does "common" mean in "cmpfiles(dir1, dir2, common)"?] This function is used to compare *files*, not directories. Multiple files in these directories. To compare directories, use dircmp class: dircmp (a, b[, ignore[, hide]]) Construct a new directory comparison object, to compare the directories a and b. ignore is a list of names to ignore, and defaults to ['RCS', 'CVS', 'tags']. hide is a list of names to hid, and defaults to [os.curdir, os.pardir]. report () Print (to sys.stdout) a comparison between a and b. etc.. It's in 2.0 lib ref under filecmp > >Thanks in advance, >Hari. > > >Sent via Deja.com http://www.deja.com/ >Before you buy. -- Andrei From com at gahnstrom.se Sat Dec 30 16:36:14 2000 From: com at gahnstrom.se (Tim Gahnström) Date: Sat, 30 Dec 2000 22:36:14 +0100 Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> <3A4D6A05.EEC97FA6@uswest.net> <92li6g$hju$1@yggdrasil.utfors.se> Message-ID: <92lkd8$ifh$1@yggdrasil.utfors.se> >The only way to acieve this exact behavior with is while is like this uops I got a nose punc for this :-) >a=1 >while a=1 or (T >=25) > a=0 > R=Themistor.ReadResistance() > T=R_to_Temperature(R) First of all, this doesn't produce the exact same behavior unless python uses lazy evaluation (does it?) Two this is ofcourse not the ONLY way to acive the behavior. Bj?rn Peterssen said another one in the first message. I have just benn tought to not use goto and I counted break as a nobler art of goto :-) Tim From aleaxit at yahoo.com Tue Dec 19 08:29:41 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 19 Dec 2000 14:29:41 +0100 Subject: while true: !!! References: Message-ID: <91nnsu016ji@news2.newsguy.com> "Delaney, Timothy" wrote in message news:mailman.977182622.11891.python-list at python.org... > > >The idiom is actually > > > > > >while 1: > > > > > > do something > > > > > > if condition: > > > break > > > > > > do something else [snip] > I go well out of my way to avoid this idiom, as I feel you should always > have the termination condition at one end of the loop, preferably the top I disagree intensely with this stance: I strongly feel that the loop-exit condition should be *in the most natural place for it*, which is often the top, but not all that rarely elsewhere. Anyway, one doesn't have to go 'well' out of one way to hide this clean, general loop structure as if it was otherwise -- one 'status-variable' will suffice, e.g: looping = 1 while looping: do something if condition: looping = 0 else: do something else I think this is *substantially* less readable than the clean, natural form: while 1: do something if condition: break do something else but it does satisfy fetishistic adherents of the Jacopini and Boehm school (and, I believe, _is_ isomorphic to the local transformation J&B's second lemma would implicitly perform on the flow diagram of the second form to produce that of the first). Alex From ahopkins at dynacare.com Tue Dec 26 15:07:30 2000 From: ahopkins at dynacare.com (Albert Hopkins) Date: 26 Dec 2000 14:07:30 -0600 Subject: Formatting for hh:mm:ss References: Message-ID: On Tue, 26 Dec 2000 13:12:33 -0500, Roy Katz wrote: >Hello, > > >I've searched the 'time' and 'locale' modules for any function which >would take a difference of two time.time()'s and format the result as >hour:minutes:seconds, but I can't find any. All I am doing is this: > > t1 = time.time() > # some processing here > t2 = time.time() > > total = t2 - t1 > > print_time( total ) > >where print_time() would format the time as above. Does anyone know if >this function already exists? > It sounds to me that you can accomplish what you need with the time.strftime() function. Of course you'll need to convert 'total' to a tuple to pass to the function. Something like def print_time(t) return time.strftime("%H:%M:%S", time.gmtime(t)) -- Albert Hopkins Sr. Systems Specialist Dynacare Laboratories ahopkins at dynacare.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 aleaxit at yahoo.com Mon Dec 11 12:13:07 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 11 Dec 2000 18:13:07 +0100 Subject: while true: !!! References: <8uthf2$pjh$04$1@news.t-online.com> <8utnqk02rlq@news1.newsguy.com> <8uu44b$4nc$04$1@news.t-online.com> <3A34CEA7.CD9D85AE@yahoo.com> <3A350405.B8F09EC7@gte.net> Message-ID: <9131vd0pnq@news2.newsguy.com> "Steve Williams" wrote in message news:3A350405.B8F09EC7 at gte.net... [snip] > I wouldn't call "While true" a python-idiom, I'd call it a > python-solecism. With some effort, I guess one MIGHT find assertions with which I'd disagree more drastically than this one -- but, it WOULD take effort. How *WOULD* you prefer to express Knuth's classical "N-times-and-a-half" loop (in Python, C, C++, Java, &c) if not by (pseudocode): 'loop until otherwise terminated': 'first-part' suite of statements if 'termination-condition': break 'second-part' suite of statements ...? The 'loop until otherwise terminated' clause is _best_ spelled while 1: in Python, while other languages offer you a choice between for(;;) and while(1) as well as do (with a while(1) at the end), etc. What do you claim is "barbarous", "grammatically faulty", etc, about using "while 1:" to express "loop until otherwise terminated" in Python? Alex From tcmay at got.net Sat Dec 9 01:54:34 2000 From: tcmay at got.net (Tim May) Date: Fri, 08 Dec 2000 22:54:34 -0800 Subject: simulated annealing References: Message-ID: In article , "Jochen K?pper" wrote: > Tim> Glad you have "found" Google. I had been hearing about how great it > was > Tim> for several months before trying it. > > Me too. > > Tim> When I finally did, I realized how much better it was than Alta > Tim> Vista and Metacrawler. (I used to like Metacrawler because it, > Tim> ostensibly, searches with N different search engines. In > Tim> practice, it doesn't find as much as just Google does.) > > It actually searches google! And that is why I was confident it was > the right thing to use metacrawler... Don't be misled by this claim. While it is claimed that Metacrawler searches N different other search engines, it often (usually) returns fewer results than Google does. How can this be? Without researching the ins and outs carefully, I surmise it's the limitations the search engine companies place on Metacrawler using their system. After all, Yahoo, Infoseek, Lycos, and the other search engine companies make some/most of their money from advertising. So if Metacrawler searches N of them and puts its _own_ advertisements on the results page.... Metacrawler often reports "search engines that time out..." In any case, the moral is to try many different engines...and then "anneal" the results, so to speak. Curiously appropriate for the topic at hand. (With such a small sample set, of perhaps 10 major search engines, SA is obviously not needed.) --Tim May -- ---------:---------:---------:---------:---------:---------:---------:---- Timothy C. May | Crypto Anarchy: encryption, digital money, ComSec 3DES: 831-728-0152 | anonymous networks, digital pseudonyms, zero W.A.S.T.E.: Corralitos, CA | knowledge, reputations, information markets, "Cyphernomicon" | black markets, collapse of governments. From pbjorn at uswest.net Sun Dec 24 15:45:04 2000 From: pbjorn at uswest.net (Bjorn Pettersen) Date: Sun, 24 Dec 2000 13:45:04 -0700 Subject: Some Python 2.1 ideas References: <3A452881.7686E717@uswest.net> <%vb16.187233$U46.5801214@news1.sttls1.wa.home.com> <3A464D5D.B541C04E@uswest.net> <20001224210742.A18246@xs4all.nl> Message-ID: <3A46604F.CF0A1DA1@uswest.net> Thomas Wouters wrote: > On Sun, Dec 24, 2000 at 12:24:13PM -0700, Bjorn Pettersen wrote: > > Greg Jorgensen wrote: > > > > "Bjorn Pettersen" wrote in message > > > [snip] > > > How should these be handled? > > > > "foo\n\n\n" > > > "foo\n\r\n\r" > > > > "foo\n\n\n" -> "foo\n\n" > > "foo\n\r\n\r" -> "foo\n\r" > > Note that the latter was a trick question! The proper order for DOS-EOL is > '\r\n', *not* '\n\r'. So the string "foo\n\r\n\r" is a Macintosh string, not > a DOS one :-) Sorry, I thought I remembered that Macintosh used \n\r and not just \r. Shows you how much I work with Macs ;-) I think the rule I was trying to follow was "the longest sequence that can be recognized as a line terminator". -- bjorn ps: anyone know what the line terminator for OS X is? (My old NeXT used the regular unix conventions..) From fredrik at effbot.org Sat Dec 16 12:48:29 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Sat, 16 Dec 2000 17:48:29 GMT Subject: Unicode and default encodings References: <91g9e1$4t2$1@news1.xs4all.nl> Message-ID: Boudewijn Rempt wrote: > I'm currently trying to work with Unicode strings, and > I was kind of wondering where sys.setdefaultencoding has > gone to - it's still mentioned in Misc/unicode.txt, but > it isn't there anymore ;-) You can use it in sitecustomize.py, but not in user code. See Lib/site.py for details. From eq3pvl at eq.uc.pt Tue Dec 5 05:27:16 2000 From: eq3pvl at eq.uc.pt (Pedro Vale Lima) Date: Tue, 05 Dec 2000 10:27:16 +0000 Subject: Programming with Python References: <90fq39$jgq$1@nnrp1.deja.com> <9iOW5.55847$L26.16633720@typhoon.southeast.rr.com> <90gj77$7a0$1@nnrp1.deja.com> <3A2BFD12.7AB3A628@anubis.network.com> Message-ID: <3A2CC304.8C451CD6@eq.uc.pt> "Joseph A. Franzmeier" wrote: > The other to recommend is "The Python Reference" by Guido Van > Rousson > the creater of Python. I never heard of this one. Are you talking of the "Library Reference" coming with the python docs, or are you talking about "Python Essential Reference" by Beazley the author of SWIG (by the way, this is the book I always carry around). The best book for learning is Programming Python, it's a bit dated but still you learn all from the basic to the expert. ORA is probably going to do a 2nd edition. regards pedro From prestonlanders at my-deja.com Fri Dec 22 11:15:27 2000 From: prestonlanders at my-deja.com (Preston Landers) Date: Fri, 22 Dec 2000 16:15:27 GMT Subject: mail processing module? References: <91rcig$rgu$1@nnrp1.deja.com> Message-ID: <91vumo$di3$1@nnrp1.deja.com> In article , Michael Haggerty wrote: > Is there a reason to put sending and retrieving into a single module? > They seem easily factorable. You're really going to like this: it's all methods of one object. You see, my main design goal here was to make working with mail as simple as possible. > In fact maybe a better breakdown would be one module that represents > an email message and allows data to be MIMEd into and out of it, one > module for sending such messages via SMTP, one module for retrieving > such messages via POP, and one for retrieving via IMAP. All of these modules exist already, are widely used and well tested. My module uses them. Why would I abstract each module up a level but keep them separate? > interfaces for the two retrieving modules should be as close as > possible, and ideally the interface to the mail-sending routine should > be generic enough that one could write a module with the same > interface but that sends emails by writing them to, e.g., sendmail or > qmail. My maillib module unifies the interface to POP and IMAP using a technique that hard core OOPers will find abhorent: if self.is_pop: do_one_thing() elif self.is_imap: do_another() Currently, only sending with smtp is supported but I could easily put in support for using a command line mail sender. Also, you could subclass the maillib class and reimplement the sending methods. > (Some of this functionality might overlap with existing Python > modules.) Ya don't say? ;-) I plan to use them. If all goes well I should be able to post some code (or a pointer to it) within a couple of weeks, and everyone will have a chance to show me the error of my ways then. ;-) Like I said, I am trying to: a) reimplement as little as possible b) make the interface for using the module as simple as possible Here's an example of use (sorry if there are formatting problems): import maillib # make mail exception availible in this namespace MailError = maillib.MailError # set up a configuration dictionary with the recommended options config_dict = { 'sendmail_from': 'Your Name ', 'sendmail_smtphost': 'smtp.yourdomain.com', 'sendmail_user_agent': 'Catchy Slogan Here', 'getmail_method': 'imap', # or 'pop' 'getmail_user': 'uname', 'getmail_passwd': 'pwd', 'getmail_server': 'imap-server.yourdomain.com', 'getmail_server_port': 143, # standard imap port, 110 is POP port } Debug = None # set to 1 for more verbose output to stderr my_mail = maillib.maillib(config_dict, Debug) # you now have a maillib object ### SENDING MAIL mailto_list = ['destination at address.com'] subject = 'Hello, maillib!' mail_body = 'Hello, world.' attachment_list = [] # no attachments, empty list or None ### ATTACHMENT 1 description_1 = 'Picture of Tux the Penguin' filename_1 = 'tux.jpg' mimetype_1 = None # let the module guess from the filename, only works with common types item_1 = open_file_handle.read() attachment_1 = (description_1, mimetype_1, filename_1, item_1) attachment_list.append(attachment_1) try: my_mail.send_mail(mailto_list, subject, mail_body, attachment_list) except MailError, msg: print 'There was a mail sending problem' print msg raise print 'Mail sent ok.' # RECIEVE EMAIL try: my_mail.getmail_login() Delete = 1 # delete the message after you fetch it raw_message = my_mail.fetch_first_msg(Delete) my_mail.do_cleanup() # logs off mail server! except MailError, msg: print 'There was a problem retrieving the email.' print msg ### The raw unprocessed message is now in raw_message ### DECODING MESSAGES try: (header_dict, message_body, attachments_list) = my_mail.decode_email(raw_message) except MailError, msg: print 'There was a problem decoding the email.' print msg print 'From: ', header_dict.get('From', 'unknown') print 'To: ', header_dict.get('To', 'unknown') print print message_body --- Preston Sent via Deja.com http://www.deja.com/ From fredrik at effbot.org Sun Dec 31 07:37:48 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Sun, 31 Dec 2000 12:37:48 GMT Subject: Line Benchmarks - Tkinter vs. wxPython References: <91uljk$12as$1@news2.ottawa.cyberus.ca> Message-ID: Gordon Williams wrote: > In November of 1999 I did some benchmark tests to gauge the performance > difference between Tkinter and wxPython when large numbers of lines are > plotted. As most Tk/Tkinter users know, the Canvas widget isn't the best thing to use for widgets like this. There are several Tk extensions that provide better support for rapidly changing data, including BLT. And then there's Tkinter 3000. As some of you know, I've been involved in a commercial UI library called uiToolkit (see www.pythonware.com for more info). Tkinter 3000 is a reimplementation of some uiToolkit concepts, on top of Tkinter (and/or Tk). One such concept is something called the "Widget Construction Kit", which is a small interface that allows you to implement new Tkinter widgets in pure Python. Using my current "proof of concept" implementation of the WCK, I implemented a simple PlotWidget, and used it to run Gordon's benchmark. Here are the results on my Win2K box: Python/Tkinter 1.5.2: 0.4356 seconds Python/Tkinter 2.0: 0.0832 Tkinter 3000, Tk driver, floating point coordinates: 0.0018 Tkinter 3000, Tk driver, integer coordinates: 0.0016 I don't have a working wxPython on this computer, but it should be clear that Tkinter can match wxPython also on a benchmark like this, if you use the right widget... (in either case, 625 fps should be enough for anyone ;-) For more info on Tkinter 3000, see http://tkinter.effbot.org (the project) http://online.effbot.org#1811114 (benchmarks) http://www.egroups.com/subscribe/tkinter3000 (mailing list) From pbjorn at uswest.net Wed Dec 27 22:15:40 2000 From: pbjorn at uswest.net (Bjorn Pettersen) Date: Wed, 27 Dec 2000 20:15:40 -0700 Subject: Some Python 2.1 ideas References: <3A452881.7686E717@uswest.net> <%vb16.187233$U46.5801214@news1.sttls1.wa.home.com> <3A464D5D.B541C04E@uswest.net> <20001225150250.6FA06A84F@darjeeling.zadka.site.co.il> <3A479C29.2631F27B@uswest.net> <3A4A50E6.11BBE0FD@uswest.net> Message-ID: <3A4AB05C.D41F4022@uswest.net> D-Man wrote: > Yeah, it is a problem if you don't know where the file came from. How > about creating a standard text file format? All files could be opened > in binary mode on all platforms, then EOL is handled by each > application (or better yet make a standard module that does the > implementation correctly once). Feeling like fighting windmills today, eh ? I think the current wish is to do it from the other end, i.e. instead of relying on the text file format to be "correct", implement a method on string object that is smart enough to handle all text file format line endings intelligently. -- bjorn From sill at localhost.kitenet.net Thu Dec 7 19:19:32 2000 From: sill at localhost.kitenet.net (Oldayz) Date: Fri, 08 Dec 2000 00:19:32 GMT Subject: Python Origins References: <90k3pq$50p$1@nnrp1.deja.com> <3A2EE2AF.AD8A51E2@caltech.edu> <3A2FE630.5C113AB@bioeng.ucsd.edu> Message-ID: On Thu, 07 Dec 2000 11:34:08 -0800, Curtis Jensen wrote: >"A.M. Kuchling" wrote: >> >> On Wed, 06 Dec 2000 17:06:55 -0800, Nathan Gray wrote: >> >It's really upsetting how often I've seen this sort of response to a polite >> >question on this newsgroup lately. Tell me, what's so terrible with asking a >> >group of experts for pointers when researching a subject? It's a perfectly >> >legitimate and highly effective way to learn about something. There's plenty >> >> I've noticed this trend, too, though T.C. May, the person you're >> replying to, has always had a low tolerance for cluelessness, as I >> noted when lurking on the cypherpunks mailing list in the early 90s; >> May's posts were often informative and entertaining, but not often >> placid. (I was pleased to turn up here, though I'm not sure why he's >> taken up Python.) > >A while back, someone wrote in and asked what a text editor was. The >answers to this were polite and informative, and non-demeaning. I'm >curious why this one and why others get ripped on, and others don't. >Luck of the draw? > Question like 'what's a text editor' shows that the inquieror (is that a right word?) is a newbie, while a question like 'guys I'm writing a paper on python, can you tell me where it comes from?' shows laziness. By the way, I tried google search for 'what's a text editor' and out of top 10 hits, only one explained the difference and was titled 'word processor vs. text editor', in other web searches you'd probably be even less lucky, while search on 'history of python' came up with self-descriptive [40]History of: GreatSoftware - Python. -- Andrei From micsaund at home.com Wed Dec 13 20:51:49 2000 From: micsaund at home.com (Mike Saunders) Date: Thu, 14 Dec 2000 01:51:49 GMT Subject: Linux version would be really cool References: <917k9b$9i9$1@nnrp1.deja.com> Message-ID: > haven't written that yet ;-). I don't know about W98. It won't work > under linux either ;-). I'm happy to write a similar extension for > linux if people are interested - it's good practice for me... Since you mentioned it :^) I think that with all the embedded Linux projects, and the fact that Linux makes it so easy to pipe stuff together, I think a Linux version of your program would be very useful. I, for one, would like to add it to my repetoire (sp?) for future projects. Thanks for taking the time to work on your .dll and possibly the Linux version!!!! Mike From rodsenra at correionet.com.br Wed Dec 13 21:48:08 2000 From: rodsenra at correionet.com.br (Rodrigo Senra) Date: Thu, 14 Dec 2000 00:48:08 -0200 Subject: Parsing Java source files in Python ? Message-ID: <3A3834E8.19C9D495@correionet.com.br> Hi everybody, I would appreciate any pointers to tools or strategies in order to parse Java source files from Python (from CPython not Jython, I know this may sound a little bit awkward, but other requirements made me rule out Jython for the time being). Do you think using regualr expressions is feasible, rephrasing..., is advisable ? TIA Rod -- Rodrigo Senra Computer Engineer (GPr Sistemas Ltda) rodsenra at correionet.com.br MSc Student of Reflection (IC- UNICAMP) Rodrigo.Senra at ic.unicamp.br http://www.ic.unicamp.br/~921234 (see also http://www.gpr.com.br) From syver at NOSPAMcyberwatcher.com Sun Dec 10 15:19:50 2000 From: syver at NOSPAMcyberwatcher.com (Syver Enstad) Date: Sun, 10 Dec 2000 21:19:50 +0100 Subject: reloading modules question References: <90scdf$hpe$1@troll.powertech.no> Message-ID: <910om3$2vk$1@troll.powertech.no> > I would suggest you are better off just stopping and starting the affected web sites. That's what we > do and it only takes a second. You mean something like pushing the unload button in the applications property sheet? Starting and stopping the default web site in inetmgr is not enough. > You can automate the procedure using WMI or ADSI. I'm sure I used to have an example script but I'm > buggered if I can find it right now. I think I saw some documentation on it in the documentation for IIS. I'll look it up. From fredrik at effbot.org Sun Dec 10 05:34:06 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Sun, 10 Dec 2000 10:34:06 GMT Subject: sgmllib nit References: Message-ID: Robin Becker wrote: > I realise that it does that! Unfortunately Zope's dtml isn't HTML. after a bit more research, I found this little piece of text from the SGML specification: If "SHORTTAG YES" is specified on the SGML declaration, the name and [the separator] can be omitted if the attribute value specification is an undelimited name token that is a member of a group specified in the declared value for that attribute. or in other words, you can leave out the *attribute name*, not the value... (this is why you cannot use the same enumeration value for more than one attribute in the same tag) ...so if DTML expects to mean instead of it's neither SGML, HTML, nor XML. > Which parser should one use to analyse dtml which can contain tags like > ? dtmllib? I suggest asking the Zope folks if/why they're using an embraced and extended syntax, and what parser they recommend... if you want to fix this in sgmllib, the id hack is way too ugly -- better move if not rest: attrvalue = attrname elif attrvalue[:1] == '\'' == attrvalue[-1:] or \ attrvalue[:1] == '"' == attrvalue[-1:]: attrvalue = attrvalue[1:-1] attrs.append((string.lower(attrname), attrvalue)) into a separate method, and override it from a dtmllib module. another way to solve it (in dtmllib) would be to have a map of attributes that are supposed to be minimized (derived from the DTML DTD). just use a simple dictionary: minimize = { ("dtml-var", "standard_html_header"): 1, ... } ... if attrname == attrvalue and minimize.has_key((tag, attrname)): out.write(" %s" % attrname) else: out.write(" %s=%s" % (attrname, repr(escape(attrvalue)))) ... > I guess I need to write my own parser that doesn't make unnecessary > assumptions. well, if you think that assuming SGML is an "unnecessary assumption" for something called sgmllib, there's not much I can do to help. From Bjoern.Giesler at gmx.de Thu Dec 7 05:12:22 2000 From: Bjoern.Giesler at gmx.de (Bjoern Giesler) Date: 7 Dec 2000 10:12:22 GMT Subject: MVC module anyone? Message-ID: <90nnq6$8n0$1@news.rz.uni-karlsruhe.de> Hi, I'm thinking of writing a Model-View-Controller based GUI wrapper around a couple of the more popular Python GUI toolkits because a) I'm tired of apps that work with only a certain GUI, so I want an abstraction layer b) I like Model-View-Controller. Is there already such a project? I don't want to duplicate efforts. If not, can anyone point me to the Smalltalk MVC specification? I've worked with Smalltalk a while ago, but don't remember exactly how the classes looked like. I'd really like to do this the way Smalltalk does it. (If I can't, I'll use the OPENSTEP AppKit as a model.) Regards, --Bj?rn From DanielK at aracnet.com Mon Dec 4 22:29:58 2000 From: DanielK at aracnet.com (Daniel Klein) Date: Mon, 4 Dec 2000 19:29:58 -0800 Subject: Calculating factorial References: <3a2a9496.647995@uutiset.nic.fi> Message-ID: Other than the the previous recommendation to use 1L, you could reduce the number of iterations by 1 by starting at 2 in the 'for' loop, ie for number in range(2, f + 1): No need to multiply 'result' times 1. Daniel Klein "Olli Rajala" wrote in message news:3a2a9496.647995 at uutiset.nic.fi... > Hi! > I've learned a few time Python and programming. I wrote a function > that calculates a factorial of N and I was wondering if it's the best > (I think it's not. =) way to do that. I'm glad to hear your comments. > > > > Ps. Sorry my poor English. > -- > Olli Rajala > A Finnish student who loves Linux. From Blair.Lowe at compeng.net Tue Dec 12 18:11:22 2000 From: Blair.Lowe at compeng.net (Blair Lowe) Date: Tue, 12 Dec 2000 16:11:22 -0700 Subject: compiling BeOpen-Python-1-2.0.src.rpm In-Reply-To: References: <9097pc+pspc@eGroups.com> <3A29DBF6.6A074D47@tridog.com> Message-ID: Hi, We are using Stock RedHat 6.2. We want to re-configure the BeOpen-Python source code for SSL, and general use. We were compiling the BeOpen-Python-2.0-1.src.rpm with the command: rpm -bi BeOpen-Python-2.0.spec , and got the following error: gcc -fpic -I/usr/local/include/xmlparse -g -O2 -Wall -Wstrict-prototypes -I./.. /Include -I.. -DHAVE_CONFIG_H -c ./pyexpat.c ./pyexpat.c: In function `newxmlparseobject': ./pyexpat.c:639: warning: implicit declaration of function `XML_ParserCreateNS' ./pyexpat.c:639: warning: assignment makes pointer from integer without a cast ./pyexpat.c: In function `pyxml_SetStartNamespaceDeclHandler': ./pyexpat.c:1024: `XML_SetNamespaceDeclHandler' undeclared (first use in this fu nction) ./pyexpat.c:1024: (Each undeclared identifier is reported only once ./pyexpat.c:1024: for each function it appears in.) ./pyexpat.c: In function `pyxml_SetEndNamespaceDeclHandler': ./pyexpat.c:1032: `XML_SetNamespaceDeclHandler' undeclared (first use in this fu nction) ./pyexpat.c: In function `pyxml_SetStartCdataSection': ./pyexpat.c:1040: `XML_SetCdataSectionHandler' undeclared (first use in this fun ction) ./pyexpat.c: In function `pyxml_SetEndCdataSection': ./pyexpat.c:1048: `XML_SetCdataSectionHandler' undeclared (first use in this fun ction) ./pyexpat.c: At top level: ./pyexpat.c:1077: `XML_SetCommentHandler' undeclared here (not in a function) ./pyexpat.c:1077: initializer element for `handler_info[8].setter' is not consta nt ./pyexpat.c:1089: `XML_SetDefaultHandlerExpand' undeclared here (not in a functi on) ./pyexpat.c:1089: initializer element for `handler_info[12].setter' is not const ant ./pyexpat.c:1092: `XML_SetNotStandaloneHandler' undeclared here (not in a functi on) ./pyexpat.c:1092: initializer element for `handler_info[13].setter' is not const ant make[1]: *** [pyexpat.o] Error 1 make[1]: Leaving directory `/home/blade/src/BUILD/Python-2.0/Modules' make: *** [sharedmods] Error 2 Bad exit status from /var/tmp/rpm-tmp.8833 (%build) Why doesn't this compile cleanly? Does it need a patch for RH6.2? Seems like an unlikely thing to do. Thanks, Blair Lowe Computer Engineering Inc. http://www.compeng.net Phone: 780 499 5687 (9 - 5 MST) Fax: 780 435 0693 (24 Hours) >From "Online LoanApplications-MoneyLendersarewaiting...."@cwi.nl Tue Dec 12 18:17:10 2000 Return-Path: <"Online LoanApplications-MoneyLendersarewaiting...."@cwi.nl> Delivered-To: python-list at python.org Received: from hera.cwi.nl (hera.cwi.nl [192.16.191.1]) by dinsdale.python.org (Postfix) with ESMTP id 5DD091CD72 for ; Tue, 12 Dec 2000 18:17:10 -0500 (EST) Received: from zeus.cwi.nl (zeus.cwi.nl [192.16.201.120]) by hera.cwi.nl with ESMTP id AAA12057 for ; Wed, 13 Dec 2000 00:17:11 +0100 (MET) Received: from Backstretch.leads.com (d83b350d.dsl.flashcom.net [216.59.53.13]) by zeus.cwi.nl with SMTP id XAA21233 for ; Tue, 12 Dec 2000 23:53:59 +0100 (MET) Subject: Interest RateOnline Loan Rates lows, tis` the season to spend money la la la .. lalalala -gtqof MIME-Version: 1.0 X-Encoding: MIME Content-Type: multipart/alternative; boundary="----=_NextPart_53036561383234" Message-Id: <31n28ei5k2bo52.0u7x5x5bjx1l00f at Backstretch.leads.com> Date: Tue, 12 Dec 2000 17:54:39 -0600 Reply-To: poogus at hotmail.com From: Online at python.org, Loan at python.org, Applications at python.org, - at python.org, Money at python.org, Lenders at python.org, are at python.org, waiting.... at cwi.nl X-Mailer: shelby090 at rocketmail.com To: python-list at cwi.nl Sender: python-list-admin at python.org Errors-To: python-list-admin at python.org X-BeenThere: python-list at python.org X-Mailman-Version: 2.0 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: This is a multi-part message in MIME format. ------=_NextPart_53036561383234 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable ******************************************************************************* *************** python-list Removal Instructions: Click on the link at the bottom of the page to be exclude from further communication. ****************************************************************************** **************** a2z National Mortgage Lender referral specialists For U.S.A. Homeowners Save Now! FREE We Shop The Best Loan For You! "FREE" We are a Mortgage lender referral service who specializes in helping people get the loans to: Debt Consolidation - http://www.a2z123.tv/debt/ 2nd Mortgage - http://www.a2z123.tv/2nd/ Refinance - http://www.a2z123.tv/refin/ Credit Repair - http://www.a2z123.tv/credit/ Home Improvement - http://www.a2z123.tv/improv/ New Car - http://www.a2z123.tv/car/ Dream Vacation - http://www.a2z123.tv/pre/ College Tuition - http://www.a2z123.tv/college/ Start a new business - http://www.a2z123.tv/newbiz/ ..and much, much more. Pay off bills - htpp://www.a2z123.tv/gen/ and stop creditors from calling 100% free service which lets you shop for a mortgage loan conveniently and securely from the comfort of your home computer. Using our vast network of lenders across the U.S., we will search our database of 50 lender rates for the best loan that fit your needs. Even if you're currently working with another lender or have been turned down before, we can still help. Funding borrowers with less than perfect credit is we can help that's our specialty! Incredibly low monthly payments We can get you the loan you need. Regardless of whether you have good or bad credit, we can help you. Ready to get started? Simply Click http://a2z123.tv/ fill out the form, and we'll begin shopping for your loan. It's that easy! Free Mortgage Quote ------------------------------------------------------------- Promotional email service provided by Backstretch Leads? ? 2000 a2z Mortgage Lender Refferal Services Email Removal Instructions: Click on the below link to be exclude from further communication. mailto:d_i_n_o_e at hotmail.com?subject=Remove From Listing. ------------------------------------------------------------- Are you in need of quality leads for any of the following industries? MLM Leads Opportunity Seeker Leads Business Buyers Investors Merchant account leads Travel Leads Mortgage Leads Long Distant Phone Services If you do... We have them and can always generate them for you. We offer lead generation services for many companies. If your industry is not listed above we may still be able to help you with your lead service needs. We can fine tune our mass advertising efforts to fit your exact needs. For quality leads at an affordable price please contact us today. Phone: 1.877.346.6123 Email: d_i_n_o_e at hotmail.com http://a2z123.tv/promo/ ----------------------------------------------------------- Promotional email service provided by Backstretch Leads? ? 2000 a2z Mortgage Lender Refferal Services Email Removal Instructions: Click on the below link to be exclude from further communication. mailto:d_i_n_o_e at hotmail.com?subject=Remove From Listing. ------------------------------------------------------------- ------=_NextPart_53036561383234 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable ------=_NextPart_53036561383234-- From c.evans at clear.net.nz Sun Dec 10 01:26:05 2000 From: c.evans at clear.net.nz (Carey Evans) Date: 10 Dec 2000 19:26:05 +1300 Subject: Handling signals and performance issues. References: Message-ID: <878zpo94hu.fsf@psyche.dnsalias.org> Roy Smith writes: > You might want to look at the source to the unix "tail" command (you > should be able to find it on any of the many GNU/Linux distribution > sites) and see how it implements the "-f" option, which is essentially > what you are trying to emulate. One trick I've seen is do a popen('tail -f filename', 'r'). Because this gives you one end of a pipe, you can use select() to tell when more data is available, unlike with a file. -- Carey Evans http://home.clear.net.nz/pages/c.evans/ From claird at starbase.neosoft.com Wed Dec 27 11:39:10 2000 From: claird at starbase.neosoft.com (Cameron Laird) Date: 27 Dec 2000 10:39:10 -0600 Subject: Python vs PHP (& Java?) References: <92d22f$cnv$1@nnrp1.deja.com> Message-ID: <9F7B793FB9C11A70.614813E4DCF61C53.380C715902E65086@lp.airnews.net> In article <92d22f$cnv$1 at nnrp1.deja.com>, wrote: . . . > Python packages for embedding scripts in HTML - aims to be comprehensive on this subject. . [various apt observations] . . >Yes, you can do it, but if you're working server side anyway, why >choose a language as limiting as Javascript? To lock yourself into an unhealthily conventional vendor relationship with Netscape. Phrased some- what more charitably, that seemed like a bang-up idea to many well-paid IT professionals not so long ago. . . . >Still, there are many very easy to use Python modules for such >functions, and if you are truly scripting InterNet Communications, >you're dealing with standard protocols. It doesn't matter what language >either end is implemented in. Java based clients can talk to Python >based servers, and vice versa. Like many things Mr. Spicklemire has written, this paragraph bears reiteration. . . . -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From bryan at eevolved.com Wed Dec 13 01:46:31 2000 From: bryan at eevolved.com (Bryan Mongeau) Date: Wed, 13 Dec 2000 06:46:31 GMT Subject: __file__ in 2.0 Message-ID: Hi all, I am interested in the mcmillan installer to generate self-extracting exe's. Unfortunately, running source/Make.py results in an AttributeError on exceptions.__file__ calls. I understand that static modules (such is the case) do not define the __file__ attribute. Documention pointed me to use .repr() or .str() instead to get the filename of a loaded module. No such luck when I edit the script (Attribute errors again)... Which leads me to my next question: is the mcmillan installer project stagnant? The release contains __file__ calls which crap out in 2.0 and they haven't even mentioned this on the site at all... Kinda leaves newbies like me scratching our heads. And my final question: How do I call __file__ on static modules in 2.0?? Tips, advice welcome. -- <==================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. www.eevolved.com <==================================> "... the true utility function of life, that which is being maximized in the natural world, is DNA survival. But DNA is not floating free; it is locked up in living bodies and it has make the most of the levers of power at its disposal." -- Richard Dawkins From jal at faxnet.com Fri Dec 15 09:55:32 2000 From: jal at faxnet.com (Jonathan LaCour) Date: 15 Dec 2000 14:55:32 GMT Subject: HELP - Threading with SCO Unix Message-ID: <91dbd4$9ot@dispatch.concentric.net> I am working with a corporation that is beginning development on a Python based product using Zope. In order for our product to function, we need to have Python built with thread support. One platform that we must support is SCO OpenServer. We have been attempting to compile python-1.5.2 with thread support for several days without success. We *must* have thread support, or we will be forced to move to another solution. Does Python even support threads in SCO Unix? Any suggestions? We have attempted our build using a binary distribution of GNU PThreads for SCO OpenServer. Installing another UNIX is not an option at this stage. If you are running SCO OpenServer and have python with threading support, please contact me! We need your help! Thanks for you help! This is absolutely critical for success, and any assistence would be appreciated! Jonathan LaCour Developer VertiSoft, Corp. From pbjorn at uswest.net Fri Dec 29 23:52:21 2000 From: pbjorn at uswest.net (Bjorn Pettersen) Date: Fri, 29 Dec 2000 21:52:21 -0700 Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> Message-ID: <3A4D6A05.EEC97FA6@uswest.net> henry_crun3583 at my-deja.com wrote: > Can someone point me at an explanation of the logic for not having > do: > until > > or explain the elegant way to achieve this in Python. > > eg > do : > R=Themistor.ReadResistance() > T=R_to_Temperature(R) > until (T >=25) while 1: R=Themistor.ReadResistance() T=R_to_Temperature(R) if T >=25: break From tcmay at got.net Tue Dec 5 21:36:10 2000 From: tcmay at got.net (Tim May) Date: Tue, 05 Dec 2000 18:36:10 -0800 Subject: Python Origins References: <90k3pq$50p$1@nnrp1.deja.com> Message-ID: In article <90k3pq$50p$1 at nnrp1.deja.com>, Nigel wrote: > I am doing some research and I would be grateful if anybody could give > me some history on the origins of Python. > If you are doing research, then you should surely understand that the large amount of material already on the Web, and findable with standard search engines, is a much better source of information than asking people to custom-write material for you. Or to do your searches for you. A handful of minutes spent with Google will yield you far more than waiting and waiting for people here to write histories for you. Why are you "doing some research" if you are this clueless? --Tim May -- ---------:---------:---------:---------:---------:---------:---------:---- Timothy C. May | Crypto Anarchy: encryption, digital money, ComSec 3DES: 831-728-0152 | anonymous networks, digital pseudonyms, zero W.A.S.T.E.: Corralitos, CA | knowledge, reputations, information markets, "Cyphernomicon" | black markets, collapse of governments. From aleaxit at yahoo.com Wed Dec 13 17:19:14 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 13 Dec 2000 23:19:14 +0100 Subject: Moving from Perl to Python References: <3a3a9552.76673185@news.tcn.net> <3a38b798.85448901@news.tcn.net> Message-ID: <918sud02por@news1.newsguy.com> "Richard Zilavec" wrote in message news:3a38b798.85448901 at news.tcn.net... [snip] > >I started with Learning Python, and I like that book. It explains the > > Wish I could see this book first, I don't want anything too basic > maybe just a quick start, then more advance features. In this case you may like the "Quick Python Book"; it's faster-paced and goes farther, while "Learning Python" covers less ground, a bit more deeply, and more slowly. Alex From sh at ttsoftware.co.uk Fri Dec 22 06:21:30 2000 From: sh at ttsoftware.co.uk (Steve Horne) Date: Fri, 22 Dec 2000 11:21:30 +0000 Subject: Speed of Python 1.5.x vs 2.0 References: <4vj54t4v0hvjsnstfmtmf36q9irotp59sj@4ax.com> Message-ID: On Fri, 22 Dec 2000 09:59:58 +0100, Andreas Jung wrote: >On Thu, Dec 21, 2000 at 10:53:32PM -0500, Tyler Eaves wrote: >> I'm soon going to attemp to talk my webhost into upgrading to >> 2.0, but I figure the only way I'm going to be able to make that >> happen is if I can show results that show 2.0 being faster / more >> effcient than 1.5.x. Their servers run on Red Hat 7. > >2.0 runs a bit faster than 1.5.X but don't expect a performance >boost. You should upgrade when you need some of the new features >of Python 2.0 like unicode support... > >Andreas I'd expect list comprehensions to work significantly faster than equivalent expressions using filter, map and lambdas - the reason being that the overhead of repeatedly calling the lambda should be avoided, not to mention avoiding the temp storage between the filter and map. I haven't tried this, but it might be worth a go. -- Steve Horne Home : steve at lurking.demon.co.uk Work : sh at ttsoftware.co.uk From removethis_kranki2 at earthlink.net Fri Dec 22 10:38:32 2000 From: removethis_kranki2 at earthlink.net (Bob W.) Date: Fri, 22 Dec 2000 15:38:32 GMT Subject: Newbie Question References: <05m64tkqev0aavea80ttjse1sj2gd447hg@4ax.com> Message-ID: I tried using "self" in the os.path.walk and I get an error saying that there 3 expected arguments, but got 4 in ntpath.py, line 264. That was my preferred way of simulating a C++ private method. Thanks for any help provided! On Fri, 22 Dec 2000 13:44:23 GMT, Bob W. wrote: >I am trying to write the following class, but it fails in the Run() >method reference to __CheckFile and I am not sure how to get it to >work. Thanks in advance for your help! > >class RmwExpireCheck: > def __init__( self, szFileName, szDir ): > self.szFileName = szFileName > FileStatList = os.stat( szFileName ) > if FileStatList: > self.iCheckDate = FileStatList[8] > self.szDir = szDir > self.szFileList = [] > > def __getitem__(self, i): > line = self.szFileList[i] > if line: > return line > else: > raise IndexError > > def __CheckFile( self, szDirName, szFileNames ): > for szFileName in szFileNames: > szPathName = os.path.join( szDirName, szFileName ) > if os.path.isfile( szPathName ): > iFileTime = os.stat( szPathName )[8] > if iFileTime > self.iCheckDate: > self.szFileList.append( szPathName ) > > def Run( self ): > os.path.walk( self.szDir, RmwExpireCheck.__CheckFile, self ) > > From SBrunning at trisystems.co.uk Wed Dec 6 05:13:13 2000 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Wed, 6 Dec 2000 10:13:13 -0000 Subject: [DAO Database in win32] What is more efficient Message-ID: <31575A892FF6D1118F5800600846864D5B1552@intrepid> > From: Arturo P?rez Mulas [SMTP:arturo_perez at wanadoo.es] > > By the way, is mxODBC any better? I dunno about better, 'cos I've never tried DAO/ADO. But I've used mxODBC quite a lot recently, and it seems fast, powerful and stable to me. I recommend it. Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From aleaxit at yahoo.com Tue Dec 5 05:11:13 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Tue, 5 Dec 2000 11:11:13 +0100 Subject: "inherited" keyword in Python? References: <3A2B9EFA.3A64C13B@schlund.de> <90gevs02uu1@news2.newsguy.com> Message-ID: <90ievt025bl@news2.newsguy.com> "Paul Foley" wrote in message news:m2elznipbl.fsf at mycroft.actrix.gen.nz... [snip] > > Metaprogramming magick was deemed inappropriate here (as I > > read the group consensus). One *might* have a global function > > called super(), which tried to gauge the appropriate class > > object to use (in single-inheritance cases, only, of course), > > Why "of course"? If you can find out the name of the method which is > calling super() (which can be done, but I don't remember how), and the Name of calling-function is easy (raise & catch an exception, it's in the stackframe you get this way). > class from which it's being called (I can think of ways to avoid > needing this, if it can't be done), This one is hellish. I can't figure out ANY halfway clean way that doesn't require either mucking with the bytecode, or going through all the dictionaries in an object's baseclasses until an entry with the same codeobject as the one previously identified is found -- slow as well as dirty. > it shouldn't be very hard to make > a super() function that works with multiple inheritance. Use > cpl(class) [see below] to get a properly ordered list of base classes, > and search for the first one that implements the named method. Call > that. [You need to know which class the current method belongs to in > order to get the right cpl, otherwise it'll infloop...but that isn't > obtainable, you could maybe have super() maintain a stack to tell it > where it's at, or something...] I think your cpl function is much more complicated than what's needed to reproduce Python's very simple rule for walking the DAG of base classes (it's just depth-first, left-first), even assuming it does end up reproducing it perfectly. But that's not the main point. A more interesting theoretical question is how you propose to solve the case in which you can't tell which class the current method 'belongs' to (also remember a given function-object may be set as a method of N classes, for any N, with any set of names -0- but, even forgetting that for the moment). E.g., a very simple case: class A: def foo(self): print super() class B(A): def foo(self): print super() A.foo(self) class C(A): def foo(self): print super() A.foo(self) class D(B,C): def foo(self): print super() B.foo(self) C.foo(self) Here, the various 'foo's are mercifully separate codeobjects so IN THEORY this is solvable (e.g., by rooting in the dictionaries of each ancestor-class of self looking for the codeobject as a value) -- of course if, say, C just did class C(A): foo = B.foo or def bar(something): print super() A.foo(something) class C(A): foo = bar we might have a harder time. But unless the class 'owning' (hoping there is some 'ownership'...) the calling-method IS identified (be it by hook or by crook), how does 'super()' does its job, even theoretically...? On a *pragmatic* level, I think this kind of "deep and dark metaprogramming tricks" are most often best eschewed for practical use. Great for writing debuggers, class-browsers, and all sorts of infrastructure, sure, but simpler and cleaner ways will generally prove more understandable and thus more maintainable. "Do the simplest thing that could possibly work" rules... and the "simplest thing" _rarely_ (not 'never') involves such reflection/introspection. It's too easy to get lost on a misguided quest to provide 'convenience', and actually end up obfuscating and obscuring things for no real good purpose. 'super()' in a multiple-inheritance context is a good example. There is no single superclass that will do for all attributes one might wish to access, so super().foo() and super().bar() just won't work. 'supercall' might work (without needing any real complication -- just a loop of getattr over the __bases__, given Python's quite-simple semantics here), IF you tell it which class it must find the 'supers' of -- the simplest and most effective way to do that is to have a convention that each class starts out by setting some specific variable to itself: class Foo: __thisclass=Foo # etc class Bar(Foo): __thisclass=Bar # etc and 'supercall' is always (but always!-) called in the form supercall(self, __thisclass, methodname, *args, **kwds) which reduces it to something decently-simple, like: def supercall(_obj, _cls, _metnam, *args, **kwds): for _bas in _cls.__bases__: _metobj = getattr(_bas, _metnam, None) if not _metobj is None: return _metobj(_obj, *args, **kwds) else: raise NameError, "No superclass of %s has method %s" % ( _cls, _metnam) But, how often is it going to be satisfactory to call 'just the one' (of several) inherited-method of a certain name, in a multiple-inheritance context? Just as often we may want to call _all_ methods of a certain name (__init__ and __del__ are frequent candidates, and indeed the last time this was discussed, a couple weeks ago I think, __init__ was the focus of the discussion) -- and shall we want to pass each of them the same arguments...? Complications flood us again pretty soon, and the harked-for "convenience" remains elusive. To quote an old local saying, I think that, in most cases, going for sophisticated metaprogramming tricks in the attempt to provide "convenience" is "quenching your thirst with ham". (P.S.: Bolognese ham tends to be pretty salty:-). Alex From dale at out-think.NOSPAMco.uk Wed Dec 6 08:18:36 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Wed, 06 Dec 2000 13:18:36 +0000 Subject: Rummaging around inside an Access DB Message-ID: I've been trying to dig some information out of an Access DB using Python. I need to access as much information as possible about the composition of all the reports. After a few false starts and lots of head scratching (I can't find a help file on the object model anywhere!!), I found something in the Python Win32 distribution called daodump.py, presumably written by Mark H. This helped a lot and produced a listing of all the reports but I can't seem to break into the Report object. This is what I've come up with so far: from win32com.client import Dispatch import sys eng = Dispatch("DAO.DBEngine.36") db = eng.OpenDatabase(sys.argv[1]) rep = db.Containers.Item('Reports') for doc in rep.Documents: print doc.Name Does anyone know how I can get at the cuts of the Report object? The only other properties I can find are: AllPermissions, CLSID, Container, CreateProperty, DateCreated, LastUpdated, Name, Owner, Permissions, Properties, UserName Thanks for any help. -- Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From francois.granger at free.fr Thu Dec 7 15:45:05 2000 From: francois.granger at free.fr (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Thu, 07 Dec 2000 20:45:05 GMT Subject: Help/example of bit testing References: <90llq7$8fc@dispatch.concentric.net> Message-ID: <1elagig.djja7k1ujl97mN@paris11-nas7-52-81.dial.proxad.net> Bryan Webb wrote: > Hi, > I am reading a file (binary)of 1024 char recs (bitmaps) . I can read the > file , bit im having trouble finding examples of testing bits. I need to > look at each bit of the above record. > Looking for examples and ideas. I got inspired by an algorithm by Tim Peters, so I did a quick hack in order to display in binary form. It need some polishing. l = [1, 2, 3, 4, 8, 16, 32, 64, 128, 255, 512, 1024, 2048, 4096, 8192, 16384, 32768] def toBin(x): a = '' y = x while x: x, y = x / 2, y % 2 if y: a = '1' + a else: a = '0' + a y = x return for x in l: print toBin(x) -- Une faq de frj: http://faq.jardin.free.fr/, pr?s de l'encyclop?die http://nature.jardin.free.fr/ From sdm7g at virginia.edu Wed Dec 20 13:09:45 2000 From: sdm7g at virginia.edu (Steven D. Majewski) Date: Wed, 20 Dec 2000 13:09:45 -0500 (EST) Subject: Python interpreter in python? In-Reply-To: <91qas9$i10$1@talia.mad.ttd.net> Message-ID: On Wed, 20 Dec 2000, Raymond Biurrun wrote: > "Steven D. Majewski" escribi en el mensaje > news:mailman.977254923.336.python-list at python.org... > > > > That is absolutely untrue! > > > > Lisp and Scheme are frequently implemented in themselves -- a > > 'metacircular interpreter' is a fairly typical student exercise. > > > > Please excuse my ignorance but what's a "metacircular interpreter" and where > can I find info about them. > Thats just the fancy name they sometimes use for a Lisp interpreter written in Lisp. The top level loops on (PRINT (EVAL (READ))) -- and usually the exercise is to implement EVAL. It's a not uncommon exercise in Lisp or Scheme books. ( See for a list. ) The Structure and Interpretation of Computer Programs by Abelson, Susman & Sussman (commmonly abreviated SICP) is one. Lisp In Small Pieces by Christian Queinnec, or John Allen's (out of print) Anatomy of Lisp are a couple other I recall. Any of those or any of the other books on implementing Lisp are useful for understanding the implementation of any other symbolic interpreted language (like Python, for example.) Parsing is completely different -- Python has a more complicated syntax -- but you can find info on parsing in any compiler book. Python's solutions for symbol management and scoping are different, but the problems are similar. Lisp and Forth just happen to have a significant implementation literature. Ralph Griswold has a good book on the implementation of Icon, and I think had one on Snobol. For everything else -- Python, Perl, Tcl, Ruby, et.al., you mostly have just the source code. -- Steve Majewski From glenfant at equod.com.nospam Tue Dec 19 08:29:25 2000 From: glenfant at equod.com.nospam (Gilles Lenfant) Date: Tue, 19 Dec 2000 14:29:25 +0100 Subject: Timers in Python? References: <3a3e42ef.16144323@news.skynet.be> <91li8l$33h$1@reader1.imaginet.fr> <3a3e61cf.24049354@news.skynet.be> <91lq8r$gu2$1@panix6.panix.com> Message-ID: <91nnj3$djm$1@reader1.imaginet.fr> Yes... Sorry for this ! "Aahz Maruch" a ?crit dans le message news: 91lq8r$gu2$1 at panix6.panix.com... > In article <3a3e61cf.24049354 at news.skynet.be>, > Daniel wrote: > > > >class TimeScheduled(threading.Thread): > > def __init__(self, function, delay): > > self.function = function > > self.delay = delay > > Gilles made a boo-boo. Here's the correct code: > > class TimeScheduled(threading.Thread): > def __init__(self, function, delay): > threading.Thread.__init__(self) > self.function = function > self.delay = delay > > For more info on threading, take a look at > http://starship.python.net/crew/aahz/ > -- > --- Aahz (Copyright 2000 by aahz at pobox.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > This is a signature anti-virus. > Please stop the spread of signature viruses! From jepler at inetnebr.com Sat Dec 30 13:43:04 2000 From: jepler at inetnebr.com (Jeff Epler) Date: Sat, 30 Dec 2000 18:43:04 GMT Subject: 2001 Enchancement Wishlist References: <3A4CEACB.220998A0@javanet.com> Message-ID: On Sat, 30 Dec 2000 10:52:10 +0200, Pearu Peterson >I see that many Python experts are against this proposal but anyway, I >would like to support this idea with the following examples. > >Say, I would like to define > >class Real: > def __init__(self,num): > self.num = num > > >class Complex: > def __init__(self,real,imag): > if imag == 0: > return Real(real) > self.real,self.imag = real,imag > > >That is, if imaginary part of a Complex number is zero, it's constructor >would return Real instance: I think that this can be accomplished by using a 'transmute' function, defined something like the following: def transmute(instance, newclass, *args, **kw): instance.__class__ = newclass apply(instance.__init__, args, kw) return instance it can be useful other places than __init__, for one thing. See Complex.__iadd__. class Real: def __init__(self, num): self.num = num # numeric methods class Complex: def __init__(self, real, imag=0): if not imag: transmute(self, Real, real) return self.real, self.imag = real, imag def __iadd__(self, other): self.real += other.real self.imag += other.imag if not self.imag: transmute(self, Real, self.real) return self # Other numeric methods >>> complex(1,0) >>> c = complex(1,1) >>> print c >>> c += complex(1,-1) Is there anything that you would like to do which transmute cannot? One issue I see is whether the dictionary should be cleared in the object before it is transmuted (for instance, "c" still has attributes 'real' and 'imaginary' after it is transmuted in Complex.__iadd__) but I don't see anything that is just plain impossible. Toss transmute in your standard library somewhere, and you have a nice way to write this code---just a function call. Or make it a method on a common base class. I don't know whether "self.transmute(Real, self.real)" makes any more or less sense than I wrote it above. Jeff From tony at lsl.co.uk Thu Dec 14 09:34:10 2000 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Thu, 14 Dec 2000 14:34:10 -0000 Subject: How to use mxTextTools In-Reply-To: <2bc4OuYTMVp87e49nlcz01wv0ybq@4ax.com> Message-ID: <003501c065da$ec392da0$f05aa8c0@lslp7o.int.lsl.co.uk> Paul Moore wrote: > More information, or better still, some complete examples, would be > very helpful. (All the examples in the distribution just use > print_tags() to display the tags, and don't do anything with them...) Well... the "obvious" (and incestuous?) examples, referenced off the mxTextTools web page itself, are my "meta language" for mxText Tools [1] and Mike Fletcher's SimpleParse [2]. They're rather different in style, and (perhaps) not a *simple* example of what one can do, but they *are* examples. A "quick" search with Google also suggests that PyFontify.py in py2html.py might be using it, and maybe dalke is as well. Of course, Marc might have some examples as well... [1] http://www.tibsnjoan.demon.co.uk/mxtext/Metalang.html [2] http://members.home.com/mcfletch/programming/simpleparse/simpleparse.htm l Have to dash... Tibs -- Tony J Ibbs (Tibs) http://www.tibsnjoan.co.uk/ Well we're safe now....thank God we're in a bowling alley. - Big Bob (J.T. Walsh) in "Pleasantville" My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From thomas at xs4all.net Sat Dec 23 15:53:25 2000 From: thomas at xs4all.net (Thomas Wouters) Date: Sat, 23 Dec 2000 21:53:25 +0100 Subject: Why Won't This Work? In-Reply-To: ; from lists@TheWebsons.com on Sat, Dec 23, 2000 at 12:18:40PM -0800 References: <20001223184357.G5515@xs4all.nl> Message-ID: <20001223215325.L5483@xs4all.nl> On Sat, Dec 23, 2000 at 12:18:40PM -0800, Ben Ocean wrote: > Hmmm. *python* at a command prompt, sans *./* is a command. > This worked when I configured 2.0, which I had to rip out because it's not > compatible with Zope. 'python' *with* './' is a command as well. './python' attempts to start the python binary in your current directory. If that fails, you don't have a python binary in your current directory, or it isn't executable :) The problem with 'python' seems to be that there is no 'python' binary in your PATH (the standard search-path for executables) according to your shell. If you really ripped out Python 2.0, and did 'make install' in a 1.5.2 tree, it could very well be that your shell hasn't registered the fact that you have a new binary. Try doing 'rehash' or 'hash -r' (depending on your shell) to 'reset' it. Another possibility is that you don't have /usr/local/bin/ in your path, or you passed a different --prefix to python's configure and don't have that in your path. All the above can only be the problem if you didn't already do 'make install' in the Python 1.5.2 sourcetree. From your mail it isn't clear whether you did that yet or not. > Also, I tried *make test* > [webmaster at thor Zope-2.2.4-src]$ make test > make: *** No rule to make target `test'. Stop. > Any other ideas as to why I'm not getting my installation of Python 1.5.2 > to respond? Well, is your problem python 1.5.2, or Zope ? If you want to install python 1.5.2, you shouldn't first try to install Zope ;) The 'make test' I was referring to is the python 'make test', so you should do it in the python 1.5.2 sourcetree, not the zope one. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From root at rainerdeyke.com Sat Dec 30 23:42:23 2000 From: root at rainerdeyke.com (Rainer Deyke) Date: Sun, 31 Dec 2000 04:42:23 GMT Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> Message-ID: "Steve Lamb" wrote in message news:slrn94t1vj.150.grey at teleute.rpglink.com... > On Sat, 30 Dec 2000 23:00:53 GMT, Kragen Sitaker wrote: > >Hahaha! You just plonked Fredrik Lundh in comp.lang.python. He was > >being helpful and polite, and you plonked him because you disagreed > >with him. I can guess how much help you'll get next time you have a > >Python question. :) > > I can tell you I'll get far better without him than with him when he is > giving advice that runs contrary to about 10+ years of programming that I've > been taught from various different sources. I don't care if he is God > himself, advocating not initing a variable is stupid, plain and simple. He > wanted to argue the point for nothing more than argument's sake, so be it. I > don't need his advice any further. Uninitialized variables do not exist in Python, therefore the concept of initializing variables is meaningless here. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From auto103690 at hushmail.com Sun Dec 10 23:29:03 2000 From: auto103690 at hushmail.com (Jeff) Date: Mon, 11 Dec 2000 04:29:03 GMT Subject: Executable python program? Message-ID: A non-text attachment was scrubbed... Name: not available Type: text/plain charset=iso-8859-1 Size: 534 bytes Desc: not available URL: From dale at out-think.NOSPAMco.uk Wed Dec 13 10:37:33 2000 From: dale at out-think.NOSPAMco.uk (Dale Strickland-Clark) Date: Wed, 13 Dec 2000 15:37:33 +0000 Subject: Source Code Management Message-ID: I'm looking for a source code management system for looking after Python, Java, Javascript and possibly other languages too. Does anyone know of such a system that matches or comes close? Essential features: * Runs on Windows 2000 * Works over the Internet (ftp would be good) * Secure (ftp level security would pobably suffice) * Module level version control with deltas or compressed archives * Package level (multiple modules) sign in/sign out * System level release control. (ie, this is now release x, note all module versions for this release.) Desirable features: * Extendible - preferably scriptable with Python * Manage arbitrary files including documentation * GUI or command line interfaces * Low maintenance * Library stored as plain files and not in some odd database format That's not too much to ask, is it! :-) Thanks -- Dale Strickland-Clark Out-Think Ltd Business Technology Consultants From Blair.Lowe at compeng.net Wed Dec 6 18:05:03 2000 From: Blair.Lowe at compeng.net (Blair Lowe) Date: Wed, 6 Dec 2000 16:05:03 -0700 Subject: XML-RPC was [pygtk] Python and Orbit Examples In-Reply-To: <20001206165355.B12869@linfoo.eink.com> References: <200012060632.eB66WIK27614@ZOOstation.cc> <20001206165355.B12869@linfoo.eink.com> Message-ID: Sounds cool. I found pyXML. at http://download.sourceforge.net/pyxml/. Can one send XML to an SSL site with pyXML as well? If so, where is some good docs for this. The version I got (PyXML-0.6.2-2.0.i386.rpm) has not docs, and the overview at 4suite say I need to download something else. Are there some better tools for doing this. I started to look at Zope, but it was rather cumbersome and knowing where to start with the documentation was not easy to find either. TTYL, Blair. At 16:53 -0500 2000/12/06, Pehr Anderson wrote: >Dear Folks, > >I would highly recommend using XML-RPC as a minimally complicated >way to communicate data between your apps. > >This might sound complicated but it really only means > 1. specify XML encodings for your data, use these throught your code > 2. open a socket on the target > 3. send an XML query and wait for an XML response > 4. parse the response > >The beautiful thing about XML-RPC (remote proceedure call) is >that it is just dirt simple. You open a socket, dump in >human readable text, and wait for a human-readable response. >Everything gets completely defined somewhere and servers and >clients could be coded in *anything*! >No complicated tools are required to implement any parts of >this system though you might want to look at how others >parse XML rather than doing it all by hand. > >And the best part is you'll have an app that anyone can understand. >No secret church of CORBA, COM or other "special tools". >XML is directly comprehensible by HUMAN BEINGS and that makes it >a sustainable encoding with simple tcp sockets for transport. > > -pehr > > >On Tue, Dec 05, 2000 at 06:32:17PM -1200, Rob Brown-Bayliss wrote: >> >or getting it to work with gnome-python, that is a bit more difficult. >> >> Sounds a little ominous... >> >> What I am doing (or planning at this stage) is to write a POS and Stock >> management system for a small retail chain. >> >> Would I be better of giving Pyhton a miss, or ditching the Corba idea? >> >> I have very little knowledge of linux programming, though I do have >> years of basic programming on the Amiga (like 18 I think if >>include vic 20 and c64) >> and a few months VC++ on windows. I have used Linux for 18 months >>now, and played >> a bit with C and a very very little with Python. >> >> I am confident I can tackle the task in either language, but I >>know python will be >> quicker to develop with. >> >> I had looked to corba as a means of communicating between the >>stores, I could always >> use some form of file transefer, but it's not as elegant or nearly >>as real time. >> >> >> >> >> -- >> >> Rob Brown-Bayliss >> ---======o======--- >> >> www.ZOOstation.cc >> >> _______________________________________________ >> pygtk mailing list pygtk at daa.com.au >> http://www.daa.com.au/mailman/listinfo/pygtk > >-- >http://www.python.org/mailman/listinfo/python-list Computer Engineering Inc. http://www.compeng.net Phone: 780 499 5687 (9 - 5 MST) Fax: 780 435 0693 (24 Hours) From bruce_dodson at bigfoot.com Fri Dec 22 23:29:08 2000 From: bruce_dodson at bigfoot.com (Bruce Dodson) Date: Sat, 23 Dec 2000 04:29:08 GMT Subject: coding convention conversion References: <20001222122015.A7987@llnl.gov> Message-ID: Better yet, import the file as a module, and scan through its public symbols (via dir()) to find out which names need to be changed, and then use that information to build a sed script which can be applied globally. You can easily take advantage of other meta-information such as the type, e.g. limit it to just functions if you want. This approach is good because the parser will recognize more variations than a regexp. Something like this is what I had in mind: from types import ModuleType, ClassType def print_symbols(symbols, prefix=''): for sym in dir(symbols): if sym[:2] == '__': continue v = getattr(symbols, sym) if type(v) is ModuleType: continue print prefix + sym if type(v) is ClassType: print_symbols(v, prefix + sym + '.') See also the pyclbr module for a way to do something similar without executing the module. Bruce "D-Man" wrote in message news:mailman.977522226.5104.python-list at python.org... > > This shouldn't be too hard with a python script and some regexes with > some more string processing in between (or maybe multiple pass). > > Everything you want to change is bounded by "def" on one side and "(" > on the other. Then replace the capitals with _ followed by the lower > case version. > > A quick (partial) solution: > > re = re.compile( "def ([a-z]+)([A-Z])([a-z]*)\(" ) > > for line in source.readlines() : > match = re.match( line ) > if ( match ) : > res = "def " + re.group( 0 ) + "_" + \ > string.lower( re.group( 1 ) + re.group( 2 ) + "(" > > > This isn't complete and won't have the arguments in the result (nor > preserve indentation before the "def"). > > I think the re.sub() function will do more of what you want it to. > > > HTH, > -D > > > On Fri, Dec 22, 2000 at 12:20:15PM -0800, Issac Trotts wrote: > > Does anyone know of a utility to change between the coding conventions > > of > > > > def fooBarBaz(): pass > > > > and > > > > def foo_bar_baz(): pass > > > > It is a pain to do this by hand. > > > > Thanks, > > Issac > From matthewrussell at my-deja.com Wed Dec 6 07:49:59 2000 From: matthewrussell at my-deja.com (matthewrussell at my-deja.com) Date: Wed, 06 Dec 2000 12:49:59 GMT Subject: urllib2, proxy, basic authentication References: <90hk8k$fqh$1@bob.news.rcn.net> <3A2D61C1.9182431D@motorola.com> <90k859$adl$1@bob.news.rcn.net> Message-ID: <90lclk$38p$1@nnrp1.deja.com> A way to pass authentication details would be to specify them in the url as follows import urllib2 urllib2.urlopen("http://username:password at www.mydomain.com") In article <90k859$adl$1 at bob.news.rcn.net>, Albert Chin-A-Young wrote: > Jeremy Lamplough wrote: > > try setting the proxy host prior to importing the other modules. > > > import os, sys > > os.environ['http_proxy'] = 'http://[PROXY_HOST]:5865' > > import urllib2 > > from urllib2 import urlopen > > > The way i'm doing basic stuff, with NO authentication is (to download a > > stock quote) > > We don't have a problem with http_proxy and the remote host not > requiring authentication. However, if the remote host does require > authentication, then we have our problem. > > -- > albert chin (china @at@ thewrittenword .dot. com) > Sent via Deja.com http://www.deja.com/ Before you buy. From rjroy at NO-SPAM.magma.ca Wed Dec 20 14:34:30 2000 From: rjroy at NO-SPAM.magma.ca (Robert Roy) Date: Wed, 20 Dec 2000 19:34:30 GMT Subject: Q: dynamic function call References: Message-ID: On Wed, 20 Dec 2000 11:56:28 -0600, "Hwanjo Yu" wrote: >Hi, > >Is there any way to bind a function name at runtime ? >For instance, we don't know the function name to call, but we know the >function name is saved in a variable, "fname". >How to call it in this case ? >Thanks in advance. > Functions are first-class objects in python so it is no big deal to assign them to other names and then call them. There are also several ways to resolve names at runtime. Here are few quick examples of how this could be done. Bob ######### # this is the function we will play with def cb(name): print 'callback:', name # this gets passed the function def foo(name, callback): callback(name) #this gets passed the function name def bar(name, callbackname): globals()[callbackname](name) # call foo foo('joe',cb) #bind cb to c and call c=cb c('ralph') # use eval to run from function name eval('cb')('called from eval') # find the function in the locals dictionary locals()['cb']('called from locals') #find the function in the globals dictionary globals()['cb']('called from globals') # call bar bar('cb called from globals in function', 'cb') # note that we bound to c earlier so can call it as well bar('c called from globals in function', 'c') From pbjorn at uswest.net Sun Dec 17 00:10:14 2000 From: pbjorn at uswest.net (Bjorn Pettersen) Date: Sat, 16 Dec 2000 22:10:14 -0700 Subject: Source Code Management References: <91aq96$tba$1@nnrp1.deja.com> <3A3AA3B7.3AC3F4BF@uswest.net> <91ggld$ble$1@nnrp1.deja.com> Message-ID: <3A3C4AB6.E264370F@uswest.net> Thanks! (The feature seems like it would still require some text parsing in most cases however...) -bjorn gtalvola at my-deja.com wrote: > In article <3A3AA3B7.3AC3F4BF at uswest.net>, > Bjorn Pettersen wrote: > > Do you have a link to how to get the result in Python > marshalled dictionary > > format? (I looked at the perforce website but couldn't > find anything...) > > > > Here's a snippet from the Perforce mailing list about the feature > (I don't have the original author's name): > > > You can use the -G option to Perforce to cause Perforce to do input > > and output as Python marshalled dictionaries. (This is a new but > > unsupported feature in 2000.1 -- see "p4 help undoc".) > > > > Using this feature it's easy to query Perforce and read the results. > > > > import marshal > > import win32pipe > > stream = win32pipe.popen('p4 -G changes', 'r') > > changes = [] > > try: > > while 1: > > changes.append(marshal.load(stream)) > > except EOFError: > > for c in changes: > > print c['change'], c['desc'] > > > > > > Sent via Deja.com > http://www.deja.com/ From rturpin at my-deja.com Thu Dec 28 13:00:45 2000 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Thu, 28 Dec 2000 18:00:45 GMT Subject: Python vs. PHP (& Java?) References: <69BC4C6AE83ED311BC9400805FA7B14AF84D2C@il93exp01.css.mot.com> Message-ID: <92fv4a$l2l$1@nnrp1.deja.com> "Kemp Randy-W18971" writes: >> Can we nip language comparisons in the bud? In comp.lang.*? I doubt it. In article , "Alex Martelli" wrote: > In each case, there are some _facts_ that can be pointed > out, .. Yep. And some of these facts point to the danger of reasoning from natural to programming languages. People use natural language for human communication. And in almost all practical contexts, small competencies bring signficant benefit. If you can ask where the bathroom is in Japanese, the waiter, recognizing your deficiency in that tongue, but pleased that you made the attempt, will point the way. This keeps you from having to translate the Japanese equivalent of "behind the screen with the crouching tiger." Which is good, because your back teeth are afloat, and the only part your limited Japanese knows is "behind." In contrast, texts in computer languages are more studied as artifacts. "How did this work?" "Why did it stop working?" "What did the original authors intend?" They, the rascals, are no longer around to explain, take credit, or defend their honor. This kind of comprehension requires a high level of competency in the language. Knowing one-tenth of Perl is not enough to understand most Perl scripts. Computer languages have more precisely defined semantics than natural languages. The niggling details are important, such as what "[[0]*10]*3" means. Natural languages are more fluid, and it is the nuances of the tacit, multiple meaning, and almost ambiguous that are important in their competence. For these reasons, I am a great believer in small computer languages, ones that can be explained well in a book no thicker than my pinkie. The use of extentions should be recognizable, so that when you come across something you don't know, you know *what* to look up and where to find it. "One way to do everything" IS better than "many ways to do anything." Of course, being small has its hazards, if core features are omitted. That's why I am fond of saying that a language's productivity is proportional to its expressive power, and inversely proportional to its complexity. (Not that these are the only considerations.) That is why I am happy to see Guido resist the temptation to continually add new bells and whistles. People tend to focus on the benefit of expressive power, while overlooking the problem of complexity. C, Lisp, and Python are examples of languages that pack a lot of expressive power into simple packages with a small set of orthogonal concepts. C++, trying to build OO on top of C while retaining maximal compile time efficiency, grew bigger than its expressive power requires. But that set of goals is hard to achieve, and to its credit, C++ does this. Perl is overly complex for what it does. I think this was due to its syncretic history, rather than the scope of what it achieves. Like Alex, I can't imagine any task that, from a pure language viewpoint, is better done in Perl than in Python. Practical constraints, such as a company's preferred language, or which language someone already knows, could determine otherwise. Russell Sent via Deja.com http://www.deja.com/ From jbalding at hotmail.com Thu Dec 14 20:14:44 2000 From: jbalding at hotmail.com (jbalding at hotmail.com) Date: Fri, 15 Dec 2000 01:14:44 GMT Subject: Is Stackless and uthread.py SMP friendly? Message-ID: <91br9v$qa4$1@nnrp1.deja.com> I read with interest a recent thread asking about threading, the global interpreter lock, and symmetric multiprocessing. Nobody mentioned, as far as I could see, Stackless Python and microthreads. Having just picked up a dual PIII machine, will Stackless and uthread.py make my SMP experience with Python a happy one? Thanks - John Sent via Deja.com http://www.deja.com/ From mfletch at tpresence.com Thu Dec 14 12:01:03 2000 From: mfletch at tpresence.com (Mike Fletcher) Date: Thu, 14 Dec 2000 12:01:03 -0500 Subject: How to use mxTextTools Message-ID: Something you might find useful would be to look at the mcf.vrml.parser module, which uses simpleparse (which just spits out mxTextTools tuples) to process a file into an in-memory node graph. See http://members.home.com/mcfletch/programming/mcf_vrml.htm for the mcf.vrml distribution. Here's some code from there... def readNext( self): '''Read the next root-level construct''' success, tags, next = TextTools.tag( self.data, ROOTITEMPARSER, self.position ) ## print 'readnext', success if self.position >= self.datalength: print 'reached file end' return None if success: #print ' successful parse' self.position = next if self.parseOnly: return success map (self.rootItem_Item, tags ) return success else: return None def rootItem (self, (type, start, stop, (item,))): ''' Process a single root item ''' self.rootItem_Item( item ) def rootItem_Item( self, item ): result = self._dispatch(item) if result is not None: ## print "non-null result" ## print id( self.sceneGraphStack[-1] ), id(self.result ) self.sceneGraphStack[-1].children.append( result ) def _getString (self, (tag, start, stop, sublist)): ''' Return the raw string for a given interval in the data ''' return self.data [start: stop] def _dispatch (self, (tag, left, right, sublist)): ''' Dispatch to the appropriate processing function based on tag value ''' ## print "dispatch", tag try: function = getattr (self, tag) except AttributeError: raise AttributeError( '''Unknown parse tag "%s" found! Check the parser definition!'''%(tag)) return function( (tag, left, right, sublist) ) def Proto(self, (tag, start, stop, sublist)): ''' Create a new prototype in the current sceneGraph ''' # first entry is always GI GI = self._getString ( sublist [0]) ## print "PROTO",GI newNode =Prototype (GI) ## print "\t",newNode setattr ( self.sceneGraphStack [-1].protoTypes, GI, newNode) self.prototypeStack.append( newNode ) # process the rest of the entries with the given stack map ( self._dispatch, sublist [1:] ) self.prototypeStack.pop( ) def fieldDecl(self,(tag, left, right, (exposure, datatype, name, field))): ''' Create a new field declaration for the current prototype''' # get the definition in recognizable format exposure = self._getString (exposure) == "exposedField" datatype = self._getString (datatype) name = self._getString (name) # get the vrml value for the field self.fieldTypeStack.append( datatype ) field = self._dispatch (field) self.fieldTypeStack.pop( ) self.prototypeStack[-1].addField ((name, datatype, exposure), field) HTH, Mike -----Original Message----- From: Paul Moore [mailto:paul.moore at uk.origin-it.com] Sent: Thursday, December 14, 2000 8:36 AM To: python-list at python.org Subject: How to use mxTextTools Hi, I'm looking at mxTextTools to see if it would be suitable for some types of text parsing work I am interested in (nothing concrete yet, so I can't give specifics...) The example in the documentation of tagging HTML looks fine - I understand what's going on there, and as I understand it, this will give me back a taglist, which is (effectively) the text stream with portions tagged as I ask. What I dont't see (yet), and I can't find any good examples for, is what to do with the resulting taglist. There seem to be no functions for working with taglists, and the lists themselves seem like relatively complex data structures, so is it right that I should be manipulating them "by hand"? More information, or better still, some complete examples, would be very helpful. (All the examples in the distribution just use print_tags() to display the tags, and don't do anything with them...) Paul -- http://www.python.org/mailman/listinfo/python-list From kalle at gnupung.net Tue Dec 12 09:07:06 2000 From: kalle at gnupung.net (Kalle Svensson) Date: Tue, 12 Dec 2000 15:07:06 +0100 Subject: Q: Print whithout \n In-Reply-To: References: Message-ID: On Tue, 12 Dec 2000, Henrik M?rtensson wrote: > How do you print a string whithout a linefeed in the end. As others have said, print with a , works, but it gives you a space instead. If this disturbs you as it does me, you can use the write method of sys.stdout (or sys.stderr): import sys sys.stdout.write("Hej, ingen nyrad") If you do something like import sys if filename: outfile = open(filename, "w") else: outfile = sys.stdout outfile.write("Whatever...") outfile can be anything with a write method, which can be nice, e.g. for handling different output formats. Peace, Kalle -- Email: kalle at gnupung.net | You can tune a filesystem, but you Web: http://www.gnupung.net/ | can't tune a fish. -- man tunefs(8) Not signed due to logistical difficulties (I'm not at home). If you doubt the authenticity of this message, please tell me. From cg at schlund.de Mon Dec 11 08:02:00 2000 From: cg at schlund.de (Carsten Gaebler) Date: Mon, 11 Dec 2000 14:02:00 +0100 Subject: while true: !!! References: <8uthf2$pjh$04$1@news.t-online.com> <8utnqk02rlq@news1.newsguy.com> <8uu44b$4nc$04$1@news.t-online.com> <3A34CEA7.CD9D85AE@yahoo.com> Message-ID: <3A34D048.62889EE2@schlund.de> Jaroslav Gergic wrote: > Do you know better construction to avoid both - duplicate lines > and horrible 'while 1' construction? > > Something like: > > while( "" != (line = fh.readline()) ): > ... do something ... You could write a wrapper class like this: class MyFile: def __init__(self, filename): self.f = open(filename, "r") def readline(self): self.line = self.f.readline() return self.line And then something like: F = MyFile("somefile") while F.readline(): print F.line cg. From moshez at zadka.site.co.il Wed Dec 27 11:49:00 2000 From: moshez at zadka.site.co.il (Moshe Zadka) Date: Wed, 27 Dec 2000 18:49:00 +0200 (IST) Subject: Python and Napster In-Reply-To: <92ap0g12b6r@news1.newsguy.com> References: <92ap0g12b6r@news1.newsguy.com>, Message-ID: <20001227164900.DF7E6A84F@darjeeling.zadka.site.co.il> On Tue, 26 Dec 2000 19:40:14 +0100, "Alex Martelli" wrote: > Python would probably let you be more productive, I suspect. It sure has > all the network functionality you need; in your shoes, I'd look into pyro -- > building file exchange on top of it should be easier than on sockets or on > protocols such as HTTP. I'm not so sure I agree -- SimpleHTTPServer/urllib/httplib is wonderful for file transfers. For anyone who wants to see a practical exmple (supports both upload and download), have a look at PMEP in the PMS source distribution (http://pythonms.sourceforge.net) -- Moshe Zadka This is a signature anti-virus. Please stop the spread of signature viruses! From garachop at club-internet.fr Thu Dec 7 19:09:35 2000 From: garachop at club-internet.fr (Patrice Garachon) Date: Fri, 08 Dec 2000 01:09:35 +0100 Subject: win32evtlogutil: How does it works ? References: <3A2D556F.6240C661@club-internet.fr> <3A2D8223.4070408@ActiveState.com> Message-ID: <3A3026BF.CB70C2E2@club-internet.fr> Mark Hammond a ?crit : > > Garachon Patrice wrote: > > > Any ideas ? > > Not really - but you are not alone. I have the same problem, and havent > been able to track it down. The PythonService support for the event log > works fine, and I can't see the difference between the 2 :-( > > I am sure it is just a registry setting, but I can't see what it is... > > Mark. Today, I have tried to use PythonService.exe as Dll message. If you use the 1001 or 1002 Id number, it doesn't works but if you use 0x4000100 1 or 2 It works ? -- Patrice From phd at phd.pp.ru Thu Dec 28 11:24:12 2000 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 28 Dec 2000 19:24:12 +0300 (MSK) Subject: cgi parameters In-Reply-To: <3A4B4BD8.6A696387@wielun.dhs.org> Message-ID: On Thu, 28 Dec 2000, QdlatY wrote: >
^ ^ you are trying to combine both GET and POST methods. WWW Servers do not allow it. Pass your value in a hidden field in the form. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From gerhard.nospam at bigfoot.de Thu Dec 28 14:21:34 2000 From: gerhard.nospam at bigfoot.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Thu, 28 Dec 2000 20:21:34 +0100 Subject: Python with Apache on WinNT newbie question References: <3a4b6391.4061375@localhost> Message-ID: I recommend to add the following line to httpd.conf under WinNT: ScriptInterpreterSource Registry and give your Python scripts the extension ".py". A Python CGI script can then look like: #!/usr/bin/env python print 'Content-type: text/plain\n\nHello!' and work perfectly under WinNT and Linux! Gerhard H?ring -- mail: gerhard bigfoot de web: http://highqualdev.com On Thu, 28 Dec 2000 16:07:07 GMT, Victor Muslin wrote: >To get Apache server to run a Python CGI script, the script needs to >have on its first line a directive telling Apache the file name of the >Python interpreter, like so: > > #!d:/apps/python/python.exe > # > # The rest of my cgi script follows > # .... > >The problem with this is deploying this script on different machines >that may have Python interpreter installed in different directories. >Surely others had run into the same issue. What is a typical solution? >Unfortunately, if this directive can take environmental variables I >could not figure out how to do it. From henrik.martensson at frontconsulting.se Tue Dec 12 06:43:02 2000 From: henrik.martensson at frontconsulting.se (Henrik Mårtensson) Date: Tue, 12 Dec 2000 11:43:02 GMT Subject: Q: Print whithout \n Message-ID: Hi How do you print a string whithout a linefeed in the end. /Henrik From pbjorn at uswest.net Sat Dec 23 17:34:41 2000 From: pbjorn at uswest.net (Bjorn Pettersen) Date: Sat, 23 Dec 2000 15:34:41 -0700 Subject: Some Python 2.1 ideas References: Message-ID: <3A452881.7686E717@uswest.net> string.chomp() (a better name would be nice) needs to handle all of: - "foo\n" - "foo \n" - "foo \r\n" - "foo \n\r" - "foo" etc. correctly, which means it should delete between zero and two bytes (characters) from the end of the string. This is very different from removing leading or trailing whitespace (whitespace can be significant you know ). Before someone suggests: line = line[:-1] I would note that this removes one character too many if you're reading a file that doesn't end in a newline. -- bjorn Pete Shinners wrote: > "Bob Alexander" wrote > > String method to remove trailing newline > > there is a string method named "strip()" that will > remove all whitespace (newline&linefeeds included) > from a string. > > actually, since strings are immutable, it returns a > new string with the appropriate changes made. > > there are also "rstrip" and "lstrip" functions which > will remove whitespace from only the end or beginning > of the string. > > >>> print 'Example string gotten from readline\n'.strip() > 'Example string gotten from readline' From richard at richardgordon.net Sun Dec 10 21:45:02 2000 From: richard at richardgordon.net (Richard Gordon) Date: Sun, 10 Dec 2000 21:45:02 -0500 Subject: recursion problem Message-ID: hi- I'm stuck on something that I thought would be easy, but has got me stumped. The scenario is that I am using python to automate the construction of a web index page that uses one of the assorted expanding/collapsing file tree javascripts (e.g., it is organized into folders and files within folders based on the physical location of stuff on the server). This particular one uses
    and
  • tags along with some trick style stuff to expand or collapse various levels of the hierarchy and looks more or less like the windoze explorer stuff once the dust settles. Anyway, walking the tree, figuring out what's a file and what's a directory and that kind of thing are easy, but where I'm getting stuck is in dealing with deeply nested folders. This will probably get screwed up in email, but what I want is something like:
      Level0folder
    • L0file
    • L0file
        Level1folder
      • L1file
          Level2folder
        • L2file
        • L2file
      • L1file
    So I am basically just reading the top level directory, then testing each item to see if it is a file or a folder. If it's a file, I just call a function that prints '
  • ' + filename + '' while if it's a directory, I go into another function that is supposed to do the initial
      stuff, then calls the file printer function for each file, then closes things out with
    before passing control back to the initial treewalker. Anyway, this is getting all screwed up as far as the closing
tags are concerned and I have managed to create the world's widest web page (kind of cool if you like fractals), hit a recursion limit, and otherwise toyed with it until I am exasperated. The question is how to drill down thru an arbitrary number of subdirectories and get the closing tags in the right places since the nesting prevents just writing one out every time you exit a directory? Thanks for any help you may have to offer. Richard Gordon -------------------- Gordon Design Web Design/Database Development http://www.richardgordon.net From peter at engcorp.com Sat Dec 30 21:12:13 2000 From: peter at engcorp.com (Peter Hansen) Date: Sat, 30 Dec 2000 21:12:13 -0500 Subject: why no "do : until"? References: <92jj3j$ff7$1@nnrp1.deja.com> Message-ID: <3A4E95FD.D6C737A7@engcorp.com> Steve Lamb wrote: > > On Sat, 30 Dec 2000 23:00:53 GMT, Kragen Sitaker wrote: > >Hahaha! You just plonked Fredrik Lundh in comp.lang.python. He was > > I can tell you I'll get far better without him than with him when he is > giving advice that runs contrary to about 10+ years of programming that I've > been taught from various different sources. I don't care if he is God > himself, advocating not initing a variable is stupid, plain and simple. He > wanted to argue the point for nothing more than argument's sake, so be it. I > don't need his advice any further. It appears to me that you've missed some of the points made in this "discussion". I would suggest you go back with an open mind and reconsider the validity of the opposing views. The advice that runs contrary to your 10+ years seems very reasonable to my 20+ years of programming experience, and apparently many others with a variety of experiences agree. I understand the point you are making; I'm just pointing out that the opposing views seem well-founded. Areas where I think you missed the point are in the importance of code maintainability, the increased complexity with your suggested approach, and the feelings of the "entire CS community" on this issue. If I may attempt to clarify what I believe is the opposing argument: you suggested an alternative which relies on initialization of a variable to a special value (anything less than 25) solely in order to enter a 'while' loop which you've rewritten to use the conditional at the top instead of at the bottom (because you believe there is some inherent advantage in doing this, though you've yet to explain what it is other than that the use of 'break' is somehow bad), and in the process you've demonstrated the *reason* others feel this is a poor approach, by leaving out the required initialization. And the first attempt to correct this was given using a wrong value for the initializer! That's the whole point: your approach is inherently open to such complexity/maintainability problems. Even experienced programmers can slip up in this way. I think those of us objecting have in our 10+ years of experience seen this kind of thing cause so many problems that we are happy with the single _idiomatic_ way which Python provides, in spite of a little so-called "ugliness". I suspect some of us would even argue that the conditional in 'do/until' can be difficult for some people to get right and that forcing the use of 'while/if/break' may actually increase the likelihood the resulting code will be correct the first time, and be interpreted correctly during maintenance. My guess is that for this precise reason the alternative loop construct was removed from/never added to Python in the first place. From chris_barker at my-deja.com Tue Dec 26 14:58:03 2000 From: chris_barker at my-deja.com (chris_barker at my-deja.com) Date: Tue, 26 Dec 2000 19:58:03 GMT Subject: Source for Linux Binaries? Message-ID: <92at88$rig$1@nnrp1.deja.com> Hi all, I'm looking for a source for Linux binaries for Python 2.0, and a whole bunch of modules to go along with it (PIL, Numeric, wxPython, etc.) I know the main Python web page has rpms for the main distro, but none of the add on packages. Has anyone set up a comprehensive source for Linux binaries? My foirst choice is RedHat 6.1 compatable rpms, but I'm flexible on that one. What I'm looking for is something along the line of Oliver Andrich's old site. If this doesn't exist, I may just have to set it up myself! -Chris Sent via Deja.com http://www.deja.com/ From phd at phd.pp.ru Tue Dec 5 07:07:27 2000 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 5 Dec 2000 15:07:27 +0300 (MSK) Subject: Random string In-Reply-To: <200012042351.QAA24052@mail.cybermesa.com> Message-ID: On Mon, 4 Dec 2000, Jay O'Connor wrote: > Is there a good algorithm or existing function for creating a random string such > as "AFYGADFGWETOQW6DSJD", suitable as a 'session id' for a web session Run md5 or sha1 over random int, convert the hash to a string and take any number of characters. Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From jepler at inetnebr.com Fri Dec 15 09:03:30 2000 From: jepler at inetnebr.com (Jeff Epler) Date: Fri, 15 Dec 2000 14:03:30 GMT Subject: __file__ in 2.0 References: Message-ID: On Wed, 13 Dec 2000 06:46:31 GMT, Bryan Mongeau wrote: >And my final question: How do I call __file__ on static modules in 2.0?? You can't. But if modulename in sys.builtin_module_names, then you know that no __file__ attribute will be defined. Jeff From phrxy at csv.warwick.ac.uk Tue Dec 12 08:39:58 2000 From: phrxy at csv.warwick.ac.uk (John J. Lee) Date: Tue, 12 Dec 2000 13:39:58 +0000 Subject: gcc and Python 2.0 on windows Message-ID: It seems that the Python 2.0 headers have been patched to allow the use of gcc on windows following Paul Sokolovsky's patch to 1.5.2, but only in config.h, not in object.h. I haven't noticed any reference to these changes in the C extension tutorial or reference. I managed to compile and run something with the plain Python 2.0 headers, so I presume it's fully working - but I don't know what the changes to object.h in Paul's patch are supposed to do - something to do with __declspec(dllimport). Are these changes redundant now? Maybe some mention of gcc / win should be made in the docs somewhere. Thanks for any help. John From landauer at apple.com Wed Dec 27 19:42:32 2000 From: landauer at apple.com (Doug Landauer) Date: Wed, 27 Dec 2000 16:42:32 -0800 Subject: A Suggestion for Python Colon Syntax References: Message-ID: > ... You should be able to tell from the overwhelming lack of > other response on the newsgroup that there's no groundswell > of desire (for making trailing colons optional) being suppressed > here! Well, there is the fact that it's currently between Chrismas and New Year's, and a lot of people aren't "here". But aside from that, I suspect - that 90% of the responses that are being suppressed are from lack of interest and/or a confidence that The Right Thing (i.e., No change) Will Happen; and - that most of those responses, were they to be written, would say something like this: "Why ever would you want to make your code less consistent and less readable by omitting the colons?" barely here-ly, -- Doug Landauer landauer at apple.com (work) landauer at scruznet.com (not-work) From darrell at dorb.com Tue Dec 5 19:06:59 2000 From: darrell at dorb.com (Darrell Gallion) Date: Tue, 5 Dec 2000 19:06:59 -0500 Subject: an apply question References: <007b01c05f15$34dcc750$3eaf2cd5@malanwin2000> Message-ID: <0ded01c05f18$749ffdf0$6401a8c0@home> >>> def a(): ... print 'a' ... >>> myMap={'a':a} >>> for k, f in myMap.items(): ... apply(f,()) ... a >>> func1 in MyMap shouldn't be a string. --Darrell ----- Original Message ----- From: "Alan Marchand" > In Python 2.0: > > What am I doing wrong? > > #!/bin/env python > ############# > MyMap = { > 'Key1' : 'func1', > 'Key2' : 'func2', > 'Key3' : 'func3', > 'Key4' : 'func4' > } > > def func1 ( ): > print "Here's func1" > > items = MyMap.items( ) > for x in range( len(items) ): > key, func = items[x] > if key == "Key3": > apply( func, ( ) ) > ------------------------- > c:\devpy\python test.py > > Traceback (most recent call last): > File "test.py", line 17, in ? > apply( func, ( ) ) > TypeError: Call of non-function (type string) From loewis at informatik.hu-berlin.de Fri Dec 8 15:07:38 2000 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 08 Dec 2000 21:07:38 +0100 Subject: newbie to python: can't load tkinter -- please help References: <90kg3p$n2p$0@pita.alt.net> Message-ID: "Mayer Goldberg" writes: > Can someone please help? Where did you get Python from? If it is ActivePython, then you need to install Tcl 8.3 separately. Regards, Martin From cg at schlund.de Fri Dec 22 11:52:29 2000 From: cg at schlund.de (Carsten Gaebler) Date: Fri, 22 Dec 2000 17:52:29 +0100 Subject: Again: compiling Python 2.0 against Berkeley DB Message-ID: <3A4386CD.5DE7EE06@schlund.de> Hi! I have to correct my posting regarding Berkeley DB 3.0.55. I *thought* I was trying to read a 3.0.55 file. In fact it's a version 1.85 file, and im trying to read it with Python compiled against BerkeleyDB 3.0.55 (dbhash.open() fails with "Invalid argument"). I have compiled BerkeleyDB 3.0.55 with 1.85 compatibility API but it doesn't like 1.85 files. Then I downloaded version 1.85 from sleepycat.com but that won't compile on my machine (numerous 'parse error before "("' messages). I'm stuck. How can I make my Python read those DB1.85 files? Regards Carsten. From robin at jessikat.fsnet.co.uk Mon Dec 4 06:17:29 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Mon, 4 Dec 2000 11:17:29 +0000 Subject: PyThreadState_Get error again :( References: <42+P6LAmqiK6Ewl1@jessikat.fsnet.co.uk> <3A2AD10F.8040803@ActiveState.com> Message-ID: In article <3A2AD10F.8040803 at ActiveState.com>, Mark Hammond writes >Robin Becker wrote: > >> I'm running BEOPEN Python 2.0, Win95 OSR2, PythonWin 134 (with the fixed >.pyds). > >I'm afraid that using "popen4("dir")" as the test, using ActivePython >201 (ie, win32all 135), on Windows 98, I can not get this code to fail >either from python.exe or pythonwin.exe :-( > >Mark. ... Well it's your co-author who claims it works with 2000 :) I can certainly 'claim' that there's something odd happening under win95. The good news is that we don't need the code any more ie we brought the calculation inboard. The crash happens when the output file is closed even when I try popen4("dir \\tmp"). The command seems to work and the output looks ok, just crashes when either of the files is closed. Is there any way to get 135 without reinstalling 2.0 or perhaps there has been a fix in that? Is it worth pursuing further? -- Robin Becker From MarkH at ActiveState.com Tue Dec 5 19:12:18 2000 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 06 Dec 2000 00:12:18 GMT Subject: activex scripting and debugging with Python win32com References: <90irub$24b$1@troll.powertech.no> Message-ID: <3A2D8317.20807@ActiveState.com> Syver Enstad wrote: > Anybody knows if there are any plans to rectify this, and in what time > perspective. I would be interested in doing some work on making this feature > work as it would help me work more productively with Python at work. I would like to help fix this, but don't currently have an ASP environment running. A good first step would be to confirm it _does_ work with IE and WSH (as it does for me, and I can work on that if it doesnt for you). After that, we need to work out what is different about ASP. Just mail me, and we can work through it - the more people that understand this the better!!! Mark. From SBrunning at trisystems.co.uk Wed Dec 13 06:04:22 2000 From: SBrunning at trisystems.co.uk (Simon Brunning) Date: Wed, 13 Dec 2000 11:04:22 -0000 Subject: Smalltalk and Python Message-ID: <31575A892FF6D1118F5800600846864D5B15DB@intrepid> > From: Alex Martelli [SMTP:aleaxit at yahoo.com] > > | It's an absolutely stunning language for free, and although not as > fast > > | as Perl > > > > (it's as fast in my experience) This site - - shows Python being outperformed by Perl in a number of categories, sometimes by a fair margin. Not that I care too much about this myself - I'd rather write a pretty program in Python that works than an ugly, fast one in Perl which probably doesn't . Still, I wonder if we could suggest some tweaks to his Python scripts which might improve Python's score. Cheers, Simon Brunning TriSystems Ltd. sbrunning at trisystems.co.uk There is no pleasure in having nothing to do; the fun is in having lots to do and not doing it. - Mary Little ----------------------------------------------------------------------- The information in this email is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. If you are not the intended recipient, any disclosure, copying, distribution, or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot accept liability for statements made which are clearly the senders own. From db3l at fitlinxx.com Fri Dec 22 19:20:07 2000 From: db3l at fitlinxx.com (David Bolen) Date: 22 Dec 2000 19:20:07 -0500 Subject: IP adresses are not unique enough. References: <3a413a17.3416402@192.168.0.1> <3A41475A.5DC4ABD8@san.rr.com> <3a4148ad.7150467@192.168.0.1> Message-ID: Ben Hutchings writes: > gogo at bluedynamics.com (Georg Gogo. BERNHARD) writes: > > > The MAC adresses are unique, as I understood. > > > I have some anecdotal evidence of cases where a manufacturer assigned > duplicate MAC addresses. Someone found me a documented case, too: > . The global MAC address space is designed to be unique, but given that most devices depend on programmed information during the manufacturing process to be assigned the MAC address, there's always the risk of error - either user (programming the wrong base into a programmer) or machine (a broken programmer). There is also the possibility (the feasibility of this on PCs probably depends on the card interface and OS) of programming a MAC to use a portion of the local address space, in which case it's up to local management to manage this. This sort of thing was much more prevalent on end stations I believe with Token Rings rather than Ethernets but its possible. And it's actually used to good effect in systems where machines back up each other (like a pair of Cisco routers) where the backup takes over the primary's MAC address in a fallover situation. In a locally reprogrammed case, you're still pretty safe assuming local uniqueness to the wire (or things wouldn't function too well), but not necessarily global uniqueness. I suppose you could detect a local address (bit 1 of the first octet) and treat that specially or something. But aside from chip serial numbers (and the ruckus that raised), MAC addresses from ethernet chipsets are probably the closest thing to a unique computer stamp (while that chipset is present at least) as we have. But it's not without some risks of duplication nonetheless. -- -- 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 qdlaty at wielun.dhs.org Thu Dec 28 09:19:04 2000 From: qdlaty at wielun.dhs.org (QdlatY) Date: Thu, 28 Dec 2000 15:19:04 +0100 Subject: cgi parameters Message-ID: <3A4B4BD8.6A696387@wielun.dhs.org> Hello! I need to pass index parameter to script executed by post method (via form) I tried to use following code: But this won't work (fieldstorage doesn't have "index" property) I'm counting on Your help :) Yours QdlatY From pbjorn at uswest.net Tue Dec 26 16:33:33 2000 From: pbjorn at uswest.net (Bjorn Pettersen) Date: Tue, 26 Dec 2000 14:33:33 -0700 Subject: <> vs != was Re: A Suggestion for Python Colon Syntax References: <92av8a$38f$1@hecate.umd.edu> Message-ID: <3A490EAD.BFE1EDDA@uswest.net> William Djaja Tjokroaminata wrote: > I personally think != is better than <>, just because not equal is != in > C/C++ (or Java too? Now I don't remember what is not equal in Java). I > like Python and I use it as much as I can. However, there isn't > a single language which is good for everything. I still use C/C++ a lot > (and also Perl for one-liners and some text processing), and therefore I > have to switch between the languages quite often. Isn't it great if all > the languages agree on what not equal should look like? We will get > syntax error less often and we have to open the reference books less often > too. Well, I still have to find my Java books to see what not equal is in > Java.... (sigh....) Well, then it is clear, we should never use !=, since if it was meant to mean not equal it would certainly have been spelt !==. != should of course be changed to the not assingment operator which would work perfectly in e.g. loops, where nobody sane would want to have an assignment. <> of course, should be read as either smaller or greater which everyone intuitively knows means not equal. this-is-all-the-timbot's-fault-and-I-should-probably-include-a--somewhere'ly y'rs -- bjorn From aleaxit at yahoo.com Tue Dec 26 19:00:32 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Wed, 27 Dec 2000 01:00:32 +0100 Subject: saving NNTP bodies to disk References: <3a4925f7.51675327@news.skynet.be> Message-ID: <92bbhp02vfb@news1.newsguy.com> "Daniel" wrote in message news:3a4925f7.51675327 at news.skynet.be... [snip] > try to write a list to disk using f.write() and Python complains about > this with following report > > f.write(TheBody[i]) > TypeError: read-only character buffer, list > > Below is the script. Can someone please explain me what I'm doing > wrong? All help is greatly appreciated. Thanks Python is saying: I need a read-only character buffer, you give me a list -- implying, a list has no conversion to such a buffer. If TheBody[i] is a list of strings, you can write it to file with f.writelines(TheBody[i]) Alex From thomas.wright1 at ntlworld.REMOVETHIS.com Thu Dec 28 12:52:43 2000 From: thomas.wright1 at ntlworld.REMOVETHIS.com (Tom wright) Date: Thu, 28 Dec 2000 17:52:43 -0000 Subject: sniffing btw my web browser and a server References: <92aush$rhc$1@news.nuri.net> <92fs3l$5gg$01$1@news.t-online.com> <92ftpn$e2j$1@news.nuri.net> Message-ID: I can email it to you if u like, its not very big, but is seems abit buggy, doesnt like webdav at all. This is under Python 2.0 Regards Tom "June Kim" wrote in message news:92ftpn$e2j$1 at news.nuri.net... > "Eduard Hiti" wrote : > > [snip] > > > > There's also a Python only solution: 'WebDebug'. It also acts as a proxy, > > logging all transfers and generating a nice and comprehensive HTML report. > > > > The URL: http://www.cyberclip.com/webdebug/download.html > > This one's what I've been looking for, but the link seems broken. Does > anyone have it or know alternative links? > > Best regards, > > June > From aleaxit at yahoo.com Mon Dec 11 04:35:41 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 11 Dec 2000 10:35:41 +0100 Subject: type vs. class References: <3A34244A.415F4DFB@t-online.de> Message-ID: <91275n02trc@news2.newsguy.com> "Greg Jorgensen" wrote in message news:uE_Y5.133498$U46.4497870 at news1.sttls1.wa.home.com... > "Thomas Thiele" wrote: > > > >>> class X: > > pass > > > > >>> x = X() > > >>> type(x) > > > > > > How can I realize that I will not get type 'instance' but type 'X'? I > > have different classes, more than one, and I want to check out which > > class it is. Are all classes type instance? > > In Python a class does not create a new type. All classes are of type > ClassType, and all class instances are of type InstanceType. > > The built-in function isinstance(object, class) may be what you need: Perfectly true -- isinstance() is often more useful than type()! However, to satisfy Thomas's request as he posed it...: when x is an instance of some class, you can learn WHICH class it's an instance of, through x's __class__ attribute (you can get the NAME of the class as a string, through the class-object's own __name__ attribute): >>> class X: ... pass ... >>> x=X() >>> x.__class__ >>> x.__class__.__name__ 'X' >>> Alex From neilh at scintilla.org Tue Dec 5 07:50:26 2000 From: neilh at scintilla.org (Neil Hodgson) Date: Tue, 05 Dec 2000 12:50:26 GMT Subject: Python programs (or scripts) as drop targets References: <90d9hi029hm@news1.newsguy.com> <3A2ACF21.4060406@ActiveState.com> <90fl26022in@news2.newsguy.com> <3A2C73CE.5060506@ActiveState.com> <90icu9023as@news2.newsguy.com> Message-ID: Alex Martelli: > if we're talking DDE, there is *another* issue which I > find more pressing: DDEML is *NOT* usable in professional apps > (although many apps that call themselves professional do use it). Agree completely here - various versions of DDEML have also had some rather nasty race conditions. I once wrote an application based upon DDEML only to stumble across these problems. There is the additional burden when using DDEML of really needing to understand the underlying DDE protocol at the same time as DDEML's 'simplified' version at the same time to debug. Its more trouble than just learning DDE. Later, a colleague who was familiar with the history of DDEML within MS said that it was an orphaned project and no one wanted to maintain it. Neil From gregj at pobox.com Sat Dec 9 01:02:18 2000 From: gregj at pobox.com (Greg Jorgensen) Date: Sat, 09 Dec 2000 06:02:18 GMT Subject: Python wrapper for C++ STL? References: <3A31760E.D157EB54@erols.com> <90s3fk$j8p$1@nnrp1.deja.com> <90s9l9$njd$1@nnrp1.deja.com> Message-ID: wrote: > I am not saying that there is any point in wrapping STL for Python. All > I'm saying is that STL can be used to write C++ extensions that > implement specific algorithms. Sure it could, though C++ + STL = C O D E B L O A T, so using that combo for Python modules will likely suck up a lot of memory. If you want some data structure Python doesn't have--sorted associative containers, for example--you'd be better off writing a module in C to implement just that, rather than try to press the STL into service where it won't give you any benefit. Anyway the original post that started this all asked about writing a wrapper for the STL, and that's the issue I was responding to. -- Greg Jorgensen Deschooling Society Portland, Oregon, USA gregj at pobox.com From amk at mira.erols.com Fri Dec 15 13:52:58 2000 From: amk at mira.erols.com (A.M. Kuchling) Date: 15 Dec 2000 18:52:58 GMT Subject: comparable shelve function in xml References: <91dg2q$3a1$1@nnrp1.deja.com> Message-ID: On Fri, 15 Dec 2000 16:15:31 GMT, Stan Lee wrote: >Is there a comparable way to store Python objects in an XML formatted >file like the shelve module does? I want to be able to store Python >objects to a file that's human-readable on both a Windows and Linux >platform. Thanks. There are a few. Hiding inside Zope there's a ppml.py file which has much the same functionality as the pickle module. Hiding inside the PyXML codebase, there's an xml.marshal package which has support for WDDX, XML-RPC, and a generic Python marshalling format. It depends if you only need simple data types -- integers, strings, that sort of thing -- or need the full generality of handling objects, recursive lists, &c. --amk From root at [127.0.0.1] Mon Dec 11 08:22:06 2000 From: root at [127.0.0.1] (deadmeat) Date: Mon, 11 Dec 2000 13:22:06 GMT Subject: Pascal -> Python 'record' structures Message-ID: <2y4Z5.7634$KY1.20696@news1.rivrw1.nsw.optushome.com.au> Can anyone tell me how to read in file records that were created by Pascal and C programs? Will I have to write a wrapper and parse the raw data manually? From chris at araidesign.com Tue Dec 19 03:21:37 2000 From: chris at araidesign.com (Chris Arai) Date: Tue, 19 Dec 2000 00:21:37 -0800 Subject: Need Help sorting alphabetically. Message-ID: <3A3F1A91.A7ED9182@araidesign.com> Hi, This seems like it should be obvious, but it is evading me! I would like to sort alphabetically (I'm not sure that is the correct term) so that strings of alpha numerics sort alphabetically instead of by ASCII order. eg: >>> m=['Pg95_100.GIF', 'Pg9_100.GIF','Pg95A_100.gif','Pg9A_100.gif','Pg10_100.gif'] >>> m.sort() >>> m ['Pg10_100.gif', 'Pg95A_100.gif', 'Pg95_100.GIF', 'Pg9A_100.gif', 'Pg9_100.GIF'] I would like the order to be ['Pg9_100.GIF', 'Pg9A_100.gif', 'Pg10_100.gif, 'Pg95_100.GIF', Pg95A_100.gif' ] What is the obvious answer?? Thanks, -- Chris Arai Arai Design chris at araidesign.com http://www.araidesign.com 707 431 1299 FAX 431 1599 -------------- next part -------------- A non-text attachment was scrubbed... Name: chris.vcf Type: text/x-vcard Size: 224 bytes Desc: Card for Chris Arai URL: From grey at despair.rpglink.com Fri Dec 8 16:03:14 2000 From: grey at despair.rpglink.com (Steve Lamb) Date: Fri, 08 Dec 2000 21:03:14 -0000 Subject: GNU tools in a library? References: Message-ID: On 08 Dec 2000 21:41:29 +0100, Martin von Loewis wrote: >I believe there is a Linux boot disk that implements a standard shell >with a small set of utilities as Python functions. Nothing more formal, however? -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. -------------------------------+--------------------------------------------- From sandj.williams at gte.net Wed Dec 13 12:39:48 2000 From: sandj.williams at gte.net (Steve Williams) Date: Wed, 13 Dec 2000 17:39:48 GMT Subject: Label-Value (was: Re: Inheriting the @ sign from Ruby) References: <3A368E11.20C17E92@san.rr.com> <9165he$lon$1@panix3.panix.com> <917pvv02clr@news2.newsguy.com> <3A379CB4.405992F8@gte.net> <9187tq02qlf@news2.newsguy.com> Message-ID: <3A37B57B.ABC2D672@gte.net> Alex Martelli wrote: > "Steve Williams" wrote in message > news:3A379CB4.405992F8 at gte.net... > > Alex Martelli wrote: > > > > > [lots of snip] > > > We don't really understand software development's technical > underpinnings quite as well as the Romans understood building's, > but I think that is not the key reason for most software's > defects; rather, I think most of them come from items that > stem more from management issues than strictly technical ones. > Here's an alternate viewpoint: http://upside.com/Open_Season/3a3661271.html From kc5tja at garnet.armored.net Fri Dec 8 15:52:20 2000 From: kc5tja at garnet.armored.net (Samuel A. Falvo II) Date: 8 Dec 2000 12:52:20 -0800 Subject: Dare I say it... References: <0ivv2tk3h07rp31c2mtheqsns6voriqq71@4ax.com> Message-ID: On 08 Dec 2000 21:43:14 +0100, Martin von Loewis wrote: >Not sure, yet. What application of that character do you have in mind? >I.e. what API that you want to call requires a Unicode string as part >of a structure? Perhaps some COM stuff on Windows, but I'm not sure. At any rate, it's still something that needs to be considered. On some systems, wchar_t is 16 bits (in particular, Win32). On others, it's 32-bits (e.g., Linux). Knowing the width of wchar_t ahead of time is required to do it manually. Just because the author of the pack module didn't see a need for it doesn't mean a need doesn't exist. :) -- KC5TJA/6, DM13, QRP-L #1447 | Official Channel Saint, *Team Amiga* Samuel A. Falvo II | Oceanside, CA | From mwh21 at cam.ac.uk Sun Dec 10 06:45:17 2000 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 10 Dec 2000 11:45:17 +0000 Subject: Bug: Readline getting stuck on Linux and Solaris References: <90m53k$ovh$1@nnrp1.deja.com> Message-ID: Michael Hudson writes: > do the IRIX manpages say anything scary about signal/sigaction > interaction? http://www.chemie.fu-berlin.de/cgi-bin/man/sgi_irix?sigaction+2 The POSIX signal routines (sigaction(2), sigpending(2), sigprocmask(2), sigsuspend(2), sigsetjmp(3)), and the 4.3BSD signal routines (sigvec(3B), signal(3B), sigblock(3B), sigpause(3B), sigsetmask(3B)) must NEVER be used with signal(2) or sigset(2). That'd be "yes", then. But I've just d/l-ed readline and it's signal handler is (predictably) straight out of Preprocessor Hell, so I can't tell what's going on at all :-(. M. -- ... but I guess there are some things that are so gross you just have to forget, or it'll destroy something within you. perl is the first such thing I have known. -- Erik Naggum, comp.lang.lisp From cpr at emsoftware.com Mon Dec 4 14:06:29 2000 From: cpr at emsoftware.com (Chris Ryland) Date: Mon, 04 Dec 2000 19:06:29 GMT Subject: Researching Python IDEs, debuggers, code coverage, unit testing and mem management tools References: <3A2A175C.D144ACA6@hotmail.com> <90fd6f$3vp$1@news1.xs4all.nl> Message-ID: <90gpvg$dih$1@nnrp1.deja.com> In article <90fd6f$3vp$1 at news1.xs4all.nl>, boud at rempt.xs4all.nl wrote: > I've just got an article published that compares Pythonworks, > Pythonwin, Wing IDE and IDLE on InformIT: http://www.informit.com. That'd be wonderful to read, but informit has a broken user registration module right now (at least for me after many tries) and requires registration to read articles. Could you perhaps post it somewhere else? -- Chris Ryland * Em Software, Inc. * www.emsoftware.com Sent via Deja.com http://www.deja.com/ Before you buy. From DanielK at aracnet.com Mon Dec 25 16:37:20 2000 From: DanielK at aracnet.com (Daniel Klein) Date: Mon, 25 Dec 2000 13:37:20 -0800 Subject: __init__ question References: <9285oj$6rh$1@panix2.panix.com> Message-ID: Is this part of the syntax or is this a regular expression? I can't find this anywhere in the online documentation or in any of the four Python books I have purchased. :^( Dan: "Aahz Maruch" wrote in message news:9285oj$6rh$1 at panix2.panix.com... > In article , > Daniel Klein wrote: > > > > def __init__(self, *args): > > > >What is the meaning of the '*args' expression? > > It means "accept any number of parameters here"; "args" is a tuple. For > example, I could create a print function instead of the blecherous > redirected print statement as follows: > > def print (file=None, *args): > if not file: > file = sys.stdout > for arg in args: > file.write("%s " % arg) > file.write("\n") > -- > --- Aahz (Copyright 2000 by aahz at pobox.com) > > Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ > Hugs and backrubs -- I break Rule 6 > > '"Crisp" is a good quality for crackers; less so for pot roast.' --pnh From jadestar at idiom.com Mon Dec 11 07:13:31 2000 From: jadestar at idiom.com (James T. Dennis) Date: 11 Dec 2000 12:13:31 GMT Subject: 3rd argument to os.path.walk(): Why? Message-ID: <912gdb$1oqr$1@news.idiom.com> In the _Python_Essential_Reference_, by David Beazley (New Riders Publishing, 2000) I notice that os.path.walk() takes three arguments which he lists as: path, visitfunc, arg It notes that the function referenced in visitfunc is called with (arg, dirname, namelist) for every directory that is traversed by the os.path.walk. I don't understand what the "args" is for. I can see how to use the other arguments. Here's a couple of trivial examples: import os def print_dirnames(a, dir, flist): print dir def list_directories(a, d, l): for each_file in d: print "%s/%s" % (d, each_file) os.path.walk("/", print_dirnames, '') os.path.walk("/", list_directories, 'x') ... these both work as I expected. Of course I'm simply ignoring the 'args' argument in my functions. I guess I could write my functions to behave differently based on the contents of the args. (I can even imagine that as useful, though I don't need it for anything right now). At first I though that this "args" element was required to be a string. However, I tried calling the os.path.walk() with numeric and anonymous (literal) lists and saw no differences in the output as a result of those. I guess I could call it with a lambda function or a reference to a function if I wanted to. I don't know Python well enough to show an example, but I could see where that might be useful. However, my question boils down to: Why is this third argument required in os.path.walk()? From DanielK at aracnet.com Thu Dec 28 23:25:31 2000 From: DanielK at aracnet.com (Daniel Klein) Date: Thu, 28 Dec 2000 20:25:31 -0800 Subject: how do i check if a file exists with python? References: Message-ID: How about something like def fileExists(f): try: file = open(f) except IOError: exists = 0 else: exists = 1 return exists Although this is not as elegant as the person who submitted the 'glob' solution. Dan "Scott Hathaway" wrote in message news:RlM26.98766$yR4.2639444 at news1.rdc1.tx.home.com... > I have searched Deja, looked in two pyton books, and searched the python.org > site trying to find out this simple question. > > Can someone please give me the call and the module it lives in? > > Thanks, > Scott > > From arturo_perez at wanadoo.es Mon Dec 11 19:17:35 2000 From: arturo_perez at wanadoo.es (Arturo Pérez Mulas) Date: Tue, 12 Dec 2000 00:17:35 GMT Subject: Fault trees structure References: <9128e902uo3@news2.newsguy.com> Message-ID: An introctury fault-tree, including a very brief introduction: http://www.riskspectrum.com/docs/methods_2.htm I have to admit that, at this point I have not been able to find any more "introductory" pieces. However, I include below a schematic description of the underlying structure for fault-trees; if anyone is interested and teh discussion proceeds, I will post a more detailed description of the 'quantification' and operations of fault-trees, along with a description of what they are really used for, and how (fault tree analysis). I will try to describe the Fault Tree Structure with my own words: a fault-tree is a tree-like structure (similar to the binary tree), developed from a unique top-event or top-node. The main characteristics of a Fault Tree are the following: - They have only ONE top node - Each node can have unlimited inputs (opposed to two allowed for binary trees) - Nodes can be of any of the following different types: a) 'Gates' : are nodes that admit further inputs; there are different types of gates, AND, OR, XOR, n/m, NOT but this is not important at this point, since from the tree structure they are all similar (except type n/m gates which must have exactly 'm' inputs) b) 'Basic Events': or final nodes, which cannot have any more inputs; for operation purposes, a basic event has a numeric 'probability' between 0 and 1, but I leave this for latter. c) 'House Events': special events, similar to the Basic Events, but they do not have a numerical probability, but a "on/off" status flag. d) 'Links', or 'link gates', are nodes which actually point to other fault-tree or other node in a different fault tree. They are used to crop large fault-trees in pieces, or in larger structures, when several fault-trees are used, they may share smaller pieces, so 'links' are used not to repeat the same structure in several places. Note that usually a link points to the top event of another fault tree, but this is not mandatory, and in some cases links pointing to intermediate nodes (gates) in other fault tree can be found. - Considering the previous description, the following 'properties' should be considered for the different types of nodes (along with a 'name' and 'description' for all of them): a) 'Gates': - type (AND, OR, XOR...) - inputs b) 'Basic Events': - probability (float between 0 to 1) - other probability data (not important at this point), such as uncertainity distributions c) 'House Events': - logical state (boolean switch) d) 'Links': - none I have developed a very simple objects hierarchy for this, but I am not very satisfied with it (I considered other issues when creating that, based on the sources from which I will obtain the fault trees, and the formats to which I have to send them later). If anyone is finally interested, I will post some info on the structure and we can discuss it. I would greatly appreciate some discussion here, since this is the first time I use OOP to model something! Arturo. From phd at phd.pp.ru Thu Dec 28 09:59:47 2000 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 28 Dec 2000 17:59:47 +0300 (MSK) Subject: PEP 222 draft In-Reply-To: <3A4B1EA2.E15B4FB7@stroeder.com> Message-ID: Hi! On Thu, 28 Dec 2000, Michael [iso-8859-1] Str?der wrote: > tlownds at my-deja.com wrote: > > > > In article , > > akuchlin at mems-exchange.org wrote: > > > Utility function: build a query string from a list of 2-tuples > > > > > > > Perhaps it would be better to extend urllib.urlencode to handle this > > case. I think it should be extended to handle lists as values as well: > > > > >>> urlencode({'x': ['a', 'b']}) > > 'x=%5b%27a%27,+%27b%27%5d' > > > > would be: > > > > 'x=a&x=b' > > But you can do that with a list of 2-tuples either. Note: The list > order of dictionary keys is normally not preserved. Not so long ago I wrote such function and sent it to Guido (it was the time before Python 1.6) and GvR rejected my code saying something like "it is rare need for someone, write it in your own library". No proble, I put it in my libraray. Here is the code. Please note, it is perfectly compatible with current urllib.urlencode: # obj must be either dict or list of tuples [(k1, v1), (k2, v2), ...] or list of lists [[k1, v1], [k2, v2], ...] def urlencode(obj): l = [] if type(obj) == type({}): obj = obj.items() for k, v in obj: k = quote_plus(str(k)) v = quote_plus(str(v)) l.append(k + '=' + v) return string.join(l, '&') Oleg. ---- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From glenfant at equod.com.nospam Wed Dec 6 12:59:01 2000 From: glenfant at equod.com.nospam (Gilles Lenfant) Date: Wed, 6 Dec 2000 18:59:01 +0100 Subject: [OT] XML introduction References: Message-ID: <90luha$s4m$1@reader1.imaginet.fr> Arturo, You'll get better answer posting your question to newsgroup "comp.text.xml". "Arturo P?rez Mulas" a ?crit dans le message news: d8qX5.227$rZ6.6363 at m2newsread.uni2.es... Hello, this is kind of off-topic, but not quite. I cannot find any comprehensive introduction to XML that gives real information on what is it used for. As far as I could grasp, it allows to define structures to store data cretaing your html-like tags, and rules to format them on a xml-compliant browser... but I keep reading things about "developing web sites or applications with xml" and then I get lost. Anyone any pointer or hint, please? Thanks Arturo P?rez From fredrik at effbot.org Mon Dec 11 04:16:34 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Mon, 11 Dec 2000 09:16:34 GMT Subject: Multiple Threads & IRC References: <3A3415E0.1080607@bellsouth.net> Message-ID: "Wilbur" wrote: > The server sends data in packets, and it sends whenever it can. How can > I get my client to be able to receive data from the server without > knowing when it will send and what amount of data will be sent? I only > know how to tell Python to wait until it receives, say, 1024 bytes. If > the server doesn't send any more, how can I tell Python to stop waiting? http://www.python.org/doc/current/lib/module-asyncore.html From lizard at mrlizard.com Sat Dec 2 02:00:37 2000 From: lizard at mrlizard.com (Lizard) Date: Fri, 01 Dec 2000 23:00:37 -0800 Subject: [OT] Apple IIe help please In-Reply-To: <20001201212507.A14226@westsidecnc.rh.rit.edu> Message-ID: <5.0.0.25.2.20001201225938.053fcde0@mrlizard.com> At 06:25 PM 12/1/2000, D-Man wrote: >Hi all. I apologize for the off topic-ness of the message and the >cross-post. >I have a friend who has a program she likes (written in BASIC) on an Apple >IIe. >I have a way to get into the code and list it on the screen. What I am >looking >for is someone who has had some experience using an Apple IIe who can tell me >how I can get the listing to be redirected to the printer port. Also if it is >possible to get a copy of the program file onto a disk for an IBM compatible >comptuer (Windows or Linux) that would be great. Gods, THAT brings back memories! Something like "PRINT #1" or the like? I know you specify a port..."IN #1" turned on the printer? Maybe? I'm sorry, I'm dredging up memories from 20+ years ago... From python9999 at my-deja.com Mon Dec 18 03:25:40 2000 From: python9999 at my-deja.com (python9999 at my-deja.com) Date: Mon, 18 Dec 2000 08:25:40 GMT Subject: How to enable html links using XmHTML module?? Message-ID: <91khm2$7as$1@nnrp1.deja.com> hi.. i am writing an application in pygtk, in which i need to display HTML screens . i could display them using python's XmHTML module, but i am not able to understand how to enable the links in the screens. i am displaying the HTML screens on a gtk frame and i know that for enabling link it needs a browser... Can we use the module available for enabling the links?? Are there any functions available for doing so ? regards, Priya Sent via Deja.com http://www.deja.com/ From rachelp_ny at yahoo.com Sat Dec 16 18:38:29 2000 From: rachelp_ny at yahoo.com (Rachel) Date: Sat, 16 Dec 2000 18:38:29 -0500 Subject: latest python release for solaris Message-ID: <3a3bff01_4@news1.prserv.net> Is anyone running the most current release? We're running 1.5.2 -- it's been pretty stable. We're having some trouble with the code for SSL connections -- it works fine with Perl, but we've had some problems with Python. My understanding is that the latest release has native SSL support in it. I wondering if upgrading is worthwhile.... From nicmila at idoox.com Mon Dec 11 02:12:51 2000 From: nicmila at idoox.com (Miloslav Nic) Date: Mon, 11 Dec 2000 08:12:51 +0100 Subject: pattern matching References: Message-ID: <3A347E73.B00368A3@idoox.com> Zvon Regexp reference was generated with Python using re module: http://zvon.org/other/reReference/Output/index.html You can download sources at : http://www.zvon.org/index.php?nav_id=3 re module is definitively the way to go deadmeat wrote: > > Is there another standard library I can use for pattern matching, other than > fnmatch? I need to be able to check for metacharacters, fnmatch doesn't > allow me to escape them... -- ****************************************** Miloslav Nic nicmila at idoox.com http://www.zvon.org http://www.zvon.org/index.php?nav_id=4 From be at et.dtu.dk Wed Dec 20 04:51:55 2000 From: be at et.dtu.dk (Brian Elmegaard) Date: Wed, 20 Dec 2000 10:51:55 +0100 Subject: Python's scope rules Message-ID: <3A40813B.C04D21C@et.dtu.dk> Hi, I am not a computer scientist, just an engineer knowing how to program in Fortran, Pascal,... So I after reading some of the python material on the web, I decided to give it a try and is now using the language some, finding it fun and easy. On usenet I have now learned from skilled scientists, that Python has some deficiencies regarding scope rules, and I am not capable of telling them why it has not (or that it has). In Aaron Watters 'The wwww of python' I have read that Python uses lexical scoping with a convenient modularity. But, other people tell me it does not. Some say it uses dynamic scoping, some say it uses it own special 'local-global-builtin' scope. What is right? The above mainly is a theoretical question. A more practical example which I agree seems a bit odd is: Python 1.5.2 (#1, Mar 9 2000, 17:40:34) [GCC 2.95.2 19991024 (release)] on hp- uxB Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> x=24 >>> def foo(): ... y=2 ... print x+y ... >>> def bar(): ... x=11 ... foo() ... >>> bar() 26 >>> Well, I can live with it. In Fortran I would always put all the variables to be passed in the parameter list. Other people say that Fortran is not easy, and this example shows how stupid python is. It does? Hopefully not, but probably, this is a faq, but I have not been able to find anything on the matter. -- Brian Elmegaard (be at et.dtu.dk) http://www.et.dtu.dk/energysystems Dept. of Energy Engineering, Technical University of Denmark, Phone +45 4525 4169 Fax +45 4593 5215 :) http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug From stevee at recombinant.demon.co.uk Wed Dec 6 15:28:50 2000 From: stevee at recombinant.demon.co.uk (Stephen D Evans) Date: Wed, 06 Dec 2000 20:28:50 +0000 Subject: rotate() in Tkinter References: <5yuX5.761950$8u4.13165276@news1.rdc1.bc.home.com> Message-ID: <3A2EA182.51F74B7@recombinant.demon.co.uk> To rotate an oval convert the oval to a polygon and rotate that. Polygons are easy to rotate, but this has to be done to the points before calling create_polygon(). Referring to Tk documentation - The canvas does not support rotation. 'Practical Programming in Tcl and Tk', 3rd edition, 2000, by Brent B. Welsh, publisher Prentice Hall PTR This is a simple example. (There are better methods of creating the points for an oval. Try fast generation of ellipsoids in 'Graphics Gems V', 1995, edited by Alan W Paeth, publisher AP Professional) # # import math import Tkinter def poly_oval(x0,y0, x1,y1, steps=20, rotation=0): """return an oval as coordinates suitable for create_polygon""" # x0,y0,x1,y1 are as create_oval # rotation is in degrees anti-clockwise, convert to radians rotation = rotation * math.pi / 180.0 # major and minor axes a = (x1 - x0) / 2.0 b = (y1 - y0) / 2.0 # center xc = x0 + a yc = y0 + b point_list = [] # create the oval as a list of points for i in range(steps): # Calculate the angle for this step # 360 degrees == 2 pi radians theta = (math.pi * 2) * (float(i) / steps) x1 = a * math.cos(theta) y1 = b * math.sin(theta) # rotate x, y x = (x1 * math.cos(rotation)) + (y1 * math.sin(rotation)) y = (y1 * math.cos(rotation)) - (x1 * math.sin(rotation)) point_list.append(round(x + xc)) point_list.append(round(y + yc)) return point_list import Tkinter root = Tkinter.Tk() canvas = Tkinter.Canvas(root, width=400, height=400) dict = {} dict['outline'] = 'black' dict['fill'] = 'yellow' dict['smooth'] = 'true' # use a polygon to draw an oval rotated 30 degrees anti-clockwise apply(canvas.create_polygon, tuple(poly_oval(40,40, 200,300, rotation=30)), dict) canvas.pack() root.mainloop() -- Stephen D Evans Dethe Elza wrote: > I'm trying to create a complex cursor in Tkinter. I want to have an image > which I can rotate, change the color of, and move about. I can build it as > a vector image, but I use ovals. I haven't found any way to rotate images, > vector drawings, or ovals in Tk. > > TIA > > --Dethe -------------- next part -------------- An HTML attachment was scrubbed... URL: From aleaxit at yahoo.com Thu Dec 28 12:08:30 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Thu, 28 Dec 2000 18:08:30 +0100 Subject: Basic MAPI References: <91vfsb02cn6@news2.newsguy.com> <92fonu$auu$1@plutonium.compulink.co.uk> Message-ID: <92ft0m029uo@news1.newsguy.com> wrote in message news:92fonu$auu$1 at plutonium.compulink.co.uk... [snip] > > > >>> s=Dispatch("Mapi.Session") > > > > There is no creatable coclass (that I ever heard of) with progId > > 'Mapi.Session'. > > There most certainly is. It comes with Outlook, among other things, and > I think lives in cdo.dll ("MAPI" is an abbreviation for "CDO" or > something). That Dispatch works fine on my machine, so I don't know > what's going wrong. Check that Outlook's installed. Aha -- maybe we have a clue here. I do have Outlook installed, but, it's Outlook 2000. "Migrating Applications to Microsoft Outlook 2000" by Jim Groves (found on MSDN) does list among the migration concerns: "Collaboration Data Objects (CDO) [...] now optional". And indeed, I have no cdo.dll on my system, nor it it anywhere in my registry. This is what Groves has to say about CDO versus MAPI: """ Support for Collaboration Data Objects Formerly known as OLE Messaging and Active Messaging, CDO is an object model that gives applications more direct access to the Messaging Application Programming Interface (MAPI) used by Outlook to structure its data storage than does the Outlook object model. Programming with CDO is more flexible than MAPI because, unlike MAPI, CDO does not require C or C++ as the programming language. Instead, CDO can be accessed through Visual Basic and Active Server Pages (ASP), as well as Visual C++? and any other development tool that creates Component Object Model (COM) objects. """ which I interpret as: CDO offers dual-interface COM access, so it can be scripted from VB or anything else (Python included), while MAPI is a C/C++ only API (making it peculiar that a CDO object could possibly be named 'MAPI' something, but, whatever). So, if Outlook 2000 is what you have, still quoting Groves: """ If users in your organization have already installed Outlook 2000, it is easy for each of them to install the CDO support. To install CDO support Click Start, point to Settings, and then click Control Panel. Double-click the Add/Remove Programs icon. In the list, click Microsoft Office 2000 or Microsoft Outlook 2000, and then click Add/Remove. Click Add or Remove Features. Click the plus sign (+) next to Microsoft Outlook for Windows to open it. Click Collaboration Data Objects, and then click Run from My Computer. """ Haven't tried this, so I don't know if this will indeed bring to life a cdo.dll implementing a cocreatable "Mapi.Session" on your computer, but, if Outlook2000 is what you're trying to work with, it sure seems worth trying. (There are other CDO implementations, "CDO for NTS" which is said to use SMTP and run on NT Server only, and "CDO for Exchange 2000", but they apparently use different prog-id strings to let you create their respective 'Session' objects). Alex From fgeiger at datec.at Wed Dec 27 01:47:19 2000 From: fgeiger at datec.at (Franz GEIGER) Date: Wed, 27 Dec 2000 07:47:19 +0100 Subject: A Q concerning map (a comparison to Maple V) References: <921sil$moe$1@newsreaderg1.core.theplanet.net> Message-ID: <92c41g$n1p$4@newsreaderg1.core.theplanet.net> > map(replace, ["abc", "cde"], ["c"]*2, ["C"]*2) > That's it, but doesn't look that beautiful. > whereas with you proposal this would give you: > > ["abc", "CDe"] No, with my proposal nothing would happen, because there is no "cd" anywhere. Be aware, the list is the list replace has to be applied on, not the strings within it. > Excuse me if I misinterpreted your proposal, but if the Excused ;-) Best regards Franz GEIGER "Peter Schneider-Kamp" wrote in message news:mailman.977570347.5588.python-list at python.org... > Franz GEIGER schrieb: > > > > map(replace, ["abc", "cde"], "c", "C"); > > instead of having to create a lambda function. > > Wouldn't it make sense to have that in Python too? Do there come > > more such opportunities into your mind? > > If I get you right you intend this to mean: > > map(replace, ["abc", "cde"], ["c"]*2, ["C"]*2) > > So basically your proposal is to reuse map parameters > which are no sequences in every iteration over the > parameters who are, s.t. > > map(f, a_1, .., a_n, b_1, .., b_m) > > for f being a (m+n)-ary function, a_1 to a_n being sequence > parameters and b_1 to b_m non-sequence parameters would yield > > maxlen = max(map(len,[a_1, .., a_n])) > map(f, a_1, .., a_n, [b_1]*maxlen, .., [b_m]*maxlen) > > But how would you decide if "abc" is a sequence parameter > or not? To keep your example, what would > > map(replace, ["abc", "cde"], "cd", "CD") > > mean? At the moment this gives you: > > ["abC", "cDe"] > > whereas with you proposal this would give you: > > ["abc", "CDe"] > > Excuse me if I misinterpreted your proposal, but if the > above is what you mean, I think this a Bad Idea(tm). > > merry-xmas-shopping-ly y'rs > Peter > From tlownds at my-deja.com Sun Dec 24 12:17:39 2000 From: tlownds at my-deja.com (tlownds at my-deja.com) Date: Sun, 24 Dec 2000 17:17:39 GMT Subject: PEP 222 draft References: Message-ID: <925b3g$5pl$1@nnrp1.deja.com> In article , akuchlin at mems-exchange.org wrote: > Utility function: build a query string from a list of 2-tuples > Perhaps it would be better to extend urllib.urlencode to handle this case. I think it should be extended to handle lists as values as well: >>> urlencode({'x': ['a', 'b']}) 'x=%5b%27a%27,+%27b%27%5d' would be: 'x=a&x=b' > The cgi.py module would be deprecated. (XXX A new module or > package name hasn't been chosen yet: 'web'? 'cgilib'?) > cgilib gets my vote. > * An HTML generation module is not part of this PEP. Several such > modules exist, ranging from HTMLgen's purely programming > interface to ASP-inspired simple templating to DTML's complex > templating. There's no indication of which templating module to > enshrine in the standard library, and that probably means that > no module should be so chosen. > There are more ASP-like modules out there than other types... > Parsing functions: carry over most of the parse* functions from > cgi.py > It would be really nice to change the main parse-form-input function to return a dictionary of plain strings instead of the FieldStorage instances. When a file is uploaded, a FieldStorage instance for that value makes sense. You've suggested this before, I may have missed it in your PEP. > > # Module-level function > def wrapper(func, logfile=sys.stderr): > """ > Calls the function 'func', passing it the arguments > (request, response, logfile). Exceptions are trapped and > sent to the file 'logfile'. > """ > # This wrapper will detect if it's being called from the command-line, > # and if so, it will run in a debugging mode; name=value pairs > # can be entered on standard input to set field values. > # (XXX how to do file uploads in this syntax?) > Regarding debugging: A command-line debugging ability is very useful! But why tie that feature to the wrapper feature? You can put it in the parse-form-input function. Also, allow name=value pairs as command-line arguments. name=value pairs would still be read even with command-line arguments, unless a final command-line argument "go" is present. One debugging feature that would be very useful in a wrapper, is a way to start pdb either right away or at an exception. Your wrapper passes (request, response, logfile) - why not pass an object with .request, .response, and .logfile attributes. Using a tuple now makes it harder to extend later. A cgi.log-like method on that "context" object would be useful too! -Tony Lownds Sent via Deja.com http://www.deja.com/ From steve at serf.org Fri Dec 15 16:32:30 2000 From: steve at serf.org (A SERFer) Date: 15 Dec 2000 21:32:30 +0000 Subject: Smalltalk and Python References: <3A2FFB8B.2030408@zoologic.com> <915qlh$89fa$1@nntp6.u.washington.edu> <3a36c85e.4409136@News.CIS.DFN.DE> <3A37DD31.C9A5F18C@pacbell.net> <91bhlh$c64u$1@nntp6.u.washington.edu> <3A395197.CB2974D5@home.com> Message-ID: "Steve Holden" writes: >James A. Robertson wrote in message >news:3A395197.CB2974D5 at home.com... >> "Russell E. Owen" wrote: >> > >> >> > >> > My point is, that Cincom's pricing policies look self-destructive to me. >> > I cannot in good conscience make my observatory rely on a language that >> > I fear will continue to be a marginal player, at best. >> > >> >> How so? We went way over our sales targets last year, and things are >> looking pretty good for the upcoming year. Cincom has devoted a lot of >> resource into Smalltalk; we are committed to it. >> >Unfortunately, sales targets are arbitrary numbers. What evidence do you >have that revenues might have been increased if you had reduced the price? >I'm sure you can appreciate that if you sold for one-third the price and >made six times as many sales, profits would be up. Most sales organizations >I've worked with don't have a model which shows profits as a function of >price. > >The fact that I've seen two postings on this thread complaining that your >prices are too high suggests sales would increase with lower pricing. Of >course the effect on profit is unknown. > >The fact that an academic version is available redeems your policy somewhat, >but I suspect your target market may be nervous about the company's survival >because it feels your pricing policies are unrealistic. Indeed we are! We keep hearing a circular argument: 1. Cincom are committed to Smalltalk in the long term. 2. We must charge these prices if Smalltalk is to survive within Cincom. Its like a sort of quantum mechanical uncertainty thing... each statement on its own makes sense, but put together, they are meaningless. > >> > I'm also reluctant to write an application with a "freebie" splash >> > screen that comes up every time. And I'm reluctant to use free versions >> > of commercial stuff we cannot afford, because it doesn't support the >> > company and because their pricing policies are risky -- if they dump the >> > free version we're in deep trouble. >> >> If an asteroid hits the planet, you're in trouble too. Nothing is >> certain. If Sun's hardware sales slip at some point, Java is uncertain >> as well. They aren't making money on Java itself. >> >Well, that's probably why this discussion is being held on the Python group! >Clearly Sun's demise would impact a lot of people and upset a lot of plans, >but they do have a certain financial momentum which means a crash would >probably be heralded by several years of poor performance. Having done some research into Java's history, I would guess that Sun are in fact making money from Java: one of the motivations was to provide a common platform and a common set of APIs for internal Sun use as well as a product. Even if Java had only succeeded as an internal tool, it would have cut costs, and so made money for Sun. > >Also, Java has a number of compatible compilers, so even if Sun died the >language would conceivably survive. It sounds as though the degree of >SmallTalk compatibility is lower, effectively making the Cincom >implementation proprietary. There is no doubt the language would survive. Its now one of IBM's primary tools for internal use, and IBM have written their own VMs (such as the UVM used in VisualAge), and they are developing Java byte code emulation tools (see the DAISY project). > >Sun's revenues are measured in the billions - they became a $1bn company in >year six, if I remember rightly. Whereas Cincom's web site says "And during >the past three decades, our annual sales have grown to $185 million". Not >quite so impressive. > >Is there NOBODY in the company who suspects this slow growth might be due to >overpricing? I'm not denigrating your figures in absolute terms (I achieved >much less in my own company), but other companies have grown much larger >revenues in the same period, and thereby become a better long-term bet. > >> > >> > If there were compatible implementations I'd not worry so much about the >> > stability of one company, but I'm reluctant to hitch our star to Cincom. >> > >> > Smalltalk is my favorite language. However, I am the only one at the >> > observatory who knows it and feels it is worthwhile. As I fight Python's >> > disgusting GUI I keep wavering, and I may yet give up and switch to >> > Smalltalk. The worst they can do is fire me. But I love my job. >> > >> > -- Russell >> >> -- >> James A. Robertson >> Technical Product Manager (Smalltalk), Cincom >> jarober at mail.com >> >> >> >regards > Steve > > > From rturpin at my-deja.com Fri Dec 29 12:42:34 2000 From: rturpin at my-deja.com (rturpin at my-deja.com) Date: Fri, 29 Dec 2000 17:42:34 GMT Subject: Python vs. PHP (& Java?) References: <69BC4C6AE83ED311BC9400805FA7B14AF84D2C@il93exp01.css.mot.com> <92fv4a$l2l$1@nnrp1.deja.com> <92gghv02iq1@news2.newsguy.com> Message-ID: <92iie9$lg3$1@nnrp1.deja.com> I wrote: >> In contrast, texts in computer languages are more studied >> as artifacts. "How did this work?" "Why did it stop >> working?" "What did the original authors intend?" They, >> the rascals, are no longer around to explain, take credit, >> or defend their honor. This kind of comprehension requires >> a high level of competency in the language. In article <92gghv02iq1 at news2.newsguy.com>, "Alex Martelli" wrote: > Are you implying that this _doesn't_ happen a lot for > many written texts in natural languages...? Literary > analysis is all about such work, after all -- and courts > and lawyers do a lot of that on laws and constitution > articles. Of course. And in both cases, it requires a proficiency beyond normal, either with language generally, as in the case of literary critics, or with a technically specialized variant, as with lawyers. I am not trying to draw too sharp a distinction between natural language and computer language. This would be foolish: computer languages ARE just technically specialized parts of natural language. All I point out is that the manner in which they are used requires proficiency and scope that most casual communication does not. The same is true for other technically specialized sublingua, including hoary examples such as law and medicine. Turpin: >> Knowing one-tenth of Perl is not enough to understand >> most Perl scripts. Martell: > Of course not, but, it IS enough to _write_ a lot of > somewhat useful scripts .. Your use of a computer language is fairly limited if you can only WRITE it. Software engineering requires the ability to READ. And not just what you once wrote, but what others have written, including others who have been using it for years and know all the idioms and tricks. Even though they are long gone. This is why software engineering is more like literary analysis or the study of Constitutional law, than it is like an after dinner conversation. The interesting and hard productivity question is not how long it takes a beginner to complete a task, but how much effort it requires a group of professionals to maintain a sizable product, over its lifecycle. (This isn't meant as criticism of those who want to use Python for teaching or personal use. It is a very good language for both purposes. But my interest and most of my comments are from the viewpoint of professional use.) > The complexity of natural language springs in good > part from the _adaptive_ characteristics (pace Gould...) > of ambiguity in its use; words serve to hide, as much as > they serve to show. That's certainly part of it. There are many social situations where it is advantageous to say something, but only so much. It's also the case that in most social interaction, communication is going on at several levels simultaneously. A rich language that admits multiple meaning and implication is very useful. If you want to look for adaptation, sexual selection may have more to do with this than natural selection. A silver tongue will not save you from the lion or bag the deer, but it will win a heart. > Nothing "is EXACTLY like" anything else (Korzibsky would > insist on such firm avoidance of "the IS of identity", but, > as he doesn't seem to be following this newsgroup regularly, > I'll have to play his role, I guess). .. I'm surprised no one brought up the good Count when Clinton uttered his infamous question. > Alternatively, of course, great complexity in implementation > MIGHT be spent towards such targets as optimization, as > you were interestingly arguing Python should be doing now. Yep. Keep in mind that only the implementation team has to tackle the complexity of optimization, whereas the world has to tackle the complexity of language and semantics. > But, even if a strongly-optimizing language processor, > being more fragile, exists more precariously, it IS still > good to have a simple, clear, transparent "reference > implementation" to fall back to... Absolute agreement. More importantly, we poor programmers need a simple, clear, transparent conceptual model, when we're trying to puzzle out why some construct behaved as it did. > [Perl's] design goals DID apparently include rich, > exhuberant, redundant abundance -- it seems to have > matched them closely. .. That is a most unfortunate goal. > .. (from your excellent diagnostic-manual on quack > theories) .. It's amazing how one post in sci.med fifteen years ago has taken on a life of its own. I would rather you criticize my recent proposal for caching attribute and method references. BTW, didn't we meet once? Regards, Russell Sent via Deja.com http://www.deja.com/ From timd at macquarie.com.au Tue Dec 12 21:38:23 2000 From: timd at macquarie.com.au (Timothy Docker) Date: 13 Dec 2000 13:38:23 +1100 Subject: Issues with the "McMillan" installer Message-ID: I'm trying to get the "McMillan" installer working on an application that I have written, and am struggling with several problems. The application uses python-2.0, wxWindows, and omniORB. My first issue is that builtin-modules are not getting resolved correctly. If I run Simple.py on the following script (test.py) | import sys, imputil | | print sys.path | | import time | import thread | | print "hello" and then use the install script to install a clean directory, when I run the created executable I get... | C:\TEMP\rt>test | ['C:\\TEMP\\rt\\', 'C:\\TEMP', 'C:\\Python20\\Pythonwin', ] | Traceback (most recent call last): | File "", line 5, in ? | File "c:\python20\lib\imputil.py", line 91, in _import_hook | raise ImportError, 'No module named ' + fqname | ImportError: No module named time | | C:\TEMP\rt> Needless to say the original script runs fine. The path as finally set up looks a bit sus to me. (The Builder.log is attached below). I got around this problem by changing the script to look like... | import sys, imputil | | print sys.path | | sys.path.insert(0, imputil.BuiltinImporter()) | | import time | import thread | | print "hello" But presumably this shouldn't be needed - what's going on here? After working around this, I then had a problem with the wxwindows library. The wxwindows library has its c extension (wxc.pyd) inside the package. After building and running the installer, I end up with the file wxwindows.wxc.pyd in the installation directory. This isn't found correctly when an attempt is made to import it. Renaming it to 'wxc.pyd' made the problem go away, but again a hack. Is this somehow related to the problem above? Any tips/pointers would be much appreciated. Tim Docker ---------------------------------------------------------------------- ---- PYZTarget: installzlib.pyz ----- {'__name__': 'installzlib.pyz', '_dependencies': [(imputil, c:\python20\lib\imputil.pyc, m), (zlib, q:\pc\zlib.pyd, b), (archive_rt, Q:\pc\installer\support\archive_rt.py, m)], 'bindepends': [], 'cfg': , 'children': [], 'debug': 0, 'dependencies': ['installutils'], 'destdir': '', 'directories': [], 'excludes': ['dospath', 'posixpath', 'macpath'], 'expatterns': [], 'exstdlib': 0, 'extypes': [], 'icon': '', 'includes': ['installutils'], 'includetk': 0, 'misc': [], 'name': 'installzlib.pyz', 'packages': [], 'pathprefix': ['Q:\\pc', 'Q:\\pc\\installer\\support'], 'script': [], 'support': 1, 'toc': [], 'trees': [], 'userunw': 0, 'zlib': []} Dependencies of installutils that couldn't be traced: {'MACFS': {'tempfile': None}, 'ce': {'os': None}, 'dos': {'os': None}, 'mac': {'os': None}, 'macfs': {'tempfile': None}, 'os2': {'os': None}, 'posix': {'os': None}, 'pwd': {'posixpath': None}} lTOC after expanding 'depends': [('archive_rt', 'q:\\pc\\installer\\support\\archive_rt.py', 'm'), ('os', 'c:\\python20\\lib\\os.py', 'm'), ('sre_parse', 'c:\\python20\\lib\\sre_parse.py', 'm'), ('ntpath', 'c:\\python20\\lib\\ntpath.py', 'm'), ('carchive_rt', 'q:\\pc\\installer\\support\\carchive_rt.py', 'm'), ('re', 'c:\\python20\\lib\\re.py', 'm'), ('sre_constants', 'c:\\python20\\lib\\sre_constants.py', 'm'), ('UserDict', 'c:\\python20\\lib\\UserDict.py', 'm'), ('tempfile', 'c:\\python20\\lib\\tempfile.py', 'm'), ('sre', 'c:\\python20\\lib\\sre.py', 'm'), ('posixpath', 'c:\\python20\\lib\\posixpath.py', 'm'), ('types', 'c:\\python20\\lib\\types.py', 'm'), ('sre_compile', 'c:\\python20\\lib\\sre_compile.py', 'm'), ('copy', 'c:\\python20\\lib\\copy.py', 'm'), ('popen2', 'c:\\python20\\lib\\popen2.py', 'm'), ('imputil', 'c:\\python20\\lib\\imputil.py', 'm'), ('repr', 'c:\\python20\\lib\\repr.py', 'm'), ('dospath', 'c:\\python20\\lib\\dospath.py', 'm'), ('macpath', 'c:\\python20\\lib\\macpath.py', 'm'), ('string', 'c:\\python20\\lib\\string.py', 'm'), ('copy_reg', 'c:\\python20\\lib\\copy_reg.py', 'm'), ('stat', 'c:\\python20\\lib\\stat.py', 'm'), ('pre', 'c:\\python20\\lib\\pre.py', 'm')] lTOC after includes, dir, pkgs: [('archive_rt', 'q:\\pc\\installer\\support\\archive_rt.py', 'm'), ('os', 'c:\\python20\\lib\\os.py', 'm'), ('sre_parse', 'c:\\python20\\lib\\sre_parse.py', 'm'), ('ntpath', 'c:\\python20\\lib\\ntpath.py', 'm'), ('carchive_rt', 'q:\\pc\\installer\\support\\carchive_rt.py', 'm'), ('re', 'c:\\python20\\lib\\re.py', 'm'), ('sre_constants', 'c:\\python20\\lib\\sre_constants.py', 'm'), ('UserDict', 'c:\\python20\\lib\\UserDict.py', 'm'), ('tempfile', 'c:\\python20\\lib\\tempfile.py', 'm'), ('sre', 'c:\\python20\\lib\\sre.py', 'm'), ('posixpath', 'c:\\python20\\lib\\posixpath.py', 'm'), ('types', 'c:\\python20\\lib\\types.py', 'm'), ('sre_compile', 'c:\\python20\\lib\\sre_compile.py', 'm'), ('copy', 'c:\\python20\\lib\\copy.py', 'm'), ('popen2', 'c:\\python20\\lib\\popen2.py', 'm'), ('imputil', 'c:\\python20\\lib\\imputil.py', 'm'), ('repr', 'c:\\python20\\lib\\repr.py', 'm'), ('dospath', 'c:\\python20\\lib\\dospath.py', 'm'), ('macpath', 'c:\\python20\\lib\\macpath.py', 'm'), ('string', 'c:\\python20\\lib\\string.py', 'm'), ('copy_reg', 'c:\\python20\\lib\\copy_reg.py', 'm'), ('stat', 'c:\\python20\\lib\\stat.py', 'm'), ('pre', 'c:\\python20\\lib\\pre.py', 'm'), ('installutils', 'Q:\\pc\\installer\\support\\installutils.py', 'm')] Applying the following filters: [, , , , , , ] Final Table of Contents for installzlib.pyz: [('os', 'c:\\python20\\lib\\os.py', 'm'), ('sre_parse', 'c:\\python20\\lib\\sre_parse.py', 'm'), ('ntpath', 'c:\\python20\\lib\\ntpath.py', 'm'), ('carchive_rt', 'q:\\pc\\installer\\support\\carchive_rt.py', 'm'), ('re', 'c:\\python20\\lib\\re.py', 'm'), ('sre_constants', 'c:\\python20\\lib\\sre_constants.py', 'm'), ('UserDict', 'c:\\python20\\lib\\UserDict.py', 'm'), ('tempfile', 'c:\\python20\\lib\\tempfile.py', 'm'), ('sre', 'c:\\python20\\lib\\sre.py', 'm'), ('types', 'c:\\python20\\lib\\types.py', 'm'), ('sre_compile', 'c:\\python20\\lib\\sre_compile.py', 'm'), ('copy', 'c:\\python20\\lib\\copy.py', 'm'), ('popen2', 'c:\\python20\\lib\\popen2.py', 'm'), ('repr', 'c:\\python20\\lib\\repr.py', 'm'), ('string', 'c:\\python20\\lib\\string.py', 'm'), ('copy_reg', 'c:\\python20\\lib\\copy_reg.py', 'm'), ('stat', 'c:\\python20\\lib\\stat.py', 'm'), ('pre', 'c:\\python20\\lib\\pre.py', 'm'), ('installutils', 'Q:\\pc\\installer\\support\\installutils.py', 'm')] ---- PYZTarget: test.pyz ----- {'__name__': 'test.pyz', '_dependencies': [(imputil, c:\python20\lib\imputil.pyc, m), (zlib, q:\pc\zlib.pyd, b), (archive_rt, Q:\pc\installer\support\archive_rt.py, m)], 'bindepends': [], 'cfg': , 'children': [], 'debug': 0, 'dependencies': ['test.py'], 'destdir': '', 'directories': [], 'excludes': ['dospath', 'posixpath', 'macpath'], 'expatterns': [], 'exstdlib': 0, 'extypes': [], 'icon': '', 'includes': [], 'includetk': 0, 'misc': [], 'name': 'test.pyz', 'packages': [], 'pathprefix': ['Q:\\pc', 'Q:\\pc\\installer\\support'], 'script': [], 'support': 1, 'toc': [], 'trees': [], 'userunw': 0, 'zlib': []} Dependencies of test.py that couldn't be traced: {'dos': {'imputil': None}, 'mac': {'imputil': None}, 'os2': {'imputil': None}, 'posix': {'imputil': None}} lTOC after expanding 'depends': [('imputil', 'c:\\python20\\lib\\imputil.py', 'm')] lTOC after includes, dir, pkgs: [('imputil', 'c:\\python20\\lib\\imputil.py', 'm')] Applying the following filters: [, , , , , , ] Final Table of Contents for test.pyz: [] ---- ExeTarget: test.exe ----- {'__name__': 'test.exe', '_dependencies': [(imputil, c:\python20\lib\imputil.py, m), (archive_rt, q:\pc\installer\support\archive_rt.py, m), (zlib, q:\pc\zlib.pyd, b), (python20.dll, C:\WINNT\System32\python20.dll, b), (carchive_rt, Q:\pc\installer\support\carchive_rt.py, m)], 'bindepends': [], 'cfg': , 'children': ['APPZLIB'], 'debug': 0, 'dependencies': [], 'destdir': '', 'directories': [], 'excludes': [], 'expatterns': [], 'exstdlib': 0, 'extypes': [], 'icon': '', 'includes': [], 'includetk': 0, 'misc': [], 'name': 'test.exe', 'packages': [], 'pathprefix': ['Q:\\pc', 'Q:\\pc\\installer\\support'], 'script': ['test.py'], 'support': 0, 'toc': [], 'trees': [], 'userunw': 0, 'zlib': ['APPZLIB']} Checking zlib[0] merging test.pyz self.zlib[0]: APPZLIB built: {'test.pyz': <__main__.PYZTarget instance at 0088BB6C>, 'installzlib.pyz': <__main__.PYZTarget instance at 00DF175C>} target: <__main__.PYZTarget instance at 0088BB6C> ltoc after bindepends: [('test.pyz', 'test.pyz', 'z'), ('imputil', 'c:\\python20\\lib\\imputil.pyc', 'm'), ('zlib', 'q:\\pc\\zlib.pyd', 'b'), ('archive_rt', 'Q:\\pc\\installer\\support\\archive_rt.py', 'm')] sections: ['MYSTANDALONE', 'INSTALLZLIB', 'MYINSTALL', 'APPZLIB'] ltoc after misc: [('test.pyz', 'test.pyz', 'z'), ('imputil', 'c:\\python20\\lib\\imputil.pyc', 'm'), ('zlib', 'q:\\pc\\zlib.pyd', 'b'), ('archive_rt', 'Q:\\pc\\installer\\support\\archive_rt.py', 'm')] ltoc after scripts: [('test.pyz', 'test.pyz', 'z'), ('imputil', 'c:\\python20\\lib\\imputil.pyc', 'm'), ('zlib', 'q:\\pc\\zlib.pyd', 'b'), ('archive_rt', 'Q:\\pc\\installer\\support\\archive_rt.py', 'm'), ('test', 'test.py', 's')] ltoc after trees: [('test.pyz', 'test.pyz', 'z'), ('imputil', 'c:\\python20\\lib\\imputil.pyc', 'm'), ('zlib', 'q:\\pc\\zlib.pyd', 'b'), ('archive_rt', 'Q:\\pc\\installer\\support\\archive_rt.py', 'm'), ('test', 'test.py', 's')] Applying the following filters: [] Final Table of Contents for test.exe: [('test.pyz', 'test.pyz', 'z'), ('imputil', 'c:\\python20\\lib\\imputil.pyc', 'm'), ('archive_rt', 'Q:\\pc\\installer\\support\\archive_rt.py', 'm'), ('test', 'test.py', 's')] ---- InstallTarget: Install_test.exe ----- {'__name__': 'Install_test.exe', '_dependencies': [(imputil, c:\python20\lib\imputil.py, m), (archive_rt, q:\pc\installer\support\archive_rt.py, m), (zlib, q:\pc\zlib.pyd, b), (python20.dll, C:\WINNT\System32\python20.dll, b), (carchive_rt, Q:\pc\installer\support\carchive_rt.py, m)], 'bindepends': ['test.py'], 'cfg': , 'children': ['INSTALLZLIB', 'MYSTANDALONE'], 'debug': 0, 'dependencies': [], 'destdir': '', 'directories': [], 'excludes': ['PyWinTypes20.dll', 'win32api'], 'expatterns': [], 'exstdlib': 0, 'extypes': [], 'icon': '', 'includes': [], 'includetk': 0, 'misc': ['MYSTANDALONE'], 'name': 'Install_test.exe', 'packages': [], 'pathprefix': ['Q:\\pc', 'Q:\\pc\\installer\\support'], 'script': ['gen_install.py'], 'support': 1, 'toc': [], 'trees': [], 'userunw': 0, 'zlib': ['INSTALLZLIB']} Checking zlib[0] merging installzlib.pyz self.zlib[0]: INSTALLZLIB built: {'test.exe': <__main__.ExeTarget instance at 00845B5C>, 'test.pyz': <__main__.PYZTarget instance at 0088BB6C>, 'installzlib.pyz': <__main__.PYZTarget instance at 00DF175C>} target: <__main__.PYZTarget instance at 00DF175C> ltoc after bindepends: [('win32api', 'c:\\python20\\win32\\win32api.pyd', 'b'), ('zlib', 'q:\\pc\\zlib.pyd', 'b'), ('_sre', 'c:\\python20\\dlls\\_sre.pyd', 'b'), ('PyWinTypes20.dll', 'C:\\WINNT\\System32\\PyWinTypes20.dll', 'b'), ('python20.dll', 'C:\\WINNT\\System32\\python20.dll', 'b'), ('installzlib.pyz', 'installzlib.pyz', 'z'), ('imputil', 'c:\\python20\\lib\\imputil.pyc', 'm'), ('archive_rt', 'Q:\\pc\\installer\\support\\archive_rt.py', 'm')] sections: ['MYSTANDALONE', 'INSTALLZLIB', 'MYINSTALL', 'APPZLIB'] checking MYSTANDALONE which is test.exe ltoc after misc: [('win32api', 'c:\\python20\\win32\\win32api.pyd', 'b'), ('zlib', 'q:\\pc\\zlib.pyd', 'b'), ('_sre', 'c:\\python20\\dlls\\_sre.pyd', 'b'), ('PyWinTypes20.dll', 'C:\\WINNT\\System32\\PyWinTypes20.dll', 'b'), ('python20.dll', 'C:\\WINNT\\System32\\python20.dll', 'b'), ('installzlib.pyz', 'installzlib.pyz', 'z'), ('imputil', 'c:\\python20\\lib\\imputil.pyc', 'm'), ('archive_rt', 'Q:\\pc\\installer\\support\\archive_rt.py', 'm'), ('test.exe', 'test.exe', 'x')] ltoc after scripts: [('win32api', 'c:\\python20\\win32\\win32api.pyd', 'b'), ('zlib', 'q:\\pc\\zlib.pyd', 'b'), ('_sre', 'c:\\python20\\dlls\\_sre.pyd', 'b'), ('PyWinTypes20.dll', 'C:\\WINNT\\System32\\PyWinTypes20.dll', 'b'), ('python20.dll', 'C:\\WINNT\\System32\\python20.dll', 'b'), ('installzlib.pyz', 'installzlib.pyz', 'z'), ('imputil', 'c:\\python20\\lib\\imputil.pyc', 'm'), ('archive_rt', 'Q:\\pc\\installer\\support\\archive_rt.py', 'm'), ('test.exe', 'test.exe', 'x'), ('gen_install', 'gen_install.py', 's')] ltoc after trees: [('win32api', 'c:\\python20\\win32\\win32api.pyd', 'b'), ('zlib', 'q:\\pc\\zlib.pyd', 'b'), ('_sre', 'c:\\python20\\dlls\\_sre.pyd', 'b'), ('PyWinTypes20.dll', 'C:\\WINNT\\System32\\PyWinTypes20.dll', 'b'), ('python20.dll', 'C:\\WINNT\\System32\\python20.dll', 'b'), ('installzlib.pyz', 'installzlib.pyz', 'z'), ('imputil', 'c:\\python20\\lib\\imputil.pyc', 'm'), ('archive_rt', 'Q:\\pc\\installer\\support\\archive_rt.py', 'm'), ('test.exe', 'test.exe', 'x'), ('gen_install', 'gen_install.py', 's')] Applying the following filters: [, , ] Final Table of Contents for Install_test.exe: [('zlib', 'q:\\pc\\zlib.pyd', 'b'), ('_sre', 'c:\\python20\\dlls\\_sre.pyd', 'b'), ('python20.dll', 'C:\\WINNT\\System32\\python20.dll', 'b'), ('installzlib.pyz', 'installzlib.pyz', 'z'), ('imputil', 'c:\\python20\\lib\\imputil.pyc', 'm'), ('archive_rt', 'Q:\\pc\\installer\\support\\archive_rt.py', 'm'), ('test.exe', 'test.exe', 'x'), ('gen_install', 'gen_install.py', 's')] From gregj at pobox.com Mon Dec 25 05:02:37 2000 From: gregj at pobox.com (Greg Jorgensen) Date: Mon, 25 Dec 2000 10:02:37 GMT Subject: Some Python 2.1 ideas References: <3A452881.7686E717@uswest.net> <%vb16.187233$U46.5801214@news1.sttls1.wa.home.com> <3A464D5D.B541C04E@uswest.net> Message-ID: <1XE16.190885$U46.5872195@news1.sttls1.wa.home.com> "Bjorn Pettersen" wrote: > This would be a good idea, except it wouldn't fit with the standard Python idiom > for reading files: > > while 1: > line = f.readline_chomp() > if not line: break # would always break Oops! That shows how far I thought my idea through! And me always talking about idioms... I always use rstrip because I never care about trailing whitespace. If I did have a reason to preserve trailing spaces I would write my own code to strip the trailing newlines. -- Greg Jorgensen Deschooling Society Portland, Oregon, USA gregj at pobox.com From fredrik at effbot.org Tue Dec 19 11:36:47 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 19 Dec 2000 16:36:47 GMT Subject: sys.stdout.write() References: Message-ID: Daniel Klein wrote: > In 'Learning Python' by Mark Lutz and David Ascher, on page 77 it makes > mention of the 'sys.stdout.write' method. However, when I check this out, I > don't see the 'write' method in the list... > > >>> import sys > >>> dir(sys.stdout) > ['shell', 'softspace', 'tags'] > > I must be doing something fundamentally wrong. :^( dir() shows the contents of a given namespace. For an instance object, this is the attributes defined in the instance object, not anything defined by its class. Instance objects provide a hidden attribute, __class__, which points to the class object. If the instance uses single-level inheritance, you can get away with dir(sys.stdout.__class__). To get the full inheritance tree, you need to check the class object's __bases__ attribute as well (recursively). From aleaxit at yahoo.com Sun Dec 24 03:18:33 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Sun, 24 Dec 2000 09:18:33 +0100 Subject: One Python 2.1 idea References: <9237md$orm$1@nnrp1.deja.com> Message-ID: <924bjt0e3n@news1.newsguy.com> wrote in message news:9237md$orm$1 at nnrp1.deja.com... [snip] > scripting languages what location is to real estate. One of > the nice things about list comprehensions is that it > improves performance by abstracting an existing language > mechanism. Hi Russell, long time no see! Unfortunately, the 'improves performance' here is counterfactual. There was a silly error in my benchmark (I was timing the same function twice -- thanks to a kind correspondent for pointing this out!-), and here it is in the correct form, augmented with a simple loop solution as a reference point...: import time def withMap(inList): return map(lambda x: x+1, inList) def withLC(inList): return [x+1 for x in inList] def withLoop(inList): l = len(inList) result = [None]*l for i in range(l): result[i] = inList[i]+1 return result def stopWatch(function, N=100*1000): start = time.clock() function(range(N)) stend = time.clock() return stend-start print "Using map and lambda: %f" % stopWatch(withMap) print "Using list-comprehension: %f" % stopWatch(withLC) print "Using a simple loop: %f" % stopWatch(withLoop) D:\PySym\cover>python spe.py Using map and lambda: 0.891596 Using list-comprehension: 1.051381 Using a simple loop: 0.721732 D:\PySym\cover>python spe.py Using map and lambda: 0.706179 Using list-comprehension: 1.005335 Using a simple loop: 0.706091 D:\PySym\cover>python spe.py Using map and lambda: 0.817602 Using list-comprehension: 1.053890 Using a simple loop: 0.703723 So, the list comprehension in this case is SLOWER by over 10% than the map-and-lambda. If speed was indeed paramount, one should thus eschew it -- counterintuitive, but I guess there must be problems in the allocation/reallocation strategy of the list comprehension, which appears to reallocate N times for N items (while map allocates the resulting-list once, I think). But note that a simple loop with preallocation of result is _at least_ as fast as map, here -- indeed, it's the fastest approach. If speed be all, then, avoiding advanced constructs may in some cases prove the best approach! Actually, for all-out speed in a higher-level language, Scheme (with the stalin compiler) or Common Lisp probably cannot be beat. There ARE, after all, decades of Lisp experience and many groups of clever people laboring away at getting such speed. (If one is willing to forego dynamic typing, O'Caml or other MLs may be contenders; Dylan may also be of interest; and Smalltalk also has speedy implementations, if one will pay...). I prefer Python because I do NOT prize speed in a higher-level language above other factors -- great practicality at "playing well with others", clarity, cleanness of syntax, great productivity. If you do have another scale of values, Python may not be the best choice for you at this time; specifically, if for some reason the solutions MUST be single-language ones (you can't or won't use a lower-level, faster language for that 10% or so of your code that bottlenecks its speed). I do not have any such constraint, so Python + some tiny amount of C++ at the right places (often already provided in the form of existing modules such as Numeric, PIL, ...) is exactly right for my needs... Alex From arturo_perez at wanadoo.es Mon Dec 11 10:45:13 2000 From: arturo_perez at wanadoo.es (Arturo Pérez Mulas) Date: Mon, 11 Dec 2000 15:45:13 GMT Subject: Fault trees structure References: <9128e902uo3@news2.newsguy.com> Message-ID: Hello! > Fault-tree analysis does appear like an interesting subject, but I > can't easily find a precise model of "a fault-tree" around the web. > Can you point to a summary description ("fault-tree analysis" gets > a lot of hits, but I wonder if a "fault-tree object" can be described > well enough without getting into the depth of the analysis issues)? I will definitely post some pointers this evening, and add some more comments myself. > Discussing how to model something in terms of Python classes &c seems > to be a rather basic purpose of this forum, so I think it would be > all right to pursue a discussion here, but you'd have to supply the > domain-expertise (at least if I'm the other discussant...!). It would be nice to know how much you know about them, to write some meaningful post that is not too simple neither too complex. My main goal is not in fault-tree analysing (quantification), since this is a very complex and computing costly exercise, and a few wonderful tools are running out there. My goal is to be able to read/write fault trees from different formats and manipulate them from my codes. This is the main reason I got into python, and for that matter into OOP. Fault trees seem a nice entity to be attacked using OOP (at a further stage I think it would be wonderful, not only to come out with an object model for FTs -fault trees-, but to set up an xml set of rules to store/interchange them... but this is far away from my knowledge, time and employer's budget! From mspal at sangria.harvard.edu Wed Dec 6 18:08:10 2000 From: mspal at sangria.harvard.edu (Michael Spalinski) Date: 06 Dec 2000 18:08:10 -0500 Subject: wither PyFITS ? References: <3A2EB29B.EBB3CCB5@noaa.gov> Message-ID: >>>>> "j" == j vickroy writes: j> Hello, j> The following link j> http://monet.astro.uiuc.edu/adass98/Proceedings/barrettpa/ j> claims there is a FITS module (PyFITS) available, but I have not j> been able to find it. j> Any help would be appreciated. Google finds this: http://ra.stsci.edu/pyfits/ --M. From slee4812 at my-deja.com Fri Dec 15 11:15:31 2000 From: slee4812 at my-deja.com (Stan Lee) Date: Fri, 15 Dec 2000 16:15:31 GMT Subject: comparable shelve function in xml Message-ID: <91dg2q$3a1$1@nnrp1.deja.com> Hi, Is there a comparable way to store Python objects in an XML formatted file like the shelve module does? I want to be able to store Python objects to a file that's human-readable on both a Windows and Linux platform. Thanks. -Stan Sent via Deja.com http://www.deja.com/ From gb at a3design.de Wed Dec 20 07:05:55 2000 From: gb at a3design.de (gunter ) Date: Wed, 20 Dec 2000 12:05:55 -0000 Subject: Greetings from the Interpreter!!! Message-ID: <91q7b3+7a78@eGroups.com> import string,time,os print (string.join((lambda x:x[:10]+x[8:])(map(lambda x: string.center("*" * (lambda x: ((x < 24) * (x - 3)) + 3)(x) ,24), range(1,28,2))),os.linesep), "Please Wait...")[time.time()<977612400] From greg at cosc.canterbury.ac.nz Tue Dec 12 22:50:35 2000 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 13 Dec 2000 16:50:35 +1300 Subject: [Q] Are Exceptions used that much in practice? References: <3A35D546.A4731B5B@enteract.com> <914mfd02ibt@news2.newsguy.com> Message-ID: <3A36F20B.7B766D0@cosc.canterbury.ac.nz> Alex Martelli wrote: > def setattr_ok(obj, attr, value): > try: setattr(obj, attr, value) > except (AttributeError, ValueError): return 0 > else: return 1 There are dangers in that approach when the exception being caught is a very common one such as AttributeError. If the obj is such that calling setattr on it causes some Python code to be executed, and there is a bug in that code which causes an AttributeError to be raised, you'll never know about it. A similar problem occurs with Python's use of IndexError to terminate a for-loop. For that reason, I have mixed feelings about whether the exception-as-normal-flow-control style of programming is a good idea. It might be okay if you use a special-purpose exception class created just for that particular use, but abusing exceptions which normally indicate bugs is asking for trouble, in my opinion. > def open_if_ok2(filepath): > try: return open(filepath, 'r') > except IOError: return None > A minor gripe here - it would be more useful if Python had some subclasses of IOError to distinguish between different reasons for failure, so you can catch them more selectively. If the reason is "the file doesn't exist", you might want to do something to make it exist and then try again. But if the reason is "the file exists but the user doesn't have permission" or "someone put peanut butter in the disk drive", you probably just want to let the exception propagate. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From rogerha at aol.com Sun Dec 10 08:36:24 2000 From: rogerha at aol.com (Roger Abbott) Date: Sun, 10 Dec 2000 13:36:24 GMT Subject: WWW_URLEcho with dde References: <3a32b7e6.8685100@24.0.228.33> Message-ID: <9100sp$a0b$1@nnrp1.deja.com> In article <3a32b7e6.8685100 at 24.0.228.33>, support @ internetdiscovery.com (Mike Clarkson) wrote: > Has anyone used the dde module in Python to register a URLEcho from > netscape or Internet Explorer? Looking at the source code to dde I see > comments about Netscape's use of poke, which indicates the author > may have been playing with URLEcho. > > I'd like to start a dde server and register it with netscape to send > me an echo when it loads a web page. Has anyone done this? Yes, in VB. The web site below has a free WebSpy program which does it. It comes with source code, I am sure you can figure out how it works. -- Roger Abbott, RHA (Minisystems) Ltd - http://www.rhaminisys.com DDE Client and Server ActiveX controls for Visual Basic DDE FAQ and DDE utility tools, browser URL monitor, Program launcher/setup menu, other freeware and shareware Sent via Deja.com http://www.deja.com/ Before you buy. From robin at jessikat.fsnet.co.uk Thu Dec 14 07:43:03 2000 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 14 Dec 2000 12:43:03 +0000 Subject: strip weirds Message-ID: Can somebody explain why strip behaves differently with and without an argument? >>> from string import split >>> split(' ') [] >>> split(' ',' ') ['', ''] >>> split(' ') [] >>> split(' ',' ') ['', '', ''] >>> with the default whitespace arg seems as though a run of whitespace is being treated as a single character. -- Robin Becker From red5sf at my-deja.com Sat Dec 9 18:43:18 2000 From: red5sf at my-deja.com (red5sf at my-deja.com) Date: Sat, 09 Dec 2000 23:43:18 GMT Subject: ActiveState: PythonWin not using PythonPath for import? References: <906ki2$s16$1@nnrp1.deja.com> <3A283CDB.8020800@ActiveState.com> <90gjah$7bh$1@nnrp1.deja.com> Message-ID: <90ug2l$8pp$1@nnrp1.deja.com> If you edit the Pythonwin path, that should solve your problem. Christian In article <90gjah$7bh$1 at nnrp1.deja.com>, Bill Seitz wrote: > In article <3A283CDB.8020800 at ActiveState.com>, > Mark Hammond wrote: > > Bill Seitz wrote: > > > > > I made a folder just below the Python root to hold my own code. > > > > > > In PythonWin, I edited PythonPath, adding my folder to the end of > the > > > value. > > > > > > Yet when I use "import aFunction" when "aFunction.py" is within my > > > folder, I get an error. When I move the file up to the Python root > > > folder, it works. > > > > The "root" PYTHONPATH entry is the core PythonPath, and is only used > if > > Python can not locate its core library etc manually. > > > > Add your path to one of the subkeys, or just add your own subkey and > add > > your value there... > > Thanks, that worked (once I quit/relaunched PythonWin). Is this (a) > recognized outside PythonWin, and (b) documented? > > Sent via Deja.com http://www.deja.com/ > Before you buy. > Sent via Deja.com http://www.deja.com/ Before you buy. From aleaxit at yahoo.com Mon Dec 11 11:59:21 2000 From: aleaxit at yahoo.com (Alex Martelli) Date: Mon, 11 Dec 2000 17:59:21 +0100 Subject: Microsoft SOAP not compatible with PythonWare's SOAP? References: <912q8s$c4i$1@news1.xs4all.nl> Message-ID: <91315o0ou8@news2.newsguy.com> "Iwan van der Kleyn" wrote in message news:912q8s$c4i$1 at news1.xs4all.nl... > Hi there, > > I'm developing an Intranet-site with Python. Part of the needed > business-logic is already implemented as Visual Basic (COM) components > (let's call this a "legacy-sytem" :-). I've investigated several means of > integrating them into my intranet-application and a low-cost, conventient > way would be to build a SOAP-interface which I would access with the > SOAPlib.py from Pyhtonware (http://www.pythonware.com/products/soap/) . > > However, during testing I've not been able to retrieve any data from the > test MS SOAP components. The soaplib seems to working fine, though. Is this > the result of "competing" SOAP implementations? Is there any info availbale > about this topic? (? haven't found any on the internet) I haven't run enough tests for this to be much more than hearsay, but what little I did do, seemed just about to confirm what I was reading around the net: the early versions of the MS SOAP toolkit had serious divergences from other reference implementations of SOAP, but things have been getting better in this regard, and the very latest MS SOAP SDK beta *is* mostly-interoperable with stuff from IBM and Developmentor. Alex From fredrik at effbot.org Tue Dec 12 14:49:21 2000 From: fredrik at effbot.org (Fredrik Lundh) Date: Tue, 12 Dec 2000 19:49:21 GMT Subject: Label-Value (was: Re: Inheriting the @ sign from Ruby) References: <914v6l02ouv@news2.newsguy.com> Message-ID: <5jvZ5.3588$Kd1.418770@newsb.telia.net> Daniel Wood wrote: > Here is what I wanted to do. I have some random parameters, lambda > and beta. My calculation uses them like so: > > plot( lambda, beta ) lambda is a reserved word, so I doubt that's what you're doing. Let's call it "spam" instead. > I'm using pygtk as a widget set. I have some sliders. I wanted to > make one of the sliders control lambda and one control beta. The > control should be scaled by some parameter etc, etc. Now I could have > a function > > def lambdaCB( val ): > global lambda > lambda = val / constant > > but instead I thought that I would have a simple class > > class ScaleCB: > def __init__( self, variable, scale ): > self.variable = variable > self.scale = scale > > def __call__( self, val ) > self.variable = val / self.scale > > (then, I can do lots of parameters with nice simple code instead of > bunches of stupid helper functions. > > This obviously didn't work. (didn't do what you wanted it to do, at least) How about this one: class PlotParams: def __init__(self): self.spam = 1 self.beta = 2 def setspam(self, value): self.spam = value self.redraw() def setbeta(self, value): self.beta = value self.redraw() def redraw(self): plot(self.spam, self.beta) myplot = PlotParams() spamScaleWidget.setcallback(myplot.setspam) betaScaleWidget.setcallback(myplot.setbeta) > I *think* that the "pythonic" sol'n appears to be lambda = [ value ] > or some such. Besides being a syntax error, it doesn't look very Pythonic to me. If you want to change a named value, the best way is to make it an attribute of a class. From sholden at holdenweb.com Wed Dec 20 07:59:38 2000 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 20 Dec 2000 07:59:38 -0500 Subject: Wanted: Python White Papers References: <91oj8v$i0r$1@nnrp1.deja.com> Message-ID: While it isn't a "white paper", the following web page details many users of the python language, some of them quite high-profile: http://www.python.org/psa/Users.html Hope this helps. regards Steve wrote in message news:91oj8v$i0r$1 at nnrp1.deja.com... > Is anyone aware of any white papers to explain the use of Python > at any big, high-profile companies? > I'm trying to use a "look-how-these-cool-companies-use-python" > argument to defend the use of Python for a project. That won't be my > only argument, of course :-) But currently Python is not winning many > management converts here based solely on its technical merits. > Many still say, "What's Python? Never heard of it...". It helps > a lot when I say "Google uses it!", but it would help more if I > knew HOW it is used and WHY. > > Actually, the only high-profile company that uses Python that I > can think of is Google. Is anyone familiar with their architecture? > How does Python fit into their design? > > Is there anyone out there from Google that can represent Google's use > of Python? What are Google's plans for the future of Python in their > architecture? I heard that they might be switching to Java. > > Yours, > Noah Spurrier > > > Sent via Deja.com > http://www.deja.com/ > From 2rkil at my-deja.com Fri Dec 8 04:28:41 2000 From: 2rkil at my-deja.com (2rkil at my-deja.com) Date: Fri, 08 Dec 2000 09:28:41 GMT Subject: Changing image in label Message-ID: <90q9k6$468$1@nnrp1.deja.com> Hi. I'm totally new to, yet amazed by, Python. I'm trying to write a program which displays a portrait, asking the user who it is. After answering, the picture should change to another person, and so on. Probably simple, but I'm new to event based programming. What happens is that the first picture disappears, and just the frame (the sizes) of the new one appears. Here's the code: #!/usr/bin/python from Tkinter import * import string root = Tk() def getquestion(): return "gfx/torkil_grindstein.gif", "Who is this?", "Torkil Grindstein" def getquestion2(): return "gfx/haakon_brugaard.gif", "But who is this?", "H?kon Brug?rd" def update(event): global photo_widget, question_widget photo, question, fasit = getquestion2() gif = PhotoImage(file=photo) photo_widget["image"] = gif question_widget["text"] = question def main(): global photo_widget, question_widget, answer_widget photo, question, fasit = getquestion() gif = PhotoImage(file=photo) photo_widget = Label(root, relief=RAISED, image = gif) photo_widget.pack() question_widget = Label(root, text = question) question_widget.pack() f = Frame(root) f.pack() answer_widget = Entry(f) answer_widget.bind("", update) answer_widget.pack(side=LEFT) answer_button = Button(f, text="Answer") answer_button.bind("