From shillcoc at mry.rbd.com Sun Aug 29 02:46:33 1999 From: shillcoc at mry.rbd.com (Scott Shillcock) Date: Sat, 28 Aug 1999 23:46:33 -0700 Subject: Need help with PyRun_SimpleFile Message-ID: <37C8D749.15FB7C93@mry.rbd.com> Hello, Here is my very simple program: #include #include "Python.h" void main (int argc, char **argv) { Py_Initialize (); FILE *fp = fopen ("test.py", "r+"); cerr << "Before PyRun_SimpleFile" << endl; PyRun_SimpleFile (fp, "test.py"); cerr << "After PyRun_SimpleFile" << endl; Py_Exit(0); } I can compile this into an exe file. I also created a very simple test.py file that just prints one line of text. When I run my program it crashes on the PyRun_SimpleFile() every time. I get the first cerr but not the second. What I am doing wrong? I have tried as many variations on this at I could think of, all with the same result. Thanks, Scott -- Scott Shillcock shillcoc at rbd.com Reality by Design www.rbd.com From webmaster at chatbase.com Sun Aug 15 21:14:40 1999 From: webmaster at chatbase.com (Tim Greer) Date: Sun, 15 Aug 1999 18:14:40 -0700 Subject: Why use Perl when we've got Python?! References: <37AAFAD1.A032765B@NOSPAM.strs.co.uk> <37B286D2.A71C3239@NOSPAM.strs.co.uk> <37b30253@cs.colorado.edu> <37B49CBA.772D9783@basho.fc.hp.com> <37b4a18f@cs.colorado.edu> <37b4ced8@cs.colorado.edu> Message-ID: <37B76600.FECF5FEB@chatbase.com> John Stevens wrote: > > On 14 Aug 1999 04:08:05 GMT, Sam Holden wrote: > >That could simply have been a reference. Or a symbolic reference. > > > >What is fundamental is that a @ tacked on the front indicates that it is an > >array. > > :-) > > What is so amusing about that, is that you can say that with a straight > face! > > :-) > > >So given @$fred, even with no knowledge of what that exactly means > >you should be able to tell that it is somehow treating $fred as an array. > > No, what any reasonable person would do would be to grab for his > Perl book. . . Until they learn the language enough to know these things. If you judge a language based only on what you remember in the smallest amount of learning time you've spent, then you're limiting yourself in too many ways to bother mentioning. Some people have a better comprehension for certain languages over others. It's really that simple. Some people are scared off, or disillusioned too quickly. Simply put, they haven't spent the proper amount of time (some languages do take longer to learn well enough to not have to use reference material every few minutes), or they weren't taught properly, or it's just something that they have less of a comprehension for, or perhaps a lack of desire to really get so involved when they could be using other languages. Sometimes that limits you and your ability. You only limit yourself at that point, because you could be writing better programs in a language that's probably better suited for the task, a language that confuses you, because you don't understand it as quickly as another. That's fine, and for some people, it's not worth the time invested to pout so much time into learning for more reasons that are equally as pointless to mention. Some people think learning Assembly is a complete waste of time.. Why learn it when you already know enough C? Right? Wrong. If you have time and reason or desire, learn it. Even if you'll never use it, I'd suggest you learn it. It might not be easy, but in most circumstances, you'll probably end up writing better C programs... You'd have to learn Assembly to know what I'm talking about... The only real drawback, is the fact that you'll cringe when you realize what the C compiler is doing to your code. You can't know this, because you either don't know the language, or know it well enough to state such things. Sure, you find it more confusing then Python, that's fine, that's you. However, in that case, you shouldn't make statements that make you look foolish here, in a Perl NG, simply based on the facts that you can't deal with the curly braces and such, or the fact that _you_ personally can't remember some of the syntax and whatnot. That's ridiculous and that's why this completely pointless thread has continued for so long. > >>Yes. . . is it a hash, or a scalar? If it is a scalar, why > >>is it called dict? If it is a hash, then why is it prefixed > >>by $? If this is a reference instead of a scalar, then why > >>doesn't it have it's own special prefix character. ;-> > > > >It's a scalar. It is named dict because TomC called it that. > > Yes. My point exactly. Yes, well, tell me, _what_ is it to be called? You should know how much Tom is involved in Perl and how much he contributes. It's not a bad idea or a wrong idea to call it something _you_ personally don't agree with. You are complaining about "lists" in Perl? It's what it's called in _this_ language, _this_ is _not_ Python. Do you just use this as an example, based on the fact that it's not what you're _used to seeing_? Or what you think it would be better called? This is a pretty high-level language, and you are sort of contradicting yourself by saying how difficult the syntax is to remember for _you_ (however that's relevant to the rest of the world?), yet you think it should be called a more technical term that _most_ people wouldn't understand? Isn't that at least _part_ of your point? > >It is > >also named that since it is a reference to a hash. I use code like this > >in C quite a bit : > > A reference to a hash. . . and yet TC claims that Perl is open to > non-computer scientists. > > :-) > > Doesn't *ANYBODY* else see the irony in that? How about the fact that you appear you be your own walking contradiction? I believe that point is and was correct, and is to the fact that; In Perl, people with no background in CS can learn enough, right off, within a very short time, to be able to write some programs that will accomplish some basic to intermediate tasks. That's not to say that they will be able to know the more complex aspects of the language with as much ease, and that goes without saying for _any_ language. Why disagree with that? > >If you know what it means then why do you continually get it wrong > >throughout this thread? > > I don't suppose that you realize that getting wrong simply > proves (and illustrates) my point? About you and your statements, yes. You aren't everyone, or the majority. If enough people asked that some of the keywords and definitions be changed and there was a real need for it, I'm sure it would happen... I don't see that happening, because there's no reason, because _most_ people here seem to understand it and remember the syntax well enough to where they don't suffer from the same problem as you. > I learned it. I used it. I haven't written a new Perl program > in three months. > > I come back to it, I get it wrong. . . do you see, yet, > or do you just not get it? I think the point is, is that you simply don't "get" Perl. You "get" Python better, it's more comprehensible to you, and that's fine. Some people find the opposite true. I myself, as both a Perl and Python programmer (among other languages) look for and find the similarities. There are more then a few if you really look at it. What's better for what you're doing, is the question? What language do you find easier to use personally? Why say one language is flawed over another based on your own experience. Who did you learn from? Where did you learn from? How much time did you spend? What, if any, do you have in prior CS/programming backgrounds? Are you willing to dismiss some or many of the things you were taught when you learned the prior, or do you feel it's a better language based on the fact that you find it's closer to, or easier to understand right off in comparison to the prior knowledge you posses? Who are you to say? This is really stupid. Have you read any, many, or all of Tom's books he's authored or co-authored? The man is not stupid and he knows what he's talking about, which you have to admit is true when it comes to Perl at least. Isn't it expected that he'll make points in defense of Perl? You obviously don't like Perl as much as Python, and no one's saying there's anything wrong with that.. The only flaw with your logic in your posts, is the fact that it seems that you're speaking for others and basing a lot of it on the fact, as you claim, that you yourself personally find remembering the syntax difficult. Ok, so? That's you, I can't think of anyone else that used Perl that has that problem, but I'm sure more then a few do, just as with any other language. Why use Perl when you've got Python? I don't know, maybe you'll enjoy Perl more, use it more, or find it better suited for you or your task? Maybe your particular program will run faster/better in perl rather then Python? Maybe you can market it with more ease? Maybe something else? maybe your program (for you, from you coding it) will run better coded in Python? There's no point to this at all! If you want to compare it in that manner, then tell me, _why_ bother with Perl OR Python, when you can use C? Further, _why_ use C, when you can code it in Assembly? After all, it's faster, you can make it do anything you want, as-long-as-you-know-how. Just because you don't "know how", doesn't mean it lacks something the language you _can_ code in better. There was really no point to any of this. Making claims one way of the other, about what you "believe" would be better named or worded does little to no good. Note that my post in reply to you is/was completely relevant and on-topic in regards to your post and this entire issue... Note also, that I didn't have to use on piece of code to make this point... after all, this is, to you as you've made it clear, to prove your point, or disprove it. I'm just wondering _what_ your "point" was supposed to be when it all comes down to it? I have been following the thread, and I have yet to see a real point made. -- Regards, Tim Greer : webmaster at chatbase.com | software at linkworm.com The ChatBase: http://www.chatbase.com | 250,000+ hits daily Worldwide! TRG Software: http://www.linkworm.com | CGI scripts in Perl/C, & more. Unix/NT/Novell Administration, Security, Web Design, ASP, SQL, & more. Freelance Programming & Consulting, Musician, Martial Arts, +Sciences. From JamesL at Lugoj.Com Fri Aug 20 00:31:14 1999 From: JamesL at Lugoj.Com (James Logajan) Date: Thu, 19 Aug 1999 21:31:14 -0700 Subject: Python to Perl Conversions References: <37bc1303@cs.colorado.edu> Message-ID: <37BCDA12.6CB5B89A@Lugoj.Com> Tom Christiansen wrote: > There are no manpages for Python. I hate HTML documentation. I want printed documentation or I get seriously pissed too. Fortunately Python has a nice set of printable documents in a variety of formats and paper sizes. See: http://www.python.org/doc/current/download.html You are fundamentally incorrect in stating that there is no man page for Python. There is a man page for Python in my /usr/local/man/man1 directory on my Linux box. It does not cover the language syntax or the huge library reference, but then neither does the man page for c++ cover its syntax or the STL. For your benefit I've included the Python man page as an attachment. I hope this helps clear up any misunderstanding you may have about Python documentation. -------------- next part -------------- .TH PYTHON "7 September, 1997" .SH NAME python \- an interpreted, interactive, object-oriented programming language .SH SYNOPSIS .B python [ .B \-d ] [ .B \-i ] [ .B \-O ] [ .B \-S ] [ .B \-u ] [ .B \-v ] [ .B \-X ] .br [ .B \-c .I command | .I script | \- ] [ .I arguments ] .SH DESCRIPTION Python is an interpreted, interactive, object-oriented programming language that combines remarkable power with very clear syntax. For an introduction to programming in Python you are referred to the Python Tutorial. The Python Library Reference documents built-in and standard types, constants, functions and modules. Finally, the Python Reference Manual describes the syntax and semantics of the core language in (perhaps too) much detail. .PP Python's basic power can be extended with your own modules written in C or C++. On most systems such modules may be dynamically loaded. Python is also adaptable as an extension language for existing applications. See the internal documentation for hints. .SH COMMAND LINE OPTIONS .TP .B \-d Turn on parser debugging output (for wizards only, depending on compilation options). .TP .B \-i When a script is passed as first argument or the \fB\-c\fP option is used, enter interactive mode after executing the script or the command. It does not read the $PYTHONSTARTUP file. This can be useful to inspect global variables or a stack trace when a script raises an exception. .TP .B \-O Turn on basic optimizations. This changes the filename extension for compiled (bytecode) files from .I .pyc to .I pyo. .TP .B \-S Disable the import of the module .I site and the site-dependent manipulations of .I sys.path that it entails. .TP .B \-u Force stdin, stdout and stderr to be totally unbuffered. .TP .B \-v Print a message each time a module is initialized, showing the place (filename or built-in module) from which it is loaded. .TP .B \-X Make the standard exceptions strings instead of classes. Use for backward compatibility with old code only. .TP .BI "\-c " command Specify the command to execute (see next section). This terminates the option list (following options are passed as arguments to the command). .SH INTERPRETER INTERFACE The interpreter interface resembles that of the UNIX shell: when called with standard input connected to a tty device, it prompts for commands and executes them until an EOF is read; when called with a file name argument or with a file as standard input, it reads and executes a .I script from that file; when called with .B \-c .I command, it executes the Python statement(s) given as .I command. Here .I command may contain multiple statements separated by newlines. Leading whitespace is significant in Python statements! In non-interactive mode, the entire input is parsed befored it is executed. .PP If available, the script name and additional arguments thereafter are passed to the script in the Python variable .I sys.argv , which is a list of strings (you must first .I import sys to be able to access it). If no script name is given, .I sys.argv is empty; if .B \-c is used, .I sys.argv[0] contains the string .I '-c'. Note that options interpreted by the Python interpreter itself are not placed in .I sys.argv. .PP In interactive mode, the primary prompt is `>>>'; the second prompt (which appears when a command is not complete) is `...'. The prompts can be changed by assignment to .I sys.ps1 or .I sys.ps2. The interpreter quits when it reads an EOF at a prompt. When an unhandled exception occurs, a stack trace is printed and control returns to the primary prompt; in non-interactive mode, the interpreter exits after printing the stack trace. The interrupt signal raises the .I Keyboard\%Interrupt exception; other UNIX signals are not caught (except that SIGPIPE is sometimes ignored, in favor of the .I IOError exception). Error messages are written to stderr. .SH FILES AND DIRECTORIES These are subject to difference depending on local installation conventions: .IP /usr/local/bin/python Recommended location of the interpreter. .IP /usr/local/lib/python Recommended location of the directory containing the standard modules. .SH ENVIRONMENT VARIABLES .IP PYTHONHOME Change the location of the standard Python libraries. By default, the libraries are searched in /lib/python and /lib/python, where and are installation-dependent directories, both defaulting to /usr/local. When $PYTHONHOME is set to a single directory, its value replaces both and . To specify different values for these, set $PYTHONHOME to :. .IP PYTHONPATH Augments the default search path for module files. The format is the same as the shell's $PATH: one or more directory pathnames separated by colons. Non-existant directories are silently ignored. The default search path is installation dependent, but generally begins with /lib/python (see PYTHONHOME below). The default search path is always appended to $PYTHONPATH. If a script argument is given, the directory containing the script is inserted in the path in front of $PYTHONPATH. The search path can be manipulated from within a Python program as the variable .I sys.path . .IP PYTHONSTARTUP If this is the name of a readable file, the Python commands in that file are executed before the first prompt is displayed in interactive mode. The file is executed in the same name space where interactive commands are executed so that objects defined or imported in it can be used without qualification in the interactive session. You can also change the prompts .I sys.ps1 and .I sys.ps2 in this file. .IP PYTHONDEBUG If this is set to a non-empty string it is equivalent to specifying the \fB\-d\fP option. .IP PYTHONINSPECT If this is set to a non-empty string it is equivalent to specifying the \fB\-i\fP option. .IP PYTHONUNBUFFERED If this is set to a non-empty string it is equivalent to specifying the \fB\-u\fP option. .IP PYTHONVERBOSE If this is set to a non-empty string it is equivalent to specifying the \fB\-v\fP option. .SH SEE ALSO Python Tutorial .br Python Library Reference .br Python Reference Manual .SH AUTHOR .nf Guido van Rossum CNRI 1895 Preston White Drive Reston, VA 20191 USA .PP E-mail: guido at cnri.reston.va.us, guido at python.org .fi .PP And a cast of thousands. .SH INTERNET RESOURCES Web site: http://www.python.org .br FTP site: ftp://ftp.python.org .br Newsgroup: comp.lang.python .SH COPYRIGHT Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, The Netherlands. .IP " " All Rights Reserved .PP Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the names of Stichting Mathematisch Centrum or CWI or Corporation for National Research Initiatives or CNRI not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. While CWI is the initial source for this software, a modified version is made available by the Corporation for National Research Initiatives (CNRI) at the Internet address ftp://ftp.python.org. STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. From Sven.Drescher at dlr.de Wed Aug 18 03:50:55 1999 From: Sven.Drescher at dlr.de (Sven Drescher) Date: Wed, 18 Aug 1999 09:50:55 +0200 Subject: Embedding python Message-ID: <7pdnso$om6@news.go.dlr.de> Hi! I want to embed python's Tk to C++, but I can't compile it. I looked for the libraries, but I didn't find the right. I have a Sun with SunOS 5.7 and Solaris CDE Version 1.3. Now I need the right library, which includes the definition of the regexpr.o module. The following modules and libraries I have linkes with it: - getpath.o - config.o - lsocket - lpython1.5 - lnsl - lm - ldl - lexpect - lpcre But once is missing. Thanks for help and hints! Sven From tim_one at email.msn.com Tue Aug 24 01:45:49 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 24 Aug 1999 01:45:49 -0400 Subject: Unsorting(randomizing) a sequence In-Reply-To: <7pp3ub$gdj@dfw-ixnews7.ix.netcom.com> Message-ID: <000501beedf3$eb737200$902d2399@tim> [Aahz Maruch] > ... > Here's another question: I know the *period* of whrandom() is very > long, but what is the granularity/precision of it? It combines 3 sequences each of which have no better than 15-bit resolution. Analyzing the combined effect is tricky. You need to define your requirements precisely, then write a realistic simulation independent of your app to test whether your requirements are met. Every non-trivial application of pseudo-random numbers should do that. Collecting random info about the period and resolution is no substitute; e.g., the lattice structure of random.random may kill you no matter how long its period or fine its resolution -- or it may be irrelevant. It depends on every detail of your app. random.random's prime virtue is that it's fast, not that it's especially good (see Ivan Frohne for a Python implementation of the Mersenne Twister, which is a much stronger generator that's slower, but not (like md5) dramatically slower). one-hour-of-you-testing-will-save-me-two-days-of-thinking- and-is-a-lot-more-trustworthy-too-ly y'rs - tim From ivanlan at callware.com Tue Aug 31 11:52:58 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Tue, 31 Aug 1999 15:52:58 GMT Subject: Apache: new release and nice change Message-ID: <37CBFA5A.1300931F@callware.com> Hi All-- I just received the email announcement for the release of Apache 1.3.9, and noticed this little announcement in the blurb for changes: > - Script errors on Windows are now copied to the server's error log > if the scripts fail; this is closer to the Unix behaviour. That should help debugging a little. The Apache team recommends that you upgrade to 1.3.9. I'll be doing it today sometime. -ly y'rs, Ivan;-) ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From someone at someplace.com Fri Aug 27 20:19:49 1999 From: someone at someplace.com (Someone) Date: Sat, 28 Aug 1999 00:19:49 GMT Subject: Why do we call python a scripting language? References: <19990827112918.12652.rocketmail@web129.yahoomail.com> <8E2F958DCPaCmAnRDLM@news.dial.oleane.com> Message-ID: <37c726c4.2148316@news.netset.com> On 27 Aug 1999 12:59:18 GMT, fredp at multimania.com.nospam (Fred Pacquier) wrote: >for the profane. The one app that 'did it' for me, curiously, is PySol. >It's a game, but a game engine, and a powerful one. And it shuffles around >a lot of graphics (pun intended), which may surprise people biased by the >'scripting language' tag. This brings me to a new point. since I first used python, I've been wondering about distribution of my final products. In general, i dont want to distribute a full python distribution and all my source, as much from not wanting to burden the user with this task as for protecting my source. I've played with freeze, but since I never really had anything to distribute, I've never really used it for anything except play things. But from what I remember, there is nothing preventing a person from putting into a small package everything needed to distribute an app. But what I find most interesting is that I havent seen much evidence that any one uses it. Is any one using freeze or some derivative or work alike? Most things I find are written for users of python, and are just distributed as source. >Yet another selling point might be if IDLE or PythonWin or some other seed >came to evolve into a full-blown IDE up to par with Microsoft's or >Borland's, that might impress the developer population. After all, VC++ is >done in MFC/C++ and Delphi in ObjectPascal, right ? But I seem to recall >this was all discussed to death some months ago... :-) I'm very impressed with what I am seeing on the python win 2 beta site. its very impressive! -guy From da at ski.org Mon Aug 2 02:44:22 1999 From: da at ski.org (David Ascher) Date: Sun, 1 Aug 1999 23:44:22 -0700 (Pacific Daylight Time) Subject: New version of compile.py Message-ID: I've upgraded the version of compile.py on my website. It is now at: http://starship.python.net:9673/crew/da/Code/compile What it is: compile.py is a tool which reads many Setup files and automates the building of Python extensions on Windows. It incorporates a modified version of Konrad Hinsen's compile.py which worked only on Unix. What's new: There have been many changes since the last website release. Most significantly, it now automatically builds the extensions using PythonCOM and Visual Studio 6.0, if both of those are available. Also, it automatically creates projects for both Debug and Release configurations. Cheers, --david PS: The entire website has been redesigned. From paul at digicool.com Fri Aug 13 08:08:29 1999 From: paul at digicool.com (Paul Everitt) Date: Fri, 13 Aug 1999 08:08:29 -0400 Subject: Zope for python.org? References: <7ouecd$9m$1@nnrp1.deja.com> <14259.30266.418140.625710@anthem.cnri.reston.va.us> Message-ID: <37B40ABD.2C5F8460@digicool.com> bwarsaw at python.org wrote: > > >>>>> "DCG" == Dinu C Gherman writes: > > DCG> Would it be desirable to turn python.org into a Python > DCG> "portal site" using the increasingly popular Zope product? > > I'm very interested in looking at Zopifying python.org at some point, > probably after Zope 2.0 is released. If it helps better serve the > Python community by allowing a more direct distributed management of > the site, and coincidentally makes my job as webmaster easier, I'm all > for it. Yes, we've had some discussions on it. Our goal here is to get Zope2 and the portal toolkit stuff running and useful on the new soon-to-be-announced zope.org site. I think it shows promise, and will provide a platform for collecting a lot of ideas about content, but right now the glitches would drain way too much of Barry's time. September is a good time to start thinking more seriously about it. We'll probably discuss it at DCPIGgie. --Paul From AKiss at GEOMETRIA.hu Tue Aug 3 04:31:39 1999 From: AKiss at GEOMETRIA.hu (Kiss, Arpad) Date: Tue, 3 Aug 1999 10:31:39 +0200 Subject: stuck on COM interface to Word Message-ID: <01BEDD9B.6052EFB0@exchange1.geometria.hu> Hi Jim, Here is an example: import time print time.ctime(int(doc.BuiltInDocumentProperties("Last Print Date"))) The online help contains other useful keywords(find the details of the DocumentProperty): "Title","Subject","Author" etc. Regards, Arpad Jim Kerr wrote in message news:<37A60515.370B5085 at sr.hp.com>... > I'm trying to write a python script to extract some properties from a set > of Word documents. The attributes I'm interested in are things like author's > name, last print date, keywords, etc. > > This is what I have so far: > > from win32com.client import constants,Dispatch > import string,os > > app = Dispatch('Word.Application.8') > app.Documents.Open(r"C:\My Documents\myMemo.doc") > doc = app.ActiveDocument > print "Last printed date: ", # ?? what goes here ?? > > I tried using combrowse.py to figure out what the properties of the doc are, > but I couldn't find anything that looked relevant. > > Is there any web-based info on COM interfaces to various programs? Or do you > have to buy Visual Basic books and translate for yourself? > > Thanks for the help! > > Jim > -- > Jim Kerr > Hewlett-Packard > Santa Rosa Systems Division > 1400 Fountaingrove Pkwy, MS 3USZ > Santa Rosa, CA 95403 > > -- > http://www.python.org/mailman/listinfo/python-list > From dfan at harmonixmusic.com Tue Aug 17 15:25:57 1999 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 17 Aug 1999 15:25:57 -0400 Subject: Unsorting(randomizing) a sequence References: <7pb1eb$elt$1@nnrp1.deja.com> <14265.29899.470021.309355@dolphin.mojam.com> <14265.35455.590852.517197@bitdiddle.cnri.reston.va.us> Message-ID: Jeremy Hylton writes: | I've rather fond of the following approach: | | import random | | def randomize(a, b): | return random.choice([-1, 0, 1]) | | l = range(2, 20) | l.sort(randomize) I'm not sure how robust this is. I've seen at least one implementation of qsort crash when given an inconsistent comparison function (e.g., one that doesn't obey transitivity). And how is sort() supposed to know when it's done? -- Dan Schmidt -> dfan at harmonixmusic.com, dfan at alum.mit.edu Honest Bob & the http://www2.thecia.net/users/dfan/ Factory-to-Dealer Incentives -> http://www2.thecia.net/users/dfan/hbob/ Gamelan Galak Tika -> http://web.mit.edu/galak-tika/www/ From amitp at Xenon.Stanford.EDU Mon Aug 23 15:03:03 1999 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 23 Aug 1999 19:03:03 GMT Subject: RPM for Python 1.5.2 ? References: <37ADE4C1.194C31D6@lemburg.com> <19990809113731.A6757@baltazar.baltazar.org> <37AFD5A9.4C45332F@lemburg.com> Message-ID: <7ps5t7$2u6$1@nntp.Stanford.EDU> | > On Sun, Aug 08, 1999 at 10:12:49PM +0200, M.-A. Lemburg wrote: | > > David Young wrote: | > > > | > > > Has anyone built an RPM for Python 1.5.2 ? I think it's sort of curious | > > > that RedHat hasn't already. Anyway, I'm building my own package right now, | > > > but I'm afraid I might be wasting my time.... | > > | > > Try: | > > | > > http://www.andrich.net/python/download.html I had good luck with these RPMs on RH 6 except when I tried installing the Tkinter stuff: # rpm -Uvh python-_tkinter-1.5.2-2.i386.rpm error: failed dependencies: blt >= 2.4c is needed by python-_tkinter-1.5.2-2 libBLT.so.2 is needed by python-_tkinter-1.5.2-2 I don't know what blt is! I did erase RH's tkinter package, but it didn't help. Do I need to install Tcl/Tk extensions to make it work with Python? :( For normal use I don't use Tkinter so it's not affecting me. All I wanted to do with Tkinter was to try out IDLE.. :) I'm quite happy with Oliver's RPMs.. it's much more convenient than asking everyone at work to compile Python 1.5.2 on their system. :) - Amit From bogw at geo.vu.nl Wed Aug 18 12:50:19 1999 From: bogw at geo.vu.nl (Patrick Bogaart) Date: Wed, 18 Aug 1999 18:50:19 +0200 Subject: Wacky Programming Tales References: <37AAFAD1.A032765B@NOSPAM.strs.co.uk> <37B54DA3.4210DC10@nospam.com> <37b62939@cs.colorado.edu> Message-ID: <37BAE44B.E66250BD@geo.vu.nl> Ben Caradoc-Davies wrote: > > [strange programming] > The most confidence uninspiring piece of code I ever had the displeasure to > maintain contained something like this (allegedly C++, but mainly it's > intersection with C): > > i = 0; > while( i < max_index ) { > /* some copying or update (not modifying i) goes here */ > i = i + 1; > } > > This was written by a *very* expensive consultant working for a large > multinational accountancy firm. > > Can anybody suggest an alternative construct which more accurately expresses > the programmer's intentions? There may be more than one way to do it, but, > puhleeze! > Yes I can: i = 0; label_1:; /* some use of i */ i = i + 1; if (i==max_index) goto label_2; goto label_1; label_2:; -- Patrick W. Bogaart Department of Geomorphology and Quaternary Geology Faculty of Earth Sciences, Vrije Universiteit Amsterdam bogw at geo.vu.nl http://www.geo.vu.nl/users/bogw From arcege at shore.net Sun Aug 15 21:15:40 1999 From: arcege at shore.net (Michael P. Reilly) Date: Mon, 16 Aug 1999 01:15:40 GMT Subject: C's isprint() concept? References: Message-ID: <0DJt3.195$mV.76681@news.shore.net> Jeff Pinyan wrote: :> If I want to replace all non-printable characters in a string with a single :> space, what would be the best way? Do I need to loop over the entire string :> character by character checking the ord() value of each one? Anyone have :> a sane way to do this with regular expressions? : In Perl, I could do it this way: : $string =~ tr/\x00-\x1f\x80-\xff//d; : What that means is this: : remove the following characters from $string: : characters whose ASCII value is from \x00 (0) to \x1f (31) : characters whose ASCII value is from \x80 (128) to \xff (255) : This can be done, almost as painlessly, in Python. Considering this was asked to a Python newsgroup, how about showing how to do it in Python. import string # works for ASCII control_chars = string._idmap[:ord(' ')] # 0 to 31 high_chars = string._idmap[ord('~')+:] # 127 to 255 to_remove = control_chars + high_chars map = string.maketrans(to_remove, ' ' * len(to_remove)) midstr = string.translate(instr, map) outstr = string.join(string.split(midstr)) or: import re outstr = re.sub(r'[^ -~]+', ' ', instr) (Indented for "easy cut&paste" ;) -Arcege From bradh at mediaone.net Sat Aug 14 22:37:08 1999 From: bradh at mediaone.net (Brad Howes) Date: 14 Aug 1999 22:37:08 -0400 Subject: Wacky Programming Tales (Was Re: Why use Perl when we've got Python?!) References: <37AAFAD1.A032765B@NOSPAM.strs.co.uk> <37B286D2.A71C3239@NOSPAM.strs.co.uk> <37b30253@cs.colorado.edu> <37B49CBA.772D9783@basho.fc.hp.com> <37b4a18f@cs.colorado.edu> <37b4ced8@cs.colorado.edu> <37B54DA3.4210DC10@nospam.com> Message-ID: Sorry to intrude on this love fest... sholden at pgrad.cs.usyd.edu.au (Sam Holden) writes: > It's like someone who starts a C program with : > > #define BEGIN { > #define END } > Hey! I actually worked on a project where someone did this! Also in their funky include file was #define AND && #define OR || It was the most bizarre thing I ever saw -- not so much the include file, but the resulting code. As if a Pascal moths had come in, eaten at some code and left little Wirth fragments sprinkled around. Has anyone else encountered such strange programming behavior? ...now back to my language is bigger/longer/wider/stiffer than yours -- Brad Howes bradh at mediaone.net From news at dorb.com Sat Aug 14 19:29:39 1999 From: news at dorb.com (Darrell) Date: Sat, 14 Aug 1999 19:29:39 -0400 Subject: deadlock when two servers call each other - will threads help? References: <199908142158.QAA24395@dolphin.mojam.com> Message-ID: There is a lot of stuff written about avoiding dead lock. Adding threads can help, but also add more stuff that can dead lock as well as complexity. Anything I would be able to suggest will most likely impact your architecture. But here goes. My favorite solution is message queues that prevent the sender from blocking. The receiver is blocked reading the message queue. The hard part is that the receiver is running more like a dispatcher. Messages must be matched up with callbacks that handle that kind of message. The handler can register for messages based on all kinds of criteria, and time outs. This is about how Microsoft's message queues work and I suspect how the Medusa web server works. If you want to know more I can dig it up. Also know as the "reactor pattern", I think ?? -- --Darrell Skip Montanaro wrote in message news:199908142158.QAA24395 at dolphin.mojam.com... > > I'm using XML-RPC as the transport mechanism within a group of database > servers to propagate change information and thus maintain database > consistency. My servers are logically connected in a tree structure. Each > server has one parent (except the topmost server) and zero or more > children. When a change request comes in to a server, if it doesn't come > from the server's parent, it forwards it there. This allows requests to > come in anywhere in the system, then get percolated through all the servers > by forcing it to travel to the top of the tree, then trickle down. > > This is fine in theory, but in practice it yields deadlocks. A child can be > making an XML-RPC call to its parent to forward one change request at the > same time the parent is trying to make another call to that child. Both > servers will block in read() waiting for a response that never arrives. > System throughput suffers... > > I don't use threads at the moment, but I'm curious whether or not threads > would help here. Would the blocked read() call allow another thread to run? > If so, I could spawn threads to make RPC calls between servers. > > Thanks, > > Skip Montanaro | http://www.mojam.com/ > skip at mojam.com | http://www.musi-cal.com/~skip/ > 847-971-7098 > > > From tim_one at email.msn.com Sun Aug 22 03:11:48 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 22 Aug 1999 07:11:48 GMT Subject: Unsorting(randomizing) a sequence In-Reply-To: <005201beea1a$5ab05f30$f29b12c2@secret.pythonware.com> References: <005201beea1a$5ab05f30$f29b12c2@secret.pythonware.com> Message-ID: <000101beec6d$99d1b380$542d2399@tim> [Tim, on Python's sort function and its robustness against sick inputs] [Fredrik Lundh] > how about JPython Don't know. > and Viper *Nobody* knows . > and Lumberjack Ditto. > and SPython and FooPython and whatever... Ditto ditto ... > as far as I can tell, the "spec" says > > sort: sort the items of s in place > > and that's about it... In case of conflict, CPython usually wins. Is it your contention that because the spec doesn't say sort must not dump core, therefore it's OK if it does? If so, the reference manual is going to need one hell of a lot more words all over the place . in-std-speak-this-kind-of-stuff-is-swept-under-the-"quality- of-implementation"-rug-ly y'rs - tim From goertzen at norscanNOSPAM.com Mon Aug 30 10:35:44 1999 From: goertzen at norscanNOSPAM.com (Daniel Goertzen) Date: Mon, 30 Aug 1999 14:35:44 GMT Subject: running python on a floppy? References: <37CA50EC.4FC03560@home.com> Message-ID: <4Fwy3.2921$1i4.189540@typhoon.mbnet.mb.ca> Doug Hellmann wrote in message news:37CA50EC.4FC03560 at home.com... > Why are people still trying to fit distributions like this on a > *floppy*? Why not use a Zip disk? Granted, they are more expensive, > but there is *so* much more room. I did try the zipslack distribution, but the continuous stream of kernel warnings didn't encourage me. Also, zip drives are not the most reliable devices on the face of the earth (not that floppies are much better), and are relatively expensive. After looking at the problem further, I've come to conclusion that 1.44 mb is just too tight. An 8 meg flash disk with a compressed filesystem should give me about 30 megs of space to play with; more than enough to do lots of interesting things with python. Regards, Dan. From aahz at netcom.com Sat Aug 21 15:36:51 1999 From: aahz at netcom.com (Aahz Maruch) Date: 21 Aug 1999 19:36:51 GMT Subject: can some one help a newbie? References: <7pkke6$lut@dfw-ixnews6.ix.netcom.com> <935227166snz@vision25.demon.co.uk> Message-ID: <7pmv4j$gtt@dfw-ixnews14.ix.netcom.com> In article <935227166snz at vision25.demon.co.uk>, Phil Hunt wrote: >In article <7pkke6$lut at dfw-ixnews6.ix.netcom.com> > aahz at netcom.com "Aahz Maruch" writes: >> >> Overall, if your background is as a sysadmin using shell scripts, grep, >> awk, sed, and so on, you'll find Perl a bit easier. > >I've used all these, and find Python easier than Perl. Perl would >probably be easier than Python for 1-liners, if I could remember >the syntax. Note that I'm specifically assuming a sysadmin with little actual programming experience. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From sholden at pgrad.cs.usyd.edu.au Sat Aug 14 22:10:03 1999 From: sholden at pgrad.cs.usyd.edu.au (Sam Holden) Date: 15 Aug 1999 02:10:03 GMT Subject: Why use Perl when we've got Python?! References: <37AAFAD1.A032765B@NOSPAM.strs.co.uk> <37B286D2.A71C3239@NOSPAM.strs.co.uk> <37b30253@cs.colorado.edu> <37B49CBA.772D9783@basho.fc.hp.com> <37b4a18f@cs.colorado.edu> <37b4ced8@cs.colorado.edu> <37B54DA3.4210DC10@nospam.com> Message-ID: On Sat, 14 Aug 1999 12:06:11 +0100, Alex Maranda wrote: >Sam Holden wrote: >> > >> >>You can write Perl programs that resemble sed, or awk, or C, or Lisp, or >> >>Python. This is Officially Okay in Perl culture. >> > >> >You cannot write Perl that resemble Python. You are required to >> >use curly braces as block delimiters. >> >> In fact you are not. You are wrong yet again. Actually thinking about how >> perl works for a minute would show you that perl is in fact flexible. >> it is not a lie when people say perl doesn't force you to write a >> particular way. >> And here is his sample code that is now valid perl (although anyone who uses >> it for real code should be killed) : >Why? You don't happen to hate Pythoneers or Python itself, do you? I've >actually appreciated the argument from your second post, when you taxed >the other guy for needlessly questioning your Python knowledge out of >context. I know a fair few pythoners in fact, I even like some of them. What I meant was that anyone who would do such a thing with perl deserves to be killed. Since no one else will be able to maintain the program. It's like someone who starts a C program with : #define BEGIN { #define END } Doing things like this means that a C programmer can't understand the code, and a Pascal programmer can't either. With impythonate.pm, a perl programmer can't understand the code, and a python programmer can't either. Also don't tell anyone but I actually like python a lot. I don't use it much since I have more experience with perl, and more importantly I know the modules available for perl better, and can quickly search for one to do whatever I need next. >I am completely ignorant with Perl and I can barely read what's above >(by interpolating my knowledge of shell, C, and Tcl). That's because it uses a lot of the not so well known perl features. > >> >> #Now newlines replace colons and indentation replaces brackets: >> >> use impythonate; # STILL NEED THAT ONE SEMICOLON, DAMMIT! >> >> for $i (1..10) # COMMENTS ARE OKAY >> print "$i: " >> my $isq = \ >> $i **2 # LINE CONTINUATIONS WORK AS IN PYTHON >> print " $isq\n" >> >> print "done\n" >I know Python fairly well (but I'm no expert) and I can easily read this >piece of Perl. But it would be no harder to read with ; on the end of each statement and a pair of {}s. Working out that strings interpolate should be a bigger leap than working out that blocks have {}s around them. > Getting back to the killing part, which kind of disturbs >me when reading comp.lang.python: >- was that necessary to make a point? >- if yes, what was the point? >- if the point (just guessing) was that Perl code should never look like >Python, isn't that against of 'there should be more ways of doing it?' I answered this above a little. It was necessary since I don't want someone actually using such an untested module in their code. Chances are it breaks on many python constructs. The obvious example is : if (1==1) : print "fred" It won't handle that. Everyone seems to misunderstand the whole concept of TMTOWTDI. It doesn't mean all ways are equal. That is a way of writing perl which works, it is however not very maintanable. The only way to determine what syntax is valid is to know perl's syntax, and to be able to read and understand the impythonate.pm code - since there is no documentation and it is _not_ the same as python. Writing it in 'normal' perl reduces the requirements to understanding, and speeds it up to boot. >I fail to see the interesting part in this whole thread, which disturbs >the habitat of comp.lang.python. I think John Stevens was mistaken to >bring the discussion over to this newsgroup in the first place. We don't >have strong feelings about Perl, and don't have plans for world >domination or anything. > >A couple of days ago I read a bit in Bugzilla's README which amused me: >"A computer which doesn't have Perl installed is a very sad computer >indeed". Your post is frightening (unless it was a Perl-style joke). How was it frightening? If you want to program in python, then use python. It's a nice language, it is portable, it is simple to install, it is easy to learn. So what is the point of munging another language to look like it? If you could munge perl so that you could name the capturing elements of a regex then that would be a useful, python like addition... -- Sam There's no such thing as a simple cache bug. --Rob Pike From mstenber at cc.Helsinki.FI Mon Aug 30 06:41:13 1999 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 30 Aug 1999 13:41:13 +0300 Subject: Upper limit?! References: <37CA1E0F.FA2A05A3@megsinet.net> <014f01bef2bd$3fd09e90$f29b12c2@secret.pythonware.com> <37CA3EBD.4077AF18@megsinet.net> Message-ID: David Oppenheimer writes: > Wow, that's quite a difference! on an Alpha you can have a 19 digit number > as opposed to a 10 digit number on my Pentium. So the limit isn't actually > a factor of the programming language but a virtue (or limitation) of my > processor. I wonder if Intel knows about this?! LOL Makes me want to Yes, for machine-spesific ints.. However, some languages can kludge around it, like Python's bigints: fingon at dreamland ?uname -m i686 fingon at dreamland ?python Python 1.5.2 (#0, Jul 16 1999, 19:02:32) [GCC egcs-2.91.66 Debian GNU/Linux (egcs-1.1.2 release)] on linux2 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> len(str(2L**666)) 202 >>> 202 digits, baby ;-) > sell this hunk of crap Packard Hell P-75, get rid of Win98 and buy an Alpha > running Linux. That PSN number thing scares the hell outta me any ways, > I'm either going AMD or Alpha next go around. Heh. > David O. -Markus Stenberg -- Running Windows on a Pentium is like having a brand new Porsche but only be able to drive backwards with the handbrake on. (Unknown source) From mcfletch at vrtelecom.com Mon Aug 9 18:13:15 1999 From: mcfletch at vrtelecom.com (Mike Fletcher) Date: Mon, 9 Aug 1999 22:13:15 GMT Subject: Packing and unpacking IP addresses into 32-bit integers In-Reply-To: References: Message-ID: Wouldn't it be something like: '>bbbb' or '!bbbb' instead (for portability to non-big-endian machines (I'm assuming the packed representation is supposed to have network byte order))? Just a thought, Mike -----Original Message----- From: python-list-request at cwi.nl [mailto:python-list-request at cwi.nl]On Behalf Of Steven D. Majewski Sent: August 9, 1999 4:50 PM To: python-list at cwi.nl Subject: Re: Packing and unpacking IP addresses into 32-bit integers ... and use either struct.pack or array to coerce it into a binary string: a = apply( struct.pack, [ 'bbbb' ] + adr ) From mpersico at erols.com Sun Aug 15 15:15:17 1999 From: mpersico at erols.com (Matthew O. Persico) Date: Sun, 15 Aug 1999 15:15:17 -0400 Subject: Wacky Programming Tales References: <37AAFAD1.A032765B@NOSPAM.strs.co.uk> <37B54DA3.4210DC10@nospam.com> <37b62939@cs.colorado.edu> Message-ID: <37B711C5.32C1CA6C@erols.com> Ben Caradoc-Davies wrote: > > [strange programming] > The most confidence uninspiring piece of code I ever had the displeasure to > maintain contained something like this (allegedly C++, but mainly it's > intersection with C): > > i = 0; > while( i < max_index ) { > /* some copying or update (not modifying i) goes here */ > i = i + 1; > } > > This was written by a *very* expensive consultant working for a large > multinational accountancy firm. > > Can anybody suggest an alternative construct which more accurately expresses > the programmer's intentions? There may be more than one way to do it, but, > puhleeze! > > Idiomatic is not quite the word. Try idiotic! > -- > Ben Caradoc-Davies -- Matthew O. Persico You'll have to pry my Emacs from my cold dead oversized control-pressing left pinky finger. -- Randal L. Schwartz From andrew at malcolmson.com Wed Aug 11 19:56:20 1999 From: andrew at malcolmson.com (Andrew Malcolmson) Date: Wed, 11 Aug 1999 19:56:20 -0400 Subject: internet programming with python References: <37AF678E.CC8E165B@netscape.com> <37B1AB33.1C81BDEA@am.appstate.edu> Message-ID: <37B20DA3.3E3ABD98@malcolmson.com> I also have it "Internet Programming with Python" and found it very good, fun to read, and probably a better book for a Python beginner than "Learning Python". I hope it gets updated. However, are you saying that there is something in it about using Python with Netscape Enterprise Server? I didn't see anything there. TMGB wrote: > I just picked it up at Barnes and Noble where it retailed for $34.95 US > and is discounted to $17.48 US. I feel sure that you can probably order > it from http://www.barnes&noble.com (not sure about URL). The ISBN is > 1-55851-484-8 published by M&T Books a division of MIS:Press, > INC(http://www.mandt.com). I'm not sure but I think some references are > to libraries that have now been updated or replaced but in general it > has been a very helpful introduction. Especially interesting (to me), > if you have Netscape Enterprise Server, is embedding Python into > Netscape Server NSAPI. > > Thomas > > Vijay Mallela wrote: > > > > Hi, > > I am looking for the book "Internet programming with python". I need it > > at the earliest.. > > I checked out amazon and other stores and they dont have it.. does any > > one know where I can get the book > > Thanks > > vijay > > -- > ---------------------------------------------------------------------- > Thomas McMillan Grant Bennett Appalachian State University > Computer Consultant II University Library > bennettt at am.appstate.edu > http://www.library.appstate.edu/admin/ > Voice: 828 262 6587 FAX: 828 262 3001 > > Windows 95 is a 32-bit extension to a 16-bit patch for an 8-bit > operating system that was originally coded for a 4-bit microprocessor. > - Chris Dunphy Boot Magazine From cjw at connection.com Mon Aug 2 07:28:20 1999 From: cjw at connection.com (Colin J. Williams) Date: Mon, 02 Aug 1999 07:28:20 -0400 Subject: Call for snippets References: <199908020821.KAA07953@axil.hvision.nl> Message-ID: <37A580D4.202AF94F@connection.com> Hans, Thanks for this posting, the site is clean and well organized. It is a useful learning tool. I might, one day, make an offering. One little suggestion, you might consistently date the entries. Colin W, Hans Nowak wrote: > Hello, > > Some of you may have noticed that I have a snippets site since a few > months. (In this definition, snippets are pieces of working Python > code, usually demonstrating something or solving a problem.) Until > now, I have extracted them from newsgroup messages. This isn't an > ideal situation, because there are lots of messages which I all have > to read, and I don't really have the time for that. (Yeah I know... > sacrilege... :^) > > This isn't really a problem though. What does bother me is that my > collection isn't growing very rapidly. I have 119 snippets online > now, with 100+ still residing on my harddisk, untested. It's a start, > but there really isn't much progress, mainly because of the reasons > mentioned above. I have a feeling that there is a lot of good and > useful code there but that I have to wait until it accidentally shows > up in the newsgroup, triggered by somebody's question. > > So, my request is obvious. I would ask everyone to browse through > their code and see if they have any interesting, useful or just plain > cool snippets. I'm not really picky; a nifty function would do. I am > not really looking for complete modules since I have a snippet > repository, not a module repository (nor anything like CPAN, the > pyPit, etc), but I won't refuse them. In fact, anything that solves > any problem could be a valuable snippets. I'd almost say, 'when in > doubt, post your code'. I'd go even farther: if you have Python > code somewhere and think there might be interesting functions in it, > I would be pleased if you pointed me to it; I will scan and extract > them myself. > > My goal is to have a site where both newbies and more advanced coders > could go to see how to do something in Python, or how to do something > *differently* if they already have some solution, because more > snippets can tackle the same problem. But in order to do that I need > some more code! Or at least a larger base. Now if everyone > reading this ng would post at least one snippet, there would be an > explosive growth... > > ?ou can check out the page at http://www.hvision.nl/~ivnowa/snippets/ > . It's (of course) still under construction. Snippets and comments > can be sent to (feeble spam protection) ivnowa @ hvision . nl or > hnowak @ cuci . nl. (The address mentioned on the side is actually > obsolete. I will remove it.) > > Thanks in advance, > > Hans Nowak (ivnowa at hvision.nl) > Homepage: http://fly.to/zephyrfalcon From mstenber at cc.Helsinki.FI Sun Aug 1 07:24:38 1999 From: mstenber at cc.Helsinki.FI (Markus Stenberg) Date: 01 Aug 1999 14:24:38 +0300 Subject: NT select.select? References: <613145F79272D211914B0020AFF6401914DC19@gandalf.digicool.com> Message-ID: Brian Lloyd writes: > > Is there some low limit on maximum number of sockets you can > > have in the > > Python-NT's select call? A program that happens to work > > perfectly on Linux > > seems to die on NT around 64(?) sockets to the 'too many file > > descriptors > > in call' error. > > > > Any portable ways to bypass it? > > > > -Markus > It turns out that NT has a default 64 fd limit on arguments to > select(). The good news is that you can actually bump the limit up > to whatever number you want by specifying a define when compiling > python15.dll. I was hoping for version that works with 'Python out of the box' (I kludged something in pure python with threads that bypasses this limit, but it isn't pretty). > The default 64 fd limit is too low for anyone trying to run > an async server that handles even a modest load, so I've > submitted a bug report to python.org asking that the define > above find its way into the next python release... Agreed. Unless it causes some Huge Load(tm) somewhere, it should be definitely raised. (say, 1024 or 4096 sounds reasonable to me) > Brian Lloyd brian at digicool.com > Software Engineer 540.371.6909 > Digital Creations http://www.digicool.com -Markus -- "...very few phenomena can pull someone out of Deep Hack Mode, with two noted exceptions: being struck by lightning, or worse, your *computer* being struck by lightning." - Matt Welsh From mwh21 at cam.ac.uk Sun Aug 15 18:10:05 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 15 Aug 1999 23:10:05 +0100 Subject: RFC: Viper: yet another python implementation References: <37b075ae.2367293988@news.triode.net.au> <37b6e9c3.345781227@news.triode.net.au> Message-ID: skaller at maxtal.com.au (John (Max) Skaller) writes: > On 11 Aug 1999 18:23:06 +0100, Michael Hudson wrote: > >I'm interested (do you have any code yet? > > Not for the compiler: I'm implementing > the interpreter first. [I have done some work on the > type inference algorithm, to make sure it is > feasible] Let me rephrase that a little: do you have any code that I can look at/play with/beat on/improve (maybe)? Actually working/complete code is not expected or desired, I'm just nosey. > >I presume fiddling with sys.exc_traceback.f_back.f_locals is out? > > At present sys.exc_info() will return a tuple in which > the third element is a traceback object. At present, that > traceback object doesn't match the Python one -- > it just has a filename and line number in it, to allow the > traceback to be printed. I feel I ought to point out that I'm not particularly desperate to retain the ability to perform this particular stunt, I was just trying to get a feel for the limitations you were talking about. > >But can foo then have a method set_bar? I guess that would be easier > >to cope with for the analyser. > > Yes. It is OK to mutate objects, as opposed > to rebinding variables: mutation has to be supported. > You may think these things are equivalent. Indeed, > they are in interpreted python. I'd dispute that, but never mind. > However, the restriction leads to a performance gain; without some > restrictions, compiled python will not execute faster than the > bytecode interpreter. Quite. > >> 5) What restrictions can you live with? > > > >One thiung I occasionally find very handy is the ability to assign > >methods to classes (or more usually within classes). > > OK. I would like to do what Guido has done in the > optimisation of functions [fast lookup for statically known variables, > plus a dictionary to support others]: provide an optimised structure > where possible, and then provide a dynamic one > for the other cases. That is, the ideal would be to provide > a 'fallback' to the interpreter. vtables might be nice (i.e. attribute accesses don't always go through a dictionary lookup). Bigger win for compiled code, I suspect. You could only vtable-ize the methods/data members that static analysis found were never assigned to in code. This suggests another restriction for exec. [snipped dictionary extensions that I still don't see the need for but then again if I don't like them I can just ignore them] > >> 5) optionally typed function parameters > > > >Out of curiosity, what syntax do use for this? > > My first idea was the obvious: > > def f(a:int): .. > > or perhaps > > def f(a: IntType): ... > > and the interpreter semantics would be > > if type(a) is not InType: raise TypeError, "Int expected for arg1 of f" Fair enough; it might be nice (& probably very easy) to hack a CPython that accepted but ignored type declarations of this sort. > However, in the compiled version, the semantic might be to generate > a compiler error: that is, the following might not work: > > try: f(1.0) > except TypeError: pass # just skip the call I'd say if you coded like that you deserved to lose anyway. Might become a bigger problem in more complex cases, of course. > >I presume if a > >parameter is typed as `Foo' then a value of type `Bar' where Bar > >derives from Foo is allowable. > > I guess that would make sense (the extension isn't > implemented yet -- not a lot of point appealing for comments > _after_ implementing the extension, only to find someone > has a better idea) I think it would be a hanging offense for anything that called itself OO to not allow a instance of a derived class to be substituted for that of a base class. > >> 6) what do you want? > > > >Can you derive from basic types? That might make some stuff harder. > > Not at present. Can you give an example where > it is useful? [It can be made to work I think: is it useful?] It's more neat than useful, as far as I can see. But I'll have to learn more ml, Haskell, smalltalk, Eiffel and lisp/clos before I can comment properly on type issues, I think (I am actually moderately serious about learning all the above languages - doing Haskell, Eiffel and ANSI common lisp at the moment). > >> It is difficult to optimise individual > >> modules. It is a different story to optimise > >> a whole program, where _every_ call > >> to a function can be traced. Of course, > >> this may involve restricting what 'exec' can do, > > > >Like banning it entirely, I suspect. > > No. I cannot do that because the program > that I want to compile, interscript, uses exec, > and depends on it to execute client script. > This is the major feature of interscript, so exec > has to work (at least with restrictions). I see; I guess what you're saying is that exec-ed code can't muck with it's calling environment too much. I'd have thought this would be a feature for interscript, otherwise malicious documents could seriously injure the environment. > That means the compiled code has to > contain a full run time system (unless it can be > detected that it isn't required). Lisp manages to have a very clean interaction between compiled and interpreted code: you type (compile 'f) and hopefully the only noticeable difference is that `f' goes quicker. Mind you lisp has had man-millennia of time from very very clever people poured into it, so that might be aiming a bit high ;-). [snip] > >Mind you, the whole thing sounds sooo hard, that > >anythong that makes it easier is good. > > The things that turn out to be hard are > often surprising. That's always the way. I think a large part of programming experience (of which I don't have a vast amount) is spotting the problems and being able to come up with top-level designs that are compatible with further growth. Hard problems. > For example, right now I having > major problems with something that sounds trivial: > getting the interpreter to set the line number > so that a traceback can print out as it does in Python. > > That sounds easy, but the LR grammar I'm > using is not well adapted to it -- NEWLINE tokens > come after statements, instead of before them, > where the line number is needed. Not something I've done, but it's always struck me that compilers/parsers that only have to deal with good code must be far easier to right... Regards, Michael From donn at u.washington.edu Thu Aug 12 18:08:56 1999 From: donn at u.washington.edu (Donn Cave) Date: 12 Aug 1999 22:08:56 GMT Subject: Help! $PYTHONPATH trouble References: <37B33980.A5318181@n-space.org> Message-ID: <7ovglo$cj0$1@nntp6.u.washington.edu> Erik Stewart writes: | The variable $PYTHONPATH doesn't seem to have any effect on my system (RH | Linux 6.0, Python 1.5.1). Here's what I get after defining $PYTHONPATH: | | $ PYTHONPATH="home/possum/test/kwp" | $ echo $PYTHONPATH | home/possum/test/kwp | $ python You need to export the variable into the environment, or it's only a shell variable that isn't inherited by python or other programs. $ PYTHONPATH="home/possum/test/kwp" > $ export PYTHONPATH $ printenv PYTHONPATH home/possum/test/kwp $ python Just to make it more confusing, if PYTHONPATH were already an environment variable you wouldn't have had to export it, and there are several ways to express that export, too: export NAME=val, NAME=val export NAME, etc. Donn Cave, University Computing Services, University of Washington donn at u.washington.edu From Doug at news.vex.net Tue Aug 24 05:05:56 1999 From: Doug at news.vex.net (Lewis) Date: 24 Aug 1999 09:05:56 GMT Subject: win32 vim +python Message-ID: <7ptn9k$mlk$1@hub.org> Is there a Win32 binary of Vim 5.4(x) compiled with +python anywhere available? I've looked around, can't seem to find one. If there isn't one... does anyone feel like making one for us c-ignorant masses? Thanks. From irclark at latveria.castledoom.org Mon Aug 23 17:00:41 1999 From: irclark at latveria.castledoom.org (Isaac) Date: 23 Aug 1999 21:00:41 GMT Subject: Parrot-0.0.1 References: <935279776snz@vision25.demon.co.uk> <935437263snz@vision25.demon.co.uk> Message-ID: On Mon, 23 Aug 99 19:41:03 GMT, Phil Hunt wrote: >In article > irclark at latveria.castledoom.org "Isaac" writes: >> Very interesting indeed! I was working on a similar program whose >> functionality would fit much of the description you give here. My >> program reads in a description of a gui that's similar in concept >> to your par files, and outputs code that implements the gui, in >> either Motif, GTK, or the EZWGL > >What's that? > Just some toolkit I found on the net. I found it useful to have several different toolkits around in order to make sure the language for the backend was general enough to get the job done. I was hoping to allow specifying backends by parsing a target file describing the target tool kit. > >My next step, once I'm happy with the parser and the HTML backend, >will be to write a Python/Tkinter backend. Then, I'll have written two >backends so I'll have a better idea of how to architect a backend >framework -- I want to make backends easy to write, to encourage >other people to contribute them. > Looks like the right approach. I think it's important to pick disparate targets for the first few backends. GTK with C or C++ might be a good choice to add to the ones your already trying. Not too hard to learn, and fairly popular. > >What language is your tool written in? AFAIK, PCCTS is a C parser >generator -- is this correct? How does it compare to yacc? > PCCTS is a superior tool to yacc/bison. I don't think I'll ever use yacc again if I get to pick the tool. PCCTS generates C or C++. There is a second generation tool, ANTLR, that uses improved technology and generates java and C++ parsers. Isaac From meowing at banet.net Tue Aug 24 14:49:46 1999 From: meowing at banet.net (meow) Date: 24 Aug 1999 14:49:46 -0400 Subject: Python equivilent of pack()? References: Message-ID: <87r9ktm2t1.fsf@slip-32-100-244-100.ma.us.ibm.net> Bit Nik wrote: > My question is this: is there a functional equivilent to the Perl pack() > and unpack() functions in Python? See the standard struct module. It's very much like the Perl equivalent, except that the documentation makes sense. From stuart.hungerford at cmis.csiro.au Sun Aug 22 20:52:15 1999 From: stuart.hungerford at cmis.csiro.au (Stuart Hungerford) Date: Mon, 23 Aug 1999 10:52:15 +1000 Subject: Anyone used Python for testing and instrumenting VB code? Message-ID: <7pq5kc$su0@gutter.its.csiro.au> Hi all, I'm in the process of developing a test strategy for a large bunch of Visual Basic (VB) programs. Products like Rational Visual Test seem to be able to record actions on a GUI for a playback later. How difficult would it be to use the win32 Python stuff to try and capture the interactions or instrument VB programs? I have access to the VB source too. Stu From dominggus at ratelindo.co.id Mon Aug 30 00:33:23 1999 From: dominggus at ratelindo.co.id (Dominggus Andy. A) Date: Mon, 30 Aug 1999 11:33:23 +0700 Subject: (no subject) Message-ID: From bart.lateur at skynet.be Sat Aug 14 03:52:51 1999 From: bart.lateur at skynet.be (Bart Lateur) Date: Sat, 14 Aug 1999 07:52:51 GMT Subject: Why use Perl when we've got Python?! References: <37AAFAD1.A032765B@NOSPAM.strs.co.uk> <37B286D2.A71C3239@NOSPAM.strs.co.uk> <37b30253@cs.colorado.edu> <37B49CBA.772D9783@basho.fc.hp.com> <37b4a18f@cs.colorado.edu> <37b4cec7@cs.colorado.edu> Message-ID: <37b6185f.2442954@news.skynet.be> John W. Stevens wrote: >By your reasoning, Perl is very, very inconsistent (since not every >data type supports '+'). You're looking for the Holy Grail of orthogonality, again. Python is designed with orthogonality in mind, while Larry Wall allegedly once said: "Any computer scientist who praises orthogonality should be sentenced to use an Etch-a-Sketch." (borrowed from a TomC sig) Bart. From vitus at wagner.rinet.ru Tue Aug 31 14:40:52 1999 From: vitus at wagner.rinet.ru (Victor Wagner) Date: 31 Aug 1999 22:40:52 +0400 Subject: Parrot-0.0.1 References: <935279776snz@vision25.demon.co.uk> <7ps4ma$n06$1@wagner.wagner.home> <37c2a462.349531009@192.77.87.74> <935523275snz@vision25.demon.co.uk> Message-ID: <7qh7jk$gaa$1@wagner.wagner.home> Phil Hunt wrote: : The Parrot tool has other potential advantages, e.g: : 1. you only have to learn one syntax, that can then be used for : lots of languages and GUI libraries. Which is completely useless, becouse you have to learn new syntax anyway if you want your program do something more than draw a pictures on screen. You need to learn details of language and GUI library to take advantage of it. If you don't - why change a library? And this is main reason of obscure errors, inefficient code and other bad things which happen to frequently - attempt to use tool without learning it. It is better to use only one language and one toolkit, but know it well. : 2. assuming the right import and export tools have been written, : Parrot can allow you to use one GUI builder to output to a different : GUI, for example you could design your GUI in Glade, and use Parrot : to output it as a series of C++ files for KDE/Qt. I've assumed that whole idea behind Parrot is that GUI builders are evil, which I agree wholehearthly, becouse there is (yet) no way to create functionality using point'n'click appoach and functionality is the first thing programmer should care about. -- -------------------------------------------------------- Victor Wagner @ home = vitus at wagner.rinet.ru I don't answer questions by private E-Mail from this address. From mlh at idt.ntnu.no Wed Aug 11 09:58:28 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 11 Aug 1999 15:58:28 +0200 Subject: report generation References: Message-ID: jsouto at dnet.br (Jairo Souto) writes: > I couldn't find a module for [plain-text] report generation > from generic data (sql data-base, lists, etc..). > > Is there such a module? Could you be more specific as to what you wish to accomplish? Pythons built-in string formatting abilities make this sort of thing quite easy in general - at least that is my experience (i.e. no need for separate module.) > > --Jairo Souto jsouto at dnet.br (+55) (38) 9971-0014 > -- Magnus Making no sound / Yet smouldering with passion Lie The firefly is still sadder / Than the moaning insect Hetland : Minamoto Shigeyuki From greg.ewing at compaq.com Fri Aug 27 00:31:00 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Fri, 27 Aug 1999 16:31:00 +1200 Subject: Extending Python: exception handling References: <3.0.6.32.19990824122931.0099e860@mail.triode.net.au> <37bdcb30.796706964@news.triode.net.au> <14271.18469.757616.424717@dolphin.mojam.com> <3.0.6.32.19990824122931.0099e860@mail.triode.net.au> <3.0.6.32.19990825123152.009a9100@mail.triode.net.au> Message-ID: <37C61484.9759CFD4@compaq.com> John Skaller wrote: > > The types of objects are NOT defined by Viper. > They're defined in Python by a client module! > So you can, for example, define any methods you like > for any type. Here is the current definition of > the type of an integer in the module 'py_types': > > class PyIntType: > def succ(x): return x + 1 > def pred(x): return x - 1 That sounds very interesting! I've been pondering the problem of type/class unification in Python, and your solution is an intriguing one. But is it possible to do this: class MyInteger(PyIntType): ... customised behaviour ... and have it inherit all the default behaviour of built-in integers? If so, how exactly does it work? For instance, can I do x = MyInteger(3) y = x + 5 and, assuming I haven't given MyInteger a custom __add__ method, have it somehow invoke the built-in integer addition code. Greg From lr at hpl.hp.com Sun Aug 29 01:39:18 1999 From: lr at hpl.hp.com (Larry Rosler) Date: Sat, 28 Aug 1999 22:39:18 -0700 Subject: Larry's and Guido's REAL sigs References: <7q9v2u$1jk$1@nnrp1.deja.com> Message-ID: In article <7q9v2u$1jk$1 at nnrp1.deja.com> on Sun, 29 Aug 1999 00:32:30 GMT, aaron_watters at my-deja.com says... ... > http://www.chordate.com/sigs.GIF > > enjoy! -- Aaron Watters Can't. No such page. Even with lower-case .gif. Try again? -- (Just Another Larry) Rosler Hewlett-Packard Laboratories http://www.hpl.hp.com/personal/Larry_Rosler/ lr at hpl.hp.com From I.Clarke at strs.co.uk Mon Aug 16 09:25:09 1999 From: I.Clarke at strs.co.uk (Ian Clarke) Date: Mon, 16 Aug 1999 14:25:09 +0100 Subject: Why use Python when we've got Perl? References: <37b4ba01@cs.colorado.edu> <7p49l5$uv7$1@nnrp1.deja.com> <37b634a2@cs.colorado.edu> <37b9a99b.635832158@nntp.ix.netcom.com> <37B7E1AC.FF4FF2CF@strs.co.uk> Message-ID: <37B81135.1B598171@strs.co.uk> My apologies, this is wandering off-topic, I will keep it short. Ok, so your point is that I was inciting flames, but that is not in itself a bad thing. I can live with that. > comp.lang.perl.misc is primarily for talking about Perl, not trying to > defend Perl to a Python advocate. I'm sure the converse is true of > comp.lang.python. Someone who starts a language advocacy flamewar and > then plays innocent about it isn't exactly holding the moral high ground. I never claimed to be perfect, Tom's post just angered me as he was accusing me of fanning the flames where as in he was contributing much more to the whole thing than I was. Ian. From bwarsaw at cnri.reston.va.us Thu Aug 19 15:52:48 1999 From: bwarsaw at cnri.reston.va.us (Barry A. Warsaw) Date: Thu, 19 Aug 1999 19:52:48 GMT Subject: More random python observations from a perl programmer References: <37BC6986.A66B044E@starmedia.net> <199908191634.KAA01333@jhereg.perl.com> <14268.21198.934117.241668@anthem.cnri.reston.va.us> <14268.23007.239507.166209@weyr.cnri.reston.va.us> Message-ID: <14268.24720.827523.852568@anthem.cnri.reston.va.us> Fred> Bucks? I'm supposed to be getting bucks for this? Oops, sorry. Don't tell Fred we're all getting rich here. Fred> Check the FTP site, Barry; GNU info is there thanks to the Fred> active Python community. Ah, that'll teach me to underestimate the Pythoneers! Barry> Tom, but I'm sure Fred would gladly take a contribution Barry> that generated manpage format from the latex source. You Barry> might even be surprised at the languages he'd accept such a Barry> contribution in! :) Fred> Hey, you're making me look bad! ;-) Just trying to fire up the masses. Look what it did for mailing list managers :) -Barry From jeremy at exit109.com Mon Aug 23 11:03:18 1999 From: jeremy at exit109.com (Jeremy) Date: Mon, 23 Aug 1999 15:03:18 GMT Subject: pyKDE Message-ID: Is anyone using pyKDE? I'm trying to get it to work. It compiled fine, but actually trying to use it, even just 'import kde', results in: Traceback (innermost last): File "", line 1, in ? File "/usr/local/lib/python1.5/kde.py", line 7, in ? import libkdec ImportError: ld.so.1: python: fatal: relocation error: file /usr/local/lib/python1.5/lib-dynload/libkdecmodule.so: symbol className__C10QImageDrag: referenced symbol not found Any ideas? This is pyKDE 0.8, Python 1.5.2, KDE 1.1.1, QT 1.44, Solaris 7. -- Jeremy | jeremy at exit109.com "How extravagant you are, throwing away women like that. Someday they may be scarce." (Casablanca) From wware-nospam at world.std.com Wed Aug 4 12:37:39 1999 From: wware-nospam at world.std.com (Will Ware) Date: Wed, 4 Aug 1999 16:37:39 GMT Subject: Python microthreads References: <933672146.479670@news.adtranzsig.de> <933751888.232337@news.adtranzsig.de> Message-ID: Will Ware schrieb in Nachricht ... > I haven't looked at Stackless Python, but it sounds like > an unrelated thing. As I recall, Stackless Python uses the > C stack for everything... Dirk-Ulrich Heise (hei at adtranzsig.de) wrote: > No, Christian wanted to eliminate the use of the C stack > and works with the frame objects as well. Maybe one of you > two re-invented the wheel of the other? It looks like wheel reinvention is definitely happening. I've now looked a little bit at Christian's work, and it looks like there is a lot in common. It probably makes sense, at least in the long term, to implement microthreads using Stackless Python. I'll need to study his work more carefully before I'm ready to migrate. > Anyway, i just wanted to know whether the two things are > of independent origins... Yes, they're independent. Christian has already been in consultation with the gods of Python, so I think his work is more in the mainstream spirit of the Python codebase. I don't think CPython loses anything by being stackless, so maybe stacklessness could be folded into the core release. So implementing microthreads separately will become an increasingly bad idea. I don't know if Christian's version of eval_code2 can be stepped a controlled number of opcodes. That would need to be done for microthreads. -- - - - - - - - - - - - - - - - - - - - - - - - - Resistance is futile. Capacitance is efficacious. Will Ware email: wware @ world.std.com From tim_one at email.msn.com Tue Aug 17 03:47:08 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 17 Aug 1999 03:47:08 -0400 Subject: C's isprint() concept? In-Reply-To: <37b8def1.474083836@news.triode.net.au> Message-ID: <000301bee884$b52e7380$112d2399@tim> [Tim] > Take a look at string.translate. [John (Max) Skaller] > And avoid it, since it isn't compatible with unicode or UTF-8 > encodings :-( I guess Aahz had better avoid len() then too ... something-that-views-the-world-as-a-raw-bytestream-can't-really-be- incompatible-with-anything-ly y'rs - tim From bowman at montana.com Tue Aug 31 09:41:52 1999 From: bowman at montana.com (bowman) Date: Tue, 31 Aug 1999 07:41:52 -0600 Subject: calling python interpreter References: <37cbccd8.5014784@news.tiscalinet.it> Message-ID: <37CBDBA0.E3ED7A41@montana.com> Kranio wrote: > > but it gave me "access denied" message. The interperter is in the > right dir and I am the owner of the file; tha same happens being root. > What is the problem? 'chmod 777 pippo.py' will probably solve it, if a little overkill. You need execute permissions set, too. do a 'ls -l pippo.py' and see if there are any 'x' or just -rw-rw-rw From dalke at bioreason.com Thu Aug 5 18:26:34 1999 From: dalke at bioreason.com (Andrew Dalke) Date: Thu, 05 Aug 1999 16:26:34 -0600 Subject: SGI C++ compile errors References: <37A88BD7.3723671D@psych.ucsb.edu> Message-ID: <37AA0F9A.19F0D6B@bioreason.com> Jerry Tietz said: > I am trying to compile an SGI C++ source > file which contains the call Py_Initializ() but I > get the following error messages: > > "/usr/people/beall/dev/Python-1.2/Include/mymalloc.h", line 64: Whew! That's really Python 1.2? Can you use the current version of Python, which is 1.5.2? It looks like you're hitting something related to the Great Renaming. It's before my time, but as I understand it, things like a Python-defined "malloc" have since been renamed to Py_Malloc to fix this problem. My shot in the dark guess is to comment out those two lines and force casting if the compiler gives warnings elsewhere. But you really should upgrade to the latest Python. Andrew Dalke dalke at bioreason.com From jstevens at bamboo.verinet.com Sat Aug 14 11:10:36 1999 From: jstevens at bamboo.verinet.com (John Stevens) Date: Sat, 14 Aug 1999 15:10:36 GMT Subject: Why use Perl when we've got Python?! References: <37AAFAD1.A032765B@NOSPAM.strs.co.uk> <37B286D2.A71C3239@NOSPAM.strs.co.uk> <37b30253@cs.colorado.edu> <37B49CBA.772D9783@basho.fc.hp.com> <37b4a18f@cs.colorado.edu> <37b4ced8@cs.colorado.edu> Message-ID: On 14 Aug 1999 04:08:05 GMT, Sam Holden wrote: >That could simply have been a reference. Or a symbolic reference. > >What is fundamental is that a @ tacked on the front indicates that it is an >array. :-) What is so amusing about that, is that you can say that with a straight face! :-) >So given @$fred, even with no knowledge of what that exactly means >you should be able to tell that it is somehow treating $fred as an array. No, what any reasonable person would do would be to grab for his Perl book. . . >>Yes. . . is it a hash, or a scalar? If it is a scalar, why >>is it called dict? If it is a hash, then why is it prefixed >>by $? If this is a reference instead of a scalar, then why >>doesn't it have it's own special prefix character. ;-> > >It's a scalar. It is named dict because TomC called it that. Yes. My point exactly. >It is >also named that since it is a reference to a hash. I use code like this >in C quite a bit : A reference to a hash. . . and yet TC claims that Perl is open to non-computer scientists. :-) Doesn't *ANYBODY* else see the irony in that? >If you know what it means then why do you continually get it wrong >throughout this thread? I don't suppose that you realize that getting wrong simply proves (and illustrates) my point? I learned it. I used it. I haven't written a new Perl program in three months. I come back to it, I get it wrong. . . do you see, yet, or do you just not get it? >>You cannot write Perl that resemble Python. You are required to >>use curly braces as block delimiters. > >In fact you are not. You are wrong yet again. Actually, I'm right, and you go on to prove I'm right. >Here is some code from Damian Conway from the 'Impythonating PERL' thread >in march. > >package impythonate; >use Text::Tabs; >my ($active, @bracket) = (0, ('{', ';', '}') ); >sub import >{ ^ Look closely. . . see that curly brace? >And here is his sample code that is now valid perl (although anyone who uses >it for real code should be killed) : To late. You already used a curly brace. Disproving your point, in case you hadn't realized it. John S. From jeremy at cnri.reston.va.us Thu Aug 19 13:59:52 1999 From: jeremy at cnri.reston.va.us (Jeremy Hylton) Date: Thu, 19 Aug 1999 13:59:52 -0400 (EDT) Subject: More random python observations from a perl programmer In-Reply-To: <37bc313b@cs.colorado.edu> References: <37bc1339@cs.colorado.edu> <19990819174800.D5227@xs4all.nl> <37bc313b@cs.colorado.edu> Message-ID: <14268.17944.323020.242210@bitdiddle.cnri.reston.va.us> >>>>> "TC" == Tom Christiansen writes: TC> :There are 'raw' strings though, 'r""', that dont do TC> backslashes. TC> Those aren't the book, and there are no manpages. Therefore, in TC> many ways, they don't really count. I know it hurts to hear TC> this, and you're all going to jump on me, but please please TC> think about it for a bit before you do so. [I know I said I wasn't going to get into this, but...] I think this statement is just plain silly. I use lots of tools, languages, libraries, etc. that have non-existent or bad manpages. The raw string exist regardless of whether there is a manpage that describes them. Which is not to say that I'm opposed to manpages; it would probably be helpful to provide them. I did think about this before I jumped, but it still seems fair to jump. As a possible counterexample to the "if it don't have manpages it don't exist" argument, I would suggest the C programming language. I don't believe there are manpages that describe the language itself, yet I found it (relatively) easy to learn. The K&R C book is mighty fine. It's also worth noting that the old Lutz book is a little like the pre-ANSI K&R C book. You're not going to find ANSI changes in the old K&R, and you're not going to find Python 1.5 info in the old Lutz book. In neither case does that mean the improvements don't exist. Jeremy From gmcm at hypernet.com Sat Aug 28 00:05:50 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Fri, 27 Aug 1999 23:05:50 -0500 Subject: Slow python on particular computer In-Reply-To: <37C6C982.35F2B199@prescod.net> Message-ID: <1276313212-39052155@hypernet.com> Paul Prescod wrote: > Has anyone seen a case where Python runs REALLY, painfully slowly on > an otherwise spritely Windows 95 machine? It takes something like 8 > seconds to launch the interpreted and parse a 10 line program. > Something must be mis-configured. Disk fragmentation is the most likely problem. Maybe registry pollution, especially if you're using COM. - Gordon From mlh at idt.ntnu.no Sat Aug 28 13:31:23 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 28 Aug 1999 19:31:23 +0200 Subject: Fuzzy string matching? References: Message-ID: Moshe Zadka writes: > On 28 Aug 1999, Magnus L. Hetland wrote: [...] > > Could perhaps be a bit more readable, though... (Maybe I'll work on > > that...) > > No need, my good man. We have a saying in Hebrew "The work of the rightous > gets done by others" OK - thanks :) > > Added a comment, made a few variables more meaningful, precalculated > ranges, changed some ; to , and here is the changed, and a bit tested, > version: Awright... I guess it's bit more readable now... However, there are a few things I think I would do differently - surly only a matter of taste... (and not meant as a sign of ingratitude :) > > def distance(a,b): > n, m = map(len, (a,b)) Is the use of map really clearer than not using it here, with only two variables? (It may be faster since you don't have to look up len twice, but...) > if n>m: # Make sure n<=m > a,b,n,m = b,a,m,n I guess I wrote this statement in the original - but I think perhaps I would split the strings and lengths into two different assignments to make it more readable, really... > range_m, range_n= map(range, (m, n)) Hm. Why? Why is range_m better than range(m)? > curr = range(0, n+1) > for i in range_m: > prev, curr = curr, [i+1] > for j in range_n: > add, dele = prev[j+1]+1, curr[j]+1 > change = prev[j] + (a[j]!=b[i] and 1 or 0) Hm. This is perhaps more compact - and the and/or thing *is* an idiom, but I don't think it's more readable than a plain if-statement... > curr.append(min(add, dele, change)) > return curr[n] > Here's another take - mainly an expression of my tastes in the matter (for lack of anything more meaningful to do in the evening... ;) def distance(a,b): "Calculates the Levenshtein distance between a and b." n, m = len(a), len(b) if n > m: # Make sure n <= m, to use O(min(n,m)) space a,b = b,a n,m = m,n current = range(0, n+1) for i in range(m): previous, current = current, [i+1] for j in range(n): add, delete = previous[j+1]+1, current[j]+1 change = previous[j] if a[j] != b[i]: change = change + 1 current.append(min(add, delete, change)) return current[n] Oh well... There's nothing like fiddling with a little piece of code. Much more fun than writing large programs methinks :) -- Magnus Making no sound / Yet smouldering with passion Lie The firefly is still sadder / Than the moaning insect Hetland : Minamoto Shigeyuki From clgonsal at keeshah.penguinpowered.com Fri Aug 27 03:29:22 1999 From: clgonsal at keeshah.penguinpowered.com (C.Laurence Gonsalves) Date: Fri, 27 Aug 1999 07:29:22 GMT Subject: Why use Python when we've got Perl? References: <37b4ba01@cs.colorado.edu> <7p49l5$uv7$1@nnrp1.deja.com> <37b634a2@cs.colorado.edu> <37C552DF.9F90BA36@megsinet.net> Message-ID: On 26 Aug 1999 10:33:03 -0500, Abigail wrote: > David Oppenheimer (davidopp at megsinet.net) wrote on MMCLXXXVI September > MCMXCIII in : > $$ > $$ That being said, are there ways to integrate Python and Perl to do things > $$ that neither one can do alone?! > > Since Python and Perl are Turing equivalent, what things are you refering to? Write a powerful and useful script that is both: - easy to understand and maintain - only 6 characters long -- C. Laurence Gonsalves "Any sufficiently advanced clgonsal at kami.com technology is indistinguishable http://www.cryogen.com/clgonsal/ from magic." -- Arthur C. Clarke From nharlow at my-deja.com Tue Aug 31 18:30:31 1999 From: nharlow at my-deja.com (nharlow at my-deja.com) Date: Tue, 31 Aug 1999 22:30:31 GMT Subject: Generating an event in Tkinter References: <7qfc5l$mll$1@nnrp1.deja.com> <011701bef37e$bcd9ece0$f29b12c2@secret.pythonware.com> Message-ID: <7qhl27$cgp$1@nnrp1.deja.com> In article <011701bef37e$bcd9ece0$f29b12c2 at secret.pythonware.com>, "Fredrik Lundh" wrote: > nharlow at my-deja.com wrote: > > I want to generate a dummy event from within a program. Then bind a > > callback to this event. > > > > How do I do that? > > > > In straight tk, it would be something like: > > event generate parent_window <> > > parent_window.event_generate("<>") > > (additional options can be given as > keyword arguments) I want to do the following: iterate over a while loop and output some text to a text widget. sleep for one second between iterations here's the code I tried. It doesn't like the way I am trying to make it sleep. i=sleeper=0 from time import sleep name="analyzer" while i< 100: print "%s: This is %s time through the loop"%(name,i+1) widget.event_generate("<>") widget.bind("<>",lambda x=sleep, y=1:x(y)) i=i+1 I get the following error: Traceback (innermost last): File "c:\program files\python\lib\lib-tk\Tkinter.py", line 752, in __call__ return apply(self.func, args) File "C:\nick\GUI\spidergui.py", line 145, in widget.bind("<>",lambda x=sleep, y=1:x(y)) AttributeError: no __call__ method defined what is the best way to do what I am trying to do? Nick Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From guido at cnri.reston.va.us Thu Aug 19 14:35:15 1999 From: guido at cnri.reston.va.us (Guido van Rossum) Date: 19 Aug 1999 14:35:15 -0400 Subject: Unsorting(randomizing) a sequence References: <7pb1eb$elt$1@nnrp1.deja.com> <14265.29899.470021.309355@dolphin.mojam.com> <37BAB643.9D4E861E@strs.co.uk> Message-ID: <5laernty8s.fsf@eric.cnri.reston.va.us> Ian Clarke writes: > I did some timing tests using the code I have attached below, here are > the results (in seconds) for sorting a list of 200 items 10 times: > > Dan Schmidt's solution (using sort): 14.98 > Stephan Houben's solution : 2.82 > Skip Montanaro's solution : 2.736 > (as modified by Dan schmidt) > Magnus L Hetland's solution : 0.032 > Skip's solution but with arrays : 3.182 > > As you can see I thought that using arrays may provide an efficiency > speed-up for Skip's algorithm, but apparently not. Oh, I haven't really > checked this code too carefully, so feel free to redo the tests if you > find any bugs in the code. > > Magnus L Hetland's solution wins hands down. The two-orders-of-magnitude-faster result should have made you look twice. There's a bug: s4(list) modifies its argument (empyting it) so you did only one run, plus 9 runs of an empty list! Corrected, I get these timings (on a slightly faster machine, it seems): s1 12.1 s2 2.31 s3 2.63 s4 2.68 s5 2.82 Here's the fixed s4(): def s4(list): """Magnus L Hetland's solution""" result = [] list = list[:] for i in range(len(list)): element = random.choice(list) list.remove(element) result.append(element) return result But the winner is Tim Peters' entry, already in the CVS tree. Its time is 1.34 seconds: def shuffle(x, random=random, int=int): """x, random=random.random -> shuffle list x in place; return None. Optional arg random is a 0-argument function returning a random float in [0.0, 1.0); by default, the standard random.random. Note that for even rather small len(x), the total number of permutations of x is larger than the period of most random number generators; this implies that "most" permutations of a long sequence can never be generated. """ for i in xrange(len(x)-1, 0, -1): # pick an element in x[:i+1] with which to exchange x[i] j = int(random() * (i+1)) x[i], x[j] = x[j], x[i] --Guido van Rossum (home page: http://www.python.org/~guido/) From dfan at harmonixmusic.com Thu Aug 19 13:35:44 1999 From: dfan at harmonixmusic.com (Dan Schmidt) Date: 19 Aug 1999 13:35:44 -0400 Subject: Python to Perl Conversions References: <37bc1303@cs.colorado.edu> <37bc2ee5@cs.colorado.edu> Message-ID: Tom Christiansen writes: | Online searchable documentation is critical in a technical subject | like this. Imagine libc without manpages! Or having no manpages | for the shell tools. Now, you might now be aware of this, but I | happened to *write* most of that on-line documenation for Perl. I'm | super senstitive to not being able to look up docs using standard | CLI text-based tools. As you said, you would be frustrated not to | have docs for tools or libraries. I use the documentation in info format, which is basically plaintext and easily searchable with text-based tools. Select "GNU Info" from . I'm not trying to be an apologist for the lack of man pages, just helping you find the plaintext documentation you (and I) prefer. (no courtesy cc's, please) -- Dan Schmidt -> dfan at harmonixmusic.com, dfan at alum.mit.edu Honest Bob & the http://www2.thecia.net/users/dfan/ Factory-to-Dealer Incentives -> http://www2.thecia.net/users/dfan/hbob/ Gamelan Galak Tika -> http://web.mit.edu/galak-tika/www/ From cfelling at iae.nl Mon Aug 23 18:10:35 1999 From: cfelling at iae.nl (Carel Fellinger) Date: 24 Aug 1999 00:10:35 +0200 Subject: matching any number of any character References: Message-ID: <7psgsr$hh$1@vvs.superst.iae.nl> Lyn A Headley wrote: > accomplish such a task. I thought this would work: it does... >>>> import regex >>>> rx = regex.compile('\(.\|\n\)+') >>>> rx.match('abc') > 3 you see, it just matched 3 characters, but... >>> rx.group(1) > 'c' here you are tricked by the semantics of a quantified grouping operator. A quantified group only remembers the last match, and as your group only matches a single character, 'c' it is:) (( shouldn't this be documented in the re module? it has stung more people recently )) > but I wanted 'abc'! so you have to refer to the whole match (rx.group(0)) or get the quantification inside a group. e.g. >>> rx = regex.compile('\(\(.\|\n|)+\)') >>> rx.group(1) 'abc' >>> rx.group(2) 'c' -- groetjes, carel From arnold at dstc.edu.au Mon Aug 23 03:09:30 1999 From: arnold at dstc.edu.au (David Arnold) Date: Mon, 23 Aug 1999 07:09:30 GMT Subject: carpe linguam In-Reply-To: Your message of "Mon, 23 Aug 1999 02:18:20 +0100." <0Hg8yBAcFKw3EwjN@jessikat.demon.co.uk> References: <0Hg8yBAcFKw3EwjN@jessikat.demon.co.uk> Message-ID: <199908230709.RAA03985@piglet.dstc.edu.au> -->"Robin" == Robin Becker writes: Robin> Oh dear are there any transputer fans left out there? yes ... ;-) d From andrew-johnson at home.com Fri Aug 20 03:52:50 1999 From: andrew-johnson at home.com (Andrew Johnson) Date: Fri, 20 Aug 1999 07:52:50 GMT Subject: making python man pages looks hard References: <1103_935134343@shoal> Message-ID: In article <1103_935134343 at shoal>, Dan Connolly wrote: [snip] ! parting shot: CPAN is cool, but I find it frustrating that I can't ! read the documentation for a module without downloading ! and upacking the module. for example, I can browse ! the list of modules, ! ! http://www.perl.com/CPAN/modules/00modlist.long.html ! ! but say I find one I'm interested in: ! ! Mac::Comm:: ! ::OT_PPP RdpO Control Open Transport PPP / Remote Access CNANDOR ! ! the only link goes to the Author contact info. Gee thanks. that is usually no longer a valid complaint --- try the CPAN front end at 'theory.uwinnipeg.ca', in particular, the search engine: http://theory.uwinnipeg.ca/search/cpan-search.html I entered Mac::Com in the box and got back: Mac-Comm-OT_PPP-1.20.tar.gz [readme / module list] 3.6 1998-01-06 CNANDOR Mac::Comm::OT_PPP [ documentation]: Interface to Open Transport PPP (and yes, those are links to the .tgz itself, the readme, a list of modules in the package; and, surprise, "[documentation]" links to the html'ified manpage). regards andrew -- They're not soaking, they're rusting! -- my wife on my dishwashing habits From philh at vision25.demon.co.uk Sat Aug 14 06:31:39 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Sat, 14 Aug 99 10:31:39 GMT Subject: Does Python run under Windows 2000? (build 2031) References: <37B40D58.DD6AADC0@RobotVision.com> Message-ID: <934626699snz@vision25.demon.co.uk> In article <37B40D58.DD6AADC0 at RobotVision.com> jgreen at RobotVision.com "James E. Green" writes: > I'm running Windows 2000 RC1 (build 2031, the very latest). Will Python > run under this OS? Use Linux instead. You know it means sense. :-) -- Phil Hunt....philh at vision25.demon.co.uk From a.eyre at optichrome.com Tue Aug 10 08:52:48 1999 From: a.eyre at optichrome.com (Adrian Eyre) Date: Tue, 10 Aug 1999 12:52:48 GMT Subject: __init__ question In-Reply-To: <1278154513-26981346@hypernet.com> References: <1278154513-26981346@hypernet.com> Message-ID: <000901bee32f$3f82fe30$3acbd9c2@peridot.optichrome.com> > > a = Vector() # x=0 y=0 z=0 > > a = Vector( 1) # x=1 y=1 z=1 > > a = Vector( 1, 2, 3) # x=1 y=2 z=3 > def __init__(self, x=0, y=0, z=0): How about: >>> class Vector: ... def __init__(self, *args): ... print args ... >>> v=Vector() () >>> v=Vector(1) (1,) >>> v=Vector(1,2) (1, 2) ...etc. You can then parse the args in the constructor. -------------------------------------------- Adrian Eyre Optichrome Computer Solutions Ltd Maybury Road, Woking, Surrey, GU21 5HX, UK Tel: +44 1483 740 233 Fax: +44 1483 760 644 http://www.optichrome.com -------------------------------------------- From mwh21 at cam.ac.uk Tue Aug 24 08:20:27 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 24 Aug 1999 13:20:27 +0100 Subject: Can't use crypt References: Message-ID: "Kieran O' Sullivan" writes: > When I tyr to compile python 1.5.2 on SuSE Linux 6.0 with the crypt module > I get the following error. > > make[1]: Entering directory `/Python-1.5.2/Modules' > gcc -Xlinker -export-dynamic python.o \ > ../libpython1.5.a -lieee -ldl -lm -o python > ../libpython1.5.a(cryptmodule.o): In function `crypt_crypt': > /Python-1.5.2/Modules/./cryptmodule.c:21: undefined reference to `crypt' > collect2: ld returned 1 exit status > make[1]: *** [link] Error 1 > make[1]: Leaving directory `/Python-1.5.2/Modules' > make: *** [python] Error 2 > > I have compiled python 1.5.2 with crypt on SuSE 5.2 with no problems. > There was a previous copy of python 1.5.1 on the SuSE 6.0 machine but > python 1.5.2 cpmpiles without any problem when crypt is not included. So edit Modules/Setup to add -lcrypt then... > When I use -lcrypt instead python will compile but I can't use cthe crypt > function. Oh. What goes wrong now? Michael From mlh at idt.ntnu.no Fri Aug 20 15:40:34 1999 From: mlh at idt.ntnu.no (Magnus L. Hetland) Date: 20 Aug 1999 21:40:34 +0200 Subject: More random python observations from a perl programmer References: <37BC6986.A66B044E@starmedia.net> <199908191634.KAA01333@jhereg.perl.com> <14268.21198.934117.241668@anthem.cnri.reston.va.us> <14268.23007.239507.166209@weyr.cnri.reston.va.us> Message-ID: "Fred L. Drake, Jr." writes: > Barry A. Warsaw writes: [...] > Manpages have never been requested, unless you consider Tom's > complaint a request. I've received nothing at > python-docs at python.org. Certainly not a contributed conversion > script. Hm. Could I request them now? I think it might be kinda nice to have... :) (Though I'm not sure I would want to make a conversion script... Does there really not exist one, either from tex, dvi or info to groff? Hm...) -- Magnus Making no sound / Yet smouldering with passion Lie The firefly is still sadder / Than the moaning insect Hetland : Minamoto Shigeyuki From eye at niksula.hut.fi Tue Aug 24 07:43:03 1999 From: eye at niksula.hut.fi (Petri Mikael Kuittinen) Date: 24 Aug 1999 14:43:03 +0300 Subject: How to sell Python to your boss? References: <11A17AA2B9EAD111BCEA00A0C9B41793034AAD03@molach.origin.ea.com> <14268.19435.271581.609@bitdiddle.cnri.reston.va.us> Message-ID: Jeremy Hylton writes: > You might also pick up some skills that would help you find a job. I think learning Python has made me a better C/assembler/Java/whatever programmer as well. By learning new programminmg languages one usually is able to pick up new programming methods and techniques, programming patterns to solve probles etc. Most of these are applicable to other languages as well. That is why I have also taken a look at exotic languages such as Ruby, Lua and Pliant. They all have some good ideas. Petri -- <(O)> Petri Kuittinen, also known as Eye, Dj Eye or Peku <(O)> <(O)> ADDRESS: Timpurinkuja 1 C 39, FIN-02600 Espoo, Finland <(O)> <(O)> EMAIL: eye at iki.fi WWW: http://www.iki.fi/~eye/ PHONE: 09-5472380 <(O)> ~Humor is the best antidote to reality. From ivanlan at callware.com Thu Aug 19 13:19:55 1999 From: ivanlan at callware.com (Ivan Van Laningham) Date: Thu, 19 Aug 1999 17:19:55 GMT Subject: More random python observations from a perl programmer References: <37bc1339@cs.colorado.edu> <37bc29d8@cs.colorado.edu> Message-ID: <37BC3CBB.7D28E3E5@callware.com> Hi All-- Tom Christiansen wrote: > [bobbit] > :Thanks for the document. It was very interesting reading. > > You're welcome. I got so fed up with the damned flames coming > from people who don't actually even know what they're talking about, > that I decided to make sure I wasn't one of them. :-) > > --tom > If that's what you believe, why are posting stuff like this (from a different, but nearly simultaneous, posting)? > You seem to be looking for a fight. Please say nothing > at all if that's all you want to do. In response to someone else's quite reasonable suggestion to read the documentation. You also say in the same message > Thanks for nothing: there are no manpages. I read the Lutz book. It's true that there are no manpages. Linux comes with manpages, but every single manpage says (paraphrased): ``Don't trust this page; we don't. See the info help system for the real scoop.'' When you do, it's harder to use and usually doesn't have any more to say than the manpage. I'm not sure that the choice of two mostly wrong options is a choice with any value. Python doesn't have manpages, true. It does have perfectly adequate documentation available at http://www.python.org/doc You can download that documentation and install it on your own computer if you wish to avoid the net. Like all documentation, it leaves something to be desired (decent search facilities, for one, but manpages don't have those either); but, like Kernighan & Ritchie's _The C Programming Language_, it's all there. Your complaint that Python doesn't have manpages is like complaining that Buddhism doesn't have a Bible. Perfectly true, and perfectly false. -ly y'rs, Ivan ---------------------------------------------- Ivan Van Laningham Callware Technologies, Inc. ivanlan at callware.com ivanlan at home.com http://www.pauahtun.org See also: http://www.foretec.com/python/workshops/1998-11/proceedings.html Army Signal Corps: Cu Chi, Class of '70 ---------------------------------------------- From tchrist at mox.perl.com Fri Aug 20 09:22:14 1999 From: tchrist at mox.perl.com (Tom Christiansen) Date: 20 Aug 1999 06:22:14 -0700 Subject: More random python observations from a perl programmer References: <37bc1339@cs.colorado.edu> <37bc313b@cs.colorado.edu> <14268.17944.323020.242210@bitdiddle.cnri.reston.va.us> <019301beeaea$004c4d80$f29b12c2@secret.pythonware.com> Message-ID: <37bd4876@cs.colorado.edu> [courtesy cc of this posting mailed to cited author] In comp.lang.python, "Fredrik Lundh" writes: :as an aside, it's a bit sad that Tom didn't read the book's :preface, where Mark says, among other things: It's a shame that so many of you should be so unbelievably harsh on me when *I'm* the one who with malice toward none and full of revulsion at the flames causes by *YOUR* community's ignorant attacks on mine, that *I* made the honest effort to learn *YOUR* language, and that I furthermore for your benefit not my own then took the additonal trouble to write-up my experiences and observations gleaned while five hundred miles away from the nearest tree or internet link. And for that, I am abused for my candor and effort in trying to convey to you what that process was like for me. Shame on you! Don't you understand your gain? How dare you punch a gifthorse in the mouth--repeatedly? If these petty slams and disdainful arrogances are the kind of response typical of your community, this bodes not well for you. But no, that's not it. It's just Usenet, the place where condescension, conceit, and cruelty all come far too easily. The more the pissier, you know. I'll try to keep that in mind as I continue to attempt to sift through this dreck to find the gems. --tom -- "I will always write it the second way, so if you're optimizing for contrariness, it's obviously better to do it the second way." --Larry Wall From cjc26 at nospam.cornell.edu Sat Aug 21 15:15:24 1999 From: cjc26 at nospam.cornell.edu (Cliff, or a close facsimile) Date: 21 Aug 1999 19:15:24 GMT Subject: Uglliness scale: Python <<< awk << p*** < SNOBOL4 References: <37bdc47f.22030506@news.erols.com> Message-ID: Pada Fri, 20 Aug 1999 21:12:55 GMT, Robert Kern bilang: | >> > Funny, I read that 'the way g-d indented'. :) | >> | >> Hey, what a great signature that would make! | >> | >> Python: Programming the way g-d indented. | > | >Make that: | >Python: Programming the way g--d- indented. | | Why does this remind me of Douglas Hofstadter's _G?del, Escher, Bach_? | :-) Programming the way g-d-- intended? Now that's just scary.. -- cliff crawford http://www.people.cornell.edu/pages/cjc26/ There are more stars in the sky than there are -><- grains of sand on all the beaches of the world. From aahz at netcom.com Mon Aug 16 19:53:45 1999 From: aahz at netcom.com (Aahz Maruch) Date: 16 Aug 1999 23:53:45 GMT Subject: C's isprint() concept? References: <000201bee78f$6bbf6ec0$f22d2399@tim> <7p9d0v$m9c@dfw-ixnews11.ix.netcom.com> <37B8A265.8A9EAC69@vision.arc.nasa.gov> Message-ID: <7pa8a9$pik@dfw-ixnews8.ix.netcom.com> In article <37B8A265.8A9EAC69 at vision.arc.nasa.gov>, Chad Netzer wrote: >Aahz Maruch wrote: >> >> Ah. Interesting. I'm using re.sub because we're still on 1.5.1, but >> we're supposed to move to 1.5.2 Real Soon Now. > >Just out of curiosity, what is the biggest source of the delay from >switching to 1.5.2? Is it a matter of "if it ain't broke...", or do the >changes warrant enough work (rewriting code, updatin libraries, >etc.) that it is a big job? I'm writing apps, and currently rely on >some 1.5.2 behaviors, so I'm curious as to how difficult it may be >for customers to upgrade if need be. There were a couple of specific bugs in 1.5.1 that required us to create a special Python package, and it will be a little tricky to back out those changes (I wasn't involved, so don't ask for more details). Plus we simply haven't had the time to do the necessary regression testing. (We've got Zope, Medusa, mxODBC, and a slew of other bits; just the back end currently has, um, about twelve running processes.) Overall, if your customers are running unpatched Python distributions and have not written workarounds for bugs in 1.5.1, upgrading should be a snap. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From forcer at mindless.com Mon Aug 23 17:32:44 1999 From: forcer at mindless.com (forcer) Date: 23 Aug 1999 23:32:44 +0200 Subject: Necessity of ``pass'' Message-ID: Hi there. Lately, i've been thinking about Python. While it is an exceptionally clean language, it has one very obvious wart: The ``pass'' statement. To quote the reference manual: pass is a null operation -- when it is executed, nothing happens. It is useful as a placeholder when a statement is required syntactically, but no code needs to be executed, for example: def f(arg): pass # a function that does nothing (yet) So it happens that Python has places where semantically nothing should be done, while syntactically it requires a statement. I consider this suboptimal. As a solution, one could allow the following: instead of if foo: pass bar one could write if foo: bar Syntactically this does not introduce any ambiguity. The only problem i see is that the "pass" version is more readable. But... Most of the time, people write if foo:pass bar anyways so the "readability" does not suffer from leaving pass out. Also, the requirement for pass makes it impractical to comment out parts of an if expression, like in if foo: # baz # qux bar The new syntax would even allow a smooth transition, or coexistence of both versions. Pass can be retained to keep the possibility for a explicit do-nothing statment, while it's just not mandatory anymore. I'd like to see such a change in the Python language, so it'll be even cleaner than it was before. I hope my opinions and thoughts are of value to you, --forcer -- ((email . "forcer at mindless.com") (www . "http://forcix.cx/") (irc . "forcer@#StarWars (IRCnet)") (gpg . "/other/forcer.gpg")) From dwelton at linuxcare.com Mon Aug 9 21:54:07 1999 From: dwelton at linuxcare.com (David N. Welton) Date: 09 Aug 1999 18:54:07 -0700 Subject: Redirect stderr Message-ID: <87lnbk8kow.fsf@linuxcare.com> I wish to do this: #!/usr/bin/python import sys import os f = open("goober", "w") sys.stderr = f sys.__stderr__ = f os.execv("/bin/ls", ["/bin/ls", "sdfsdfdsfds"]) and have it dump the errors into 'goober'. I'm having some difficulties figuring out exactly why this isn't working, or how I ought to be doing this. Thanks, -- David N. Welton, Web Engineer, Linuxcare, Inc. 415.354.4878 x241 tel, 415.701.7457 fax dwelton at linuxcare.com, http://www.linuxcare.com/ Linuxcare. At the center of Linux. From mwh21 at cam.ac.uk Wed Aug 25 07:35:12 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 25 Aug 1999 12:35:12 +0100 Subject: [Python] Can't use crypt on SuSE 6.0 References: Message-ID: Oops, I meant to follow up to your follow up to my follow up to your original post... but I never got round to it. "Kieran O' Sullivan" writes: > When I tyr to compile python 1.5.2 on SuSE Linux 6.0 with the crypt module > I get the following error. > > make[1]: Entering directory `/Python-1.5.2/Modules' > gcc -Xlinker -export-dynamic python.o \ > ../libpython1.5.a -lieee -ldl -lm -o python > ../libpython1.5.a(cryptmodule.o): In function `crypt_crypt': > /Python-1.5.2/Modules/./cryptmodule.c:21: undefined reference to `crypt' > collect2: ld returned 1 exit status > make[1]: *** [link] Error 1 > make[1]: Leaving directory `/Python-1.5.2/Modules' > make: *** [python] Error 2 > > I have compiled python 1.5.2 with crypt on SuSE 5.2 with no problems. > There was a previous copy of python 1.5.1 on the SuSE 6.0 machine but > python 1.5.2 cpmpiles without any problem when crypt is not included. That'll be a libc5 vs. libc6 issue, I'd warrant. This is not mysterious. > When I use -lcrypt option in the Setup file python will compile but I > can't use the crypt function. > > When I try I get ImportError: no module named crypt *This* is the odd bit. Are you sure you're executing the right Python? I've done things like this to myself where I compile & install a package in /usr/local and then carry on getting the version that's installed in /usr... > I have tried the following command with crypt inabled: > > strace -o /tmp/foo -f make install > > but the file that this produced is not a lot of help. I'm curious - how did you expect that to help? More productive might be the output of python -vc 'import crypt' and python -c 'import sys; print sys.builtin_module_names' the-link-error-is-not-the-problem-ly y'rs - Michael From fleck at informatik.uni-bonn.de Wed Aug 25 08:48:40 1999 From: fleck at informatik.uni-bonn.de (Markus Fleck) Date: 25 Aug 1999 12:48:40 GMT Subject: equivalent of getch References: <37C3C97A.59BF653E@acay.com.au> Message-ID: <7q0on8$h3i@news.rhrz.uni-bonn.de> Gurvijay Singh Bhatti wrote: > could someone tell me what is equivalent of getch in jpython? I want the > program to wait for the user to hit enter before going forward. AFAIK, this cannot be done in Java. I would be surprised if it could be done in JPython. Yours, Markus. -- //////////////////////////////////////////////////////////////////////////// Markus B Fleck - University of Bonn - CS Department IV - WHOIS MF5079 UNIX Administrator - comp.lang.python.announce Moderator "GNU Gather" Free Internet Groupware Project - http://gather.net/ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ From aarhodes at cisco.com Tue Aug 10 12:03:43 1999 From: aarhodes at cisco.com (Aaron Rhodes) Date: Tue, 10 Aug 1999 16:03:43 +0000 Subject: What's a good way to get my IP from Python? Message-ID: <37B04D5F.2F00EE6C@cisco.com> Hello, Does anyone know of a really good way to determine the IP address of the ethernet cards on a Linux system using Python only (i.e. no C code/parsing external binaries, etc.) ? Thanks in advance, Aaron -- Aaron Rhodes Network Security Engineer aarhodes at cisco.com (512) 378-1097 From MHammond at skippinet.com.au Tue Aug 3 19:13:53 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Wed, 4 Aug 1999 09:13:53 +1000 Subject: An idea - request for comments References: <37A6A2DB.9B11FB01@strs.co.uk> Message-ID: <7o7t4p$rgp$1@m2.c2.telstra-mm.net.au> Ian Clarke wrote in message <37A6A2DB.9B11FB01 at strs.co.uk>... >It is to create a Python web server which automatically parses embedded >Python in HTML (there is a Perl extension that does this too). So, for >example, the following HTML code: Attached is some code I wrote for exactly this purpose. I looked into Zope and it's DocTemplate class, but it had some restrictions that I didnt like for my purpose. I wanted something closer to what you describe. I stole my implementation idea from Microsoft's ASP. <% and <%= tags delimit Python code. There is no requirement on the text outside the <% tags, so HTML (or indeed many other things) work fine. <%= indicates a Python expression to be evaluated and the result placed in the output stream. <% indicates a Python block to be executed. A "write" function can be called by this code to insert text into the output stream. The application provides a dictionary to this tool - this dictionary is the "namespace" made available to the executed code. there is no support for rexec, as I trust the users running this :-) A special token <% #end %> is used to overcome Python's white-space in this environment. Indentation is automatically applied to subsequent code blocks. Example text may be: <% for i in range(3): %> <%= "This is loop number %d" % i %> <% #end %> <% import string # Keep newline in token so not in output! %><% words = string.split("hi there") %> <% for word in words: %><%= word %><% #end %> Note that the second line of the example is not indented, but magically appears in the for loop. The <% #end %> token ends the block, meaning the import is not indented. Attached for your amusement. Mark. begin 666 doctemplate.py M:6UP;W)T('-Y71H:6YG(&9R;VT@;&%S=%!O M'0@;VYE(&ES#0HC"0EI9" ](&1A=&%;3H-"@D)'!R+"!G+"!L*0T*"0ER971U&-E M<'0Z#0H)"70L('8L('1B(#T@&,H*0T*"0EI9B!T(&ES($%T=')I8G5T945R2!A;F0 at 9VEV92!T:&4@=7-E"!I;B!R86YG92AL96XH:71E;7,I*3H-"@D)"0D);F%M92 ]('-T"LQ72PB+B(I#0H)"0D)"79A;" ](&!E=F%L*&YA M;64L(&&5C(BD-"@EE M>&-E<'0 at 4WEN=&%X17)R;W(L(&1E=&%I;',Z#0H)"6UE'0I(#T at 9&5T86EL&5C(&-O9&4@:6X@;F%M97-P86-E#0H)97AC M97!T. at T*"0EI9B!S>7,N97AC7W1Y<&4@:6X@&5C=71E5&5M<&QA=&4H8U-T > Message-ID: <37B9A83B.A987188F@starmedia.net> Olivier Deckmyn wrote: > > Hi ! > > I would like a method of my own to be able to print the module it is > declared in: > > ex: > the text for the module : toto.py is : > > class MyClass: > def myMethod(self): > print "I am in module", ???????? > > and then > MyClass().myMethod() > should produce : > 'toto' > > .... > Thanx for your help ! > > --- > Olivier Deckmyn, Paris - France > "Any sufficiently advanced technology is indistinguishable from > magic." -Arthur C. Clark the name of the current module is __name__ so if you have a module foo.py def f(): print __name__ and the main executable: import foo foo.f() will print 'foo' -- "Programmers are just machines that convert coffee to executable code" -Unknown "Drew Csillag" From hnowak at cuci.nl Sat Aug 28 10:36:22 1999 From: hnowak at cuci.nl (Hans Nowak) Date: Sat, 28 Aug 1999 14:36:22 GMT Subject: Fuzzy string matching (snippet candidate?) In-Reply-To: <37C718AA.544E3FB8@msfc.nasa.gov> References: <37C718AA.544E3FB8@msfc.nasa.gov> Message-ID: <199908281437.QAA22455@dionysus.fw.cuci.nl> On 27 Aug 99, at 23:00, Drew McDowell wrote: > Magnus, > Did you think of submitting this to the python snippets repository? > http://www.hvision.nl/~ivnowa/snippets/ He doesn't have to; I already added this to the pile of snippets sitting on my hard disk. As a matter of fact, the snippet maintainer (me ;-) also the one who asked the initial question for the fuzzy string match. Apropos snippets; I haven't been able to work on it for the last weeks since I've been on a little vacation. ^_^ I will try to add some new snippets this weekend. (Apparently people are actually *using* this page. Amazing. ;-) --Hans Nowak (zephyrfalcon at hvision.nl) Homepage: http://fly.to/zephyrfalcon Python Snippets: http://www.hvision.nl/~ivnowa/snippets/ The Purple Kookaburra Forum: http://www.delphi.com/kookaburra/ From tim_one at email.msn.com Fri Aug 20 01:48:14 1999 From: tim_one at email.msn.com (Tim Peters) Date: Fri, 20 Aug 1999 01:48:14 -0400 Subject: sliciing dicts (was RE: More random python observations from a perl programmer) In-Reply-To: Message-ID: <001301beeacf$9819a560$712d2399@tim> [tchrist] >> GOTCHA: (medium) >> Slices in Python must be contiguous ranges of a sequence. >> In Perl, there's no such restriction. [Michael Hudson] > At some point Python will probably support `extended slice syntax' > like so: > > range(0,10)[1:4:2] => [1,3] > > Numerical Python already does this. [tchrist] >> GOTCHA: (medium) >> You can't slice dictionaries at all in Python. In Perl, it's >> easy to slice a hash, and just as sensible. [Michael Hudson] > Huh? What would that mean? There's no reason to suspect that the keys > of a dictionary are ordered. What Tom calls "slicing" here the NumPy folk would call gather/scatter subscripting. A list can be used as an index, e.g. thing[[7,2,3]] == [thing[7], thing[2], thing[3]] Perl has something like that; Python does not. can't-tell-the-subscripting-modes-without-a-scorecard-ly y'rs - tim From wtanksle at dolphin.openprojects.net Fri Aug 27 18:09:58 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 27 Aug 1999 22:09:58 GMT Subject: Why use Python when we've got Perl? References: <37b4ba01@cs.colorado.edu> <7p49l5$uv7$1@nnrp1.deja.com> <37b634a2@cs.colorado.edu> <37C552DF.9F90BA36@megsinet.net> <14277.63776.733073.298192@dolphin.mojam.com> <37C60262.C6771B75@megsinet.net> Message-ID: On Thu, 26 Aug 1999 23:13:39 -0400, David Oppenheimer wrote: >Where can I find info on Minotaur? I don't remember, but try looking it up on http://freshmeat.net/. >David O. -- -William "Billy" Tanksley From ketil at ii.uib.no Wed Aug 25 05:16:00 1999 From: ketil at ii.uib.no (Ketil Z Malde) Date: Wed, 25 Aug 1999 09:16:00 GMT Subject: Parrot-0.0.1 References: <935279776snz@vision25.demon.co.uk> <7ps4ma$n06$1@wagner.wagner.home> <37c2a462.349531009@192.77.87.74> <935523275snz@vision25.demon.co.uk> Message-ID: philh at vision25.demon.co.uk (Phil Hunt) writes: > The Parrot tool has other potential advantages, e.g: > 1. you only have to learn one syntax, that can then be used for > lots of languages and GUI libraries. > 2. assuming the right import and export tools have been written, > Parrot can allow you to use one GUI builder to output to a different > GUI, for example you could design your GUI in Glade, and use Parrot > to output it as a series of C++ files for KDE/Qt. Or - you could extend Parrot to allow switching between GUIs on the fly. Parse the GUI spec, building the dialogs and other GUI components, and voila! your application has a new "skin" (or "theme" or whatever). I suppose it might be easier to use an already interpreted language like TCL to do this, create GUI as separate components that hook into the application main code. You'd probably want some business logic in the GUI scripts though, like disabling certain widgets depending on the state in another, etc. -kzm -- If I haven't seen further, it is by standing in the footprints of giants From fredrik at pythonware.com Wed Aug 25 04:03:19 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 25 Aug 1999 08:03:19 GMT Subject: xanadu and python Message-ID: <009c01beeed0$4e6babc0$f29b12c2@secret.pythonware.com> I doubt anyone have missed that Ted Nelson's Xanadu, the original hypertext system, has finally been released as open source: http://www.udanax.com/ what Python has to do with it? well, go to the site and find out for yourself ;-) From bruce_dodson at bigfoot.com Sat Aug 14 05:10:39 1999 From: bruce_dodson at bigfoot.com (Bruce Dodson) Date: Sat, 14 Aug 1999 06:10:39 -0300 Subject: OCX and PythonWin.... References: <7oq27u$th0$1@nnrp1.deja.com> Message-ID: <%oat3.62670$jl.39620751@newscontent-01.sprint.ca> On a similar subject. I was experimenting with MapObjects (an ActiveX control) and PythonWin. It seems that every time I load it, PythonWin crashes on exit (access violation or something). I tried generating a quick AppWizard test in VC++, and had no such problems there. Also no problems in VB, of course. My application follows the Internet Explorer example in pywin/demos/ocx. That example runs fine, but not with MapObjects. Is there something that needs to be done to tell pythonwin that this object should be torn down after its window is closed? An explicit DestroyWindow didn't help. I might try putting the control in a dialog resource and launching it into a CFormView to do the doc/view thing and perhaps get better integrated with MFC, but I'd really rather not. Can anyone offer some words of wisdom? (btw Mark if you're listening, there's a spot reserved on my bookshelf for your upcoming Python/Win32 book.) There is some benefit to this pain. I am slowly coming to grips with the way PythonWin wraps MFC. A light turned on as I was writing this and realized why the docs talk about PyCMDIChildWnd while the examples derive from things like MDIChildWnd, why the latter isn't mentioned in the help file whereas the former can't be found in the object browser. But it's 6:00am. After a good morning's sleep I will probably have forgotten what I learned. :-) From jb12345678 at my-deja.com Sun Aug 22 11:35:09 1999 From: jb12345678 at my-deja.com (jb12345678 at my-deja.com) Date: Sun, 22 Aug 1999 15:35:09 GMT Subject: win32com: ambient properties Message-ID: <7pp5bc$dnh$1@nnrp1.deja.com> Hi, I am experimenting with mshtml as a control (obtained from WebBrowser control as HTMLDocument instance). I have a problem getting the mshtml control into Editing mode. According to the mshtml specs I need to set an ambient property in the container: AMBIENT_USER_MODE to false. The control should query the container for this ambient property. I don't know how to do this. It does not work when I set the property on the HTMLDocument instance directly. Does anyone have a hint? -Jb Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From joe at strout.net Mon Aug 30 14:31:36 1999 From: joe at strout.net (Joseph J. Strout) Date: Mon, 30 Aug 1999 11:31:36 -0700 Subject: 'if foo' calls getattr?!? In-Reply-To: <1276085477-52750363@hypernet.com> References: <1276085477-52750363@hypernet.com> Message-ID: Hi Gordon, >In which case "if foo is not None" will be the fastest and >closest-to-your-intention test possible. (But "if foo != None" will >get you right back to where you are now!). Yep, that's what I'm looking for. (I had tried "if foo != None" already, but I rarely use "is" and "is not", so it didn't even occur to me to try.) Thanks, -- Joe ,------------------------------------------------------------------. | Joseph J. Strout Biocomputing -- The Salk Institute | | joe at strout.net http://www.strout.net | `------------------------------------------------------------------' From greg.ewing at compaq.com Mon Aug 23 17:08:52 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 24 Aug 1999 09:08:52 +1200 Subject: More random python observations from a perl programmer References: <37bc1339@cs.colorado.edu> Message-ID: <37C1B864.970C63DC@compaq.com> Evan Simpson wrote: > > A syntax for expressing explicit tuple > unpacking has been proposed (fn(*t)), and it remains to be seen whether it > will enter the language. I'm working on an implementation of that, by the way, so it may be possible for people to try it out soon. > There are no compound > assignment operators since there are no assignment operators, period. I don't think it's helpful to jump on that particular terminological detail. The people who ask "why is there no += operator" aren't using the word "operator" in its precise technical Python sense. > It's what you would expect if you assume floating point arithmetic at all > times. If you're operating on integers, it's quite wrong. Explicitness > wins, in Python. I'd say quite the opposite - this is a rare case in Python where IMplicitness loses! If the distinction between integer and floating point division were made explicit, by having different operators for them, this would cause much less grief. Greg From tim_one at email.msn.com Sat Aug 21 22:47:05 1999 From: tim_one at email.msn.com (Tim Peters) Date: Sat, 21 Aug 1999 22:47:05 -0400 Subject: More random python observations from a perl programmer In-Reply-To: <7pmsdi$81u@ds2.acs.ucalgary.ca> Message-ID: <000401beec48$9e4e88e0$cb2d2399@tim> Skipping most of this, since I already posted my own long reply to Tom. [Tom Christiansen, admits that Perl copies arrays] [Neil Schemenauer] > What happens when you have a large array and pass it to a > function? This seems pretty inefficient. If the array is not > copied then why are they so many rules about when something is > copied and when it is not. The array gets copied. In Perl4 there were tricks you could play with symbol tables to avoid the copy, or you could rely on dynamic scoping and not pass anything; in Perl5 there's a general notion of "reference type", and you can avoid the copy by passing a reference to the array. The callee needs to know it's a reference, though (indexing a (de)reference to an array requires different syntax than indexing an array directly; a huge (to me) advantage of Python's uniformity is that the caller can choose to pass the original array or a copy as it pleases, and the callee doesn't know the difference). >From a Python person's point of view, Perl *always* copies, and in the case of passing a reference simply copies a small indirection object. Python never copies, but that's hard to explain to a Perl person because "no copy == construct a reference" to them, while that way of viewing it makes little sense to a Python person. there's-no-way-to-break-out-of-thisly y'rs - tim From arcege at shore.net Mon Aug 16 20:44:33 1999 From: arcege at shore.net (Michael P. Reilly) Date: Tue, 17 Aug 1999 00:44:33 GMT Subject: Redirecting Python Output References: Message-ID: Alberto Fonseca wrote: : Hello, I am embedding Python into my app under Windows. I would like to : redirect Python's output so that I can just print it myself. Has anyone : done this? What is the easiest way to do this? Probably something like: import sys try: from cStringIO import StringIO except: from StringIO import StringIO sys.stdout = StringIO() sys.stderr = StringIO() Each file output is seperate here, but could be the same to redirect the output to both places. This will allow you to retrieve it in your embedded C program thusly: PyObject *sys_stdout, *str; sys_stdout = PySys_GetObject("stdout"); str = PyObject_CallMethod(sys_stdout, "getvalue", NULL); fprintf(stderr, "Python output: %s\n", PyString_AsString(str)); Py_DECREF(str); Py_DECREF(sys_stdout); -Arcege From greg.ewing at compaq.com Mon Aug 16 16:59:24 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Tue, 17 Aug 1999 08:59:24 +1200 Subject: Anyone else find Tk akward? References: <37B34DBB.E5A79760@sprint.ca> Message-ID: <37B87BAC.CE092017@compaq.com> Christopher Browne wrote: > > The Tk model of packing "objects" onto a "canvas" allows it to > self-optimize, and lets the programmer not need to worry so much about > those sorts of fiddly details. This is good, except that if you just pack things together in the simplest and most obvious way, the results are awful -- everything is jammed together, and nothing resizes the way you want. To get a layout which looks good and works properly, you need to deal with another set of fiddly details, namely the various padding, filling and expanding options, which (for me, anyway) seem to work in very unintuitive ways. The idea of an automatic layout manager is as good one, but I don't think that any of Tk's geometry managers are a good implementation of it. I'm not surprised that some people find them frustrating. Greg From hschroeder at gmx.net Sat Aug 7 19:29:07 1999 From: hschroeder at gmx.net (Henning Schroeder) Date: Sun, 8 Aug 1999 01:29:07 +0200 Subject: Tkinter -- tarred up documentation? References: <934062911snz@vision25.demon.co.uk> Message-ID: <3gfio7.ia4.ln@odin.henning-schroeder.de> Phil Hunt wrote: > On the Pythonware site (www.pythonware.com) there's a some Tkinter > documentation entitled "Introduction to Tkinter", and "Tkinter > Class Reference pages". > Unfortunately these are stored as single HTML pages. "Introduction to Tkinter" is also available as PDF on there website. Nevertheless PIL documentation are single HTML pages :-( Maybe someone has one of these download-utilities and could provide .tgz? Henning From thomsensven at my-deja.com Fri Aug 13 04:29:07 1999 From: thomsensven at my-deja.com (thomsensven at my-deja.com) Date: Fri, 13 Aug 1999 08:29:07 GMT Subject: Problems importing Modules under win32 References: <7oud1c$vcd$1@nnrp1.deja.com> Message-ID: <7p0l0d$i3j$1@nnrp1.deja.com> Hi, i found it, a __init__-File was missing. Thanks to Lars Marius Garshol for the help... Bye, Sven Thomsen Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From chad at vision.arc.nasa.gov Sun Aug 15 06:28:17 1999 From: chad at vision.arc.nasa.gov (Chad Netzer) Date: Sun, 15 Aug 1999 10:28:17 +0000 Subject: Enough [Why fight when we can hoist a few at OSC?!] References: <1277478426-31364719@hypernet.com> <37b58c4a@cs.colorado.edu> Message-ID: <37B69641.35128019@vision.arc.nasa.gov> Tom Christiansen wrote: > That man, along with Ian Clarke, have stirred up the biggest flame war > in the Perl newsgroup that we're seen for a long time, inflicting their > standard overrighteous prattle on us. As one who put a flaming bag-o-turd on Tom's home doorstep (c.l.p.m, that is), when I should not have contributed to such a bonfire of abuse (although that "if 1:" trick can be useful :), I'd like to say that it is a shame this had to start so near to the O'Reilly conference. I won't be able to make it, but I hope others will not let this interfere with any potential discussion and socializing between the two "camps". Anyone who buys Tom a beer for me (or an equivalent, depending on his tastes), I'll pay them back. Chad Uhhh, but don't everyone do it, or I'll go broke. :) From tietz at psych.ucsb.edu Wed Aug 4 14:52:07 1999 From: tietz at psych.ucsb.edu (Jerry Tietz) Date: Wed, 04 Aug 1999 11:52:07 -0700 Subject: SGI C++ compile errors Message-ID: <37A88BD7.3723671D@psych.ucsb.edu> I am trying to compile an SGI C++ source file which contains the call Py_Initializ() but I get the following error messages: "/usr/people/beall/dev/Python-1.2/Include/mymalloc.h", line 64: error(3419): more than one instance of overloaded function "malloc" has "C" linkage extern ANY *malloc Py_PROTO((size_t)); ^ "/usr/people/beall/dev/Python-1.2/Include/mymalloc.h", line 65: error(3419): more than one instance of overloaded function "calloc" has "C" linkage extern ANY *calloc Py_PROTO((size_t, size_t)); ^ Can anybody tell me how to fix this? Thanks, Jerry Tietz From sjmachin at lexicon.net Tue Aug 17 16:23:00 1999 From: sjmachin at lexicon.net (John Machin) Date: Tue, 17 Aug 1999 20:23:00 GMT Subject: Regarding the magical "or" operator In-Reply-To: <000601bee6cb$a5e747e0$832d2399@tim> References: <000601bee6cb$a5e747e0$832d2399@tim> Message-ID: <19990817202744770.AAA404.73@max41104.izone.net.au> A non-text attachment was scrubbed... Name: not available Type: text/enriched Size: 1300 bytes Desc: not available URL: From gary at onegoodidea.com Tue Aug 24 08:40:17 1999 From: gary at onegoodidea.com (Gary O'Keefe) Date: Tue, 24 Aug 1999 12:40:17 GMT Subject: Why use Perl when we've got Python?! References: <37AAFAD1.A032765B@NOSPAM.strs.co.uk> <37b34edc@cs.colorado.edu> <37B3DC02.C9DDB210@NOSPAM.strs.co.uk> <37b414d7@cs.colorado.edu> <37c126a6$0$813@newsreader.alink.net> <37c21fae$0$216@nntp1.ba.best.com> Message-ID: <37c28ac9.13320348@news.hydro.co.uk> A keyboard was whacked upside Xah's head and out came: [ a vast and rambling discourse snipped ] >AppleScript only looks English, but does not have all the essential >qualities of natural languages. Like Python and others, it's too consistent >and ram some OOP or Object Models down your throat. Don't start me on Apple. >When it comes to Apple, they always push for useless change. In the past >years they degraded programers' social status with the oh--sooo-cute color >iMacs and G3 towers, and in September they'll have this >oh--sooo-cute-I'm-drooling iBook and AirPort technology probably semi-stolen >from unix's RFC standards. (RFC is an abbreviation for Really Fucking >Common) IIRC, AirPort is licensed from Lucent. Anyway... damn straight! Back to the bad old days of gnawing out the holes in punched cards with your canines, 'cos the hole punching machine costs another $500,000, fits into a small warehouse, uses enough electricity to electrocute England and weighs more than the Earth itself. Programming that got respect. Real spit and bailing-wire programming. None of this namby-pamby open-up-a-spreadsheet-record- a-macro-and-knock-it-about-a-bit "programming" for us, eh? How unfortunate that computers (and programming) have been brought to the attention of the bungled and the botched by the Great Satan Apple and their evil couterparts in Redmond. When the proletariat figure out how easy all this stuff *really* is, then they're going to turn on us and rip us to shreds like a pack of hungry wolves for charging them so damned much all these years. >As Larry has well said, Perl is a post-modern language. The language of the >New Age era. Pity all the hippies have got colostomy bags and Zimmer frames these days. We're post-post-modern now, or hadn't you heard? (Turn up the hearing aid... ;) Gary p.s. To the other poster (who I really cannot be bothered searching for) who asked if the point of learning programming was just to earn vast lumps of cold, hard cash at a F500 company: yes it is. -- Gary O'Keefe gary at onegoodidea.com You know the score - my current employer has nothing to do with what I post From cbbrowne at news.hex.net Mon Aug 30 22:18:17 1999 From: cbbrowne at news.hex.net (Christopher Browne) Date: Tue, 31 Aug 1999 02:18:17 GMT Subject: Python Versus Whitespace (Re: Best language for graphical apps?) References: <2vwvuijaxf.fsf@spls61.ccs.mt.nec.co.jp> <935778741snz@vision25.demon.co.uk> <7q98h5$n2815@george.sabre.com> Message-ID: On 28 Aug 1999 21:16:49 -0400, Collin W. Hitchcock wrote: > On some earlier date, Christopher Browne wrote... >> There seem to be dogmatic positions about the evils of Python's >> ability to use whitespace to signify control structures; >> unfortunately, the dogmatic positions seem more often based on blind >> faith than on tenable arguments. > >A list of tenable arguments why I hate white-space syntax dependent >languages: > > 1) A whole slew of trouble with code that uses tabs. Use your > imagination. Read about the history of "make". I've never had problems with makefiles, no, never... :-) > 2) For bracket grouped languages I prefer the indenting style: > > block_start > { > sub_statement > sub_statement > } > > In Tcl it's a syntax error to put the opening bracket on a new > line. In Python the brackets don't exist. So now I'm looking at > someone else's hideous code with 240 column lines. It's written so > that it's completely incomprehensible unless you can see whole > lines at a time, so you have to put your editor in wrap mode. If > the brackets exist you can first make sure the code is indented > consistently and then look for opened and closed brackets in the > same column. You can filter out all the line wrap garbage when > you're looking at block structure. Analyzing Lisp code is Pretty Easy on a similar basis; the lack of ambiguity is indeed attractive. > 3) If you are trying to write a code generator, white-space syntax > dependent languages are a nightmare. So much easier to produce the > code without worying about indenting and then run a second program > to indent it. This is *not* one that I see as being a big problem. In a brace-structured language, you need some structure that counts braces. That parallels the need, in a Python generator, to have some structure that counts the amount of whitespace in effect. They're isomorphic to one another. >4) You can introduce *hideous* bugs by cutting and pasting between >two differently indented sections of code. When white space >doesn't matter, you just paste and tell your editor to reindent. > >None of these are deal breakers -- you can work around all of them. >They just add to the general stress level. I already have enough >stress, thankyou. As you say, these can be worked around. Thank you for not merely making dogmatic comments; mere dogmatism is more common in such discussions. -- if (argc > 1 && strcmp(argv[1], "-advice") == 0) { printf("Don't Panic!\n"); exit(42); } (Arnold Robbins in the LJ of February '95, describing RCS) cbbrowne at ntlug.org- From stalnaker at acm.org Sun Aug 15 15:04:28 1999 From: stalnaker at acm.org (Max M. Stalnaker) Date: Sun, 15 Aug 1999 12:04:28 -0700 Subject: Does Python run under Windows 2000? (build 2031) References: <37B40D58.DD6AADC0@RobotVision.com> Message-ID: <37B70F3C.1A194BB5@acm.org> It works for me, but I am on build 2072, which I think of as RC1. 2031 sounds like beta 3. In my configuration, win32all-125, in common with some other software, puts some dlls into the c:\documents and settings subdirectories, unexpectedly. This results in a need to use regedit and then manually register some com components. Not all users have reported this to be true. I spent $50 for registration of win32all with Mark Hammond and he provided excellent technical support for me in getting past the regedit and com registration difficulties. This is very nice to have on an unsupported os. python itself showed no difficulties in installing. "James E. Green" wrote: > I'm running Windows 2000 RC1 (build 2031, the very latest). Will Python > run under this OS? Only NT4 is mentioned on the Python web page. > > Thanks, Jim Green -- Max M. Stalnaker mailto:stalnaker at acm.org http://www.astarcc.com 253-565-2366 fax 253-565-0892 From e_l_green at hotmail.com Sun Aug 1 22:52:43 1999 From: e_l_green at hotmail.com (Eric Lee Green) Date: Sun, 01 Aug 1999 19:52:43 -0700 Subject: RMI and Python References: Message-ID: <98A6BBA3E6835B16.321CAF48B0B697EF.8965F6D61944B70C@lp.airnews.net> Tim Egbert wrote: > Java is able to do remote method invocation (RMI) which is a neat concept. > It is the basis for Jini, another neat idea. Does Python have anything > like RMI? It's easy enough to create one, using the SimpleTCPServer class. In fact, I have done it. As soon as I get a chance to re-visit the code and clean up some boojums I will toss it onto my web site (it currently is functional and working, but there are some known denial-of-service problems that I wish to tackle before considering it halfway finished). If you're wanting to do it youself, think HTTP -- HTTP is at its heart a remote method invocation mechanism, you have the HTTP libraries available, you have the BaseHTTPServer available so that you can add your own methods (HTTP is NOT restricted to GET and POST, though that's all that most HTTP servers understand!), and Python's 'pickles' make it very easy to wrap up data to pass it to a remote server. -- Eric Lee Green http://members.tripod.com/e_l_green mail: e_l_green at hotmail.com ^^^^^^^ Burdening Microsoft with SPAM! From tchrist at mox.perl.com Sat Aug 14 17:52:34 1999 From: tchrist at mox.perl.com (Tom Christiansen) Date: 14 Aug 1999 14:52:34 -0700 Subject: Regarding the magical "or" operator Message-ID: <37b5d712@cs.colorado.edu> I was wondering how often most python programmers make use of that remarkably nifty property of the logical operators, in which they produce not merely 0 or 1, but the value is last looked at when it decided whether the expression was true or false. For example: print [] or "Some" Some print "Peter" and "Paul" Paul print (20 - 4*5) or None None My question is this: have you ever had an urge for it (or a variant) to care about the difference between None and any other false value? I am certainly *not* asking for such a thing. I'd just like to know whether anyone ever cared. For example, given these three functions: def f(): return [] def g(): return None def h(): return ["Some"] Consider these prints: print f() or h() ['Some'] print g() or h() ['Some'] The idea would be a version of "or" that would return the first non-None value. For example, supposing this were called "nor" (silly name, but this is *not* a proposal): print f() nor h() [] print g() nor h() ['Some'] The argument is that this would be used not with prints, but with assignments, as in a = f() nor g() The reason I ask is not because I actually want such a thing. Gosh, no. I'm rather uncomfortable with the idea. I'm just trying to gather some understanding and perspective for use with the folks who *would* like such an oddity. :-) --tom -- Mister Catbert, the company is trying to force me to use a different kind of computer. You're the human resources directory. what are you doing to sop this religious persecution?! What every happened to "Diversity"?? The longer you verk here, diverse it gets. next. --Scott Adams, "Dilbert" From emile at fenx.com Sun Aug 1 13:28:07 1999 From: emile at fenx.com (Emile van Sebille) Date: Sun, 1 Aug 1999 10:28:07 -0700 Subject: spawnv References: <19990801171952.JFVG5731@default> Message-ID: <1w%o3.4414$VL2.474450@news.direcpc.com> Hi Craig, This works on WIN95: os.system(r"start /w c:\windows\notepad.exe") It leaves a dos window displayed however. If you change the properties of the dos window to minimized, the next time through it won't display. I imagine it's possible to preset this, but I haven't tried. Does anyone know how to stop this or get around it? -- Emile van Sebille emile at fenx.com ------------------- Craig Curtis wrote in message news:19990801171952.JFVG5731 at default... > I am trying to spawn c:\windows\notepad.exe from a Python program. I want > the python script to wait for Notepad to exit. > How can I do this? > > I have tried all combinations I can think of using execv, spawn, system and > cannot get it to work. > > Could someone please post the exact command sequence to type in. > > Thanks in advance, > Craig Curtis > > From goertzen at norscanNOSPAM.com Thu Aug 26 17:58:35 1999 From: goertzen at norscanNOSPAM.com (Daniel Goertzen) Date: Thu, 26 Aug 1999 21:58:35 GMT Subject: static python build Message-ID: How do I build python statically on linux so I don't need any of the shared libraries? Dan. From fdrake at acm.org Wed Aug 4 13:45:56 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Wed, 4 Aug 1999 17:45:56 GMT Subject: building embedded classes as in C/C++ In-Reply-To: <37A86B09.CB163857@psych.ucsb.edu> References: <37A78579.9856D16@psych.ucsb.edu> <37A86B09.CB163857@psych.ucsb.edu> Message-ID: <14248.31828.719428.809970@weyr.cnri.reston.va.us> Andy Beall writes: > Here, 'p' does not seem to be class-wide while 'pos' and 'ang' are. Why > the discrepancy? Andy, The 'p' set in the class statement is class-wide. Setting 'p' on an instance creates a new instance-specific binding for 'p', which is retrieved on subsequent attribute accesses since it overrides the class-wide value. If you accessed it as Object.p, the original value would still be available. This is a situation where the "binding" and "namespaces" terminology is pretty important and makes it easier to understand. There really aren't variables in the C/C++/lots-of-others sense. Sections 9.1 and 9.2 in the tutorial may be worth reviewing here: http://www.python.org/doc/current/tut/node11.html -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From wtanksle at dolphin.openprojects.net Mon Aug 23 22:18:53 1999 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Tue, 24 Aug 1999 02:18:53 GMT Subject: Necessity of ``pass'' References: Message-ID: On 23 Aug 1999 23:32:44 +0200, forcer wrote: >Hi there. >Lately, i've been thinking about Python. While it is an >exceptionally clean language, it has one very obvious wart: >The ``pass'' statement. I disagree that 'pass' is an obvious wart. I think it's very nice. >To quote the reference manual: > pass is a null operation -- when it is executed, nothing > happens. It is useful as a placeholder when a statement is > required syntactically, but no code needs to be executed, for > example: > def f(arg): pass # a function that does nothing (yet) >one could write > if foo: > bar >Syntactically this does not introduce any ambiguity. The only >problem i see is that the "pass" version is more readable. Precisely. You're suggesting a change with the sole purpose of reducing redundancy. The problem is that humans _need_ redundancy. Not only does redundancy help us to read the code, it also helps the computer to find our errors. Another example of redundancy in Python -- and one with just as much chance of being changed -- is the ':' symbol. Take a look at the following: if foo: pass bar if foo pass bar if foo pass bar As you see, the colons aren't necessary. They're only there as a convenience to the programmers and readers. > --forcer -- -William "Billy" Tanksley From .xanafonte at mail.pt Tue Aug 31 19:59:54 1999 From: .xanafonte at mail.pt (Xana) Date: Tue, 31 Aug 1999 23:59:54 GMT Subject: position on the screen Message-ID: <37cc6b98.873539@news.telepac.pt> I'm working with PythonMegaWidgets and i have a problem using Pwm.dialog boxes. Can anyone tell me if (and how) I can define the position in wich the window will appear in the screen ? thanks in advance Xana From python-list at teleo.net Sat Aug 21 03:21:12 1999 From: python-list at teleo.net (Patrick Phalen) Date: Sat, 21 Aug 1999 00:21:12 -0700 Subject: More random python observations from a perl programmer References: <7ple6r$kf0@ds2.acs.ucalgary.ca> Message-ID: <9908210028270C.00619@quadra.teleo.net> On Fri, 20 Aug 1999, Neil Schemenauer wrote: > As no one seems to have written a reply to all of Tom's points, I > will make an effort. Some of this information has been already > presented in other posts. Hopefully this will be an accurate > summary. [deliciously well-balanced summary snipped] Accurate indeed; and a real pleasure to read. This is the Usenet at its best. You have such a talent for clear explanation that I would hope you might try your hand at writing some succinct Python tutorials for beginners. I'm sure they would earn a place beside Guido's own Tutorial, Learning Python, and the Grimoire. From rodzilla2000 at my-deja.com Wed Aug 4 23:22:31 1999 From: rodzilla2000 at my-deja.com (rodzilla2000 at my-deja.com) Date: Thu, 05 Aug 1999 03:22:31 GMT Subject: Stupid question about .EXE References: <7o93uk$sjrn$1@reader2.wxs.nl> Message-ID: <7ob01f$ghn$1@nnrp1.deja.com> In article <7o93uk$sjrn$1 at reader2.wxs.nl>, "Rik" wrote: > Hi everybody, > > I've got a (stupid) question. I'm learning myself Python now, but I still > have a question: > How can you make .EXE files with python??? I'm using Python 1.5.2 (final) > for Windows. > > Greets > > Rik > Hi, I'm new to python too... I'm sure that python itself cannot make .EXE files, but I have read somewhere that you can encapsulate a python script into an EXE... Don't know what the name of the utility is, or if it's executable itself or is c source code to allow the making of a python .EXE Does anyboy know what the name of the utility is and where it's located? I read somewhere about it, but can't remember.... Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From arcane*SPAM*dragon at home.com.invalid Thu Aug 19 10:10:50 1999 From: arcane*SPAM*dragon at home.com.invalid (Chris Herborth) Date: Thu, 19 Aug 1999 14:10:50 GMT Subject: CVS classes in Python References: <37B9969B.BB40C25F@primenet.com> <934914414snz@vision25.demon.co.uk> Message-ID: According to Phil Hunt : > In article <37B9969B.BB40C25F at primenet.com> > yerny at primenet.com "Bryan Jernigan" writes: > > I'm a newbie to Python and I would like to create a Python script to > > maintain a distributed CVS CM system. Before I re-invent the wheel, I > > was wondering if anyone has some decent CVS classes and/or functions. > > If so, please drop me a line. > > Why not have your Python classes acting as a front end to CVS or PVS? This is what I did for some RCS-aware SGML parsers I've written in Python; they just call out to the RCS commands when necessary, via os.system(). Not very sophisticated, but it works. :-) -- ----------================================================---------- _ Chris Herborth, R&D, Technical Writing | \ _ Arcane Dragon Software Arcane Dragon -==(UDIC)==- | < /_\ arcane dragon at home dot com DNRC Holder of Past Knowledge |_/ \_ From andrew at starmedia.net Thu Aug 19 18:31:43 1999 From: andrew at starmedia.net (Andrew Csillag) Date: Thu, 19 Aug 1999 22:31:43 GMT Subject: More random python observations from a perl programmer References: <199908191634.KAA01333@jhereg.perl.com> <37BC75F0.B482DA6D@starmedia.net> <37bc4352@cs.colorado.edu> Message-ID: <37BC85CF.7AA4A23B@starmedia.net> Tom Christiansen wrote: > > [courtesy cc of this posting mailed to cited author] > > In comp.lang.python, > drew_csillag at geocities.com writes: > :There are the python manuals which are excellent, available at: > :http://www.python.org/doc/ (linked to from the homepage) > :available in your choice of HTML, PostSript, PDF, Info, LaTeX and > :windows help. > > The fact that they did icky windows help and not man pages says > something significant. Yes, that python has a decent sized population of windows users. I'm no windows guy but PythonWin is way cool from what I've seen (IDE, cool COM support, etc.). -- "Programmers are just machines that convert coffee to executable code" -Unknown "Drew Csillag" From shecter at darmstadt.gmd.de Thu Aug 19 16:13:21 1999 From: shecter at darmstadt.gmd.de (Robb Shecter) Date: Thu, 19 Aug 1999 22:13:21 +0200 Subject: More random python observations from a perl programmer References: <37bc1339@cs.colorado.edu> Message-ID: <37BC6561.6B4CC7@darmstadt.gmd.de> Evan Simpson wrote: > ...Python programmers appear to prefer hyperlinked over man-style > documentation... Well, I don't think we should base assumptions on the posts of one vocal advocate, but - I'd say it has to do with the language itself: Perl is "old school", along with awk, and sed: The complexity of the system is in the language definition itself. Pure OO/Component-like libraries are a secondary source for features. In this environment, having docs that read linearly, more like a book, may be the best solution. Python is "new school", along with Java and Smalltalk (years ahead of its time). The language is intended to be simple, and the complexity is in the libraries. In this case, having highly structured, hyperlinked refs may be the best way to go. - Robb From gmcm at hypernet.com Mon Aug 9 23:46:07 1999 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 9 Aug 1999 22:46:07 -0500 Subject: Redirect stderr In-Reply-To: <87lnbk8kow.fsf@linuxcare.com> Message-ID: <1277869823-7876266@hypernet.com> David N. Welton wrote: > I wish to do this: > > #!/usr/bin/python > > import sys > import os > > f = open("goober", "w") > > sys.stderr = f > sys.__stderr__ = f > > os.execv("/bin/ls", ["/bin/ls", "sdfsdfdsfds"]) > > and have it dump the errors into 'goober'. I'm having some > difficulties figuring out exactly why this isn't working, or how I > ought to be doing this. Because sys.stderr is a Python file object, which (by default) uses C's stderr. Reassigning it doesn't change C's assignment. If you want to twiddle file descriptor 2, you can do it with os.close(2) etc. Or be lazy and just redirect it on the command line to the subprocess. - Gordon From ngps at madcap.dyn.ml.org Fri Aug 20 11:15:34 1999 From: ngps at madcap.dyn.ml.org (Ng Pheng Siong) Date: 20 Aug 99 15:15:34 GMT Subject: ANNOUNCE: M2Crypto 0.01 Message-ID: <37bd7116.0@news.cyberway.com.sg> Hello, I am pleased to announce the release of M2Crypto 0.01; the package is available at http://www.post1.com/home/ngps Following is the README: The M2 Python Crypto Toolkit 0.01 ----------------------------------- The M2 Python Crypto Toolkit (M2Crypto) == Python www.python.org + OpenSSL www.openssl.org + SWIG www.swig.org Python is an interpreted, dynamic-typing, object-oriented programming language that is often compared to Perl, Scheme, Tcl or Java. SWIG - Simplified Wrapper and Interface Generator - provides glue to link C/C++ libraries with the above-mentioned languages. M2Crypto presents a Python interface to OpenSSL, via SWIG. M2 stands for "me, too!"* This release includes the following: DH, RSA, DSA, RC4, MD5, SHA1, RIPEMD160, and the EVP interfaces for message digests, HMACs, and symmetric ciphers. It requires Python 1.5.2, OpenSSL 0.9.4, and, optionally, SWIG 1.1p5 or later. It has been tested under FreeBSD 2.x, Redhat Linux 5.2, and WinNT4. It should run anywhere Python and OpenSSL run. M2Crypto is released under a license similar to Python's. See LICENSE for details. For now, M2Crypto is intended to be a prototyping tool; it is _not_ for writing production crypto software. In particular, note the following caveats: 1. There will be memory leaks, because of pointer ownership contention between Python and SWIG. (These would be due to my misprogramming.) 2. There is no memory locking/clearing for keys, passphrases, etc. 3. The PRNG has no interface for CS**; it is unlikely to be CS***. 4. AFAIK, Python and OpenSSL have not been subjected to the full attention of the Bugtraq crowd. M2Crypto's handling of active hostile input is probably suspect. Of course, I hope to address these in future. Meanwhile, have fun! Your feedback is welcome. Ng Pheng Siong ngps at post1.com * Similar software are Marc-Andre Lemburg's mxCrypto, and two (?) Python interfaces to the SSL portion of SSLeay/OpenSSL. ** Continuous seeding. *** Cryptographically strong. -- Ng Pheng Siong From mwh21 at cam.ac.uk Thu Aug 19 13:06:03 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 19 Aug 1999 18:06:03 +0100 Subject: More random python observations from a perl programmer References: <37bc1339@cs.colorado.edu> Message-ID: I'm going to be quite picky in some of what follows. Tom Christiansen writes: > COOLNESS: > Python's print() function is more like the Perl debugger's > "x" command; that is, it's recursive and pretty-printed. Python doesn't have a print() function. It has a `print' statement. > GOTCHA: (high) > Local variables are never declared. *Nothing* is ever delcared in Python. > GOTCHA: (medium) > If you have a function that expects two arguments, such as: > def fn(x,y): > return x + y > and you have a tuple of the two elements: > t = (1,2) > You can't just call that function: > print fn(t) > Or you get a "TypeError: not enough arguments; expected 2, got 1" > error. You have to use this apply() function to get around this > issue: > print apply(fn,t) > 3 Well, no. How would you like to pass a tuple to a function? > GOTCHA: (medium) > Perl's hex() function is the opposite of Python's. Perl's hex > function converts 22 into 37. Python's hex function converts 37 into > 0x22. Oh my! Like hex, Python has oct() completely backwards from > Perl. Python's oct(44) returns 054, but Perl's oct(44) return 36. This would have to do with strings not being automatically coerced into numbers, methinks. > SIMILARITY: > Constructors and destructors (__init__ and __del__) aren't > automagically called in parent classes in Python. Neither > in Perl. This sucks, IMHO. > GOTCHA: (medium) > Things that return lists can't be used where a tuple is expected. > A function that returns a list must be coerced into a tuple to > use this, though. > def fn: return [1,2] > print "this %d is %d here\n" % fn() # ILLEGAL > print "this %d is %d here\n" % tuple(fn()) > The illegal part points out that this is an > TypeError: illegal argument type for built-in operation > Which isn't very helpful. I think this may have changed in the CVS sources. , Oh no, it hasn't. It should. > GOTCHA: (high) > Python has no manpages! The horror!!!!!!!!!!!!!!!!!!!!!! > ENODOC There's info format if you look for it and you have to have a CLI. > GOTCHA: (low) > Often Python's error messages leave something to be desired. > I don't know whether Is this a joke? This is improving. > GOTCHA: (medium) > All ranges are up to but *not including* that point. So range(3) > is the list [0,1,2]. This is also true in slices, which is the > real gotcha part. A slide t[2:5] does not include t[5] in it. This does mean that range(a,b) or t[a:b] has b-a elements in it. > DISSIMILARITY: > This also means that instead of substr() in Perl, you slice a string > as in > s = "string" > print s[2:4] > ri > Yes, that's all you got. Strange, eh? See below on ranges. What were you expecting? > GOTCHA: (medium) > Slices in Python must be contiguous ranges of a sequence. > In Perl, there's no such restriction. At some point Python will probably support `extended slice syntax' like so: range(0,10)[1:4:2] => [1,3] Numerical Python already does this. > GOTCHA: (medium) > You can't slice dictionaries at all in Python. In Perl, it's > easy to slice a hash, and just as sensible. Huh? What would that mean? There's no reason to suspect that the keys of a dictionary are ordered. > GOTCHA: (high) > As we saw with lists, because everything is a reference, and there's > no way to dereference that reference, this means that again there > is also no built-in, intuitive way to copy a dictionary. Instead, > the suggested work-around is to write a loop: > new = {} > for key in old.keys: > new[key] = old[key] > But this is guaranteed slower, because it's not at the C level. new = old.copy() > GOTCHA: (medium) > There's no way to set up a permitted exports list. The caller may have > anything they ask for. This is a general Python convention; you *can* shoot yourself in the foot if you try hard enough. Means the debugger can be written in Python, for one thing. > COOLNESS: > DBM files seem (?) to automatically know about nested datatypes. Ah, that's pickle. pickle is cool. > GOTCHA: (high) > Scopes don't nest in Python, but they they do in Pascal, Perl, or C. > This is supposedly "simpler", but it's very suprising in many ways: > x = 1 # global > def fn1(): > x = 10 # implicit local > def fn2(): > print x # whose? > fn2() > fn1() > The answer is that it prints 1, because fn2 has no x in its local > scope, so gets the global. The suggested work-around is > def fn2(x=x): > using default parameters. Yes this is a bit annoying. The Right Way to attach state to a function is a class, of course. Not that that helps much. > GOTCHA: (low) > List objects have built-in methods, like > l.append(x) > But string objects don't. You have to import > from the string module to get them, and then they're > functions, not methods. This will change in 1.6. > GOTCHA: (low) > You have insert and append methods for lists, but only > a del function. del statement. > GOTCHA: (high) > Because you can't use readline() to get a number, people seem to enjoy > calling eval() just to get a string turned into a number: > import sys > str = sys.stdin.readline() > num = eval(x) > This is scary. Do people really do that? I don't. It can be made safe: num = eval(string,{'__builtins__':{}}) but that's a bit hairy. Use float instead. > Even scarier is the propensity for calling input(), > which auto-eval()s its input to make sure it's the right "type". > (Funny that a soi-disant "typeless language" should be so danged > picky about this.) Python is more "dynamically typed" than "typeless", I'd say. > GOTCHA: (low) > Regexes default to emacs style, not egrep style! Not any more. import re. > GOTCHA: (low) > Python's eval() only works on expressions, not full code blocks full > of statements. You need exec() for the whole thing. Writing exec() suggests it's a function; it isn't, it's a statement. > GOTCHA: (medium) > Anything that python doesn't like, it raises an exception about. > There is no fail-soft. Even non-exception issues raise exceptions. > It's pervasive. K&P curse languages that force people who want > to open() a file to wrap everything in exception code, saying that > "failing to open a file is hardly exceptional". This is a bit of a flaw, IMHO. Mind you, it forces you to pay attention. > GOTCHA: (medium) > You can't just interchange tuples and lists in python the way > you can lists and arrays in Perl. This is an error: > import sys # otherwise, no argv for you, buddy > print "First arg %s and second %s" % sys.argv[1:3] > because you need > print "First arg %s and second %s" % tuple(sys.argv[1:3]) This has been changing over the last year or so. I expect the trend will continue. > COOLNESS: > I believe that Python checks the prototype signature on methods > as well as on functions. I wonder whether Tim Bunce's ideas run-time > evaluation of prototypes for Perl might be able to do this. You mean perl doesn't? Ouch. > QUESTION: > What is and what is not thread safe? Everything is, but in a crude way. There's a global interpreter lock. This isn't the best of situations. I hope this post has raised the signal-to-noise ratio in the perl/Python debate (it could hardly lower it). Michael From I.Clarke at strs.co.uk Mon Aug 16 07:41:57 1999 From: I.Clarke at strs.co.uk (Ian Clarke) Date: Mon, 16 Aug 1999 12:41:57 +0100 Subject: Enough [Was Re: Why use Perl when we've got Python?!] References: <1277478426-31364719@hypernet.com> <37b58c4a@cs.colorado.edu> Message-ID: <37B7F905.B7FF8DE0@strs.co.uk> > That man, along with Ian Clarke, have stirred up the biggest flame war > in the Perl newsgroup that we're seen for a long time, inflicting their > standard overrighteous prattle on us. That is rich coming from the guy that sets up automatic monthly emails to people because he doesn't like their quoting style. As for stirring up the flame war, Tom has posted around 60 messages on that thread, more than most if not all others, many of them rude, patronizing, and inflammatory. I have posted around 20, and in all cases I remain polite and respectful to the people I am posting to (even, in most cases, Tom). If anyone would like some samples of Tom's postings I would be happy to supply (he sent 'courtesy' carbon copies to my email address of most of his utterances). To describe this as hypocrisy is an understatement. Ian. From MHammond at skippinet.com.au Thu Aug 12 09:45:11 1999 From: MHammond at skippinet.com.au (Mark Hammond) Date: Thu, 12 Aug 1999 23:45:11 +1000 Subject: Problems importing Modules under win32 References: <7oud1c$vcd$1@nnrp1.deja.com> Message-ID: <7ouj5c$jja$1@m2.c2.telstra-mm.net.au> Maybe an early version of sax with a later version of Python? Is there an __init__.py in the xml and sax subdirectories? What do: >>> import xml >>> import xml.sax Yield? Mark. thomsensven at my-deja.com wrote in message <7oud1c$vcd$1 at nnrp1.deja.com>... >Hi, > >I wanted to try out saxlib, but I can't import it under Windows NT: > >dir-structure: From n89553 at squid.uni-paderborn.de Fri Aug 6 10:15:03 1999 From: n89553 at squid.uni-paderborn.de (Mirko Liss) Date: Fri, 06 Aug 1999 16:15:03 +0200 Subject: Stupid Question? References: Message-ID: <37AAEDE7.86687CF4@squid.uni-paderborn.de> jim moore wrote: > > Is there a bulit in function that will give you N evenly spaced numbers > between X1 and X2. For example: 10 numbers between 0 and 1 ([0.1, 0.2, 0.3, > ...]) > It would be similar to MATLAB's linspace. > How about a function similar to range but allowing a floating point step? > Seems like there would be one out there, so I thought I'd check before I > wrote one. If you want to do numerics in python, you might want to install the LLNL-Distribution. It provides matrix-oriented math like Matlab and there's good documentation. regards, Mirko -- M Li?, From fredrik at pythonware.com Thu Aug 26 02:38:38 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 26 Aug 1999 06:38:38 GMT Subject: problem with im.show() References: <7q1f58$r7v$1@tribune.mayo.edu> Message-ID: <007301beef8d$a221bda0$f29b12c2@secret.pythonware.com> Tom Kinter wrote: > >>> im.show() > TypeError: illegal argument type for built-in operation it's a bug. here's a fix: http://www.python.org/pipermail/image-sig/1999-August/000826.html From phd at emerald.netskate.ru Mon Aug 9 04:27:08 1999 From: phd at emerald.netskate.ru (Oleg Broytmann) Date: Mon, 9 Aug 1999 12:27:08 +0400 (MSD) Subject: International characters and Python's string functions on Linux In-Reply-To: Message-ID: On Sat, 7 Aug 1999, Alexander Staubo wrote: > > import locale > > locale.setlocale(locale.LC_ALL, "") > > > Good idea, but: > > Python 1.5.2 (#9, Jul 2 1999, 04:33:02) [GCC 2.8.1] on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> import locale > Traceback (innermost last): > File "", line 1, in ? > File "/usr/local/lib/python1.5/locale.py", line 4, in ? > from _locale import * > ImportError: No module named _locale > >>> > > This is Slackware Linux 2.2/libc6. Should I configure Python with some > kind of magic parameter for the locale stuff to work? Just recompile python and enable _locale module (or compile _locale yourself). > -- > Alexander Staubo http://www.mop.no/~alex/ > "Elvis skipped around the car and threw open the trunk. > 'Hoopla!' he was heard to say, 'This is a 7.62mm M134 General > Electric Minigun. Up to 6,000 rounds per minute. 7.62mm X 51 shells. > 1.36kg recoil adaptors. Six muzzle velocity of 869m/s.' > 'Oh,' said Rex, 'So that's what it is.'" > --Robert Rankin, _They Came And Ate Us: Armageddon 2: The B-Movie_ Oleg. ---- Oleg Broytmann Netskate/Inter.Net.Ru phd at emerald.netskate.ru Programmers don't die, they just GOSUB without RETURN. From greg.ewing at compaq.com Wed Aug 18 19:09:01 1999 From: greg.ewing at compaq.com (Greg Ewing) Date: Thu, 19 Aug 1999 11:09:01 +1200 Subject: representation of unbound methods - strange behaviour References: <37bbecf1.100354231@news.omnilink.de> <14266.59462.274125.746880@dolphin.mojam.com> Message-ID: <37BB3D0D.A66BAE0E@compaq.com> Skip Montanaro wrote: > > I believe it is constructing the method name on-the-fly using the names it > finds in the class and function. Yep. A slightly different test reveals what is going on: def h(): pass class A: pass A.f = h A.g = h print A.f print A.g Output: Greg It's not using the attribute name. > > >>> class A: pass > ... > >>> def foo(): pass > ... > >>> A.f = foo > >>> A.g = foo > >>> A.f > > >>> A.g > > > Skip Montanaro | http://www.mojam.com/ > skip at mojam.com | http://www.musi-cal.com/~skip/ > 847-971-7098 From rav at smo3k.z.pl Wed Aug 4 10:05:36 1999 From: rav at smo3k.z.pl (Rafal Smotrzyk) Date: Wed, 04 Aug 1999 14:05:36 GMT Subject: An idea - request for comments References: <37A6A2DB.9B11FB01@strs.co.uk> Message-ID: #Simple but working import re class Response: def __init__(self): self.HTMLDocument='' def write(self,adata): self.HTMLDocument=self.HTMLDocument+adata def GetTextAsHTMLText(s,repldict={}): for akey in repldict.keys(): c=re.compile('\<\%\= *'+akey+' *\%\>', re.I) s=c.sub(repldict[akey],s) c=re.compile('\<\%', re.I) s=c.sub('""")',s) c=re.compile('\%\>', re.I) s=c.sub('Response.write("""',s) s='Response.write("""'+s+'""")' aresponse=Response() gdict={'Response':aresponse} exec s in gdict,repldict return aresponse.HTMLDocument def DoTest(): ahtmlsource=r""" <% Response.write('

'+ScriptName+'

\n') Response.write('') x=0 while x<10: s='\n'%('d1_'+`x`,'d2_'+`x`) Response.write(s) x=x+1 Response.write('
%s%s
') %>

<% for i in range(10): Response.write(`i`+',') Response.write('
') %> Test line 1 = <%= Test1 %> Test line 2 = <%=Test2%>

""" adict={'Test1':'this is page constant','Test2':'another constant','ScriptName':'This is script name'} s=GetTextAsHTMLText(ahtmlsource,adict) print s if __name__=='__main__': DoTest() # Rafal Smotrzyk From che at debian.org Tue Aug 24 16:26:37 1999 From: che at debian.org (Ben Gertzfield) Date: 24 Aug 1999 13:26:37 -0700 Subject: Python equivilent of pack()? References: <14274.61530.251401.762453@weyr.cnri.reston.va.us> Message-ID: >>>>> "Fred" == Fred L Drake, writes: Bit> My question is this: is there a functional equivilent to the Bit> Perl pack() and unpack() functions in Python? Or even better, Bit> is there an easier way to do what I want with Python? If not, Bit> how many people think this would be Fred> Take a look at the struct module; the pack() and unpack() Fred> functions are exactly what you're looking for! (What names Fred> were you looking up in the index of the Library Reference? Fred> I'll add them to the index if they make sense to others.) Fred, I think the problem is that the link to the index of all functions in the library reference is hidden way down at the bottom of the page, and as a very non-descript button hidden at the upper-right hand corner of the page. In fact, I had no idea until just now that such an index even existed for Python! I think it must not be too uncommon for folks to miss out on the fact that there's a function index to the library reference. Perhaps there should be a big fat bold link to it at both the top and bottom of the page. It would also be a good idea to use better icons than 'toc' 'm' and 'i' at the top of the page; I know I completely overlooked them until just now because they weren't very noticeable. Ben -- Brought to you by the letters R and Z and the number 4. "If you turn both processors off, you will have to reboot." Debian GNU/Linux maintainer of Gimp and GTK+ -- http://www.debian.org/ From tismer at appliedbiometrics.com Thu Aug 12 07:59:24 1999 From: tismer at appliedbiometrics.com (Christian Tismer) Date: Thu, 12 Aug 1999 11:59:24 GMT Subject: Macro preprocessor. References: Message-ID: <37B2B71C.E380A71@appliedbiometrics.com> Kaz Kylheku wrote: [description of a cute macro processor skipped] > Okay, enough. :) I'll probably get hate mail now about being off topic. No hate mail, but some thoughts: I can think of macro processors being useful for verbose, clumsy languages. For sure it makes sense to use them for ASM, C(++), and sendmail, for instance. But why for Python? Python is short, concise, readable, has a cute class system and introspection. Would any of the above be improved by introducing macroes, new syntax, namespaces, and would this cost be justified? There are a few cases where I admit that I generate scriptlets on-the-fly using the formatting operator. I can also imagine that macroes could be used to make debugging easier than with conditionals in rare cases. Maybe I would like to splice parameterized function bodies into a caller, maybe there is a cleaner compromise somewhere between textual replacement and the bytecodehacks approach. But: Plain textual replacement is covered good enough by the % operator, if this is needed. Macroes on the token level are fine for languages with limited namespaces, no inheritance features and so on. Python has these to a very high extent, so what would macroes help what cannot be done by classes and inheritance, which justifies another level of indirection, new syntax, and all of that? If I would introduce macroes into Python at all, then probably on the parser level, in order to replace nodes by equivalent constructs which are faster or would be otherwise less readable. Conclusion: I consider it a virtue of a language if it is powerful enough to go without macroes. Macroes are needed for languages which have a lack of expressiveness, except for Scheme, where macroes are part of the language with the goal to use them to define language constructs. If introducing macroes for Python at all, then they should use the existing Python structures and namespaces, macro features should be bound to syntactic language elements and parts of expressions, should not introduce another level of indirection but work at runtime. And I'd wish to see an example where a macrofied source file is more readable than a plain one. IMHO, this all does not apply for Python, and it the last language where I would want to use macroes. This is no complaint against your implementation which I think is very useful for languages which really need it. please-keep-the-good-work - ly y'rs - chris -- Christian Tismer :^) Applied Biometrics GmbH : Have a break! Take a ride on Python's Kaiserin-Augusta-Allee 101 : *Starship* http://starship.python.net 10553 Berlin : PGP key -> http://wwwkeys.pgp.net PGP Fingerprint E182 71C7 1A9D 66E9 9D15 D3CC D4D7 93E2 1FAE F6DF and we keep the good language :-) From mal at lemburg.com Fri Aug 13 05:55:32 1999 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 13 Aug 1999 11:55:32 +0200 Subject: ifconfig C module References: <87g11o941w.fsf@linuxcare.com> Message-ID: <37B3EB94.68BE201F@lemburg.com> > I got permission to publish the results of my 'ifconfig' module. > > Since it's rather small, I thought I would post the whole thing here. > > I realize it's not perfect, but it does what I need. I'll accept > patches to make it better. I'm sure the license could be changed to > the Python one if there is interest in including it in the main > distribution. I'd suggest adding this to either the socketmodule.c or the fcntlmodule.c in the standard Python distribution. FYI, I've spiced up the file a bit and turned it into a package which is available here for easier install: http://starship.skyport.net/~lemburg/ifconfig-0.1.zip I changed the names a little in the above archive: Package name: ifconfig API: ifconfig.ifconfig >From David's code: The command ifconfig.ifconfig(interface_name), where interface_name is the name of the interface, such as 'eth0' or 'lo' returns a dictionary with the following keys: hwaddr: hardware address addr: ip address brdaddr: broadcast address netmask: netmask Great work, David ! I never thought it would be that easy to get at the hardware MAC address. Now the only question remaining is: how portable is this code ? E.g. does it compile on Windows ? Cheers, -- Marc-Andre Lemburg ______________________________________________________________________ Y2000: 140 days left Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/ From aa8vb at yahoo.com Thu Aug 5 09:40:20 1999 From: aa8vb at yahoo.com (Randall Hopper) Date: Thu, 5 Aug 1999 09:40:20 -0400 Subject: Python GUI In-Reply-To: <7ni69d$nc7$1@nnrp1.deja.com>; from Brad on Mon, Jul 26, 1999 at 05:35:41PM +0000 References: <7ni69d$nc7$1@nnrp1.deja.com> Message-ID: <19990805094020.A1838753@vislab.epa.gov> Brad: |Is there a Python GUI builder out there anywhere? Not that I'm aware of. Anyone know of one in-the-works? -- Randall Hopper aa8vb at yahoo.com From wiener at enews.nrl.navy.mil Wed Aug 11 08:27:52 1999 From: wiener at enews.nrl.navy.mil (Zach) Date: Wed, 11 Aug 1999 08:27:52 -0400 Subject: sys.argv attribute error Message-ID: <37B16C47.E6212B21@enews.nrl.navy.mil> Within a python file, I am trying to pring sys.argv, but I get an AttributeError with argv. I can print sys.path fine, however. Does anyone know why I would be having problems with printing argv? Thanks. From bennettt at am.appstate.edu Fri Aug 13 16:37:52 1999 From: bennettt at am.appstate.edu (TMGB) Date: Fri, 13 Aug 1999 16:37:52 -0400 Subject: Help: sendmail under MS NT References: <7p1pma$ak6$1@nnrp1.deja.com> Message-ID: <37B4821F.66E706AF@am.appstate.edu> Being new to Python, someone else may be able to give you a more efficient way to do this or maybe a real sendmail command. But, using smtplib.py I found that I had to initialize mailserver with a valid mail server and mail recipient for it to work. I also imported cgi, urllib, os, and my_mailtomessages which shouldn't be needed for this snippet. This is running Python and Netscape Enterprise Server on an intel NT box with the form data coming from an ALPHA NT box. ------------------ import smtplib import string # Get form data up here or any other code you may need # HERE BEGINS THE MAILTO Defaults PORTION OF THE SCRIPT mailserver="my.mailserver.appstate.edu" mailrecip="me at my.mailserver.appstate.edu" subject="ERROR" # Asign MAILTO results from form to mailto values # first get user's domain from email address and use their server to mail from mailserver=form["sentfrom"].value[string.find(form["sentfrom"].value,"@")+1:] mailrecip=form["sendto"].value subject=form["subject"].value sender=form["sentfrom"].value message=form["message"].value # send the mail mail=smtplib.SMTP(mailserver) mail.sendmail(sender,mailrecip,message) mail.quit -------------------- This has not been tested with a server outside of my Domain but has worked with different accounts on different mail servers in this domain. Thomas Shicheng wrote: > > Under unix platforms, using, for example, > > sendmail_cmd = "/usr/lib/sendmail -oi " > > to access the SMTP sendmail utility. > > Our enquery is: under Windows NT/95/98 platforms, > how to access the "sendmail" utility from within > python code? > > Thanks, > > Shicheng > > Sent via Deja.com http://www.deja.com/ > Share what you know. Learn what you don't. -- ---------------------------------------------------------------------- Thomas McMillan Grant Bennett Appalachian State University Computer Consultant II University Library bennettt at am.appstate.edu http://www.library.appstate.edu/admin/ Voice: 828 262 6587 FAX: 828 262 3001 Windows 95 is a 32-bit extension to a 16-bit patch for an 8-bit operating system that was originally coded for a 4-bit microprocessor. - Chris Dunphy Boot Magazine From bitwise at io.com Fri Aug 27 12:29:46 1999 From: bitwise at io.com (Bit Nik) Date: Fri, 27 Aug 1999 11:29:46 -0500 (CDT) Subject: A Plea For A Return To Sanity!!! In-Reply-To: <37C68564.15207535@callware.com> Message-ID: Hi. I just recently joined this newsgroup/mailinglist and I missed out a lot on the previous flame war (lucky me!). And I certainly don't want to stroke the coals and recreate the flame, but i'm very curious /how/ is Python lacking in documentation? This seems to be the major argument against it right? Also, who are these Python biggots people are always talking about?? I think the Python documentation is excellent, almost every question I've had so far has been answered by searching through python.org. Sometimes I've had trouble finding some bit of information and perhaps not even reading all of TFM have naively posted a question here to be met with a slew of helpful posts pointing my in the right direction. Pythoners you are to be commended! I think I have found a language I really like, and a part of the reason is because of all of the helpful support and good documentation. No doubt perl has a lot of cool things going for it too, the perl module collection is unbeatable, perl has excellent user support even though there are a few perl biggots. Most perlers I have met are a preaty logical bunch, and the perl mongers are on their way to certain world domination. Another quick question, are there such things as PUGs? (Python User Groups). I couldn't find any information on python.org... Andrew "mask compliments in the form of a question" Tanner From aahz at netcom.com Sun Aug 15 00:50:15 1999 From: aahz at netcom.com (Aahz Maruch) Date: 15 Aug 1999 04:50:15 GMT Subject: Why use Python when we've got Perl? References: <37b4ba01@cs.colorado.edu> <7p49l5$uv7$1@nnrp1.deja.com> <37b634a2@cs.colorado.edu> Message-ID: <7p5gu7$nlq@dfw-ixnews14.ix.netcom.com> [c.l.perl.misc removed] In article <37b634a2 at cs.colorado.edu>, Tom Christiansen wrote: > >So what do you do? You either bail out of this untenable situation, as >Larry Wall has done, or else "customer-service battle fatigue" sets in. >When that happens, people end up getting snapped at, sometimes mistaking >an honest learner for yet another beggar looking for handouts. I dare >say this would happen even in the best of families, given equivalent >circumstances. I do think that earnest individuals seriously wanting >to work hard are still given the same helping hand they always got. I've snipped the part of the post that I mostly agree with to disagree somewhat with that last sentence. Without going into details, there were a couple of module maintainers who treated me somewhat roughly. -- --- Aahz (@netcom.com) Androgynous poly kinky vanilla queer het <*> http://www.rahul.net/aahz/ Hugs and backrubs -- I break Rule 6 (if you want to know, do some research) From urner at alumni.princeton.edu Tue Aug 24 23:28:57 1999 From: urner at alumni.princeton.edu (Kirby Urner) Date: Wed, 25 Aug 1999 03:28:57 GMT Subject: Pro Python remarks to math ed folks (pointers) References: <37c2a51e.18050990@news.teleport.com> <37c2b213.49798667@news.teleport.com> <37C30FAC.C542DB6C@cybercable.fr> Message-ID: <37c36092.94476642@news.teleport.com> Jean-Claude Rimbault wrote: > def __repr__(self): # convert object to string > return 'Vector'+`self.data` OK, why not? I've added: def __repr__(self): return self.__class__.__name__ + str(self.data) And to my Poly class: def __repr__(self): return self.__class__.__name__ >>> v = vector.Vector(quad=(1,0,0,0)) >>> v Vector(1, 0, 0, 0) >>> v=v*2 >>> v=v+vector.Vector(quad=(0,1,0,2)) >>> v Vector(2, 1, 0, 2) >>> oTet = polys.Tetra() >>> oTet Tetra Without a separate __str__ method, print has the same behavior as just entering the object name. OK for my purposes, but anyone can tweak my code. Polyhedra have a lot of info associated with them. My __repr__ method might return a lot more data. Pondering this. Kirby PS: also fixed a bug in Poly() class, which is an abstract class -- designed only to be subclassed and not used directly. Before fix: >>> oPoly = polys.Poly() Traceback (innermost last): File "", line 1, in ? oPoly = polys.Poly() File "G:\python\polys.py", line 70, in __init__ self.distill() # distill edges and points from faces File "G:\python\polys.py", line 98, in distill for i in self.edges: AttributeError: edges After fix: >>> oPoly = polys.Poly() Abstract class From fdrake at acm.org Fri Aug 13 09:07:20 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 13 Aug 1999 13:07:20 GMT Subject: L postfix char on longs - what is the best way to discard it.? In-Reply-To: <934546409.21489.0.nnrp-14.d4e5b0e4@news.demon.co.uk> References: <934546409.21489.0.nnrp-14.d4e5b0e4@news.demon.co.uk> Message-ID: <14260.6280.851268.67080@weyr.cnri.reston.va.us> Jim Crumpler writes: > query = "... WHERE guff = %s" % repr(long(x))[0:-1] > > -- its ugly when you use alot of longs, but does the job.. So pack it up in a function: def l2a(x): return `long(x)[:-1]` query = "... WHERE guff = %s" % l2a(x) It's still not pretty, but it's more clear than coding it inline every place you need it! -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From esuzm at dcs.warwick.ac.uk Wed Aug 18 16:31:42 1999 From: esuzm at dcs.warwick.ac.uk (Andrew J Clover) Date: 18 Aug 1999 21:31:42 +0100 Subject: Bug in ntpath.exists? References: <7pbp9c$1b4$1@holly.csv.warwick.ac.uk> <006601bee8d1$b3b2a1f0$f29b12c2@secret.pythonware.com> Message-ID: <7pf57e$g1c$1@stone.dcs.warwick.ac.uk> Fredrik Lundh (fredrik at pythonware.com) wrote: > that's an NT file system "feature". trying to work around > it in the interface layer is probably a bad idea (when you > think you've got it 100% right, Microsoft releases yet an- > other implementation...) After spending all day tracking down other, unrelated MS bugs, I would just like to say: Curse Microsoft, all their developers, and all their families! Thank you. That's it. > fragment in os.listdir(prefix) > to make sure there's really something called fragment > with the given prefix. (better ideas are welcome...) Yeah, you're right. Since I'm using os.listdir to try to find similarly- named matches, it makes sense to use it here as well. Yes! Erm, hurrah! Cheers, -- This posting was brought to you by And Clover. (Sorry.) From tim_one at email.msn.com Tue Aug 17 20:04:18 1999 From: tim_one at email.msn.com (Tim Peters) Date: Tue, 17 Aug 1999 20:04:18 -0400 Subject: Unsorting(randomizing) a sequence In-Reply-To: <14265.35455.590852.517197@bitdiddle.cnri.reston.va.us> Message-ID: <000401bee90d$37627a80$eaa22299@tim> [Jeremy Hylton] > I've rather fond of the following approach: > > import random > > def randomize(a, b): > return random.choice([-1, 0, 1]) > ... > No idea how fast this is, though not very I expect. def test(N): d = {} for i in xrange(N * 6): x = range(3) x.sort(randomize) t = tuple(x) d[t] = d.get(t, 0) + 1 print N, d test(1000) 1000 {(2, 1, 0): 68, (0, 2, 1): 625, (0, 1, 2): 4443, (2, 0, 1): 289, (1, 2, 0): 155, (1, 0, 2): 420} With a chi square busting distribution like that, I'm not sure speed is the first thing you should be worried about . a-random-decision-may-not-yield-a-random-outcome-ly y'rs - tim From kernr at mail.ncifcrf.gov Fri Aug 20 01:04:40 1999 From: kernr at mail.ncifcrf.gov (Robert Kern) Date: Fri, 20 Aug 1999 05:04:40 GMT Subject: Python to Perl Conversions References: <37bc1303@cs.colorado.edu> Message-ID: <37bcd7ed.45850344@news.erols.com> I'll skip parts that have already been addressed (hopefully). On 19 Aug 1999 08:21:55 -0700, Tom Christiansen wrote: >Per your collective requests, here is one of the documents >with my collective observations from learning Python. Cool. [snips left unmarked] >delattr(object,name) n/a? "delete named attribute from object". > I suppose this might be > delete $obj->{name} > but that's pretty uncool to do it without > asking the object. BTW, Python does ask the object. If object is of a builtin type, this delattr (or "del object.attr" where "attr" is name's value) will call the C function that the type defines for __delattr__. If object is an instance of a class that has a __delattr__ method, then delattr will be equivalent to object.__delattr__(name). If object's class doesn't define __delattr__, then Python will simply delete that attribute. >eval(code) Same as Perl, but Perl's handles > statements, and python's only handles > expressions. Also, python hurls an > exception if it doesn't like you, > whereas Perl sets $@. People use this > to convert string to numbers. This is > a terrible security hazard. Not used so much for converting strings to numbers since int(x), float(x), and long(x) were changed to handle strings. This change (IIRC) was made from 1.4 -> 1.5, I believe, to solve this very issue. >exec(code) eval(code); plus see previous entry. I only say this in case you revise this document for use elsewhere: The parens are unnecessary. "exec" is a statement keyword. >getattr(obj,name) n/a? maybe just $obj->{$name}. I don't > understand why this exits. Oh heck, yes I > do. Because you can say > name = "widget_count" > obj.name > Because there's no interpolation and > otherwise it will look up name. Oh my. > This is like the apply() mess. It's really not so bad. This actually keeps Python simple and clear. IMO, it is not desirable for interpolation to exist for the usual attribute access method "obj.name". In debugging a complicated class definition, this unambiguity can be very important. We could add special punctuation to do this interpolation (which, if I read you correctly, perl does?), but getattr works just as well without futzing with the grammar. Truly, getattr isn't used a whole lot. I don't think that we'd benefit from interpolation. >hash(x) huh? "returns the hash value of the object, > if any" Most (all?) immutable objects and class instances that define a __hash__ method can be assigned a hash value with this function. This value is the same one that is used internally for dictionaries (IIRC). This can be useful for some arcane things. >input(prompt?) n/a. This reads and evals the input > stream! Needed because otherwise you can't > read a number. Or you could read the > string and convert it. Ick. Security > hazard waiting to happen. The number issue changed from 1.4 to 1.5, so no-one uses input to take care of numbers anymore. The only thing I think it would really be used for anymore is a quick-and-dirty interpreter shell. >reload(module) First delete from %INC, then require the > module again, as in: > delete $INC{"Module.pm"} > require Module; > Note that Python doesn't directly support > nested modules as in > require Dir1::Dir2::Dir3::Module; > except via a disgustingly named hackaround > module. Again (whoops, there goes my promise), this changed from 1.4 to 1.5. You owe us a shrubbery. >setattr(obj,name,value) $obj->{$name} = $value; > Interpolation wins again. See getattr. Shrug. Simplicity won in Guido's mind, I guess. >str(x) I thought this was the same as repr(). repr() *should* return a string that can be popped into eval and recover the original object (well, one that is equivalent in value to the original). str() is sometimes used for a prettier version designed for viewing, not evaluating. E.g. for Numeric Python arrays >>> from Numeric import * >>> a = reshape(arange(16), (4,4)) >>> print repr(a) array([[ 0, 1, 2, 3], [ 4, 5, 6, 7], [ 8, 9, 10, 11], [12, 13, 14, 15]]) >>> print str(a) [[ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11] [12 13 14 15]] >tuple(seq) n/a. This is a nasty hack to deal with the > fact that (1,2,3) is different from [1,2,3]. > Hm... maybe it's like this: > $aref = [1,2,3]; > @list = @$aref; Not so nasty. Tuples have properties (like immutability and hashability) that justify their co-existence with lists. A function to convert objects to tuples is desirable, just like int(), float(), list(), etc. are desirable. >sys.exit(status) exit(status) and no import is bloody > necessary just to leave the program. > But that Python does this by raising > a SystemExit exception. Perl can use > END{} handlers to catch these and do > at-exit processing, and Python doesn't. > You have to roll your own. Non-issue really. There aren't many times where sys.exit() is needed. If the interpreter is run in non-interactive mode, it will exit when the script is completed successfully or it hits an unhandled exception. Exiting the interpeter from interactive mode is done by the user with Ctrl-D on UNIX and CTRL-Z on Windows. Unless you really need to set the exit status, explicitly calling sys.exit or raising SystemExit isn't usually beneficial. The default behaviour is sufficient for most contexts, especially debugging in interactive mode. Instead of exiting when it hits an unhandled exception in interactive mode, the interpreter gives you the prompt. >From there, you can sometimes diagnose the problem. >sys.exitfunc This is one function to call on normal exit > (not exception exits, unlike perl). > It would have to manage all the handlers > in your roll-your-own scheme. Very ugly. Not much of an issue, really. > +-------------------------------------------------------------+ > | POSIX library. These aren't there unless you have imported | > | the library module via "import posix". | > +-------------------------------------------------------------+ Generally, you should use the os module which loads the right OS-dependent module for your environment. Thanks for listening. >-- >If you consistently take an antagonistic approach, however, people are >going to start thinking you're from New York. :-) > --Larry Wall to Dan Bernstein in <10187 at jpl-devvax.JPL.NASA.GOV> Robert Kern | ----------------------|"In the fields of Hell where the grass grows high This space | Are the graves of dreams allowed to die." intentionally | - Richard Harter left blank. | From rjroy at takingcontrol.com Wed Aug 25 09:14:50 1999 From: rjroy at takingcontrol.com (Robert Roy) Date: Wed, 25 Aug 1999 13:14:50 GMT Subject: Python 1.5.2 on HPUX 10.20 References: <37C3D5BD.72024971@abg1.siemens.de> Message-ID: <37c3e683.52758937@news1.on.sympatico.ca> On Wed, 25 Aug 1999 13:38:37 +0200, Volker Hetzer wrote: >Hi! >This is my first look into python. I tried to install it >% ./configure --prefix=/opt/python >% make all install > >and to test it >% make test > >The fcntl test failed (twice): > >% /opt/python/bin/python Lib/test/test_fcntl.py >Status from fnctl with O_NONBLOCK: 0 >struct.pack: '\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000' >Traceback (innermost last): > File "Lib/test/test_fcntl.py", line 30, in ? > rv = fcntl.fcntl(f.fileno(), FCNTL.F_SETLKW, lockdata) >IOError: [Errno 22] Invalid argument >% > >Is this serious? What am I to do? > >Greetings! >Volker > >-- >Hi! I'm a signature virus! Copy me into your signature file to help me spread! Hi Volker, I have run into this problem before. Where things worked fine on our HP-UX but not on our client's. There is a relatively simple fix. The file lib/python1.5/plat-hp-uxB/FCNTL.py is generated from header files. In one of the header files there is a conditional that is evaluated. The program that generates the Python does not understand the conditional thus defines some values twice. .... bunch of stuff #if !defined(_FILE64) # define F_GETLK 5 /* Get file lock */ # define F_SETLK 6 /* Set file lock */ # define F_SETLKW 7 /* Set file lock and wait */ #else # define F_GETLK 8 /* FILE_OFFSET_BITS=64 name space */ # define F_SETLK 9 /* Map GET/SETLK to their 64-bit */ # define F_SETLKW 10 /* counter parts */ #endif /* !_FILE64 */ ... more stuff This generates the following python code # Included from sys/fcntl.h # Included from sys/types.h # Included from sys/_inttypes.h MAXSUSE = 65535 MAXFUPLIM = 60000 MAXFUPLIM = 2048 FD_SETSIZE = MAXFUPLIM FD_SETSIZE = MAXFUPLIM # Included from .unsupp/sys/_types.h F_DUPFD = 0 F_GETFD = 1 F_SETFD = 2 F_GETFL = 3 F_SETFL = 4 F_GETLK = 5 <<< F_SETLK = 6 <<< F_SETLKW = 7 <<< F_GETLK = 8 <<<<2nd def F_SETLK = 9 <<<<2nd def F_SETLKW = 10 <<<< 2nd def F_GETLK64 = 8 F_SETLK64 = 9 F_SETLKW64 = 10 F_GETOWN = 11 F_SETOWN = 12 FD_CLOEXEC = 1 F_RDLCK = 01 F_WRLCK = 02 F_UNLCK = 03 SEEK_SET = 0 SEEK_CUR = 1 SEEK_END = 2 .... and more This means that regardless of the system under which it is compiled, FCNTL.py sets the values of these vars to the second value. Of course the OS expects otherwise. Thus if you have a system that uses _FILE64 your fcntl test breaks. The fix? 3 little # marks. comment out the second set of definitions and things should work. Good Luck! Robert Roy rjroy-nospam at takingcontrol.com From skip at mojam.com Thu Aug 5 14:37:17 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 5 Aug 1999 13:37:17 -0500 (CDT) Subject: downloading web based email In-Reply-To: <7och4d$jr0$1@nnrp1.deja.com> References: <7och4d$jr0$1@nnrp1.deja.com> Message-ID: <14249.55454.471036.787883@dolphin.mojam.com> Preston> I'm thinking of writing a Python program to download email from Preston> web-based services such as Yahoo mail, Deja, Hotmail, and so Preston> on, and deliever the mail in a format that standard unix Preston> mailers can use. Preston> I'm posting here to make sure that this work has not already Preston> been done. If someone has already seen a program like this, Preston> that can be adapted for a variety of web based email services, Preston> please let me know. I'm not writing this as a learning Preston> exercise, I just need the tool. ;-) Presuming the services you're interested in support a standard mail transfer protocol like POP or IMAP, you need look no further than Eric Raymond's excellent fetchmail program: http://www.tuxedo.org/~esr/fetchmail/ If not, perhaps you can train fetchmail to use whatever transport they do offer. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 847-971-7098 From chad at vision.arc.nasa.gov Tue Aug 24 14:40:20 1999 From: chad at vision.arc.nasa.gov (Chad Netzer) Date: Tue, 24 Aug 1999 18:40:20 +0000 Subject: anyon know anythin about "squeeze"? References: <7psj1a$u24h@eGroups.com> <37C1DC7D.A5B698BF@vision.arc.nasa.gov> Message-ID: <37C2E714.8980CF01@vision.arc.nasa.gov> Chad Netzer wrote: > > that there is a utility called squeeze that, > > This program is in the source distribution "Tools/freeze" directory; Doh, what a bonehead mistake. Sorry. Others have pointed out where "squeeze" and other neat stuff is... Sorry. Chad From fdrake at acm.org Fri Aug 20 10:07:47 1999 From: fdrake at acm.org (Fred L. Drake, Jr.) Date: Fri, 20 Aug 1999 14:07:47 GMT Subject: Python to Perl Conversions In-Reply-To: <1276999045-22443458@hypernet.com> References: <1276999045-22443458@hypernet.com> Message-ID: <14269.24883.363109.219497@weyr.cnri.reston.va.us> Tom Christiansen wrote: > posix.environ The %ENV hash; no import > needed in Perl. However, assignment doesn't > appear to propagate to > unborn children as it does in Perl. Gordon McMillan writes: > Use putenv() to do that. I think the current recommendation is to use os.environ instead of posix.environ; there's something about that in the documentation for posix.environ as well. -Fred -- Fred L. Drake, Jr. Corporation for National Research Initiatives From Bart.Raatgerink at cscd.nl Tue Aug 31 09:26:54 1999 From: Bart.Raatgerink at cscd.nl (Bart Raatgerink) Date: Tue, 31 Aug 1999 15:26:54 +0200 Subject: calling python interpreter References: <37cbccd8.5014784@news.tiscalinet.it> Message-ID: <37CBD81E.A96DF3FF@cscd.nl> try +x pippo.py and then ./pippo.py Kranio wrote: > > Under Red Hat 5.x I use to call the file pippo.py as > > $ python pippo.py > > I would like to call it as > > $ ./pippo.py > > by writing the first line > > #!/usr/bin/python > > but it gave me "access denied" message. The interperter is in the > right dir and I am the owner of the file; tha same happens being root. > What is the problem? > > Marco Buzzo From bruce_dodson at bigfoot.com Sun Aug 1 13:56:01 1999 From: bruce_dodson at bigfoot.com (Bruce Dodson) Date: Sun, 1 Aug 1999 14:56:01 -0300 Subject: NT select.select? References: <613145F79272D211914B0020AFF6401914DC19@gandalf.digicool.com> Message-ID: It does cause a huge load, because in Winsock an fd_set is represented as an array of SOCKETs, not as a bitmap. So in a normal program, which uses select for simple things like polling a single FD, a large FD_SETSIZE will degrade performance. For example, if FD_SETSIZE were 4096, then select.select() would allocate about 48KB (~16KB per fd_set) on the stack whenever it is called, even if there are just a few calls. The good news is that, since those fake fd_sets are always passed by reference, it is safe for the core Python to define a small FD_SETSIZE like 64 while some module overrides the builtin select with another that defines a larger FD_SETSIZE. Then no changes to "core" python would be required, and only those who want the bigger fd_sets will get them. Another thing that you can do is just dynamically allocate an array of 32-bit integers: the first holds the count, and the others hold the SOCKETs. You can fill this without using the FD_SET macros if you are careful to avoid duplicate FDs, or you can define FD_SETSIZE to be huge, cast the allocated memory to fd_set *, and use the macros. (It won't matter that your buffer is smaller than FD_SETSIZE, because you know you're going to run out of elements before you run out of buffer.) If your malloc does a reasonable job of handling small and large objects, and of re-using memory quickly, this could be pretty much ideal. Bruce From philh at vision25.demon.co.uk Sun Aug 22 19:04:25 1999 From: philh at vision25.demon.co.uk (Phil Hunt) Date: Sun, 22 Aug 99 23:04:25 GMT Subject: Parrot-0.0.1 References: <935279776snz@vision25.demon.co.uk> <37BFD9F7.7552BFB3@fnmail.com> Message-ID: <935363065snz@vision25.demon.co.uk> In article <37BFD9F7.7552BFB3 at fnmail.com> kistler at fnmail.com "Per Kistler" writes: > Phil Hunt wrote: > > Would anyone like to have a look at it, and possibly > > suggest some improvements? If so, tell me, and I'll put it on > > my website. > > Let's give it a look:-) Where is it? > -Per. It'll put it on my website tomorrow (I'm just off to sleep now). -- Phil Hunt....philh at vision25.demon.co.uk From thehaas at my-deja.com Sat Aug 14 13:39:51 1999 From: thehaas at my-deja.com (thehaas at my-deja.com) Date: Sat, 14 Aug 1999 17:39:51 GMT Subject: Why use Python when we've got Perl? References: <37b4ba01@cs.colorado.edu> Message-ID: <7p49l5$uv7$1@nnrp1.deja.com> In article <37b4ba01 at cs.colorado.edu>, Tom Christiansen wrote: > Unbelievably stupid subject, eh? I certainly thought so when it was > shoved at us. The flame war begun in comp.lang.perl.misc isn't doing > anyone any good, and then coming over to comp.lang.python to stir up the > shock troops to send in a few commandos is even worse. I don't think > you'd like it if we in comp.lang.perl.misc sent 100,000 script kiddies > over to comp.lang.python to rant at you guys about how K31L they though > Perl was and how L at M3 they thought Python was. > I've been reading that flame war but I noticed that it is the Perl people, for the most part, that have donned the asbestos undies and charged up their flame throwers (this isn't without exception, of course). The Python people have remained relitively calm (the original post was cross-posted, remember?). Although Perl and Python, as languages, are very similar, the culture that surrounds the two languages are quite different. I know when I've asked someone for help in either Python or Perl, the Python people are definitely the most helpful. I think I can safely say, that the Perl community is quite arrogant, especially to people new to it. In Python, I haven't found that to be the case at all - in fact, quite the opposite. They are very helpful in helping out and leading people in the right direction. For example: I emailed an another of one Perl module for help in something and his reply was, "Maybe you should learn Perl better", nevermind the fact that what I was trying to do was undocumented. For help with a Python module, the author told me, "The problem here is that you are new to Python and my documentation sucks, so here is how you do it . . ." The funny part was, *his* documentation was better then the Perl documentation for the module discussed above. And, yes, I do program in both, though most often I choose Perl. However, when I look at some of my dusty Perl programs, I think "what the f*** was I doing?" and it takes me a while to dig through it and figure it out. That situation is almost impossible with Python - the way it has to be structured makes far more readable code. In that respect, Python is better. Yes, Tom, "neatness" may be subjective, but in any language, my handwriting is terrible. I may write in English but some may say it looks like Arabic. However there isn't a Arab or an American that can make heads or tails of it. Even me sometimes . . . > > Please and thank you. And thank you. > > --tom > - mikeh Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't. From sphilip at t2.technion.ac.il Sat Aug 7 15:38:35 1999 From: sphilip at t2.technion.ac.il (Philip Derbeko) Date: Sat, 07 Aug 1999 19:38:35 +0000 Subject: Help. Tracking ButtonRelease events References: <199908071600.MAA10049@python.org> Message-ID: <37AC8B3B.D4EBAC8A@t2.technion.ac.il> Hello. Thanks for your help. Actually I wanted to reduce the complexity of this to O(1) , since search is O(log N). Well I've found another way of doing it , in the cost of changing a GUI a bit : now if you want to draw an edge you click on the source vertex ( regular click with release) move pointer to the destination , pointer followed by the edge , and click on it. This is the same model as in XFig for example. I've done it by tracking enter and leave events for each vertex , this way i know when and which vertex entered and if button was clicked in it. I'm sorry i can't post the code , its in very early development stage , if you want it anyway email me. Regards Philip Hever Zsolt wrote: > This is not a direct answer, but hopefully it is a help. > I am working on a bit similar program and I have put out some code. > http://www.nexus.hu/hever/prog/vu/visualut.py <=main program > http://www.nexus.hu/hever/prog/vu/frameobj.py <= module > http://www.nexus.hu/hever/prog/vu/vu.gif <= help, a picture of the > program > It grew out from the same script(s) you mentioned, there are same problems > you have now that I had to solve somehow. > In the frameobj.py module there is a "class Connecting_Objects:" which does > that. I maintain an ordered taglist for additional information. > > Zsolt > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mhagger at blizzard.harvard.edu Wed Aug 11 10:59:10 1999 From: mhagger at blizzard.harvard.edu (Michael Haggerty) Date: 11 Aug 1999 10:59:10 -0400 Subject: RFC: Viper: yet another python implementation References: <37b075ae.2367293988@news.triode.net.au> Message-ID: skaller at maxtal.com.au (John (Max) Skaller) writes: > Extensions: > > 3) 'in' applies to dictionaries 'as if a sequence of keys were used' At first I thought `hey that's cool!' since I'm kindof sick of typing has_key() all the time. But then I realized that this is not really consistent with sequence types. item in list IMPLIES list[something] == item but according to your definition, item in dict IMPLIES list[item] == something where in each case `something' is undetermined. I suggest you rethink this `feature'. Michael -- Michael Haggerty mhagger at blizzard.harvard.edu From jgreen at RobotVision.com Fri Aug 13 08:19:36 1999 From: jgreen at RobotVision.com (James E. Green) Date: Fri, 13 Aug 1999 08:19:36 -0400 Subject: Does Python run under Windows 2000? (build 2031) Message-ID: <37B40D58.DD6AADC0@RobotVision.com> I'm running Windows 2000 RC1 (build 2031, the very latest). Will Python run under this OS? Only NT4 is mentioned on the Python web page. Thanks, Jim Green From fredrik at pythonware.com Wed Aug 25 08:15:39 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 25 Aug 1999 12:15:39 GMT Subject: Newbie Needs Direction References: <37C3BC8F.1DFFC151@megsinet.net> Message-ID: <00be01beeef3$8bf00860$f29b12c2@secret.pythonware.com> > I have decided to learn python and Tcl. Are there any great tutorials > out there for python? I would also appreciate links to any resources > you may know about that are full of add-on tools, etc for python. I am > also interested in wxPython. I would like to also know what kinds of > programs people are designing with python. And your comments on the > strengths and/or weaknesses you perceive in the language. What > compilers are compatible, etc.? http://www.python.org has it all From khalsa at acay.com.au Thu Aug 26 06:30:43 1999 From: khalsa at acay.com.au (Gurvijay Singh Bhatti) Date: Thu, 26 Aug 1999 20:30:43 +1000 Subject: equivalent of getch References: <37C3C97A.59BF653E@acay.com.au> <7q0on8$h3i@news.rhrz.uni-bonn.de> Message-ID: <37C51753.620A5E3@acay.com.au> Ok, I understand now that getch is not a C function, but still I don't know how to wait for "enter" in JPython? Kaz Kylheku wrote: > On 25 Aug 1999 12:48:40 GMT, Markus Fleck wrote: > >Gurvijay Singh Bhatti wrote: > >> could someone tell me what is equivalent of getch in jpython? I want the > >> program to wait for the user to hit enter before going forward. > > > >AFAIK, this cannot be done in Java. I would > >be surprised if it could be done in JPython. > > Note that waiting for enter doesn't require character-at-a-time input. There > is no getch() function in C, but if all you want is to wait for enter, you > would use, say, fgets(). From garry at research.att.com Fri Aug 27 14:44:01 1999 From: garry at research.att.com (Garrett G. Hodgson) Date: Fri, 27 Aug 1999 18:44:01 GMT Subject: A Plea For A Return To Sanity!!! References: Message-ID: <37C6DC71.447B1388@research.att.com> Bit Nik wrote: > I just recently joined this newsgroup/mailinglist and I missed out a lot > on the previous flame war (lucky me!). And I certainly don't want to > stroke the coals and recreate the flame, but i'm very curious /how/ is > Python lacking in documentation? the complaint seems to be about the format of the documentation. Real Men use man pages, like God intended, not this namby-pamby HTML crap. -- Garry Hodgson "Hey, mister, can ya tell me, garry at sage.att.com where a man might find a bed?" Software Innovation Services He just grinned and shook my hand, AT&T Labs "No", was all he said. From I.Clarke at NOSPAM.strs.co.uk Wed Aug 4 03:57:52 1999 From: I.Clarke at NOSPAM.strs.co.uk (Ian Clarke) Date: Wed, 04 Aug 1999 08:57:52 +0100 Subject: An idea - request for comments References: <37A6A2DB.9B11FB01@strs.co.uk> <7o78fb$blb$2@chief.death.de> Message-ID: <37A7F280.1B4A8583@NOSPAM.strs.co.uk> > How would you make a web page display this message, e.g.? I think you > should at least define environments for Python code. That is what the {}s are for. > Do you know PHP3? I did take a look at it, and it does do something similar, but: A - PHP is not Python, and we all know that Python is the best language in the world ;-) B - There doesn't appear to be any facilities for web page caching C - It is alot larger than the system I am proposing Ian. -- Remove the "NOSPAM." from my email address before replying. From fredrik at pythonware.com Sun Aug 22 13:06:42 1999 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 22 Aug 1999 17:06:42 GMT Subject: More random python observations from a perl programmer References: <000001beec6d$9753e240$542d2399@tim><00c601beecbc$15ac4210$f29b12c2@secret.pythonware.com> <14272.10641.952348.992882@gargle.gargle.HOWL> Message-ID: <013e01beecc0$b5808f90$f29b12c2@secret.pythonware.com> Les Schaffer wrote: > okay. but what is the significance of __this__ orthogonal in the > statement: > > "The builtins strive to stick to those type/operator combos that make > plain sense; Guido has never been a fan of gratuitous orthogonality." > > does it mean simply that guido et al believe not all type/operator > pairs need coverage in the builtins? something like "we dont feel the > need to span all of type/operator space since the phase space of > python coder trajectories seems well bounded by the span of existing > pairs" couldn't have said it better myself ;-) (btw, this is also related to "consistency" in the "worse-is- better" sense: http://www.jwz.org/worse-is-better.html ) From jlj at cfdrc.com Mon Aug 23 12:33:37 1999 From: jlj at cfdrc.com (Lyle Johnson) Date: Mon, 23 Aug 1999 16:33:37 GMT Subject: Python scripts for GNATS? Message-ID: <37c17756.272463902@192.77.87.74> Has anyone out there already written any Python scripts for use with GNATS? I was about to go down that road since I didn't see any references to it on the Python or GNATS web sites but thought I'd double-check here. What I'm specifically interested in is a script (or set of scripts) which would compute some useful statistics on the GNATS database, e.g. how many new bug reports this week/month versus how many closed. From skip at mojam.com Thu Aug 26 12:04:31 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 26 Aug 1999 11:04:31 -0500 (CDT) Subject: emacs with python mode In-Reply-To: <37C540CF.9CE369EE@rubic.com> References: <37C50DAD.840B67C5@xsoft.co.at> <37C540CF.9CE369EE@rubic.com> Message-ID: <14277.25758.596769.209050@dolphin.mojam.com> Jeff> "Gerhard W. Gruber" wrote: >> I'm using Xemacs 21.0 Beta (August 1998) on Win32 and it works quite >> fine (is there a newer version out there?). Now my real >> question. When I'm using Python emacs recognices the mode but it >> doesn't automatically activate syntax highlighting, Jeff> I'm not very knowledgable about emacs, but I'm using Jeff> XEmacs on NT for Python editing. Below are some settings Jeff> in my home .emacs that you might find useful. ... Jeff> (setq-default indent-tabs-mode nil) I believe this is the key setting. If indent-tabs-mode is nil, Emacs will only use spaces to generate indentation, so your code should work on different machines, regardless of the size of a tab. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 847-971-7098 | Python: Programming the way Guido indented... From skip at mojam.com Thu Aug 26 11:56:00 1999 From: skip at mojam.com (Skip Montanaro) Date: Thu, 26 Aug 1999 10:56:00 -0500 (CDT) Subject: equivalent of getch In-Reply-To: <37C51753.620A5E3@acay.com.au> References: <37C3C97A.59BF653E@acay.com.au> <7q0on8$h3i@news.rhrz.uni-bonn.de> <37C51753.620A5E3@acay.com.au> Message-ID: <14277.25469.526198.318152@dolphin.mojam.com> Gurvijay> Ok, I understand now that getch is not a C function, but still Gurvijay> I don't know how to wait for "enter" in JPython? Try the raw_input() builtin function. Skip Montanaro | http://www.mojam.com/ skip at mojam.com | http://www.musi-cal.com/~skip/ 847-971-7098 | Python: Programming the way Guido indented... From smithy at promail.pl Sat Aug 28 16:15:08 1999 From: smithy at promail.pl (£ukasz Kowalczyk) Date: 28 Aug 1999 20:15:08 GMT Subject: IDLE and iso-8859-2; threading tutorial Message-ID: I was trying to use IDLE (version 0.4) on Linux but was unable to use font with iso-8859-2 encoding. Since I'm new to Python and don't know anything about Tk, could someone explain to me what I should be looking for in IDLE's code? Also, is there a tutorial about using threads in Python? I know there are a few examples in doc/Demos directory but I would like to read about real-world problems that may arise. I still remember how much time I spent looking for bugs in my Java threading program and finally found out that putting Thread.yield() all over the code did the trick... -- ?ukasz Kowalczyk http://tempac.fuw.edu.pl/~lukow/ From kernr at mail.ncifcrf.gov Thu Aug 19 18:10:38 1999 From: kernr at mail.ncifcrf.gov (Robert Kern) Date: Thu, 19 Aug 1999 22:10:38 GMT Subject: More random python observations from a perl programmer References: <199908191819.MAA04074@jhereg.perl.com> <37bc71cc.19700984@news.erols.com> <37bc7de2@cs.colorado.edu> Message-ID: <37bc7da5.22734202@news.erols.com> On 19 Aug 1999 15:57:54 -0700, Tom Christiansen wrote: > [courtesy cc of this posting mailed to cited author] > >In comp.lang.python, > kernr at mail.ncifcrf.gov (Robert Kern) writes: >:This is a holdover from the time before the >:source and documentation were split into separate distributions. > >Why was this done? Is this a good thing? You can't do that with Perl >modules' documentation because all the module doc is embedded. We did >this to avoid a sync problem, and so people could never not have the docs. >In fact, they can even be links to the same file, e.g. File::stat.3 >linked to and File/stat.pm. Or do you just mean core docs, not >module docs were split? The core docs (Tutorial, Ref. Manual, Ext. and Emb., etc.) plus the Library Reference, which, I guess, *is* the module docs (except for doc strings, which are embedded). I think that the reasoning behind the split was to allow Fred to update the documentation between releases. For the most part, this is A-Good-Thing, since the documentation is still incomplete in some regards (probably not enough to justify a split if we were considering the docs now, but back then the docs were). The issue was more of getting the documentation into sync than keeping it there. And, generally speaking, there aren't enough sync problems to justify losing the flexibility of separate distributions (IMO). >--tom >-- >"IMHO, CAPS LOCK should be somewhere more >convenient; e.g., in another building." --jgreely Robert Kern | ----------------------|"In the fields of Hell where the grass grows high This space | Are the graves of dreams allowed to die." intentionally | - Richard Harter left blank. | From Cancel at Post.Gov Sat Aug 28 05:55:39 1999 From: Cancel at Post.Gov (Cancel at Post.Gov) Date: 28 Aug 1999 09:55:39 GMT Subject: NEW_VER-NewsControlSystem2.1.0_EMailForDemoKey(FreeNEWSservers) Message-ID: <7q8bmr$eqm273@www.siast.sk.ca> (ATT:WEBMASTER) 1.NO WAREZ OR CRACKS ON MY PAGES 2.NO SPAM COMING FROM MY SITES 3.Because Someone Doesnt like this doesnt justifity Deleting any Page 4.There is no ILLEGAL product or Activity on my site WhiTeRaBBiT,s News Control System What Does Do??? This program does a few things: * Allows you to forge posts (i.e. make other people look as if they posted something) * Allows you to make 100% anonymous posts (when used with certain NNTP servers; installed with system) * Allows you to post to moderated groups without the approval of some asshole moderator * Allows you to cancel others posts * Allows you to send your own "control" messages (e.g. you can remove groups or make your own groups) *Includes large list of free news servers (search groups in free servers)Never Hunt for another Server *Read news on one server post or cancel using another *Mail to News posting using built in EMail Sender (large list of mail2news gateways) some of the changes from 2.0.1 in 2.1.0 Added Mail2News List to Mail2News Added NEW NEWS GROUP SEARCH Added Change in Code For Better Close click this ling to download http://rabbitpro.hypermart.net/ http://wowsites2.com/rabbitpro/ Email me at mailto:rabbitproductions at bigfoot.com FOR 10 DAYFREE TRIAL RUN or questions if you are already a registered owner download and install over Ver2.0.0 the program will check and install new serial if it matches the code For Full Registration and UpGrades and Improvements If you find this program usefull send $20.00 Money Order Leave Pay To Blank Include Your Registration Name: Include Your E-Mail Address You will Recieve Your Full Registration By E-Mail Send To RocksU.com P.O. Box 468 Zionsville,In 46077 Thank You For Useing A WhiTeRaBBiT RaBBiTproDucTionS ProDuct (ATT:WEBMASTER) 1.NO WAREZ OR CRACKS ON MY PAGES 2.NO SPAM COMING FROM MY SITES 3.Because Someone Doesnt like this doesnt justifity Deleting any Page 4.There is no ILLEGAL product Activity on my site From thomas at xs4all.nl Tue Aug 17 02:58:25 1999 From: thomas at xs4all.nl (Thomas Wouters) Date: Tue, 17 Aug 1999 08:58:25 +0200 Subject: help printing dictionary, sorted by values. In-Reply-To: <37B8F03F.654FA9DE@xmission.com>; from Jerry Williams on Mon, Aug 16, 1999 at 11:16:47PM -0600 References: <37B8F03F.654FA9DE@xmission.com> Message-ID: <19990817085825.L21639@xs4all.nl> On Mon, Aug 16, 1999 at 11:16:47PM -0600, Jerry Williams wrote: > I have searched and searched the docs and am really frustrated with > them. > All I can seem to find is bits and pieces that hint about dictionaries. > I finally found a table under mappings that listed the methods. But > I couldn't find anything that would list each data type and what methods > are available. What I am trying to do is take a file with a bunch of > entries that appear more than once and list the count of each occurance > in order of the highest count. So if the file looked like: > a > a > a > b > b > c > Then is would print: > 3 a > 2 b > 1 c > I thought a dictionary would work great, but can't seem to figure out > how to sort it by values and also get the key. > list = dict.values() > list.sort() > Then I get lost. And the counts aren't going to be unique. > Thanks for any help. Please point me to where the methods are listed > for > the dictionary. And some examples of dictionaries would be helpful. Have you tried the Python Tutorial ? http://www.python.org/doc/current/tut/ As for examples, here's probably what you want: [thomas at tilburg ~]$ python Python 1.5.1 (#1, Sep 3 1998, 22:51:17) [GCC 2.7.2.3] on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> dict = {} # an empty dictionary >>> dict['spam'] = 'eggs' # Insert a string, with a string as key >>> dict[5.4] = [2, 3, 4] # Insert a list, with a floating point number as key >>> dict[1,2,3] = {} # insert an (empty) dictionary, with a tuple as key >>> dict['me'] = dict # insert a reference to the dict itself >>> dict # 'print' the dict {'spam': 'eggs', (1, 2, 3): {}, 'me': {...}, 5.4: [2, 3, 4]} >>> dict.keys() # print the dict's keys ['spam', (1, 2, 3), 'me', 5.4] >>> dict.values() # print the dict's values. ['eggs', {}, {'spam': 'eggs', (1, 2, 3): {}, 'me': {...}, 5.4: [2, 3, 4]}, [2, 3, 4]] >>> dict['spam'] # Index by string 'eggs' >>> myindx = 5.4 >>> dict[myindx] # Index by variable [2, 3, 4] >>> dict["me"]["me"][1,2,3] # Index-index-index {} >>> for key in dict.keys(): # Print all dict values by hand ... print dict[key] ... eggs {} {'spam': 'eggs', (1, 2, 3): {}, 'me': {...}, 5.4: [2, 3, 4]} [2, 3, 4] What you want to do is probably something like this: import sys if len(sys.argv) < 2: print "Usage: %s "%sys.argv[0] sys.exit() result = {} file = open(sys.argv[1], 'r') for line in file.readlines(): line = line[:-1] # We want to lose the newline if result.has_key(line): # This could be done with exceptions too. result[line] = result[line] + 1 else: result[line] = 1 resultlines = result.keys() resultlines.sort(lambda x, y: cmp(result[y], result[x])) for line in resultlines: print "%d %s"%(result[line], line) Note cmp(result[y], result[x]), not cmp(result[x], result[y]), to sort the list highest value first. You can also do a 'resultlines.reverse()' after the sort to get the same effect. This is what it does: % python mysort.py testfile 66 d 60 f 36 l 36 ; 24 u 24 k 24 n 24 j 12 e 12 i 12 h 12 2 12 0 12 r 12 w 12 v 6 , 4 s 3 p 2 a 1 m Nevertheless, reading the tutorial and parts of the Library Reference really are really good ideas. and-i-didnt-even-show-the-other-10-good-ways-to-do-it'ly y'rs. -- Thomas Wouters Hi! I'm a .signature virus! copy me into your .signature file to help me spread! From gherron at aw.sgi.com Wed Aug 18 16:11:31 1999 From: gherron at aw.sgi.com (Gary Herron) Date: Wed, 18 Aug 1999 20:11:31 GMT Subject: Win32 Installer - new beta References: <1278333954-16187909@hypernet.com> Message-ID: <37BB1373.6686F844@aw.sgi.com> Gordon McMillan wrote: > > A new beta (02) of the Win32 Installer package is available on > starship: > > http://starship.python.net/crew/gmcm/install.html > > This release incorporates bug fixes and some enhancements: > > The major changes are that command line arguments are > passed into your script, and a standalone / installer can be run > from anywhere -it is no longer assumed that the current working > directory is also the directory the program lives in. Files are > always unpacked into the "home" directory, and the absolute path of > the "home" directory is always available. > > See http://starship.python.net/crew/gmcm/install.html#beta02 for > details. Gordon, Nice work! With enough work to gain an understanding of this thing, I was able to get to within inches of what I really wanted. I'd like to suggest a small change to allow me to get all the way to my goal. First the suggestion, then (in case you care) the description of what I'd use it for. There appears to be two differences between Run.exe and Runw.exe: (1) Run.exe is a console app, and Runw.exe is not. (2) Run.exe cleans up all its extracted files, and Runw.exe does not. Are these two features necessarily connected. From looking at the compiler switches un uplaunch.cpp, I'd say not. What I'd really like is a version that is NOT a console app but DOES cleanup after itself. Is there a good reason why Runw.exe does not cleanup after itself? OPTION 1: If not, lets compile Runw.exe with the cleanup flag on. OPTION 2: If there is a good reason to leave Runw.exe alone, then can we include a third Run?.exe that is compiled with the flags set the way I'm suggesting, and perhaps, for completeness sake, a fourth version so that all four combinations of console/no-console and cleanup/no-cleanup are covered? Here is why I want such thing. I'm building a .exe (using one INSTALL and one PYZ section) which wraps up a GUI script (pyWindows/wxWindows in this case) with a carchive containing all of its binary dependencies and single PYZlib containing all of its python script dependencies. When run, it unpacks the carchive in the local directory, and runs the script which gets all of its binary dependencies and python imports from these files. Upon completion, all these files are cleaned up. The only hitch is the damned console window which comes up and remains blank. (The script is a GUI so there is no console input or output.) If I modify builder.py to use Runw.exe instead of Run.exe (or better yet modify the InstallTarget class to honor the userunw flag similarly to the RunTarget class), then the console window goes away, but the current directory is left with a dozen or two files not cleaned up. If you care to look at it, my config file looks like this: [EVERYTHING] type= INSTALL name= app.exe script= app.py zlib= PYZLIB bindepends= app.py [PYZLIB] name= app.pyz dependencies= app.py, ..\installer\support\installutils.py excludes= dospath, posixpath, macpath includes= ..\installer\support\installutils.py The only modification I have to make to my normal application to run in this environment is to put from installutils import * at the top and, at the bottom, execution cannot be based on the usual if __name__ == '__main__': As I said before, I really like this package. If I could get rid of the console I'd REALLY like this package. I may attempt to compile my own version of Run?.exe, but I'm an old Unix weenie still learning to swim in the deep end of the Windows pool. Any help you could provide would be appreciated. Thanks Gary Herron -- Dr. Gary Herron 206-287-5616 Alias | Wavefront 1218 3rd Ave, Suite 800, Seattle WA 98101 From da at ski.org Mon Aug 30 14:05:59 1999 From: da at ski.org (David Ascher) Date: Mon, 30 Aug 1999 11:05:59 -0700 (Pacific Daylight Time) Subject: 'if foo' calls getattr?!? In-Reply-To: Message-ID: On Mon, 30 Aug 1999, Joe Strout wrote: > [[ This message was both posted and mailed: see > the "To," "Cc," and "Newsgroups" headers for details. ]] > > Doing some profiling on Graphite this weekend, we found a very curious > thing: a gazillion calls to __getattr__ on one of our classes, where we > expected to find none. We eventually tracked it down to a seemingly > innocent test, basically, "if foo: self.myfoo = foo". The "if foo" was > invoking foo.__getattr__ (which is very expensive). > > I can think of no reason why it should be this way, but it is. Below is > a very simple stand-alone demonstration. It leads me to the absurd > idiom of saying "if id(foo) != id(None)" when I really mean "if foo", > just because using id() avoids the __getattr__ call. > > Can anybody explain why this should be? Is it a bug in Python? Is > there some other way to check whether I have a reference to an object > that doesn't involve a function call? Use 'if foo is not None' to do identity checking and not truth testing. You're getting a getattr call because your class might define its own way of testing truth -- for more details, see: http://www.python.org/doc/current/ref/customization.html#l2h-134 --david From nathan at islanddata.com Fri Aug 20 22:23:06 1999 From: nathan at islanddata.com (Nathan Clegg) Date: Fri, 20 Aug 1999 19:23:06 -0700 (PDT) Subject: signals and multithreaded apps Message-ID: If I'm receiving on a socket or sleeping, even the friendliest of handled signals will cause an IOError exception. Thus I've put extra loops around every sleep, receive, etc., to keep them alive. This is a little annoying, but doable. However, do I also need to protect database queries, file writes, and print statements? Some of these are difficult to test because they are so short, but I don't want my app to except out on that fateful 1000th run because a SIGHUP was sent at the wrong nanosecond that I didn't prepare for. Any wisdom on the safes and unsafes? ---------------------------------- Nathan Clegg nathan at islanddata.com From jblake at stamp-coin.com Sat Aug 14 19:00:10 1999 From: jblake at stamp-coin.com (Jonathon) Date: Sat, 14 Aug 1999 23:00:10 +0000 (UTC) Subject: ECommerce & Python Message-ID: Can somebody point me in the direction of shopping carts, and related items, that have been written in python. The only thing I have found, has been ECommerce, for Zope. << An alpha release for an old version of Zope. >> Asking, because I am about to write a shopping cart, and if I don't have to re-invent the wheel.... << And yes, I have seen umpteen shopping carts written in perl, none of which will correctly do what I need a shopping cart to do. >> xan jonathon From godzilla at netmeg.net Sun Aug 22 10:28:18 1999 From: godzilla at netmeg.net (Les Schaffer) Date: Sun, 22 Aug 1999 14:28:18 GMT Subject: More random python observations from a perl programmer References: <000001beec6d$9753e240$542d2399@tim> Message-ID: Tim_one said to tchrist: > I keep thinking that everything should work on everything. > The builtins strive to stick to those type/operator combos that make > plain sense; Guido has never been a fan of gratuitous orthogonality. what does orthogonality mean here? (i come from a world where (0,1) and (1,0) are archetypal orthogonals and cant map that meaning to this discussion) gracias.... les schaffer From bmcd at es.co.nz Sun Aug 15 18:30:28 1999 From: bmcd at es.co.nz (Ben Caradoc-Davies) Date: 15 Aug 1999 22:30:28 GMT Subject: Wacky Programming Tales References: <37AAFAD1.A032765B@NOSPAM.strs.co.uk> <37b62939@cs.colorado.edu> <7p7cel$l7h@dfw-ixnews14.ix.netcom.com> Message-ID: On 15 Aug 1999 21:45:57 GMT, Aahz Maruch wrote: >Not only that, but perhaps that was the third or fourth draft of the >code, and a while loop was more appropriate for the original draft. >It's often the case that even when I know there's a more "appropriate" >structure for code that I'm modifying, I leave the old code intact as >long as there's nothing actually *wrong* with it -- fewer changes >equates to fewer bugs (not always, but in general). Sure, if it ain't broke ... Unfortunately, in this case, the original specifications appear to have been reduced, and there are huge chunks of partly implemented and even obsolete code, including a large source source file which should have been entirely deleted as it's functionality had been absorbed into another. This was only deducible by examiing the linker options. If there was any evidence of a drafting process, it wasn't obvious. But yes, there may well have been something more complicated in the loop. For example, if he was messing with "i" in the loop, a while loop would have been a good way to draw another programmer's attention to the fact that something fishy was going on, if he was so averse to comments. -- Ben Caradoc-Davies From mikael_aronsson at mail.bip.net Sun Aug 8 14:22:01 1999 From: mikael_aronsson at mail.bip.net (Mikael Aronsson) Date: Sun, 8 Aug 1999 20:22:01 +0200 Subject: Weird problem ? Message-ID: <000101bee1ca$e9795940$46f8143e@pc58-mikael.fas.flygt.com> Hi ! I have an application with a Python interpreter embedded and when I start it up I load a file with PyRun_SimpleFile, the file looks like this: # Vector class class VECTOR: x = 0.0 y = 0.0 z = 0.0 def __init__(self,xx=0.0,yy=0.0,zz=0.0): self.x = xx self.y = yy self.z = zz # Color class class COLOR: r = 0.0 g = 0.0 b = 0.0 a = 0.0 def __init__(self,rr=0.0,gg=0.0,bb=0.0,aa=1.0): self.r = rr self.g = gg self.b = bb self.a = aa xx = VECTOR() zz = COLOR() This loads without any error message, but when I try to compile and run this code: xx = COLOR() With PyRun_SimpleString() I get the following error: File "", line 1 xx = COLOR() ^ SyntaxError: invalid syntax I can call PyRun_SimpleString() with "xx = VECTOR()", this does not give any error, I cannot fine anything wrong with my code, does anyone have any clue to what the problem might be ?, I am running Python 1.52 on Windows NT SP4 regards, Mikael Aronsson From mwh21 at cam.ac.uk Mon Aug 30 06:37:36 1999 From: mwh21 at cam.ac.uk (Michael Hudson) Date: 30 Aug 1999 11:37:36 +0100 Subject: How to change default behaviour of a class? References: <37CA5E90.28D60E87@xsoft.co.at> Message-ID: "Gerhard W. Gruber" writes: > How can I change what is printed when I use the statement "print class"? > Usually this leads to an output like but I > rather want it to print variables contained in my class instead of the > pointer adress. Add a __repr__ method: class C: def __init__(self): self.a = 1 def __repr__(self): return "self.a = %s"%self.a C() => "self.a = 1" appears on stdout. HTH, Michael From chad at vision.arc.nasa.gov Fri Aug 20 20:32:39 1999 From: chad at vision.arc.nasa.gov (Chad Netzer) Date: Sat, 21 Aug 1999 00:32:39 +0000 Subject: What is a troll by the way? [offtopic] References: <37bdeb1b.31915768@news.erols.com> Message-ID: <37BDF3A7.75FEA04F@vision.arc.nasa.gov> Robert Kern wrote: > _Troll_ is a USENET term for someone that deliberately posts an > inflammatory message simply to stir up argument. I've found it funny to watch this term evolve over the past few years. It started (I believe) as a reference to the fishing term, and used to mean "trolling for flames" (ie. hoping to bring flames to the discussion), perhaps employing "flame bait" for this purpose. It is now used by many (I believe), as a derogatory reference to someone being like an ugly, flesh-eating beast that lives under a bridge. :-) And that calling someone a "troll" is simply meant to imply they are contemptible for trying to incite flame wars (much like a Troll is contemptible for, well, being a Troll). Anyway, I personally like the first usage, and sometimes lament that it is evolving toward the second. I used the term "troller", rather than "troll", but it is probably a lost cause. :-) ob. python. Tried "idle" for the first time today... Neat! Chad From nikolai.kirsebom at siemens.no Tue Aug 3 07:24:29 1999 From: nikolai.kirsebom at siemens.no (Nikolai Kirsebom) Date: Tue, 03 Aug 1999 11:24:29 GMT Subject: stuck on COM interface to Word References: <01BEDD9B.6052EFB0@exchange1.geometria.hu> Message-ID: <37a6d12b.192256@news.mch.sni.de> In Arpad's example on *Last print date*, the returned