From tekatch at idirect.com Sun Jan 27 10:12:00 2002 From: tekatch at idirect.com (Anthony Tekatch) Date: Sun, 27 Jan 2002 10:12:00 -0500 Subject: strftime year Message-ID: strftime seems to improperly computer the year on the December 31, 2001: Here is an example program and it's output: #!/usr/local/bin/python import time,os os.environ['TZ']='EST5EDT' for offset in range(10): time_flt=1009757224.0+(offset*3*3600) print time_flt, print time.strftime('%m/%d/%g %l:%M%P',time.localtime(time_flt)) 1009757224.0 12/30/01 7:07pm 1009768024.0 12/30/01 10:07pm 1009778824.0 12/31/02 1:07am 1009789624.0 12/31/02 4:07am 1009800424.0 12/31/02 7:07am 1009811224.0 12/31/02 10:07am 1009822024.0 12/31/02 1:07pm 1009832824.0 12/31/02 4:07pm 1009843624.0 12/31/02 7:07pm 1009854424.0 12/31/02 10:07pm Note, December 31 should still be year "01". Am I doing something wrong? From Stefaan.Eeckels at ecc.lu Mon Jan 28 18:23:03 2002 From: Stefaan.Eeckels at ecc.lu (Stefaan A Eeckels) Date: Tue, 29 Jan 2002 00:23:03 +0100 Subject: Genuine computer Scrience >Re: Autocoding project proposal. References: <83sn8rgmc7.fsf@panacea.canonical.org> <1695.793T706T7603932threeseas@earthlink.net> <20020128225640.24490efb.Stefaan.Eeckels@ecc.lu> Message-ID: <20020129002303.0fa11605.Stefaan.Eeckels@ecc.lu> On Mon, 28 Jan 2002 23:08:04 +0000 philh at comuno.freeserve.co.uk (phil hunt) wrote: > Doesn't computer science deal with HCI and making computers easier to > use, then? Maybe it's in the curriculum. If the current crop of programs is anything to go by, they could as well have left it out. In any case, it's about people, and how they react to devices (soft or hard). It's psychology, not comp.sci. Take care, -- Stefaan (GPG Fingerprint 25D8 551B 4C0F BF73 3283 21F1 5978 D158 7539 76E4) -- "Object-oriented programming is an exceptionally bad idea which could only have originated in California." --Edsger Dijkstra From abulka at netspace.net.au Thu Jan 24 00:52:30 2002 From: abulka at netspace.net.au (Andy Bulka) Date: 23 Jan 2002 21:52:30 -0800 Subject: Parsing complex web pages safely with htmllib.HTMLParser Message-ID: <13dc97b8.0201232152.66d56faa@posting.google.com> The following snippet of code parses a web page on my disk and prints the urls found in it. It works for everything I've tried but not the page I really want http://www.bom.gov.au/cgi-bin/wrap_fwo.pl?IDV60029.html which lists the weather in my state. Intead I get an exception SGMLParseError: unexpected char in declaration: '<' import htmllib import formatter parser=htmllib.HTMLParser(formatter.NullFormatter()) parser.feed(open('ATROUBLESOMECOMPLEXPAGE.htm').read()) parser.close() print parser.anchorlist MY QUESTION: Is htmllib.HTMLParser likely to fail here and there, on complex or otherwise web pages? Loading the above page into Frontpage and saving it out again does nothing to fix the problem - so its proably ok HTML. What do I do about this - ask my Government Bureau of Meteorology to change the way they do their web pages ?!! Of course I can catch the exception, but I REALLY *want* the info on that weather page... Or is this just a bug in htmllib.HTMLParser ? Andy Bulka Australia www.atug.com/andypatterns From TomH at optiscan.com Wed Jan 23 00:41:03 2002 From: TomH at optiscan.com (Tom Harris) Date: Wed, 23 Jan 2002 16:41:03 +1100 Subject: Calling Python scripts as Visual Studio custom build step. Message-ID: Greetings, Microsoft Visual Studio allows the specification of custom sets of commands to be run when a file is built. Usually the output (stdout & stderr) of these commands is redirected to a log window. When MSVC runs a Python script, however, the output is lost. It works fine if the command is a batch file or a Perl script. This is on MSVC 6.0 on NT 4.0, with Python 2.1 or 2.2. Is there a workaround? Apart from using a real OS of course. Tom Harris, Software Engineer Optiscan Imaging, 15-17 Normanby Rd, Notting Hill, Melbourne, Vic 3168, Australia email tomh at optiscan.com ph +61 3 9538 3333 fax +61 3 9562 7742 This email may contain confidential information. If you have received this email in error, please delete it immediately,and inform us of the mistake by return email. Any form of reproduction, or further dissemination of this email is strictly prohibited. Also, please note that opinions expressed in this email are those of the author, and are not necessarily those of Optiscan Pty Ltd. From torstenson at no-spam.oti-hsv.com Wed Jan 9 18:13:48 2002 From: torstenson at no-spam.oti-hsv.com (Eric Torstenson) Date: Wed, 9 Jan 2002 17:13:48 -0600 Subject: IMAP Socket errors on Windows 2000 Message-ID: Has anyone experienced anything like this, and were they able to figure out what the problem was. I am trying to write a script that will perform a little bit of maintenance on an IMAP mail account. I can connect just fine from several linux boxes and one other windows 2000 box (connecting to the mail server, that is), but on the machine that I am actually doing the development (it needs to stay on win2k, unfortunately, will not allow me to connect. I have uninstalled and reinstalled Python several times, to no avail. I don't think it has anything to do with python, but with windows 2k. Unfortunately, from what I can tell there is nothing unusual about my machine. It is a clean installation (just a couple of weeks old), and everything else works fine. I can do the mail testing on a linux box if necessary, but it is a nagging feeling knowing that there has to be a solution to allow it to run locally. FYI, the mail server is Exchange 5.5, and the machine is just down the hall from the machine with the problem. Since I can send and recieve mail using various IMAP clients, I know that the primary network config is fine. Also, since I can get it to work using 1.5 (linux) and 2.2 (windows 2k on a lab computer) I really don't think it is a python problem. If anyone has dealt with this, and can send me somewhere to start, I would be very grateful. Thanks, Eric Torstenson From martin at v.loewis.de Wed Jan 2 16:54:31 2002 From: martin at v.loewis.de (Martin v. Loewis) Date: 02 Jan 2002 22:54:31 +0100 Subject: Problem with any of os.system(), os.fork() & os.execp() and os.spawn() References: <3C332A5D.1A841338@videotron.ca> Message-ID: Eric Chamberland writes: > So, I need to have commands in "myscript" to be run in background, > so how do I make this simple thing work correctly? This has nothing to do with python. Please try (sleep 5;/tmp/myscript) & in your shell. You will see that the same effect happens. If you strace the shell, you will see that tcsh executes the sequence ... 1912 write(1, "first\n", 6) = 6 1912 _exit(0) = ? 1905 setpgid(1912, 1912) = 0 This is the fragment where the first subshell exits; 1905 is the tcsh and 1912 the echo process. Shortly afterwards, you see 1905 write(17, "[1] 1912\n", 9) = -1 EIO (Input/output error) 1905 munmap(0x40017000, 33577) = 0 1905 _exit(1) = ? FD 17, in this case, is a dup of stdout. Since the terminal is closed, the write operation gets a SIGIO. In turn, tcsh decides to exit, instead of invoking the rest of the script. So if there is a problem, it is in tcsh. I'd recommend to rewrite this script in Python. Regards, Martin From ruediger.maehl_nospam at web.de Thu Jan 17 10:14:54 2002 From: ruediger.maehl_nospam at web.de (Ruediger Maehl) Date: Thu, 17 Jan 2002 16:14:54 +0100 Subject: Write both in std output and in a file ? References: Message-ID: "Daniel Dittmar" schrieb im Newsbeitrag news:a23icn$249$1 at news1.wdf.sap-ag.de... > class TeeStream: > def __init__ (self, *streams): > self.streams = streams > > def write (self, data): > for stream in self.streams: > stream.write (data) > > call as > stream = TeeStream (sys.stdout, open ('...', 'wt')) > > Daniel Very smart! Is there an easy way to implement, that a timestamp is also printed for each print that I call without having to specify it in the print statement itself? The statement: print "Hello", 1, "more here" should produce (in stdout and in the file): 2002-01-17 16:10:22 Hello 1 more here R?diger From oblomov at freemail.it Wed Jan 30 10:16:02 2002 From: oblomov at freemail.it (Giuseppe Bilotta) Date: Wed, 30 Jan 2002 15:16:02 GMT Subject: VIM - python errors after upgrading to Python 2.2 (Windows OLE) References: <3281a460.0201290759.78cfcd0@posting.google.com> Message-ID: Jonathan Hogg wrote: > > I believe that VIM embeds a Python interpreter into itself if it is compiled > with Python support. It will still have the 2.1 interpreter compiled in, > which will now be very unhappy that the 2.1 library has disappeared on it. I > think you will need to recompile VIM pointing configure at the new 2.2 > install. :version tells you if python is compiled in or if it loads an external library (+python/dyn means it loads the external library). Even in the latter case, though, it looks for a specific version of the library (in the compile options of version you'll find: -DYNAMIC_PYTHON_DLL="python21.dll"). -- Giuseppe "Oblomov" Bilotta Axiom I of the Giuseppe Bilotta theory of IT: Anything is better than MS From p.g at figu.no Sat Jan 12 08:53:19 2002 From: p.g at figu.no (Per Gummedal) Date: Sat, 12 Jan 2002 14:53:19 +0100 Subject: Ruby Impressions In-Reply-To: References: Message-ID: <100871494000.20020112145319@figu.no> 12.01.2002, 08:42, you wrote: > adamspitz at bigfoot.com (Adam Spitz) wrote: > | class Person: > | def __init__(self, name, age, gender): > | self.name, self.age, self.gender = name, age, gender > | self.doSomeStuff() > |I'd like to be able to tell Python, "Make me an __init__ method that > |takes these three parameters, stores them as attributes, and then does > |this other stuff." You could use this function: import sys CO_VARARGS, CO_VARKEYWORDS = 4, 8 def initParms(obj): f = sys._getframe(1) n = f.f_code.co_argcount # dict is new in 2.2. Do not include first parm (self) args = dict([(vn, f.f_locals[vn]) for vn in f.f_code.co_varnames[1:n]]) obj.__dict__.update(args) # skip varargs if f.f_code.co_flags & CO_VARARGS: n += 1 # keywords if f.f_code.co_flags & CO_VARKEYWORDS: obj.__dict__.update(f.f_locals[f.f_code.co_varnames[n]]) class A: def __init__(self, a, b, c, d): initParms(self) a1 = A(1,2,3,4) Per From jkraska at san.rr.com Sat Jan 12 12:44:49 2002 From: jkraska at san.rr.com (Courageous) Date: Sat, 12 Jan 2002 17:44:49 GMT Subject: Another Language Change for Debate References: Message-ID: >So here's my idea. Allow the following syntax: > >class MyClass(OtherClass): > def self.addItems( newItems ): > self.items += newItems I wouldn't really change Python in this particular way, but it does have a certain appeal to it. For example, it could also be written... ... def MyClass.addItems ( ... ... ...to define a static function. Face it, though, one way or another all of these various kinds of things are just different kinds of syntactic sugar. *shrug* C// From andy at reportlab.com Tue Jan 8 19:37:03 2002 From: andy at reportlab.com (Andy Robinson) Date: Wed, 09 Jan 2002 00:37:03 GMT Subject: ANN: ReportLab Demo Download Message-ID: The ReportLab Demo is now available for download. Packaged as a single Windows installer, this demo includes both commercial and Open Source tools for creating and manipulating PDF files in a variety of ways. This enables people without a prior installation of Python to try out and begin exploring our tools. Included are: * reportlab: our free, Open Source toolkit for producing PDF files from the Python scripting language * RML2PDF: our easy to use enterprise reporting solution allows you to write files in Report Markup Language (RML, our simple, high-level XML dialect) and convert them into PDF * PageCatcher: allows you to reuse existing PDF files or elements of existing PDF files in a range of flexible ways * Other useful tools including Preppy: a small, versatile text pre-processor (JSP/ASP-like) PythonPoint: generates PDF slides from simple XML * Python: the general purpose scripting language (Windows v2.1.1) * support files, examples, tests and documentation for the above. (RML2PDF & PageCatcher are evaluation versions of commercial software) The ReportLab demo provides you with Enterprise-level solutions you can try from your desktop. Everything in it is proven technology; elements have been in production use in high volume environments for major financial institutions for over a year. Using these products, you can create and use PDFs in ways you never though possible: dynamically insert text and images from a range of sources, create new PDFs (from a low level canvas or high level XML) equally easily from your desktop or a server, overlay new content on existing PDFs, re-order pages, do conditional flow in dynamic-created documents... To download the ReportLab Demo, go to our web site: http://www.reportlab.com/newdemo.html (Platform: Windows. File size: 6.4 Mb) For more information: web site: www.reportlab.com email: info at reportlab.com user group: groups.yahoo.com/group/reportlab-users From jgardn at alumni.washington.edu Thu Jan 17 16:35:03 2002 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Fri, 18 Jan 2002 06:35:03 +0900 Subject: dumb newbie questions In-Reply-To: References: <5a3612cc.0201171053.5257ce97@posting.google.com> Message-ID: <200201172150.g0HLo6O31591@my.knctv.co.kr> On Friday 18 January 2002 04:28 am, Andrew Koenig wrote: > > The readline function returns the entire input line as a string, > including the newline at the end. That's not what you want -- you > want to convert the line to an integer. To do so, write > > row=int(sys.stdin.readline()) > > and similarly for col. And once you get it turned into an int, you should be able to do: for i in range(row): and similarly for col and j. Don't forget to check what they typed in for col and row! if not row or not col: raise Exception, "Invalid inputs!" Jonathan From jrfyqs at yahoo.com Thu Jan 31 19:43:31 2002 From: jrfyqs at yahoo.com (jrfyqs at yahoo.com) Date: Fri, 1 Feb 2002 00:43:31 +0000 (UTC) Subject: *E*R*O*T*I*C F-R-E-E ? H-A-C-K the Membersites ! 6520 Message-ID: http://sexhack.h3.to ytedqdbrorksjtdcwstufoigqeudikmcrbviiflqitimmjlobkmmnitsxhqszzbnbpzjsixpetsbjvmfzwxgyytrxltvjthcjpdqqfmokvevwugxzkqliekcysqxejhqxeupwkejhedgsysokbemjpruijuhglcezloperbxeversxbdmzbtvvpsglvkjrrlvpwchpcfgdupqjfklkstpqhtbefrhs From sholden at holdenweb.com Tue Jan 15 14:48:20 2002 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 15 Jan 2002 14:48:20 -0500 Subject: Function that enters a line at the beginning of a file? References: Message-ID: "Alex Martelli" wrote in message news:a21p2u$did$1 at serv1.iunet.it... > "Jason Orendorff" wrote in message > news:mailman.1011111801.11359.python-list at python.org... > ... > > Maybe you want this. It avoids using os.system() too, so it should > > be faster. I hope it's self-explanatory. > > > > #!/usr/bin/python > > exec "import my_module" > > execfile("script_file") > > I think I must be missing something. Why > exec "import my_module" > rather than the plain good old > import my_module > ...? Because the OP said: > Now I want to open script_file and shift the whole text one line down, > and enter in the top line "import my_module", so that the commands are > available without having to enter the import-line myself. which Jason took to mean a requirement for importing modules with names not known a priori? regards Steve -- http://www.holdenweb.com/ From altis at semi-retired.com Tue Jan 1 18:40:05 2002 From: altis at semi-retired.com (Kevin Altis) Date: Tue, 1 Jan 2002 15:40:05 -0800 Subject: Client-side web scripting in Python? References: <8abfe95a.0112311037.35fb4c2@posting.google.com> <7x3d1r2paa.fsf@ruckus.brouhaha.com> <8abfe95a.0201011104.2905994f@posting.google.com> Message-ID: Rolf, based on your description I don't see the advantage of having the GUI in the browser. If you need a simple GUI tool, you might want to look at PythonCard. http://pythoncard.sourceforge.net/ There is a simple layout editor (the resourceEditor sample) in the latest version. There is also support for converting to and from PIL image format and drawing PIL images into PythonCard buffered bitmaps for use in the GUI. You shouldn't have to change any of your existing PIL code. You can create a Windows binary of your application using py2exe and then end-users won't have to have Python, wxPython, PIL, or PythonCard, or any other libraries installed. You can post questions to the PythonCard mailing list http://lists.sourceforge.net/lists/listinfo/pythoncard-users or ask them here on comp.lang.python as long as you put PythonCard in the subject line so it is easy to spot. ka "Rolf" wrote in message news:8abfe95a.0201011104.2905994f at posting.google.com... > Paul Rubin wrote in message news:<7x3d1r2paa.fsf at ruckus.brouhaha.com>... > > rolffreimuth at hotmail.com (Rolf) writes: > > > Is there any way to do *pure* python client-side scripting? Are there > > > any good resources with examples of how to do it? > > > > If you mean for publishing web pages on the internet, it doesn't sound > > like such a great idea. I've stopped paying attention to Windoze but > > I believe there's a Python version (ActiveState?) that's callable as a > > COM object. So you'd have to download the huge interpreter to the > > client, and then you could call it from Javascript. You should be > > able to pass it the document object as an argument. From there, the > > python script can use the regular COM automation methods to navigate > > inside the document object, or it can call javascript code to > > manipulate the document. I've forgotten most of this stuff but > > basically once you get hold of the IWebBrowser2 interface you can > > make the browser do most anything you want. > > > I dont mean for it to be a web application. I am just considering it > as a possibility for a simple GUI. To run the app, a user would need > Python installed, plus MSIE, plus a few other python libs. It is > primarily for my own use and education. To launch the app, the user > would just click on an HTML file on the local hard drive. > > Having the GUI in a browser is an advantage for this application. The > app basically scans a directory tree for large digital photos (~2MB > each) then it uses PIL to create thumbnails and and some more > reasonably sized "large" images for publishing on the web. I also was > considering writing some code to manage the FTP of the "processed" > images up to my website. > > Rolf From sholden at holdenweb.com Mon Jan 28 21:17:37 2002 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 28 Jan 2002 21:17:37 -0500 Subject: COM error/exception in Python, but not in VB (no dispatch interface available) References: Message-ID: "Jason R. Coombs" wrote in ... > Hi all. I hope there's someone out there that might know the intricacies of > Python and COM enough to help narrow this problem down. I realize this post > is a bit long and perhaps tedious, but I wanted to be sure to communicate > the problem clearly. Feel free to skim the technical details first to get > an overview of the problem. > [technical details snipped] > > I have not been able to successfully use this component with Python, and I > need to be able to do so. I've tried passing different parameters; I've > tried assigning the result to a variable; I've tried passing (0 == 1) > instead of 0 for the boolean (second) parameter, but this has no effect. > > I will pay for technical support, but I need to know where to go. Is this a > python issue or an issue with their component? Can I identify for which > object there is no dispatch interface available? Can I tell from the > traceback if it's the return value or a parameter? > > Obviously, I've already run make_py on the appropriate object. Do I maybe > need to make_py on another interface? If that's a possibility, how could I > know which one? > > Any suggestions are greatly appreciated. > Short question which might answer your problem: have you tried running makepy on the object? As far as paid technical support goes, the guy who wrote all the COM stuff is Mark Hammond, and you can reach him at mhammond at my-deja.com -- if Mark can't solve a COM-related problem then it probably isn't COM-related. regards Steve -- Consulting, training, speaking: http://www.holdenweb.com/ Python Web Programming: http://pydish.holdenweb.com/pwp/ From pinard at iro.umontreal.ca Sun Jan 6 19:58:11 2002 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 06 Jan 2002 19:58:11 -0500 Subject: Pymacs 0.13 Message-ID: Hi! A new release of Pymacs is available as: http://www.iro.umontreal.ca/~pinard/pymacs/pymacs.tar.gz Pymacs allows Emacs users to extend Emacs using Python, where they might have traditionally used Emacs LISP. Pymacs runs on systems having sub-processes. Here are the few changes appearing with this release. * `pymacs_load_hook' gets invoked at `pymacs-load' time if defined in the loaded Python module. * `pymacs-load' better handles Pymacs modules which are part of Python packages (thanks to Syver Enstad). * A few users asked me for some more substantial example, so I included one in the distribution. See below. The `rebox' batch script and the `rebox.py' Pymacs interactive module may be used to refill boxed comments, for various programming or scripting languages. These tools may also change the box style. Installation is optional, yet once installed, `rebox --help' yields usage documentation. The `README' file, in the example section at the end, holds a discussion of `rebox.py' as a Pymacs application. The translation of `rebox' from Emacs LISP to Python is fairly recent, so please report bugs for `rebox' as well. Pymacs uses its own interactive `setup' script, while `rebox' uses a standard Distutils `setup.py' script. See `README' for installation details. I would like to progressively switch to Distutils, but am not familiar enough yet for getting rid of the interactive `setup'. This might be uneasy, I'm not sure. If you know Distutils well and feel like helping me at this, you are welcome. I would probably like to change how Pymacs is used. Currently, we do: import pymacs from pymacs import lisp while I would like that we become able to do: from Pymacs import lisp, pymacs instead. In fact, `lisp' should still be part of `pymacs', but I presume the above could be achieved with some `__init__.py' trickery. Please tell me if you know how to do these things, or share your comments on the change. Take this as my humble New Year gift. Keep happy, all! -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From kfarmer at thuban.org Tue Jan 29 17:57:28 2002 From: kfarmer at thuban.org (Keith Farmer) Date: Tue, 29 Jan 2002 22:57:28 GMT Subject: Extension/Threading conflict under Win2k References: Message-ID: Fixed. It was a lack of CoInitialize/CoUninitialize when trying to access ADO. It works now, http://www.thuban.org/astro. At least, it seems to work ;) ---------- Keith J. Farmer kfarmer at thuban.org http://www.thuban.org From sholden at pgrad.cs.usyd.edu.au Tue Jan 29 01:41:13 2002 From: sholden at pgrad.cs.usyd.edu.au (Sam Holden) Date: 29 Jan 2002 06:41:13 GMT Subject: Autocoding evolves from........ References: <4314.793T504T6883966threeseas@earthlink.net> <1_f58.7090$X64.3179143@news1.rdc2.pa.home.com> <1461.793T849T12044163threeseas@earthlink.net> <1229.794T2372T485782threeseas@earthlink.net> Message-ID: On Tue, 29 Jan 2002 05:42:59 GMT, Timothy Rue wrote: >On 28-Jan-02 22:41:39 Sam Holden wrote: >>On Tue, 29 Jan 2002 02:42:49 GMT, Timothy Rue >>wrote: >>>On 28-Jan-02 12:35:57 Terry Reedy wrote: >>>>"Timothy Rue" wrote in message >>> >>>>>%> shop yardsale >>> >>>>OK, so you are aware of prior art and are willing to acknowledge that >>>>you are building upon it. Good >>> >>> >>>I would like to know what is going thru your head that you'd write such a >>>thing. >>> >>>Perhaps if you tell me what your interest is in the prior art issue and >>>what it is you think is going thru my mind, then maybe I can correct your >>>perspective of me. > >>I can't speak for the OP,.... > >You shouldn't assume. Really. > >But from what you said, you think re-invention is the surest way to create >something that is valid. Previously you accused someone else of being dishonest by trimming your post in their reply. Here you have trimmed all but one unrelated line from my post and then presented the very opposite of my point as if it was my point. Re-invention is a pointless waste of time (except obviously if the original invention has been lost, or is a trade secret of some sort). However, if one does not examine the prior art there is no way one could know if they are re-inventing something or not. Hence examining the prior art is a good thing. The humourous thing is that the OP gave a compliment, but due to your consistantly demonstrated lack of comprehension ability you have decided to take issue with it. I then tried to clear up the miscomprehension by brielfy explaining the well known principal of examining prior art, of course your lack of comprehension skills mean you somehow managed to read the exact opposite of what I actually wrote. -- Sam Holden From aleax at aleax.it Mon Jan 21 11:46:01 2002 From: aleax at aleax.it (Alex Martelli) Date: Mon, 21 Jan 2002 17:46:01 +0100 Subject: not in References: <3m4o4u8tnumteu12vtd8solunp2ai7kjvo@4ax.com> Message-ID: "rihad" wrote in message news:aibo4u48sa16v8fvrjsrrip9coc47n2108 at 4ax.com... ... > >the semantics of "not a and not b" had better be basically the same > >as those of "not (a or b)". So what? Would you can "not a and not b" > >``new syntax''? I suspect I'm missing your point -- what IS it? > > > Sorry (language barrier?). By `new' I meant that `not in' is a > language construct, just as if it were a distinct not_in/is_not > keyword. IOW, `new' eq `not necessary'. :) Ah, just like, say, unary-plus (strictly non-necessary), binary minus (non-necessary given the presence of unary-minus and binary plus), and the backquote operator `...` (non-necessary given the existence of builtin function repr). Yes, operators 'not in' and 'is not' are indeed not part of a provably minimal subset of necessary operators, just like many others. Python does not even attempt to provide a provably minimal subset; there is a carefully-balanced amount of redundancy for increased readability. For example, most readers will find: a - b more readable than a + -b even though they're obviously equivalent, semantically. Alex From logiplexsoftware at earthlink.net Tue Jan 15 14:23:30 2002 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Tue, 15 Jan 2002 11:23:30 -0800 Subject: * separated values In-Reply-To: <15428.20927.672666.714907@beluga.mojam.com> References: <15428.20927.672666.714907@beluga.mojam.com> Message-ID: <20020115112330.7060c8ce.logiplexsoftware@earthlink.net> > I'm a bit biased because I use CSV files heavily to both import data to and > export data from the Mojam/Musi-Cal database. It's not the world's best > data format, but every package I've ever encountered in the database and > spreadsheet worlds supports it. I suggest Dave Cole's csv module (fast, > easy to use, appears complete) be added to the core: How dare you. ;) www.sf.net/projects/python-dsv/ This module has heuristics that can determine the delimiter, the text qualifier as well as whether the first row is a header or data (or you can provide explicit values yourself). It correctly parses embedded newlines, embedded quotes, etc. Basically it was designed to work with the files generated by MS Excel. It also has an optional wxPython dialog similar to the one found in Excel so the user can preview and change the values decided upon by the heuristics. As a bonus, it's even easy to use (IMHO). -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From othello at javanet.com Fri Jan 25 00:35:23 2002 From: othello at javanet.com (Raymond Hettinger) Date: Fri, 25 Jan 2002 00:35:23 -0500 Subject: indexed() generator References: <52e5ab5f.0201231101.472744fe@posting.google.com> Message-ID: FWIW, I give this idea a +1. Please include some form of iterindexed(seq, start=0) as a built-in in Python2.3. I've been coding something like this in many of my programs since 2.2 came out. Raymond > > In article , Delaney, > > Timothy wrote: > > > > >A perhaps better method would be: > > > > > >def indexed (seq, start=0) > > > i = start > > > for obj in seq: > > > yield i, obj > > > i += 1 From aahz at panix.com Wed Jan 23 17:06:37 2002 From: aahz at panix.com (Aahz Maruch) Date: 23 Jan 2002 14:06:37 -0800 Subject: How are exceptions actually implemented in assembly? References: Message-ID: In article , hungjunglu wrote: >--- In python-list at y..., Steven Majewski wrote: >> >> C doesn't really have exceptions in the language, but the equivalent >> functionality is usually coded in C using setjmp & longjmp (which >are > >Thanks to all that have replied. I was more looking into really low >level implementation (i.e., single CPU instruction, one level further >down from setjump/longjmp. That is, all I wanted to know was whether >it was an interrupt or a jump), because all of a sudden I realized >that exception handling can have an appreciable cost in resources, >when routines call routines that call routines, etc. Python exception >handling is at much higher level, and it charges this cost at that >level. Not too bad, in a sense, since the underlying C code does not >necessarily have to propagate the exception handling all the way down >to assembly. But, it also means that at Python level, exception is >built into everywhere. That's OK, I guess... compared to other things >(e.g: variable name look up), exception handling is probably pretty >cheap in resources/performance. Note carefully that the cost comes almost entirely during the handling of exceptions, not in setting up exception blocks. So if as a percentage of instructions executing exceptions are rare, it's a very small penalty. -- --- Aahz <*> (Copyright 2002 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "I support family values -- Addams family values" --www.nancybuttons.com From eppstein at ics.uci.edu Fri Jan 11 16:49:46 2002 From: eppstein at ics.uci.edu (David Eppstein) Date: Fri, 11 Jan 2002 13:49:46 -0800 Subject: generators : random shootout References: Message-ID: In article , "Mark McEahern" wrote: > Oops, after tweaking the timing a bit, they seem to take the same amount of > time: > > # using globals > $ gen.py 1000 > 8.163294467 > 0.010000 seconds. > > # using generators > $ gen2.py 1000 > 8.163294467 > 0.010000 seconds. You don't think it's suspicious that they both take an amount of time with so many zeros at the end? To me, it looks like they both take one least-measurable-unit of time. You need to try again with much larger counts to get any useful information out of the experiment. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From hans at inenco.no Thu Jan 10 09:13:05 2002 From: hans at inenco.no (Hans Kristian Ruud) Date: Thu, 10 Jan 2002 14:13:05 GMT Subject: The book "Programming Python" by van Rossum et al Message-ID: <3C3DA255.7E22F390@inenco.no> I have the 1st edition. What are the differences between that and the 2nd edition? Thanks in advance Hans Kristian From erno-news at erno.iki.fi Wed Jan 16 06:10:20 2002 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 16 Jan 2002 13:10:20 +0200 Subject: what's wrong with this cookie script References: Message-ID: In article , QdlatY writes: | c = Cookie.SmartCookie() i don't know the answer to your question, but you should never use the SmartCookie class. as mentioned in the documentation, it is a huge security hole. it is only there for backwards compatibility (i wonder why). -- erno From erno-news at erno.iki.fi Thu Jan 31 09:52:40 2002 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 31 Jan 2002 16:52:40 +0200 Subject: Naming higher order functions Message-ID: hello, what would be a good name for the following function? def name_me(n): def g(x): return x[n] return g "make_nth_getter" came to mind but it doesn't sound that good to me. -- erno From rms at computerbytesman.com Tue Jan 15 17:04:36 2002 From: rms at computerbytesman.com (Richard M. Smith) Date: Tue, 15 Jan 2002 17:04:36 -0500 Subject: Serious privacy leak in Python for Windows Message-ID: <3C44A774.5DFCDE15@computerbytesman.com> Hello, There is a privacy leak problem in many Python implementations for Windows which allow a malicious Web page or HTML email message to read the contents of file from a user's hard drive and send the contents back to a Web site. The problem occurs in Windows Python implementations that supports Python as a scripting language for Web pages in Internet Explorer. The problem exists because the Python runtime library does not consider file read operations to be a security risk. File read operations are allowed to execute on a Web page without restriction. File write operations, on the other hand, are blocked. For example, the following Python code on a Web page will run successfully: This particular example opens the file c:\autoexec.bat and writes the file contents to the Web page. The program could easily be changed to send the contents of the file back to a Web site by using an HTML form, a Web bug, or the Microsoft XML HTTP ActiveX control. Here is a second example, that shows a directory listing of C:\ on a Web page: This directory listing example is available online to test to see if a particular computer system is vulnerable to the problem or not: http://www.computerbytesman.com/privacy/pythondirdemo.htm To fix this privacy leak, the Python runtime library should block all file operations when Python code is being used on a Web page, not just file write operations. There might also be workarounds to this problem either in Microsoft's ActiveScripting support in IE or in the Python runtime library. However, I am not an expert on either technology to know what these work-arounds might be. Please drop me an email if you have any suggestions. Richard M. Smith http://www.computerbytesman.com From brian at sweetapp.com Mon Jan 7 12:22:41 2002 From: brian at sweetapp.com (Brian Quinlan) Date: Mon, 7 Jan 2002 09:22:41 -0800 Subject: SimpleXMLRPCServer In-Reply-To: <200201071603.g07G3Il13205@lewis.abi.tconline.net> Message-ID: <002201c1979f$e9f02bf0$445d4540@Dell2> Lewis Bergman wrote: > After much headbanging (and some heIp from the list) I came up with this > method to register functions from multiple classes. As per the docs the > server can only natively instantiate one class at a time and that was less > than I needed. I don't know if anyone else would ever need it but here it > is anyway. This is my first program in python so it probably isn't worth > looking at. Why can't you simply write something like: class MyMethods: def __init__(self, nixUser, icradiusUser): self.NixUser = nixUser self.icradiusUser = icradiusUser NixUser = NixUser.NixUser() icradiusUser = icradiusUser.icradiusUser() server = SimpleXMLRPCServer(("localhost", 8000)) server.register_instance(MyMethods(NixUser, icradiusUser)) server.serve_forever() I haven't tested this so don't be shocked if there you need to fiddle with it to make it work. Let me know if it doesn't do what you want it to do. Also, masking module names with variable names is probably a bad idea. Cheers, Brian > Here is the whole thing so you can get an idea. > > #!/usr/local/bin/python2.2 > from SimpleXMLRPCServer import * > import re > import NixUser, icradiusUser > > NixUser = NixUser.NixUser() > icradiusUser = icradiusUser.icradiusUser() > > server = SimpleXMLRPCServer(("localhost", 8000)) > > importedClass = [NixUser, icradiusUser] > for name in importedClass: > for method in dir(name): > if re.match("^[_]", method) is None: > funcName = name.__module__ + '.' + method > server.register_function(getattr(name, method), > funcName) > > server.serve_forever() From aleax at aleax.it Wed Jan 2 11:50:47 2002 From: aleax at aleax.it (Alex Martelli) Date: Wed, 2 Jan 2002 17:50:47 +0100 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) References: <3C2A9D33.67FEC261@earthlink.net> <3C2BA7B8.35286DE3@earthlink.net> <3c2de385.9780406@news.t-online.de> Message-ID: "Michael Kelly" wrote in message news:vbc63u8okomlah7e0m6c5b9th1vh82fsb8 at 4ax.com... > On 02 Jan 2002 09:11:55 -0500, pinard at iro.umontreal.ca (Fran?ois > Pinard) wrote: > > >My feeling is that C programmers (and I still work at C programs once in a > >while :-) do a "reasonable" error checking, but are rarely fully thorough > >with it. A compromise is needed, because both extremes (no error checking > >at all, checking every possible error) are just unbearable in real programs. > > There was an interesting article in one of the programmer > magazines(maybe C/C++ User Journal but I don't recall) > about how doing error checking for memory allocations > was pretty much a waste of time and effort(since usually > if you are that short of resources you can't do anything > to recover anyway.) Big applications written by people with some smarts start with the equivalent of: global_emergency_ballast = malloc(a_reasonably_big_chunk); The ballast is released in emergency short-of-memory situations, exactly to finesse these kinds of issues. Alex From pinard at iro.umontreal.ca Thu Jan 17 11:12:43 2002 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 17 Jan 2002 11:12:43 -0500 Subject: What does Python fix? In-Reply-To: References: Message-ID: [Mark McEahern] > As for Lisp's parentheses, I've never used Lisp, but when I look at > examples, I have to control my overwhelming desire to vomit when I see that > profusion of parentheses. Of course, whoever reads LISP code (and I still like LISP, even if I prefer Python) looks at the indentation to understand it, not the parentheses. Your editor looks at the parentheses and translates these into proper indentation. Some LISP editors are quite good at this jobs. In a word, for me at least, both Python and LISP need proper indentation to be readable. Parentheses still need to be looked at for deciphering a single line, while Python often does not have equivalent devices to batch many things on one line. It sometimes make that LISP code is a bit more compact than equivalent Python. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From rmunn at pobox.com Thu Jan 10 11:25:04 2002 From: rmunn at pobox.com (Robin Munn) Date: 10 Jan 2002 16:25:04 GMT Subject: if as an operator? References: <3C3E25C5.C4A47384@gol.ge> Message-ID: On Thu, 10 Jan 2002 15:37:41 -0800, Giorgi Lekishvili wrote: >Hi! > >As most of us knows, scheme programming language presents a function as >a list. > >On a grate scale, our Python has many features of a functional >programming language, and first of all, that's the support of the lambda >calculus. > >If we apply the operator module, we can also present a simple function >as a list: > >>>> import operator as o >>>> add=o.add >>>> sub=o.sub >>>> div=o.div >>>> a,b,c=3,5,7 >>>> f=[add,a,[sub,b,c]] >>>> f >[, 3, [, 5, 7]] >>>> print f[0](f[1],f[2][0](f[2][1],f[2][2])) >1 >>>> f[2][0]=div >>>> print f[0](f[1],f[2][0](f[2][1],f[2][2])) >3 >>>> f[2][1]=5.0 >>>> print f[0](f[1],f[2][0](f[2][1],f[2][2])) >3.71428571429 >>>> > >That means that Python can be very successfully employed for the >Gennetic Programming, if only one could have at hand 'if' as the >operator, e.g., like this: >>>> if_=o.if #doesn't work now, of course >Even more important is to make comparisons in this vay: >>>> more_=o.more # a would-be analog of '>' >>>>less_=o.less # a would-be analog of '<' >etc. > >Of course, we can use operator.truth instead of 'if', but how about the >comparison? > >Mayba, I have missed something? Do the lt(a,b), le(a,b), eq(a,b), ... functions in the operator module not do what you want? Ah, I just saw in the Python documentation that these functions are new in Python 2.2. So it looks like you have your wish now. Just upgrade to version 2.2 and all your problems will be solved! :) > > >I believ that the complete, though optional support of functional >programming in Python would make it even more powerful and useful. > >I am familiar with the basics of compiler/interpreter design, but 'm a >chemist, working in the field of data analysis, not a programmer, as you >have surely noticed:) > >Greetings, >Giorgi > > > > -- Robin Munn rmunn at pobox.com From woodsplitter at rocketmail.com Thu Jan 3 23:54:22 2002 From: woodsplitter at rocketmail.com (stalin) Date: 3 Jan 2002 20:54:22 -0800 Subject: a few more questions on XML and python References: Message-ID: <7876a8ea.0201032054.7c7268be@posting.google.com> Rajarshi Guha wrote: > As you can see I'm pretty confused :( Why not use DOM instead of SAX? XML is clearly tree-based, so processing it in terms of trees (DOM) tends to be more easily comprehensible than processing it in terms of streams and event handlers (SAX). SAX has definite resource utilization advantages over DOM for read-only XML access, but I daresay that working code can eat a great deal of memory and still perform better than a dysfunctional collection of highly optimized fragments :) At its simplest, DOM parsing consists of setting up a series of nested node iterations to reach the information you want, as in (Python 2.2): -------------------------------------------------------------- from StringIO import StringIO import xml.dom.minidom as dom theXML = """ The Fascist Menace Josef Stalin unclejoe at kremlin.ru Alexei Voloshnikov just-another-tovarisch at kremlin.ru 1941 """ doc = dom.parse(StringIO(theXML)) book = doc.documentElement print 'edition:', book.attributes['edition'].value # It is the first child (a text node) of the title element, # rather than the title element itself, that contains the value. title = book.getElementsByTagName('title')[0].firstChild.nodeValue print 'title:', title authors = book.getElementsByTagName('authors')[0] for author in authors.getElementsByTagName('author'): print "an author's email:", print author.getElementsByTagName('email')[0].firstChild.nodeValue description = book.getElementsByTagName('description')[0].firstChild.nodeValue print "The critics say [well, aside from omygodisthatakgvbofficer?]:", print description -------------------------------------------------------------- Although that code is totally lax about error handling and quite inefficient (overuse of getElementsByTagName, etc.), it's also brief, and hopefully more comprehensible that the SAX you've been trying to write. If you're processing huge data sets, DOM isn't going to cut it. DOM builds an in-memory representation of the entire document, whereas SAX handles a single element at a time. But after you have a bit of Python and XML parsing under your belt, you can always move on to SAX if necessary, eh? From rhymes at myself.com Thu Jan 24 11:16:14 2002 From: rhymes at myself.com (Lawrence Oluyede) Date: Thu, 24 Jan 2002 17:16:14 +0100 Subject: Classes and Python Message-ID: <2jc05usg0sic5f9evcdfsa9jebecvkmb93@4ax.com> I'm a newbie of Python and I'm still reading its tutorial (downloaded from the official site). I've found this sentence: I also have to warn you that there's a terminological pitfall for object-oriented readers: the word ``object'' in Python does not necessarily mean a class instance. Like C++ and Modula-3, and unlike Smalltalk, not all types in Python are classes: the basic built-in types like integers and lists are not, and even somewhat more exotic types like files aren't. However, all Python types share a little bit of common semantics that is best described by using the word object. What's the real meaning of that? -- Lawrence "Rhymes" Oluyede (rhymes at myself.com) "Per cambiare, per diventare un'altra cosa dobbiamo prima sapere cosa siamo" (Bruce Lee) From sholden at holdenweb.com Sun Jan 27 10:11:35 2002 From: sholden at holdenweb.com (Steve Holden) Date: Sun, 27 Jan 2002 15:11:35 GMT Subject: How to break out of two nested for loops? References: <3c4c8a45$0$3191$626a54ce@news.free.fr> <3C51F09E.4040200@skippinet.com.au> Message-ID: "Aahz Maruch" wrote in message news:a2t4jh$h1t$1 at panix2.panix.com... > In article <3C51F09E.4040200 at skippinet.com.au>, > Mark Hammond wrote: > >Alex Martelli wrote: > >> "Laura Creighton" wrote in message > >> news:mailman.1011889735.22267.python-list at python.org... > >>> > >>>Last night I got to thinking that instead of _except_ > >>>what I would like as the keyword is _discover_ > >> > >> Cool. Or maybe 'expect' -- a mental-typo I do make > >> sometimes for 'except' when I am _expecting_ the > >> _exception_ to happen...:-). > > > >Actually, I think "expect" is perfect, and have indeed made the same > >typo. The exception is obviously expected by virtue of the handler. > > > >And an unqualified handler could use > > > > expect the unexpected: > > Naw. For Python, that should be > > expect the Spanish Inquisition: No, that *can't* be right. *Nobody* expects the Spanish Inquisiton. regards Steve -- Consulting, training, speaking: http://www.holdenweb.com/ Python Web Programming: http://pydish.holdenweb.com/pwp/ From jemptyg at rwmc.net Thu Jan 31 11:37:50 2002 From: jemptyg at rwmc.net (George Jempty) Date: Thu, 31 Jan 2002 16:37:50 GMT Subject: zope's acquisition inheritance References: <3B41E221.CE23D83E@home.com> Message-ID: <1012494640.311651@airwave-sb.scottsbluff.net> Keith Ray wrote in message news:k1e2i3t4h5r6a7y-E9623E.08532703072001 at news... > In article <3B41E221.CE23D83E at home.com>, Wostenberg > wrote: > > > Anybody heard of acquisition outside Zope, or is it a new contribution > > to OO modelling? > > It reminds me of NewtonScript, an OO language without classes, where > every object had two 'parents' for inheritance, one of which, IIRC, is > the GUI containment hierarchy... It seems like NewtonScript's direction > of 'containment inheritance' is opposite of Zope. > > I'm not sure how accurate this paper is, but I never programmed > extensively in NewtonScript, so my memory may be flawed: > > > "3. Inheritance > NewtonScript uses an inheritance scheme which is derived from SELF. > SELF's inheritance mechanism is very flexible. For the special purpose > of writing GUI application, NewtonScript has a simplified double > inheritance scheme. The two ways of inheritance are very much fixed in > purpose when implementing windows and dialog controls, but can be used > more generally as well. > > "3.1 Prototype inheritance > First, each frame can have a prototype frame from which it is derived. > The mechanism is rather simple, the frame contains a slot called _proto > and each time the NewtonScript interpreter does not find a slot variable > or function locally it looks into the frame's prototype and then > recursively into its prototype until the whole inheritance chain was > searched through. When a new slot variable is created that already > exists in a prototype a new slot variable is created in the current > frame. During lookup this new variable is found first and semantically > replaces the prototype variable. From a conventional viewpoint > prototypes serve two roles. First, they are the equivalent to > user-defined types, to create an instance of the type, you just have to > create an object derived from the object that defines the behavior of > your type. Second, prototypes provide the class inheritance mechanism of > class based languages. > > "The dialog creation mechanism of NewtonScript uses prototype > inheritance extensively to create dialog items. When a new instance of a > built-in dialog element is created the new instance has the built-in > object as its prototype. This object created by the user is then called > a template in NewtonScript terminology. When this object is then > actually put onto the screen, the system itself creates another object > having the template as prototype, with some redefined slots to designate > view boundaries for example. Thus the template can be reused to create > more dialog controls with similar properties. > > "3.2 Parent inheritance > The second way of inheritance is conceptually quite similar to prototype > inheritance, besides the _proto slot a slot called _parent points to > another inheritance chain similar to the prototype chain. This second > inheritance scheme is again made to fit into the GUI design, all > child-windows have a child-parent inheritance relationship to their > parent windows. An application normally consists of a parent window, > which is in turn child of the system's root window. All windows and > dialog controls are then hierarchically ordered below this application > parent window. Parent inheritance has an effect similar to prototype > inheritance, variables not found neither in the frame itself nor in its > prototypes are searched for in the parent frames and their prototypes > and so forth. Thus slots in the parent window of an application serve as > application wide globals. Assignment rules are a little different from > the prototype inheritance rules, you can assign values to slots which > reside in your chain of parents and grandparents as you can assign > values to global variables in other languages without replicating these > variables locally in the current frame. > > "For function lookup, NewtonScript only searches the prototype chain, > not the parent chain, although a frame can call a function in one of its > parents directly by dereferencing its _parent slot. It does not become > entirely clear why this is so, I think it is more because of > practicality than principle." Fascinating thread. I've used a little Python in my day, but what drew my attention is some similar Javascript functionality. An outline of a presentation I gave to Colorado's "FROST" (Front Range Object Study) group can be found at http://js.inetsw.com/frost_jan2002/ Of particular interest is the second page. Here is the code from the library that is used, it's very elementary but demonstrates the idea: // // function NumberExam(fieldVal) { this.val = fieldVal; this.wholeNumExp = /^[1-9]\d*$/; this.isWhole = this.wholeNumExp.test(this.val); } function ArabicNumExam(fieldVal) { this.incorporate = NumberExam; this.incorporate(fieldVal); } And the calling code: function Convert2Roman(field) { this.val = field.value; var IsValid = new ob.ArabicNumExam(this.val); if (!IsValid.isWhole || this.val > 3999) alert('Please try again with a whole number between 1 and 3999') else........................................................................ ...................... // // As can be seen, the ArabicNumExam constructor gets the 'isWhole' attribute from the NumberExam constructor. This functionality is not unknown within Javascript circles, but there is no agreed upon name for it: I for instance called it 'incorporation', but acquisition it will be from now on! From nmjoseph at earthlink.com Wed Jan 9 22:09:10 2002 From: nmjoseph at earthlink.com (Neal and Monica Josephson) Date: Thu, 10 Jan 2002 03:09:10 GMT Subject: Freeze with 2.2 Message-ID: I'm trying to build a standalone python program. I've tried Freeze as well as the standalone/simple scripts and they all seem to error in the same way. I'm using Python 2.2 on Win2K. The error looks like: C:\installer>python freeze.py c:\myproject\boot.py > "C:\Program Files\Python\python.exe" C:\installer\Builder.py boot.cfg Cannot determine your Windows or System directories Please add them to your PATH if .dlls are not found The win32api module is not available - modules listed in the registry will not be found. opts: [] args: ['boot.cfg'] Initializing Traceback (most recent call last): File "C:\installer\Builder.py", line 502, in ? main(opts, args) File "C:\installer\Builder.py", line 473, in main target = makeTarget(cfg, section) File "C:\installer\Builder.py", line 416, in makeTarget return dispatch[cfg.get(section, 'type')](cfg, section, optcnvrts) File "C:\installer\Builder.py", line 281, in __init__ ArchiveTarget.__init__(self, cfg, sectnm, cnvrts) File "C:\installer\Builder.py", line 245, in __init__ CollectTarget.__init__(self, cfg, sectnm, cnvrts) File "C:\installer\Builder.py", line 144, in __init__ Target.__init__(self, cfg, sectnm, cnvrts) File "C:\installer\Builder.py", line 34, in __init__ print "Initializing", self.__name__ AttributeError: FullExeTarget instance has no attribute '__name__' From hugomartires at hotmail.com Mon Jan 7 13:50:19 2002 From: hugomartires at hotmail.com (Hugo Martires) Date: 7 Jan 2002 10:50:19 -0800 Subject: Send a Class Object by Socket Message-ID: Python 1.5.2 Linux Socket Stream I wan't to send an object of my class vector() to a client socket. When the client receive the object, i wan't to treat it with all the class functions of that object. (They exist on the remote computer) My problem is: When the object reach the client, how can the client recognize it like an object of the class vector ? Tanks for help... From gleki at gol.ge Wed Jan 2 17:39:31 2002 From: gleki at gol.ge (Giorgi Lekishvili) Date: Wed, 02 Jan 2002 14:39:31 -0800 Subject: Modul gotchas:) References: <3C337808.ECCE968E@gol.ge> <3c330997$0$5765@news2.zeelandnet.nl> Message-ID: <3C338C23.68EA0294@gol.ge> Thanx! Just what I needed! Ewald wrote: > Giorgi Lekishvili wrote in news:3C337808.ECCE968E at gol.ge: > > > Hi all! > > > > happy new year, first of all!!! > > > > My question is simple, yet I missed the right answer, although have lots > > of books on Python:( > > > > Suppose, one has a module, which defines some set of functions. > > > > The question: > > > > How can one get the names of all these functions as list entries? > > > > [snip] > > Chapter 2 of Dive Into Python show how this can be done (a little edited): > > def methodlist(object): > return [method for method in dir(object) if callable(getattr > (object, method))] > > See http://www.diveintopython.org/apihelper_divein.html From johnroth at ameritech.net Wed Jan 23 06:08:46 2002 From: johnroth at ameritech.net (John Roth) Date: Wed, 23 Jan 2002 03:08:46 -0800 Subject: Why aren't colons optional? References: <3C49FED0.8C0F254E@tds.net> <3c4c5f6f.1987456212@news> <2n9s4uscrdnf1kn7tqeoljq1bn2mngibsa@4ax.com> Message-ID: "Courageous" wrote in message news:2n9s4uscrdnf1kn7tqeoljq1bn2mngibsa at 4ax.com... > > >On the other hand, those very "stodgy old grammaticians" are the very people > >that allow other people to 'scale', understand a language, test limits > >etc.... Without those persons, there would be no room to expand. What I mean > >is that those very persons contribute to the whole. Every part is useful to > >the whole, whether you agree with its usefulness or not. The very thing that > >defines something as bad is "useful" in that it allows us to use it as a > >model (or the opposite of) to follow/avoid. > > Certainly. When I think of these things, I recall old memes, antiquated > and out of date: "Thou shalt not end a sentence with a preposition." > "Sentences are not to be begun with a conjunction." "Objects of the verb > 'to be' or to be left in subjective case." Two points. He's talking about computer grammers, specifically about the grammer for the Python language. He's not talking about English, or any other natural language. A computer language is dictated by the language designer, and if you want a good, flexible language that can be cleanly extended, you do need to follow some rules about how you design programming languages. To stray onto your off-topic response, there has always been some tension between the prescriptivists and the descriptivists. The basic difficulty with English grammer (whichever dialect you use) is that it was invented in the late 19th century in order to have something to teach grammer school children. They based it on Latin grammer, and there is no resemblance. The rule about not ending a sentence with a preposition is typical. I am told that is absolutely true in Latin. No exceptions. In English, it is perfectly legitimate to do so, as long as the object occurs earlier in the sentence. To see why that is the case, you need to consider the actual semantics of the language. That, however, is so far off topic that I'm not going to go into it here. > Ever pick up the phone and say "It's me"?. This is incorrect. You're quite right it's incorrect. The correct response is either "Hello?," your name or company affiliation or some such thing. John Roth From phr-n2002a at nightsong.com Thu Jan 31 07:46:44 2002 From: phr-n2002a at nightsong.com (Paul Rubin) Date: 31 Jan 2002 04:46:44 -0800 Subject: Equivalent of Perl chomp? References: Message-ID: <7xbsfag023.fsf@ruckus.brouhaha.com> "Paul Watson" writes: > Is chomp worth considering as an addition to the string functions? I think it should be added. I constantly find myself wanting it. From aleax at aleax.it Wed Jan 16 03:11:34 2002 From: aleax at aleax.it (Alex Martelli) Date: Wed, 16 Jan 2002 09:11:34 +0100 Subject: efficient idiomatic queue? References: Message-ID: "David Eppstein" wrote in message news:eppstein-3B0408.21320615012002 at news.service.uci.edu... > In article , aahz at panix.com (Aahz Maruch) > wrote: > > > Just to be a jerk, why not use a dict with a couple of index variables? > > Maybe you could unpack that a little? dicts are useful but AFAIK they > aren't the same thing as queues, index variables or no. Well, they obviously CAN be used to IMPLEMENT queues -- performance characteristics apart: class DictFifo: def __init__(self): self.data = {} self.nextin = 0 self.nextout = 0 def append(self, value): self.data[self.nextin] = value self.nextin += 1 def pop(self): value = self.data[self.nextout] del self.data[self.nextout] self.nextout += 1 No "being the same" asserted or implied, of course -- the dict and the two indices are just tools to _implement_ a fifo queue, here. Alex From Gareth.McCaughan at pobox.com Sun Jan 13 14:13:37 2002 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Sun, 13 Jan 2002 19:13:37 +0000 Subject: tt = a, b = t References: <5bl34uc7rumgpnbloe4o5cttotuiaj99g0@4ax.com> Message-ID: "rihad" wrote: > Playing with Python goes on.... > > tup = 1, 2 > tuptup = a, None = tup > > >>> tup > (1, 2) > >>> a > 1 > >>> tuptup > (1, 2) > > How did 2 manage to propagate to tuptup through None? None is just an ordinary name. You changed its value to 2. I strongly recommend you not to do that again. :-) -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From yvan.radenac at equant.com Tue Jan 22 03:07:57 2002 From: yvan.radenac at equant.com (Yvan Radenac) Date: 22 Jan 2002 00:07:57 -0800 Subject: I need your experience - classification and comparison of languages References: Message-ID: Michael Chermside wrote in message news:... > Two questions for Yvan: > > (1) I am curious why YOU are compiling this classification if "[you > are] not programmer, analyst or responsible of projects and the > criterias are subjective" (Sic). Perhaps you'd be better off going > with data from someone else who has already tried to classify > languages? There are many such comparisons available on the web. > > (2) Can you make your survey a little more clear? I'd be willing to > fill it out (so far as I am qualified), but I can't really tell > what you want me to do! A straightforward listing of questions > with ratings/answers listed at the top would be nice -- if it looks > quick and easy to fill out I'd probably be willing to help > (although I doubt you would learn anything useful this way). > > -- Michael Chermside I'm not now a programmer but i'm in a course of software engineering. I maded some personal software with Turbo Pascal and some scripts with the shell of Unix. Why choose that kind of subject: - because i use GNU/Linux and i think that public software is a great thing. - i'm interesting in programming, and particularly in oo because i'm curious and perhaps i will program. I post it to have the point of view of programmer, responsible of project, ... cause of their different experience(s). The real goal it's just to propose some tables to find the right language for a type of deveolpment. I think that each language have its own area of applications for a type of development: like Perl for rapidly create a test cleint for a smtp server developped in C ... I'm not interesting , YOU TOO a suppose, to find the badiest or the best language but just the most usefull language for a area of applications and a type of develpment (rapid, big project, ...). I tried to find the most general criterias which be applied on each language. I use this interview to obtain a real result by a average of all result. From nospam at bigfoot.com Thu Jan 31 09:32:21 2002 From: nospam at bigfoot.com (Gillou) Date: Thu, 31 Jan 2002 15:32:21 +0100 Subject: Python like the old-time batch files. References: Message-ID: Not in the standard distro for win32 Unix have a curses package for this. You can get a curses like package for windows from there... http://effbot.org/efflib/console/ HTH "MDK" a ?crit dans le message news: a3bhcf$176195$1 at ID-98166.news.dfncis.de... > I was thinking back to years ago when I wrote batch files and I was able to > make these real nice double-line borders, change the color of things, and, > one of my favorite things, move the cursor up, down, left, or right in order > to write text or put lines anywhere. > > In Windows when I double click on a Python.py file it runs in a DOS-like > box. Is it possible in Python to make those neat double-line borders, > change colors, and move the cursor to the exact position you want? > > Thanks. > > From m.hadfield at niwa.co.nz Wed Jan 23 17:30:20 2002 From: m.hadfield at niwa.co.nz (Mark Hadfield) Date: Thu, 24 Jan 2002 11:30:20 +1300 Subject: [module] cygwin directory browser References: Message-ID: "Anton Vredegoor" wrote in message news:a2mbkc$q7j$1 at news.hccnet.nl... > line 62: sys.path.append(r'c:/Program Files/python22/Tools/Idle') Yes this does work, so does: sys.path.append(r'c:\\Program Files\\python22\\Tools\\Idle') I prefer the latter because it's clear that what's being represented is a Windows path. Maybe what's happening is that by adding the Idle directory to the path, we're dragging Windows Tcl and Tk into the equation as well as Cygwin Tkinter. And Windows Tcl and Tk obviously wouldn't understand Unix-style paths. ...Then again maybe not. > If you can do: "cd /disk0/" in your shell, you could use "/disk0/" > instead of "/cygdrive/". In my shell only "cd /cygdrive/" or "cd c:/" > and such works so I can't check this "/disk0/" alternative. /disk0 is just a mount point on my Cygwin system, pointing to C:\. I've been thinking recently that I might omit it and use /cygdrive/c instead. But this points to a weakness in your cygdir script: it doesn't know what directories are mounted under /. It assumes there is a /cygdrive and does the equivalent of "ls /cygdrive". This scans all the disks on the machine and comes up with a list: "a c d e" or whatever. But doing "ls /" does not find /cygdrive, or any of the other mount points. BTW I have both Cygwin and native-Windows versions of Python on my system. I have a similar directory-choosing script to yours, but implemented in native-Windows Python using the WxPython directory-dialogue. I wrote it some time ago but I find that I don't use it much. What I tend to do is track down the directory I want in Explorer and open a bash prompt or Python prompt there. Or cd to it in bash using its excellent input-completion facilities. --- Mark Hadfield m.hadfield at niwa.co.nz http://katipo.niwa.co.nz/~hadfield National Institute for Water and Atmospheric Research From paul at boddie.net Mon Jan 21 18:24:59 2002 From: paul at boddie.net (Paul Boddie) Date: 21 Jan 2002 17:24:59 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Jan 21) Message-ID: QOTW: "[U]nlike Crays [supercomputers], the M100 [a hand-held from 1984, still in common use in certain professional circles] never crashed, so overall it was more productive." Tim Peters "I do scientific computing for a living, and these days all I use for new code is python, looking at C libraries and snippets of code only when I know that I need it." Fernando Perez Python is the "most powerful language you can still read". Paul Dubois VisualPython.NET appears as a MSDN download. In a Microsoft- dominated world, all other news pales in comparison. Python 2.1.2 is released (for users of Python 2.1 or 2.1.1 who don't want to upgrade to 2.2). http://www.python.org/2.1.2/ Privacy is a concern with ActiveState Python on Windows or standard Python with the win32all extension. http://groups.google.com/groups?th=2d549683d06ab8a0 http://www.securityfocus.com/archive/1/250580 Mark Hammond comes to the rescue with new win32all releases. http://groups.google.com/groups?selm=3C4A252A.3020908%40skippinet.com.au http://starship.python.net/crew/mhammond/win32/PrivacyProblem.html The Python Spread Module 1.0 provides a wrapper for the Spread messaging toolkit. There's clearly an application in mind for this wrapper... http://groups.google.com/groups?selm=mailman.1011109326.31993.clpa-moderators%40python.org http://www.zope.org/Wikis/ZODB/StandbyStorage For engineering in the forward direction, PyChecker v0.8.8 helps in the development of good, solid code. http://groups.google.com/groups?selm=mailman.1011022022.7295.clpa-moderators%40python.org The intriguing PyReverse is updated to release 0.2.1, helping with the documentation of existing code. http://groups.google.com/groups?selm=slrna48kg2.s2.syt%40gemini.logilab.fr altis claims Python is a serious language. http://altis.manilasites.com/2002/01/21 The weave package provides a means of mixing C or C++ into Python code, permitting interesting optimisation techniques. http://groups.google.com/groups?selm=mailman.1011113062.15515.python-list%40python.org More Python, C and C++ synergy: the UK Python Conference 2002 takes place on 4th, 5th April in Oxford, alongside the Association of C and C++ Users conference event. http://groups.google.com/groups?selm=mailman.1011344071.31602.python-list%40python.org The PythonCard project issues release 0.6.2 of its HyperCard-aspiring software construction kit. http://groups.google.com/groups?selm=mailman.1011260881.5074.clpa-moderators%40python.org A new print magazine, "Py", seeks to cover all aspects of Python four times a year. http://groups.google.com/groups?selm=mailman.1011376682.27341.clpa-moderators%40python.org Related to books and print magazines, Bookland.py v 0.92 generates bar codes. http://groups.google.com/groups?selm=m2n0zhpm6h.fsf%40tcraft.cgpp.com Albatross 0.05 is a Web development framework with lots of documentation. http://groups.google.com/groups?selm=mailman.1011022022.7294.clpa-moderators%40python.org Not quite printable, maps with "clickable objects" as PDF files can be made with PDFMap 1.00. http://groups.google.com/groups?selm=Pine.LNX.3.96.1020116162649.4931L-100000%40cortex.unice.fr Python 2.2 arrives for StrongARM-based Pocket PCs. http://groups.google.com/groups?selm=3c4b444b_10%40news.newsgroups.com XML, XML-RPC, SOAP and SSL support come to the Sharp Zaurus. http://groups.google.com/groups?selm=mailman.1011093501.15461.python-list%40python.org Should comma-separated value tools be part of the standard library? To the rescue: Python-DSV 1.3.3 is released. http://groups.google.com/groups?th=cac932a9de0b0389 http://groups.google.com/groups?selm=mailman.1011260882.5075.clpa-moderators%40python.org Stackless Python has certainly inspired features in "standard" Python, but it never reached "integration point". Christian Tismer outlines the future of Stackless... http://groups.google.com/groups?selm=mailman.1011288507.11431.python-list%40python.org ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily Mygale is a news-gathering webcrawler that specializes in (new) World-Wide Web articles related to Python. http://www.awaretek.com/nowak/mygale.html While cosmetically similar, Mygale and the Daily Python-URL are utterly different in their technologies and generally in their results. comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Michael Hudson continued Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list once every other week, into July 2001. Any volunteers to re-start this valuable series? http://starship.python.net/crew/mwh/summaries/ http://www.amk.ca/python/dev The Vaults of Parnassus ambitiously collect Python resources http://www.vex.net/~x/parnassus/ Much of Python's real work takes place on Special-Interest Group mailing lists http://www.python.org/sigs/ The Python Software Foundation has replaced the Python Consortium as an independent nexus of activity http://www.python.org/psf/ Cetus does much of the same http://www.cetus-links.org/oo_python.html Python FAQTS http://python.faqts.com/ The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://python.sourceforge.net/peps/pep-0042.html Python Journal is at work on its second issue http://www.pythonjournal.com Links2Go is a new semi-automated link collection; it's impressive what AI can generate http://www.links2go.com/search?search=python Tenth International Python Conference http://www.python10.org Archive probing tricks of the trade: http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python&num=100 http://groups.google.com/groups?meta=site%3Dgroups%26group%3Dcomp.lang.python.* Previous - (U)se the (R)esource, (L)uke! - messages are listed here: http://www.ddj.com/topics/pythonurl/ http://purl.org/thecliff/python/url.html (dormant) or http://groups.google.com/groups?oi=djq&as_q=+Python-URL!&as_ugroup=comp.lang.python Suggestions/corrections for next week's posting are always welcome. [http://www.egroups.com/list/python-url-leads/ is hibernating. Just e-mail us ideas directly.] To receive a new issue of this posting in e-mail each Monday morning, ask to subscribe. Mention "Python-URL!". -- The Python-URL! Team-- Dr. Dobb's Journal (http://www.ddj.com) is pleased to participate in and sponsor the "Python-URL!" project. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From jmboone at telocity.com Wed Jan 23 20:35:25 2002 From: jmboone at telocity.com (Jim Boone) Date: Wed, 23 Jan 2002 20:35:25 -0500 Subject: How do I grab stdout from a shell command in jython? Message-ID: <3c4f64c9$1_2@nopics.sjc> Hi, I recently began to explore using jython to handle many of the nasty text processing tasks that I need to do in my Java programs. Jython looked like the answer to my prayers until I tried to apply it to a problem I hope someone can point me in the right direction. I need to execute commands on AIX, parse the output, and package the results as a Java Bean. Since I am brand new to Python, I anxiously imported os and tried to execute os.popen('command') and grab the output stream. However, popen has not yet been implemented in jython! Given that big let down, does anyone know how in the world can I execute a shell command and process the resulting output stream from jython? Thanks in advance for your help! Jim From borovik at hotmail.com Thu Jan 10 12:04:28 2002 From: borovik at hotmail.com (IB) Date: 10 Jan 2002 09:04:28 -0800 Subject: Ruby Impressions References: <752891fc.0201091327.5842485f@posting.google.com> <23891c90.0201100347.19c0a672@posting.google.com> Message-ID: Hello, Paul: Just a thought here... I am new to Python too and before diving into it I spent some time researching what language would satisfy the following: 1. Must be free open source 2. Must be true multiplatform with ports to Windows, Linux and MacOS. 3. Must have same or comparable to Perl's number of packages covering GUI, databases, expert systems, numerical programming, web, TCP/IP and graphics programming. The main packages must be updated on a regular basis for new versions of the language and must have ports to all of those major platforms. 4. Must be easily extendable and imbeddable. (Then it must have a good selection of books on it. Otherwise you have to supply general documentation on the language with every application where you imbed it.) 5. Applications must be rather easy to distribute. 6. Must support OOP with possibility to mix it with functional programming. 7. Preferrably clean and clear syntax. The best two candidates were Perl and Python. Python won by the last item - its syntax. (Actually, I had another item on the list - the language should be rather common to 3D graphics community. I believe Python is unsurpassed here. Just to name few examples - Blender, PoserPro and trueSpace use Python. VTK has bindings for Python.) I have not look into Ruby, though. I thought it is just Yet Another Programming Language. It would be interesting to see how items 1-7 apply to Ruby and see how Ruby does in comparison to Python and Perl. I would appreciate if someone will continue the thread with a follow up on this. --Igor From dale at riverhall.NOTHANKS.co.uk Tue Jan 22 07:35:42 2002 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Tue, 22 Jan 2002 12:35:42 +0000 Subject: How to break out of two nested for loops? References: <3c4c8a45$0$3191$626a54ce@news.free.fr> Message-ID: aahz at panix.com (Aahz Maruch) wrote: >That's an attitude. It's an incorrect attitude, but it's one you share >with a fair number of people. You might want to check up on the >workings of the for loop. You pompous fuckwit but thanks for your point of view. -- Dale Strickland-Clark Riverhall Systems Ltd From skip at pobox.com Wed Jan 9 10:38:46 2002 From: skip at pobox.com (Skip Montanaro) Date: Wed, 9 Jan 2002 09:38:46 -0600 Subject: JavaScript considered harmful (was Re: New online index to Be azley's tutorials) In-Reply-To: <3C3C308B.D9A97E65@stroeder.com> References: <3C3C308B.D9A97E65@stroeder.com> Message-ID: <15420.25606.794849.330004@12-248-41-177.client.attbi.com> >> Can't you add >> >> >> >> to your document's and then gzip the body? Michael> No, you can't do it like this. The HTML section is Michael> already part of the HTTP body which is meant to be gzipped. Oops, yeah, you're right... Skip From cbbrowne at acm.org Thu Jan 24 22:27:38 2002 From: cbbrowne at acm.org (Christopher Browne) Date: 24 Jan 2002 22:27:38 -0500 Subject: Autocoding >Re: "Introduction to Ethics", References: <321.788T2944T10325794threeseas@earthlink.net> <87it9sn0jc.fsf@becket.becket.net> <6322.789T326T13093628threeseas@earthlink.net> Message-ID: "Timothy Rue" writes: > On 23-Jan-02 17:51:51 ---name removed until ok'd for newgroups -- wrote: > >"Timothy Rue" writes: > >> I know enough to know that I know more than I need to know, to > >> know the project I presented is a valid one. > >Autocoding is a nice dream, but it's a little like world peace. > >It's not just a matter of saying "here's a great idea, do this". > World peace is a lot closer than many realize and the more that do > realize, the closer it gets. > http://www.osearth.com/resources/wwwproject/ [Vast array of wishful thinking omitted.] The way that free software projects succeed is when people release actual software that _works_. It doesn't forcibly have to work _well_; it doesn't have to be as fully featured as it might, someday, become. In contrast, it is blatantly obvious that projects that merely involve people waving their hands, "visualizing whirled peas," never amount to _anything_. Take a quick look at There are _vast numbers_ of projects that have been "started" where someone got wishful and decided to start "designing something" in the hopes that other people would come along and actually do the work of making it useful. There are probably 10,000 such projects that will be forever ignored, in spite of the fact that each involves high aspirations for success. If you can't release a preliminary _functional_ "autocoder," then I don't think it's going far to say that there's no reason why _anybody_ should feel compelled to listen to you. And the best you can expect, without some _working code_, is for people to say "that's nice" and go on to the _real_ things they have to do. People may be polite, in the beginning; if you are persistent in wasting their time on your pipe dream, they will get less polite as they tell you to go away. -- (reverse (concatenate 'string "moc.adanac@" "enworbbc")) http://www.ntlug.org/~cbbrowne/emacs.html "...Unix, MS-DOS, and Windows NT (also known as the Good, the Bad, and the Ugly)." -- Matt Welsh From s.schwarzer at ndh.net Mon Jan 28 12:53:27 2002 From: s.schwarzer at ndh.net (Stefan Schwarzer) Date: Mon, 28 Jan 2002 18:53:27 +0100 Subject: script detection References: Message-ID: <3C559017.2B31C131@ndh.net> cyclotron wrote: > I get a page where it says something about that my login was > successful (so I think the cookie part works) but it also says "We > don't support scripts" in the html code. > How can I fake the browser identification? I couldn't find useful > information about it on the net. The following code contains the headers which my Netscape browser sends: url = 'http://www.python.org/' host = urlparse.urlsplit(url)[1] req = urllib2.Request(url) req.add_header('Connection', 'Keep-Alive') req.add_header('User-Agent', 'Mozilla/4.61 [en] (OS/2; U)') req.add_header('Host', host) req.add_header('Accept', 'image/gif, image/x-xbitmap, ' 'image/jpeg, image/pjpeg, image/png, */*') req.add_header('Accept-Encoding', 'gzip') req.add_header('Accept-Language', 'de-DE,en') req.add_header('Accept-Charset', 'iso-8859-1,*,utf-8') response = urllib2.urlopen(req) got = response.read() response.close() HTH Stefan From jbauer at rubic.com Wed Jan 30 10:42:38 2002 From: jbauer at rubic.com (Jeff Bauer) Date: Wed, 30 Jan 2002 09:42:38 -0600 Subject: IPC10: share ground travel from BWI? Message-ID: <3C58146E.A1C6663@rubic.com> Hello to all Python Conference attendees. If anyone is planning on arriving at BWI on Monday afternoon and would like to share costs for ground transportation to the conference site, please contact me via email: jbauer at rubic.com Jeff Bauer Rubicon Research From dgrisby at uk.research.att.com Wed Jan 23 05:23:32 2002 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 23 Jan 2002 10:23:32 GMT Subject: omniORBpy, was re: SOAP server in Python References: <3c4e6d69.43478538@news.laplaza.org> Message-ID: In article <3c4e6d69.43478538 at news.laplaza.org>, Mats Wichmann wrote: >Hey, Duncan, speaking of 2.2 compatibility, what's the story with >OmniORBpy - the current kit is tagged as 2.1, does it work with 2.2? If you build it from source, omniORBpy works fine with 2.2. Unix versions compiled against 2.1 seem to work OK, but warn about the version mismatch. Windows versions compiled for 2.1 die horribly with 2.2. The next release of omniORBpy will have binaries for Python 2.2. Cheers, Duncan. -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From kragen at pobox.com Tue Jan 29 14:48:14 2002 From: kragen at pobox.com (Kragen Sitaker) Date: 29 Jan 2002 14:48:14 -0500 Subject: tt = a, b = t References: <5bl34uc7rumgpnbloe4o5cttotuiaj99g0@4ax.com> <3ia54uocesio888stl6s3vvr2iladtvnr7@4ax.com> Message-ID: <83pu3tey69.fsf@panacea.canonical.org> rihad writes: > Hmm, I tried what you implicitly suggested :-) (__builtins__.None = 1) > It worked... Now, isn't that a threat to security? > > if something is None: > # deny access > else: > # allow access > > Then maybe it's not the case. In Python, any code you're running that isn't properly enclosed in a rexec will be able to redefine all the builtins and break all your other code. Sorry. From jason at jorendorff.com Mon Jan 14 01:58:40 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Mon, 14 Jan 2002 00:58:40 -0600 Subject: HTTPLib and POST problem with '?' In-Reply-To: Message-ID: Alex Martelli wrote: > Jason Orendorff wrote: > >Alex Martelli wrote: > >> > h.putrequest("POST", "/cgi-bin/script.cgi?name=Paul") > >> > >> No; this violates the HTTP standards (the ? and after are > >> only used for GET, to encode the FORM values; in POST, the > >> form values are sent as the request's data instead of in > >> the URL) [...] > > > > Is this true? Admittedly I avoid using POST this way, > > but is there really something in RFC 2616 that forbids it? > > I wasn't able to find anything. > > If I recall correctly the last time this discussion came up, the relevant > paragraph is in section 9.5, POST, of RFC 2616, and I quote: > "The posted entity is subordinate to that URI in the same way that a file > is subordinate to a directory containing it, a news article is > subordinate to a newsgroup to which it is posted, or a record is > subordinate to a database." where "that URI" is the request URI. > > In the CGI standard (sorry, no standard text at all, so summarizing from > memory) there is no "subordinate" relationship between QUERY_STRING > and the script's stdin; thus it doesn't meet the requirements of POST. That depends on what the CGI program does with the data. It may store the posted data in a database specified by the query string, in which case it completely fulfills the letter and spirit of the standard. And, not all HTTP-based server-side applications use CGI. In fact, whether they do or not is really none of the client's business. > In the light of the meta-principle "be conservative in what you generate, > and liberal in what you accept", I think a server should probably accept a > (probably-incorrect) mix of both, and try to do something sensible; but a > client (e.g., httplib) should never generate the mix. Hmm. Well, under the Principle of Least Surprise, a library should not silently truncate data being sent to a server. httplib behaves correctly, as far as I can tell. ## Jason Orendorff http://www.jorendorff.com/ From threeseas at earthlink.net Sat Jan 26 21:20:49 2002 From: threeseas at earthlink.net (Timothy Rue) Date: Sun, 27 Jan 2002 02:20:49 GMT Subject: Autocoding project proposal. References: <5372.791T2458T1516056threeseas@earthlink.net> <5203.791T524T9503446threeseas@earthlink.net> Message-ID: <2674.791T1120T13154166threeseas@earthlink.net> On 26-Jan-02 19:38:38 David Masterson wrote: >>>>>> Jonathan Hogg writes: >> AppleScript (to continue my example) has a few basic commands (OK, >> it also has a lot that aren't basic, but run with me...). For >> instance (not tested, don't bother ratting on me if I get them >> wrong): >> * Selecting an application: >> tell application "Finder" to ... >> * Getting a thing from an application: >> ... get the startup disk >> * Identifying a thing in terms of a container: >> ... get the folder "Documents" of the startup disk >> * Sending a command: >> ... move the folder "Documents" of the startup disk to the trash >> These are simple concepts that most people can quickly grasp, but >> the devil is in the details. The hard thing is mapping the things >> that the application works with into terms that the user can >> understand. Things such as "folder", "trash", etc. >Whoa! Shades of COBOL... >> Apple manage this by asking programmers to write a dictionary for >> their application and to document it. The dictionary and the >> documentation are built into the application itself, and any user >> can point the Script Editor (an application that comes with every >> Mac) at an application and ask for this documentation. The Script >> Editor application uses the application supplied dictionary to check >> that the commands entered by the user are legal. >Whoa! Shades of Emacs... There have been over 3000 programming language created in a period of around 50 years. That's alot more than human recorded language in all of mans history. Certainly by now we have enough to look at and determine what the general programming concepts are, as well as knowing such general concepts are by far much less in number than languages they are expressed in. As such, "Whoa@ Shades of...." can be filling in with most any programming language. But no matter what, you still have to: start/stop things keep track of where you are in doing things Get input determine where you are getting input from determine wherre you are sending output to do things one step at a time look up the meaning of things look up the identy of things Reduce you look up via constraints WHOA! SHADES OF EVERYTHING!!!!!! --- *3 S.E.A.S - Virtual Interaction Configuration (VIC) - VISION OF VISIONS!* *~ ~ ~ Advancing How we Perceive and Use the Tool of Computers!* Timothy Rue What's *DONE* in all we do? *AI PK OI IP OP SF IQ ID KE* Email @ mailto:timrue at mindspring.com >INPUT->(Processing)->OUTPUT>v Web @ http://www.mindspring.com/~timrue/ ^<--------<----9----<--------< From marklists at mceahern.com Wed Jan 2 11:58:35 2002 From: marklists at mceahern.com (Mark McEahern) Date: Wed, 2 Jan 2002 08:58:35 -0800 Subject: waterfall In-Reply-To: Message-ID: > How do you KNOW that "the customer's requirements are definitive"? To which I would add so as to emphasize the inevitability of change: "How do you KNOW that the customer's requirements however definitive they might be NOW, will not change before you're done?" // mark From pinard at iro.umontreal.ca Sun Jan 27 09:04:51 2002 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 27 Jan 2002 09:04:51 -0500 Subject: Float compression [Re: floating point math results question] In-Reply-To: References: <88bc63c6.0201250748.241385d2@posting.google.com> <3C52F8E9.9589B626@engcorp.com> Message-ID: [Fran?ois Pinard] > > A more interesting problem is an efficient algorithm for refactoring an > > arbitrary rational number into a sequence of the form: > > ... + 100.k[2] + 10.k[1] + k[0] + k[-1]/10 + k[-2]/100 + ... > > where 0 <= k[i] < 10, which you would want for printing out the > > representation as a normal floating point number. > > many rationals are non-terminating as floats.] > I would guess that `str()' has been implemented with some care about > efficiency. Couldn't you just use it? Oops, sorry! I missed the `rational' on the second quoted line, above. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From eppstein at ics.uci.edu Wed Jan 23 11:22:47 2002 From: eppstein at ics.uci.edu (David Eppstein) Date: Wed, 23 Jan 2002 08:22:47 -0800 Subject: Alter the compression-ratio on JPEG-images using PIL & Resizing/scaling images properly References: Message-ID: In article , "Thomas Weholt" wrote: > And what is the proper way to resize or scale an image? When I use > img.thumbnail() the result is very jaggy around the edges. Any hints? I want > to create thumbnails and a resized version with specific max values for > height/width of the original image. For modest downsizing without jaggies, I use: filter(ImageFilter.SMOOTH) resize(..., Image.BICUBIC) The smoothing step should really be a carefully tuned box filter -- the effect you're trying to achieve is to make each downsized pixel be the average over a small square of (the bicubic interpolation of) the original image, rather than just a point sample from that image. But I didn't see any box filters in PIL's docs... -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From claird at starbase.neosoft.com Fri Jan 4 13:14:29 2002 From: claird at starbase.neosoft.com (Cameron Laird) Date: 4 Jan 2002 12:14:29 -0600 Subject: Book Royalties References: Message-ID: <725D989D4EABAA23.7E7330ECA11138F5.060A7A10105DAABD@lp.airnews.net> In article , Alex Martelli wrote: . . . >It seems to me that existing publishers and bookshops (including >both online and brick-and-mortar stores) are a reasonably good setup >to market and sell books (as well as, at least potentially, helping >enormously with editing, production, and so on). No doubt better >alternatives may one day emerge, but, so far, I have seen none. . . . Distribution and marketing--those are the reasons, and pre- dominantly the former. Tim O'Reilly writes frequently on this subject, both in public and elsewhere. In principle, publishers add value in the editorial process, but that has become secondary or even tertiary for most. Distribution's the key thing, though: publishers (when they're doing their job) get inventory out on display shelves where modestly-motivated prospective consumers are liable to exercise their impulses. Most of the other publishing functions are fungible. In particular, self-publishing can work out great for people, such as Bruce, who are in front of their audiences a lot. Apart from a few elephant-generators (the original Dummy authors, ...), some of the best livings among authors are those made by trainers or seminar speakers who capture the dollars in the pockets of their listeners. I second Alex: while 'twould appear that more efficient social forms will appear some day, it's not obvious what beats a traditional book right now. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From amackay at radical.ca Fri Jan 25 16:25:08 2002 From: amackay at radical.ca (Angus Mackay) Date: Fri, 25 Jan 2002 13:25:08 -0800 Subject: Which LIBC version under windows!!!! Message-ID: <3C51CD34.11F3C4C7@radical.ca> okay, this is driving me crazy. which LIBC version do I have to use to allow me to play nice with the FILE*'s that I get back from the python DLL? I can't believe how retarted windows is when it comes to LIBC. it boggles the mind. Angus. From pete at shinners.org Wed Jan 9 11:08:03 2002 From: pete at shinners.org (Pete Shinners) Date: Wed, 09 Jan 2002 16:08:03 GMT Subject: Distributing Python, slimer? References: <3c3be0f4.29628343@nntp> Message-ID: <3C3C6B47.8060105@shinners.org> Jeffrey Drake wrote: > I am considering using python for developing the second version of a > program I made called Q3FLauncher. ( http://members.rogers.com/jpt.d ) > > My main problem is that I don't want the user to have to download 6mb > for something they probably won't actually develop with. Py2EXE is an > even worse option (from what I understand of how it works) as it would > need to transfer a smaller (1/2?) transfer but have to do it more > often. for a small script, i'm guessing py2exe will build you something that's about 1mb in size. if that's just too big, you can set your program up so that the program created by py2exe calls an extrernal .PY script. that way users would only need to download the updated version of your .PY script for any changes. From max at alcyone.com Thu Jan 17 16:03:22 2002 From: max at alcyone.com (Erik Max Francis) Date: Thu, 17 Jan 2002 13:03:22 -0800 Subject: script portability trick References: Message-ID: <3C473C1A.A7D4FC0@alcyone.com> Roy Dragseth wrote: > I usually start my python scripts with > > #!/usr/bin/env python > > I haven't seen an environment where env wasn't in /usr/bin yet. > > Anyone? If you install Python manually, it will invariably be in /usr/local/bin. The /usr/bin/env trick is fairly good practice, but runs into a problem if there are multiple Python's (named python) installed on the same system. For instance, if your default installation puts one in /usr/bin, and you upgrade to a new version and it gets installed in /usr/local/bin. Now which one /usr/bin/env finds will depend on the PATH setting, which, for instance, will tend to be different in an interactive shell than in a cron job. (The best approach is to rename or delete the python in /usr/bin if you really don't want that one.) Using #!/usr/local/bin/python isn't too bad, since you can always put a symlink in /usr/local/bin to where the Python executable really is should it not be there. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From sholden at holdenweb.com Wed Jan 30 17:32:58 2002 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 30 Jan 2002 17:32:58 -0500 Subject: lists, uppercase? References: Message-ID: "Bjorn Pettersen" wrote in message news:mailman.1012427749.9821.python-list at python.org... > From: maximilianscherr [mailto:MaximilianScherr at T-Online.de] > > just two questions this time: > [list reversal] > how can i get to know if a string is totally uppercase? if myString == myString.upper(): # it's all upper case Well, not strictly true: what that tells you is that there are no lower-case letters in the string. But "123" == "123".upper() even though there's not an upper case character to be seen. Depends exactly what the requirement is, I suspect. regards Steve -- Consulting, training, speaking: http://www.holdenweb.com/ Python Web Programming: http://pydish.holdenweb.com/pwp/ From cliechti at gmx.net Tue Jan 15 16:55:41 2002 From: cliechti at gmx.net (Chris Liechti) Date: 15 Jan 2002 22:55:41 +0100 Subject: Performance Issues with Threaded Python Network Server References: Message-ID: Joao Prado Maia wrote in news:mailman.1011124161.26356.python-list at python.org: > > Hi, > > Before even starting with the description of my problem, let me explain > my situation. I'm trying to create a custom Python based NNTP server to > serve as a gateway of sorts to some web message boards. This way people > can connect to the News server and get messages / reply and such. nice ... > The problem here is that whenever this happens, the CPU usage of the > NNTP server goes to about 35% and continues increasing slowly while the > newsreader is receiving all the message headers and bodies. in some of your SQL expressions you write "WHERE... A.id >= %s" doesn't this mean that the number of messages that have to be filtered increases with the id to get? (snipet above from get_XOVER) (long a go my SQL experiences....) > My guess right now is that I'm doing something bad on the routines that > spit the information to the newsreader somehow and because of this the > server is consuming a lot of CPU. Since I'm not an expert in the > performance tweaks or even about possible bottlenecks, I would love if > someone could take a look and maybe get some insight into what could be > wrong. have you looked at the memory consuption too? maybe you allacte more and more space each request. (what's your log class doing?) to find out where the CPU spends it cycles the python profiler is the right tool. its easy to use and helps to find bottlenecks. look at the docs in the stdlib for info about using it. i sugest running one session and then identify the function that receives most of the execution time and look also at functions that are called often. other comments: i saw you compare often with 'ggg'. if you use this for not yet defined etc. i sugest to use "if article is not None: ..." etc. (of course initializing undefined values as "article=None" at the beginning) you don't need to compare "if somestring != '': ..." just write "if somestring:..." as every non empty string will evaluate as TRUE. have fun chris > ************************************************************************ > *** > The contents of this communication are intended only for the addressee > and > may contain confidential and/or privileged material. If you are not the > intended recipient, please do not read, copy, use or disclose this > communication and notify the sender. Opinions, conclusions and other > information in this communication that do not relate to the official > business of my company shall be understood as neither given nor > endorsed by it. > ************************************************************************ > *** note that most people don't care about such disclaimers, well you posting to a open newsgroup! -- Chris From lac at strakt.com Fri Jan 25 14:31:11 2002 From: lac at strakt.com (Laura Creighton) Date: Fri, 25 Jan 2002 20:31:11 +0100 Subject: Autocoding project proposal. In-Reply-To: Message from "Timothy Rue" of "Fri, 25 Jan 2002 16:31:44 GMT." <7913.790T2087T5925609threeseas@earthlink.net> References: <1911.788T2678T8325744threeseas@earthlink.net> <1451.789T1404T13174678threeseas@earthlink.net> <83vgdri0bj.fsf@panacea.canonical.org> <7913.790T2087T5925609threeseas@earthlink.net> Message-ID: <200201251931.g0PJVBvv027369@ratthing-b246.strakt.com> > Timothy Rue: > > Oh, I'm sure there is a spectrum of people intensely focused on a project, > to those who are helpping a little here and there in a project to those > who are at the other extream of putting on an act with intent to cleverly > hinder..... and all else inbetween.... > [snip] > > Kragen, where do you fall in the spectrum mentioned in the beginning of > this post? > [In case Kragen is modest] In the past week Kragen has released the arrayfrombuffer package (really cool - I spent this afternoon playing with it when I was supposed to be working on something else, because I couldn't put it down), http://pobox.com/~kragen/sw/arrayfrombuffer/ and a preliminary version of MetaPy, http://pobox.com/~kragen/sw/MetaPy-7.tar.gz (also available as .zip, .src.rpm, .noarch.rpm, and .win32.exe) plus a vastly more interesting bit of pythonic philosophical speculation: http://lists.canonical.org/pipermail/kragen-tol/2002-January/000659.html which you could have found out simply by reading this list this week. Kragen thus is this week's winner in my 'Reasons that I love Open Source' competition. Laura Creighton From dale at riverhall.NOTHANKS.co.uk Thu Jan 24 18:59:30 2002 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Thu, 24 Jan 2002 23:59:30 +0000 Subject: New Time format References: Message-ID: "Mark McEahern" wrote: >Have you checked out the egenix mx.DateTime stuff? > > http://www.lemburg.com/files/python/eGenix-mx-Extensions.html > >$ python >Python 2.2 (#1, Dec 31 2001, 15:21:18) >[GCC 2.95.3-5 (cygwin special)] on cygwin >Type "help", "copyright", "credits" or "license" for more information. >>>> import mx.DateTime >>>> t = mx.DateTime.now() >>>> print t >2002-01-24 11:46:55.52 > >That seems like what you're asking for, eh? Nice one. It is almost exactly what I'm after but I want it in the base package. Every additional package I depend on just adds hassle when I upgrade, switch PCs or a new Python comes out. -- Dale Strickland-Clark Riverhall Systems Ltd From zhangsc at neusoft.com Sun Jan 20 20:05:51 2002 From: zhangsc at neusoft.com (=?gb2312?B?1cXJ2bPb?=) Date: Mon, 21 Jan 2002 09:05:51 +0800 Subject: How to establish TCP through Proxy Server? Message-ID: <012d01c1a217$cdd8ce90$4301010a@sky> Hello: I want to write a my HTTP proxy server program.But My computer is in a LAN,my IP address is 10.1.1.67.The LAN has a proxy,it's IP address is 10.1.1.105,it's port number is 3128.I listen request message from IE6.0 and transfer the message to the destination .But how can I through the proxy 10.1.1.105:3128? My step is follows: I choose tools option of IE6.0 and choose Internet option and set LAN proxy and make proxy server address:10.1.1.67 and port:8888,then I establish TCP connection at port 8888,and accept .When I receive a request message from IE6.0 at port 8888,such as GET request,I draw the Host name from message and establish TCP connection with Host at port number 80,for example I receive message as: GET http://www.python.org/ HTTP/1.0 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */* Accept-Language: zh-cn User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) Host: www.python.org Proxy-Connection: Keep-Alive I found Host is www.python.org ,then I establish TCP connection at port 80: .... import socket HOST = 'www.python.org' PORT = 80 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect((HOST, PORT)) s.send(data) .... How can I through proxy 10.1.1.105:3128 and establish TCP connection? My next question is that my step of establish HTTP server is correct? Is there a better method to realize HTTP proxy server with python programming,is there python source code about proxy server? Any ideas will be appreciated. Thanks! Edward ` -------------- next part -------------- An HTML attachment was scrubbed... URL: From peter at engcorp.com Sat Jan 26 17:43:15 2002 From: peter at engcorp.com (Peter Hansen) Date: Sat, 26 Jan 2002 17:43:15 -0500 Subject: Sockets - how to nominate local port number? References: <3c5321c1$0$17957$afc38c87@news.optusnet.com.au> Message-ID: <3C533103.34BC5980@engcorp.com> djmitchell wrote: > > For a particular sockets application I'm working on, I need to be able to > specify both the port number on the remote machine, *and* the port number > on the local machine. In other words, the function/method call to > establish the connection needs to look something like this: > ... > socket = connect(remote_host, remote_port, local_port) > ... > > Any suggestions how to go about this? For "normal" apps, you don't usually > care about the local port number, but the security requirements of this > particular application mean that I have to specify it. I believe bind()ing a socket to a port works fine even for a client socket. Just don't execute listen()... From quinn at upchuck.ugcs.caltech.edu Thu Jan 17 03:13:07 2002 From: quinn at upchuck.ugcs.caltech.edu (Quinn Dunkan) Date: 17 Jan 2002 08:13:07 GMT Subject: confusion about __getattr__ References: Message-ID: On Wed, 16 Jan 2002 21:47:37 -0500, Russ Cox wrote: >Could someone explain the error message in the >following to me? I apologize if it should be >obvious, but clearly I have the wrong mental >picture of what's going on. > >g% python >Python 2.2+ (#0, Jan 16 2002, 19:28:19) [C] on unknown >Type "help", "copyright", "credits" or "license" for more information. >>>> class Test: >... def __getattr__(self, name): >... return '__getattr__ for '+name >... def __init__(self): >... self.foo = 'bar' >... def asdf(self): >... return 'jkl;' >... >>>> t=Test() >>>> t.foo >'bar' >>>> t.sdfsdfdsf >'__getattr__ for sdfsdfdsf' >>>> t.asdf() >'jkl;' >>>> t.asdf >Traceback (most recent call last): > File "", line 1, in ? >TypeError: 'str' object is not callable >>>> > >What is the str object in question that isn't callable? > >Thanks. >Russ > From jason at jorendorff.com Mon Jan 14 01:56:40 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Mon, 14 Jan 2002 00:56:40 -0600 Subject: HTTPLib and POST problem with '?' In-Reply-To: <3C4042EB.30208.167FD1B@localhost> Message-ID: > it works well but only if the script is like > http://www.musi-cal.com/cgi-bin/script.cgi > but if the script is like > http://www.musi-cal.com/cgi-bin/script.cgi?name=Paul > (note a part after ? ) it means that PUTREQUEST should be > > h.putrequest("POST", "/cgi-bin/script.cgi?name=Paul") > > but httplib ignores everything after '?' and sends only > /cgi-bin/script.cgi I don't think this is true. httplib sends whatever string you pass to it. It doesn't check the string at all. It doesn't chop anything off. What version of Python are you using? ## Jason Orendorff http://www.jorendorff.com/ From emile at fenx.com Fri Jan 25 07:45:27 2002 From: emile at fenx.com (Emile van Sebille) Date: Fri, 25 Jan 2002 04:45:27 -0800 Subject: Calendars and recurring events References: Message-ID: "Dave Swegen" wrote in message news:mailman.1011954759.15321.python-list at python.org... > I'm about to write a calendar, which I hope will eventually support > events. Now I know how I'm going to go about most of the task, but the > one aspect that has me stumped is recurring events. > > I'd like the user to be able to specify "repeat once a year", "repeat > until ddmmyyyy", "repeat every two weeks", "repeat first Monday of the > month" etc etc. Consider adding start and end date or times, eg to allow things like "12 weekly sessions starting 12jun02" or "Modays starting 04Mar02", or my favorite missing feature: "Saturdays preceeding the 1st or 15th" ;-) > > The only way I can think of doing it is by having an Event class, which > contains the details of the recurrence. As Events are created they are > placed into a list (or possibly a dbm keyed using a unique Event id). Or both... ;-) > > My problem is that any time I want a view of events (say a one month > view), the program is going to have to traverse the whole list, and ask > if that event is due to be repeated for every day in that view. For one > month that would be ~30 traversals of the list, which seems disgusting in > its innefficiency. It might be possible to mitigate it somewhat by > cacheing results into a second hash (using the date as the key), but > that only seems like a small improvement. > Sooner or later, I'm assuming you'll want to fire the events. How about a class that keeps an ordered list of events by next occurrence. This of course would only have each event once, but if you write an getnext iterator that pops the next event, and a scheduler that puts it back in based on it's schedule, you could pass the list once putting each event in, then run it through getnext and scheduler over the period in question. HTH, -- Emile van Sebille emile at fenx.com --------- From DeepBleu at DeepBleu.org Tue Jan 15 11:39:44 2002 From: DeepBleu at DeepBleu.org (DeepBleu) Date: Tue, 15 Jan 2002 10:39:44 -0600 Subject: Telnet Problem References: Message-ID: Thank you Eddie Right after posting my message I sent a cancellation but you got my original post first. This is exactly what was happening. Connection closing before even the process had a chance to start. So of course it was running fine in interactive mode :O I included a tn.read_until(ExpectedString) before closing and it works fine now. DeepBleu "Eddie Corns" wrote in message news:a21igg$gj0$1 at scotsman.ed.ac.uk... > "DeepBleu" writes: > > >I am running into the following frustration problem: > >I am telneting a server to run a command on it. When I run the script in > >interactive mode (line by line in PythonWin 2.1.211), it works. When I run > >the script, it does not work. > >This is the very simple script: > >######################### Start > >from telnetlib import Telnet > >tn=Telnet("dvlp") > >tn.read_until("login: ") > >tn.write("UserID\n") > >tn.read_until("Password: ") > >tn.write("UserPWD\n") > >tn.read_until("data>") > >tn.write("cd ..\n") > >tn.read_until("server>") > >tn.write("cd bin\n") > >tn.read_until("bin>") > >tn.write('newjob "par1" "PathToFile" "PythonWin Test"' + "\n") > >tn.close() > >################################################## End > >As I said, when I run it line by line, the process 'newjob "par1" > >"PAthToFile" "PythonWin Test"' takes place fine. When run in the regular > >way as a script, the same process does not take place. > >Can anyone help with any hints. > >Thanks, > >DeepBleu > > Try doing a read_until() after the final write and before the close(). What's > probably happening is that the connection close is causing the far end to > terminate the session. > > Eddie > From aleax at aleax.it Wed Jan 9 09:29:34 2002 From: aleax at aleax.it (Alex Martelli) Date: Wed, 9 Jan 2002 15:29:34 +0100 Subject: ADO/ODBC/ASP/Python error References: Message-ID: "Steve Holden" wrote in message news:ntG_7.109150$2b1.4678955 at atlpnn01.usenetserver.com... ... > rows. Unless you really want to use ADO, why not consider using a DB > API-conformant ODBC driver and doing your database work in Pure Python? This > will work fine under Active Scripting. > > [Alex Martelli will now tell you why ADO is superior, right, Alex?] Only if you want to, or must, run on Microsoft platforms. Otherwise, ODBC is probably superior, since it's available on more platforms. Alex From marklists at mceahern.com Thu Jan 24 13:26:36 2002 From: marklists at mceahern.com (Mark McEahern) Date: Thu, 24 Jan 2002 10:26:36 -0800 Subject: Validating EMailAdresses for syntactical correctness In-Reply-To: <54da4e24.0201241019.4a4b222e@posting.google.com> Message-ID: Michael W. Dietrich wrote: > Has anyone ever written a class, function or regular expression, that > validates EMail-Addresses (e.g. such entered in Web Forms) for their > syntactical correctness? If so, is that algorithm available? Where? Hmm, have you tried google? There may not be such in Python, but I'm sure you can translate whatever samples you find. The basic idea is to use regular expressions, right? I remember seeing an approach that explicitly provided different levels of strictness. Something like this: Level 1: Just make sure you have something at something Level 2: Make sure you have something at something.something Level 3: Make sure the tld is valid. Level 4: Make sure the domain is valid (whois, ping, etc) Level 5: Make sure the address itself is valid (resolve the mx record and test the address via smtp). Cheers, // mark From jason at jorendorff.com Sat Jan 26 10:56:33 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Sat, 26 Jan 2002 09:56:33 -0600 Subject: Python is just as good as C++ for real apps In-Reply-To: Message-ID: Courageous wrote: > Well I've always been talking about p, because "*p" isn't an atomic > thing, it's the identifier "p" with the operator "*". I could with > a lot of work show you an abstract syntax tree that proves it, too. :) I think someone didn't read the original message before replying, actually. Not to name names. (C: Grant wrote: > Think of it as meaning that *p is of type int > rathing than p is of type int*, > and then it makes a bit more sense. ## Jason Orendorff http://www.jorendorff.com/ From jason at jorendorff.com Mon Jan 7 16:26:23 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Mon, 7 Jan 2002 15:26:23 -0600 Subject: ZODB (and OODB) question In-Reply-To: Message-ID: > I am writing an application using zope and I am saving my objects > (customers, transactions, etc.) in the ZODB rather than using a RDBMS > such as MySQL. My advice: Save yourself some headaches and use an RDBMS. ZODB is fine for content and code, but it's best to keep tabular data in a "real" database. It's faster and will scale farther, and Zope has some nice tools to help you out. If you need more help, try the Zope mailing list. ## Jason Orendorff http://www.jorendorff.com/ From chris.gonnerman at newcenturycomputers.net Thu Jan 31 17:30:19 2002 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Thu, 31 Jan 2002 16:30:19 -0600 Subject: Autocoding project proposal. Message-ID: <002b01c1aaa6$e0915b00$0101010a@local> "David Masterson" wrote in message news:... > >>>>> Timothy Rue writes: > > > Language is abstraction, created in order to communicate, but it can > > never completely communicate reality. A pictures says a thousand > > words..... And that ain't language. > > Yes it is. Language exists in order to communicate an abstraction of > reality from one entity (usually people, but it could also be animals) > to another. That abstraction can be as simple as "hunger" to as > complex as the theory of relativity. The same is true with pictures > since they are also an abstraction of reality and are used to > communicate what something (might have) looked like at some time. > There are many pictographic languages around. > > > This project would move forward faster if people would chose to > > help. And the sooner it get more complete the sooner more can be > > explained by way of example. > > We *CANNOT* help if we cannot understand the abstraction of reality > that this project represents. You must find the proper language by > which to communicate that abstraction. > > > #! Python > > I don't know Python (yet), but I think I get the idea. Neither does Rue. The "shebang" line above is not qualified properly for any OS I am familiar with; as Windows doesn't need the shebang it's probably not hurting anything (no way I can imagine Rue using anything but Windows). You certainly have more chance to learn Python than Rue does, IMO. > > # PK file array - VIC Dictionary > > # Setting the standard variables to defaults > > For brevity, I'm going to cut out your code and simply comment on it. > > > vic = { > > * Your case statement doesn't provide any info on what the VIC is > supposed to do. It appears to be merely creating an array. That's the beginning of a Python dictionary declaration (and assignment to the variable vic). The original code didn't get here so I can't comment much on it. > > # Test!!! > > * Your test is merely a printout of various array items -- again, no > info on what the VIC is supposed to do. > > > /*Reading in the PK file. > > * Okay, I assume you get some information from the PK file, but I see > nothing to tell me what it's supposed to contain. Urr. That looks like a C/C++ comment, not a Python comment. > > current_line = READLN('PK_file') > > PARSE VAR current_line vic.1 ':' vic.1.1 ';' vic.1.2 ';' vic.1.3 > > * Whoops, there is some reading going on here and a basic format > (lines of "something" with 4 fields separated by ":" and ";"). Those two lines look like REXX, not Python. > > /* Writing the PK file */ > > * Writing? We haven't done anything with what we read in yet? That's not the right format for a comment in Python either. > > CLOSE('PK-file-out') > > * What was achieved in this program? Did you merely rearrange the > data in the PK file? If so, why? That CLOSE function has me floored. I can't make out any language that does exactly that. To be fair (I don't have to) Rue has admitted he can't program; he also can't write. I'm not talking about spelling, or grammar; Rue can't express an idea so that another ordinary human being can understand it. We really are wasting time and bandwidth here on an imaginary project which he expects us to do for him. From printers at sendme.cz Mon Jan 14 01:00:03 2002 From: printers at sendme.cz (A) Date: Mon, 14 Jan 2002 07:00:03 +0100 Subject: HTTPLib and POST problem with '?' Message-ID: <3C4281F3.16845.1A0EEF@localhost> >In the light of the meta-principle "be conservative in what you generate, and >liberal in what you accept", I think a server should probably accept a >(probably-incorrect) mix of both, and try to do something sensible; but a >client (e.g., httplib) should never generate the mix. I would like to thank you all who tried to answer my question but yet I did not receive any good solution. If you use a client like MS Explorer and use a sniffer you can see that this client also sends posting script in a form "/cgi-bin/script.cgi?name=Paul. The same is true about PERL( LWP module). Does it mean PERL is better?? And as an example you can check http://www.globaltradeweb.com/default.asp?w=fbjm You will not be probably post successfully if you send form like /cgi-bin/script.cgi that is without '?' ANd this is not the only example So, Can anyone help me? Ladislav From aleax at aleax.it Tue Jan 15 03:22:46 2002 From: aleax at aleax.it (Alex Martelli) Date: Tue, 15 Jan 2002 09:22:46 +0100 Subject: algorithms and ADTs (was Re: efficient idiomatic queue?) References: Message-ID: "David Eppstein" wrote in message news:eppstein-C4AE42.20190114012002 at news.service.uci.edu... ... > Actually, the merge step in merge sort is a great example for simple > generators, or would be if not for the difficulty of keeping track of the > first item of each input iterator: So, why not encapsulate that "difficulty"? E.g.: class Peeker: def __init__(self, iterator_or_sequence): self.iterator = iter(iterator_or_sequence) self.head = None self.advance() def advance(self): head = self.head try: self.head = self.iterator.next() except StopIteration: self.more = 0 else: self.more = 1 return head With an ADT such as this one, operations such as merging get simpler: def merge(A, B): A=Peeker(A) B=Peeker(B) while A.more and B.more: if A.head < B.head: yield A.advance() else: yield B.advance() while A.more: yield A.advance() while B.more: yield B.advance() Note that the sum total of wrapper class Peeker and this merge version is less than or equal to the merge version that tries to do everything, in terms of both lines of code and "conceptual load". Basically, this is because Peeker "captures" the right "primitive concepts" (attributes more and head, operation advance) for merge's purposes, and therefore eliminates duplication present in the "stand-alone version of merge". One might start with the large, code-duplicating version of merge, and work towards this one, as a way to motivate ADT's, I guess. But I'm not sure such a bottom-up-and-refactor approach is didactically more valid than top-down-and-refine, although it's closer to how one might work to develop Peeker in real life. Alex From jason at jorendorff.com Sun Jan 6 12:04:33 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Sun, 6 Jan 2002 11:04:33 -0600 Subject: confused if i should be doing type checking in the code ( a confused java programmer) In-Reply-To: Message-ID: > So in python code i needed a singleton and then the immutable constants. > Then came across this recipie in Cookbook and Well it's brillaint! > i had'nt even imagined such things could be done. > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65207 Yes, but the best thing is to write: REGULAR = 1 NEW = 2 CHILDREN = 3 and leave it at that. Realistically, no one is going to mess with your constants. It just isn't a problem, in real life. Python doesn't have "private" or "final", or static type-checking. Don't try to fake these features; it's not really possible. > even after a couple of months of python..i think i have not > been able to understand the differences in the way > you code in java and python! :-( The main difference is that it takes 1/5 the time. :-) Just relax, and don't try to do everything "the Java way". ## Jason Orendorff http://www.jorendorff.com/ From joshm at taconic.net Fri Jan 25 15:11:15 2002 From: joshm at taconic.net (Joshua Muskovitz) Date: Fri, 25 Jan 2002 15:11:15 -0500 Subject: Transfer data between two separately running python programs. References: Message-ID: <3c51b8ab_1@corp.newsgroups.com> > Using PythonWin32 extensions I have a python program (collector.py) that > just monitors the serial port and collects data by running in a continuous > loop. > > I want to get at that data from a different python program. A TCP socket would seem like the obvious choice. Make collector have a server socket (in its own thread, most likely). This will then accept connections from one or more (depending on your need) client apps, either local or remote (you can refuse connections based on their IP address). In this way, you abstract the serial port nastiness from the final consumer app, allowing you more flexibility in the future, should you need it. -- # Joshua Muskovitz # joshm at taconic.net def lyyrs(sig): return '-'.join(sig.split()+["ly y'rs"]) lyyrs('Hire me! I need the work!') -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From daculas at yahoo.com Tue Jan 8 06:59:12 2002 From: daculas at yahoo.com (Nielson) Date: Tue, 08 Jan 2002 19:59:12 +0800 Subject: How to "ping" a host ? References: Message-ID: <2gnl3uglonjviacdvhc7npv5efspl40514@4ax.com> I want a copy too, can I get one? Thanks in advance! On Tue, 8 Jan 2002 10:29:17 +0100, Radovan Garabik wrote: >Gillou wrote: > : Alex, > > : Thanks for the reply but it's a 404 URL. > >I have local copy which I downloaded some time ago and then >tried to extend a bit (but never got too far). >If you want I can send you a copy. > >btw I understand your desire to evade spamming, but you should indicate >your e-mail somewhere in your postings. From aleax at aleax.it Mon Jan 21 15:16:36 2002 From: aleax at aleax.it (Alex Martelli) Date: Mon, 21 Jan 2002 20:16:36 GMT Subject: not in References: <3m4o4u8tnumteu12vtd8solunp2ai7kjvo@4ax.com> Message-ID: rihad wrote: ... >>Ah, just like, say, unary-plus (strictly non-necessary), binary >>minus (non-necessary given the presence of unary-minus and binary >>plus), and the backquote operator `...` (non-necessary given the >>existence of builtin function repr). > > All of the above are OK with me since I see them as funny ways to call > functions back from C++. Aliases and syntactic sugar are cool, but Not necessarily: it takes flair, which Guido has, to decide which technically redundant operators to leave in. You seem to base your feelings strictly with analogies with C++ -- does this seem like a sensible criterion to you, in the abstract? Why should it be OK to have both > and <=, even though (a <= b) is always identical to not (a > b), but somehow not ok to have both is and is not, because (a is not b) is always identical to not (a is b)? Etc, etc, for all the other redundant cases above listed. What other criterion besides "to THAT one I was used in C++" are you applying? > still, not in/is not feels different... YMMV, after all, it's just a > matter of style. Python's style is a careful blend of simplicity and readability -- whether it works for you, of course, IS a subjective judgment, in the end, but at least some of Python's stylistic choices are, it seems, based on actual usability studies (dating back to the times of ABC, Python's predecessor), thus, presumably, they are meant to work optimally for most. >>For example, most readers will find: >> a - b >>more readable than >> a + -b >>even though they're obviously equivalent, semantically. > > AOL! Is that AOL as in AOL Time Warner, or what? Again I miss your point. Alex From tim.one at home.com Tue Jan 15 17:55:33 2002 From: tim.one at home.com (Tim Peters) Date: Tue, 15 Jan 2002 17:55:33 -0500 Subject: efficient idiomatic queue? In-Reply-To: Message-ID: [James_Althoff at i2.com] > Speaking of generator abuse ... > > Anything like this: > > def mergesort(alist): > if len(alist) <= 1: > return iter(alist) > return merge(mergesort(alist[:len(alist)//2]), > mergesort(alist[len(alist)//2:])) > > is probably going to create way too many generator/iterator instances to > scale well. Well, it was clear from the start that there's no interest in a practical algorithm here, else we'd just use a temp array and a handful of index variables. "Theoretical efficiency" (O() where a multiplier of 10000000 is as good as 1) is an interesting area of study, full of papers with schemes so convoluted the authors cheerfully confess to not even trying to implement them. "computer-science"-isn't-about-programming-computers-but-python-is-ly y'rs - tim From aleax at aleax.it Sat Jan 26 04:07:58 2002 From: aleax at aleax.it (Alex Martelli) Date: Sat, 26 Jan 2002 09:07:58 GMT Subject: [Jython/Java] Which books, which IDEs, which other tools? References: Message-ID: James_Althoff at i2.com wrote: > [Jim] >> I know what you mean. I've seen many examples of Java programmers being >> unwilling to use Jython because they felt it would make their resumes/CVs >> less marketable. > > [Alex Martelli] >>However, mr Hogg's just-quoted text seems to say the contrary -- that >>having Python on his CV makes him MORE marketable -- isn't that what >>those calls from agents mean, "marketability"? > > Right you are -- when they zig, we zag! All the way to the bank, > hopefully! Aha, I see, a contrarian strategy -- exploiting "herd instinct" by moving just the other way 'round from the herd. Clever... Alex From store_li at sina.com Wed Jan 9 23:40:33 2002 From: store_li at sina.com (Kick) Date: Thu, 10 Jan 2002 12:40:33 +0800 Subject: Is there any way can make me using python with mysql on win32 References: Message-ID: Thank you for your reply. I do installed myODBC and mxODBC, while I try to connect mysql using mxODBC, python told me that mysql doesn't support transaction and refuse to connect. I don't why. Could you do me a favor to tell me more details? Thank you! "Steve Holden" wrote in message news:bjo_7.80532$2b1.3347717 at atlpnn01.usenetserver.com... > "Kick" wrote in message > news:a1aaeg$nhe93$1 at ID-12869.news.dfncis.de... > > Thank you! I got it. It is now running on my machine. But mxODBC still > won't > > work for me on mysql. While,...it really can get well with SQL 7.0. > > > Did you install the ODBC driver for MySQL? It's called MyODBC, and you can > get it at > > http://www.mysql.com/downloads/api-myodbc.html > > Once you install it, MySQL databases can be accessed via mxODBC just like > any others with ODBC drivers. Works fine for me on Win98, and shoudl also > work on other Windows platforms. > > > regards > Steve > -- > http://www.holdenweb.com/ > > > > > From debl2nonospammywhamm at bellatlantic.net Thu Jan 17 00:00:00 2002 From: debl2nonospammywhamm at bellatlantic.net (David Lees) Date: Thu, 17 Jan 2002 05:00:00 GMT Subject: High-resolution timers References: <3C464602.8060000@skippinet.com.au> Message-ID: <3C465A53.E3F38FEA@bellatlantic.net> Works pretty well on my Win98 box. PythonWin 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (mhammond at skippinet.com.au) - see 'Help/About PythonWin' for further copyright information. >>> import time >>> time.clock() 5.0285790911681387e-006 >>> time.clock() 5.1122890092022999 >>> time.clock() 9.3571322013443066 Also quite high resolution for timing running code. import math, time def timeIt(n): t0=time.clock() for i in xrange(n): j=math.sqrt(i) t1=time.clock() print 'loops = %d total time = %f time/loop = %f' % (n,t1-t0,1e6*(t1-t0)/n) Running this for loop counts that take a milliseconds >>> loops = 1000 total time = 0.003536 time/loop = 3.535929 loops = 2000 total time = 0.007100 time/loop = 3.549758 loops = 3000 total time = 0.010510 time/loop = 3.503243 loops = 4000 total time = 0.013995 time/loop = 3.498634 loops = 5000 total time = 0.017825 time/loop = 3.564927 loops = 6000 total time = 0.020906 time/loop = 3.484386 loops = 7000 total time = 0.025111 time/loop = 3.587293 loops = 8000 total time = 0.027922 time/loop = 3.490253 loops = 9000 total time = 0.031517 time/loop = 3.501940 which shows that execution time measurements in the 10 millisecond range are varying only about 2%, which could easily be due to other processes running on my machine. David Lees Ben Wolfson wrote: > > On Wed, 16 Jan 2002 21:32:42 -0600, Mark Hammond wrote: > > > Use time.clock() - it will always provide the best timer for the > > platform. > > It acts pretty strangely on all the computers to which I have access: > > harper:~> python > Python 2.0 (#1, Feb 26 2001, 17:11:04) [C] on sunos5 > Type "copyright", "credits" or "license" for more information. > >>> import time > >>> print time.clock() > 0.0 > >>> print time.clock() > 0.01 > >>> print time.clock() > 0.01 > >>> time.clock() > 0.01 > >>> ^D > harper:~> python > Python 2.0 (#1, Feb 26 2001, 17:11:04) [C] on sunos5 > Type "copyright", "credits" or "license" for more information. > >>> import time > >>> time.clock() > 0.0 > >>> print time.clock() > 0.0 > >>> time.clock() > 0.0 > >>> time.clock() > 0.0 > >>> ^D > From mmueller at dgfz.de Thu Jan 24 14:45:20 2002 From: mmueller at dgfz.de (=?ISO-8859-1?Q?Mike_M=FCller?=) Date: 24 Jan 2002 11:45:20 -0800 Subject: Intel C/C ++ compiler for Linux for Pytrhon extension? Message-ID: <7049ba55.0201241145.4be1771f@posting.google.com> I am going to port a numerically intensive application from windows to Linux (RH). Right know the numeric part is a Python extension compiled with MCVC (which in turn calls DF compiled FORTRAN 90 code). I plan to use the Intel C/C++ compiler for Linux because it is considerably faster than gcc. The CPU is a Pentium 4 for which this complier is optimised. Is it possible to write Python extension with the Intel C/C++ compiler for Linux? Since it is supposed to be source and binary compatible with gcc it should. If yes, are there any differences to the extension building process with gcc? Later on, I plan write some code in C++ using templates. Does this compiler support this and can I use this C++ code in Python extension? I have not found real useful links with google, so somebody might share some experience or can point to resources. Thanks Mike From mhammond at skippinet.com.au Sat Jan 19 21:23:39 2002 From: mhammond at skippinet.com.au (Mark Hammond) Date: Sun, 20 Jan 2002 02:23:39 GMT Subject: Python COM server running as a singleton References: <6411841c.0201170920.25185769@posting.google.com> <6411841c.0201180202.3ab669dd@posting.google.com> Message-ID: <3C4A2A5A.90008@skippinet.com.au> Marc ENGEL wrote: > I would suggest to add an else statement for the if at line 176: > > if not clsctx or clsctx & pythoncom.CLSCTX_INPROC_SERVER: > ........ > else: > _remove_key(keyNameRoot + "\\InprocServer32") > > Of course, it could be done also for CLSCTX_LOCAL_SERVER if statement: > > if not clsctx or clsctx & pythoncom.CLSCTX_LOCAL_SERVER: > > Does this make sense? Yep - done. Thanks, Mark. From emile at fenx.com Thu Jan 3 13:51:51 2002 From: emile at fenx.com (Emile van Sebille) Date: Thu, 3 Jan 2002 10:51:51 -0800 Subject: Is types.InstanceType no longer valid with Python 2.2 References: <43293uk34r6dgn5vgel7j0uiekhg6jp0no@4ax.com> Message-ID: "Georg Lohrer" wrote in message news:43293uk34r6dgn5vgel7j0uiekhg6jp0no at 4ax.com... [snipped] > Therefore I need recognizing an instantion of a class. If I could be > assured that only a class-instantiation could have a __dict__ then a > possible solution would be try..catch AttributeError to catch all > other items. But with Python 2.1 the InstanceType decision was more > elegant. > > Ciao, Georg > Aside from Skip verifying that InstanceType works in 2.2 (which I hadn't, but have since) and so it should for you, one attribute that may do it is __class__. I'm not aware that this is used otherwise. HTH, -- Emile van Sebille emile at fenx.com --------- From graham.ashton at cis.co.uk Thu Jan 3 08:20:57 2002 From: graham.ashton at cis.co.uk (Graham Ashton) Date: 3 Jan 2002 05:20:57 -0800 Subject: Killing processes on win32 References: Message-ID: Stefan Schukat wrote in message news:... > the pdh (performance data helper) library is only available for > NT 2k and I think XP. > > [snip] > > To kill a process under win9x you should write a pyd to get the > process information. Thanks for the (impressively speedy) response. I'm now off to find somebody with a copy of MSVC++. -- Graham From sholden at holdenweb.com Tue Jan 15 07:38:07 2002 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 15 Jan 2002 07:38:07 -0500 Subject: how is python bytecode different from java's References: Message-ID: "Karthik Gurumurthy" wrote in message news:mailman.1011083001.14788.python-list at python.org... > what is the difference between a .class file and .pyc file > They are for two completely different virtual machines. *Jython*, however, is a 100% pure Java implementation of Python which compiles it into JVM bytecodes. It's neat, though a little behind the main (C)Python track just at present. regards Steve -- http://www.holdenweb.com/ From db3l at fitlinxx.com Tue Jan 22 16:29:49 2002 From: db3l at fitlinxx.com (David Bolen) Date: 22 Jan 2002 16:29:49 -0500 Subject: Newbie needs to be set straight again ... References: Message-ID: Jyrinx writes: > Anyway, as you can see, I'm speculating quite a bit; I'm sure I'm dead > wrong in some subset of the real world. Who wants to play Educate The > Confused, Wayward Newbie? :-) Well, in my own subset of the real world, I do get asked by some folks here about how our external Python projects would get distributed and the ramifications for the source. But so far (our target environment is Windows), I've been quite comfortable with how a fully packaged installation (we use Gordon McMillan's Installer, but py2exe is similar) turns out. All of your Python code is packaged into the executable (and all but the main script is in a compressed archive format made up of only pyc files). While certainly not a major effort to decompose by someone experienced in Python (and using the Installer package classes), it tends to be more than enough to cover basic concerns. And while decompiling a pyc file does yield workable source, it's not quite the same as having original source. I'm not quite sure how I'd fight the battle if the question was one of really just directly distributing .py files (I know my view personally is fine with it, but talking from a corporate perspective now), but I don't see the need when you have reasonable packaging tools. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From ws at mystrobl.de Fri Jan 4 15:47:18 2002 From: ws at mystrobl.de (Wolfgang Strobl) Date: Fri, 04 Jan 2002 21:47:18 +0100 Subject: open new window problem of webbrowser under win32 References: Message-ID: On 4 Jan 2002 07:49:03 -0800, newgene at bigfoot.com (newgene) wrote : >when I run the following code(activepython 2.1,windows 2000): > > import webbrowser > > webbrowser.open("http://my.yahoo.com") > webbrowser.open("http://www.msn.com",new=1) > >It does not open two browser windows,but open one single window with >the latter URL. Whatever I change the value of "new" or use >"open_new", it's still the same thing. Well, you could try from win32com.client import Dispatch def start(url): w=Dispatch("InternetExplorer.Application") w.Navigate2(url) w.visible=1 start("http://www.python.org") start("http://www.zope.com") >I don't know how about under UNIX. Maybe it's a problem under win32? Perhaps. -- Wir danken f?r die Beachtung aller Sicherheitsbestimmungen From boud at rempt.xs4all.nl Mon Jan 7 06:41:14 2002 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 7 Jan 2002 11:41:14 GMT Subject: 49 new online articles about Python since Xmas References: <3C37A4CB.74E3001A@earthlink.net> <3C394332.467C04B2@earthlink.net> Message-ID: Hans Nowak wrote: >> It has missed all Python articles at InformIT -- and I know that there >> are quite a few, since I wrote them myself. > That's because it currently doesn't scan InformIT. Of course, that > can be changed... I'll see what I can do. (Unfortunately, not every > site can be queried easily, so I cannot guarantee anything at this > point.) InformIT might be difficult... -- Boudewijn Rempt | http://www.valdyas.org From threeseas at earthlink.net Thu Jan 24 21:30:31 2002 From: threeseas at earthlink.net (Timothy Rue) Date: Fri, 25 Jan 2002 02:30:31 GMT Subject: Autocoding project proposal. References: <5422.785T1897T13084671threeseas@earthlink.net> Message-ID: <5006.789T1349T13304507threeseas@earthlink.net> On 23-Jan-02 17:45:37 David Masterson wrote: >>>>>> Timothy Rue writes: >> This posting is to introduce or suggest an open source software >> project to produce a core tool that will allow an autocoding >> environment to be developed, allowed to evolve in the open source >> software community and spirit of. I believe we can overcome many of >> the problems that proprietary autocoding systems inherently have >> (not to mention that existing autocoding systems appear to be >> field/domain specific limited and that it may be possible to beat >> this too.) >After making the mistake of commenting on a followup to this message >without reading this message, I went back and found it. I've now done >a brief skim of the references that you listed in this message. I >consider myself a good "skimmer" (although I could've missed much), >but I (like another newspost you referenced) came away confused about >what you were trying to accomplish. In my mind, the basic problem >seems to be that you have a long (perhaps very long) term goal >described in these papers with some (*BIG*) steps about how to get >there, but you lack the rigorous small steps needed before what you're >talking about will actually make sense. not long term. Certainly a shell (optional function library) having nine commands is.....well not long term. That's just the core, the rest, though bigger,.... much is already available to work with. >Many different disciplines are involved in aspects of this in one way >or another: not really. More like realizing it's just a matter of understanding why it appears to cross so many different disciplines. Which is the nine action constants are used in all disciplines. >* Object Orientation -- to describe the process of building components > that can be assembled into large pieces of knowledge. recursion. take these part put them to-get-her to make this part and use it with these other other parts to get this together ....etc.. >* UML -- to define a visual mechanism for describing the processes > involved with object orientation. a glorified flow chart that evolved out of recognizing commonality of the scratch work everyone was doing and then trying to standardize it. What is a high level graphical language that needs foot notes. Useful for perhaps those who want to use it, but needs gears and bearing under it in order to translate it down thru various levels of abstraction to what may or may not be the target of code. (see other post about gears and bearings) >* Artificial Intelligence -- to find and describe ways of converting > information into knowledge. AI - nothing is naturally that stupid. Artificial Intelligence (as has been so preceived by the public and promoted in the "Turing Test" is in act the by-product illusion of dynamically automating stuff to the point of fooling a human into thinking they are communicating with another human that may be really really smart. to achiveve this, you need gears and bearings of and for automation. 9acts >* Relational Database Management -- to provide mathematical foundation > to relating pieces of information to one another in an efficient > manner. Math is a subset of the class "abstraction" and as such it is limited. However what is going on at www.archive.org to create a database of all human knowledge is really amazing. and How they are doing it is even more amazing. >* Pattern Recognition -- to describe how pieces of data can be broken > down into patterns for efficient recognition. pattern matching ---> word = extending definition the most basic form that is beyond the abstraction set of roman numerals or what we came up with to replace roman numerals. Alpha-numeric+++ >* ... many others that I'm not familiar with (not that I'm very > familiar with the above either). Yes there are indeed many specialized fields which can sometimes have very focused and fast solutions. And although these things can be used with great success (Image recognition, AI algorythims, database algorithims for super fast access, etc..) there is still the much slower and simpler movement/actions that can be used to put these things together to make bigger parts. Everything doesn't have to be a speed deamon, includint the turtle that beat the rabbit over the finish line. >Do you have a "strawman" proposal of (at least) a small piece of what >you're getting at that can show the value of what you want? yes. see other message for IQ in python link. As well as the links to specific command specifications --- *3 S.E.A.S - Virtual Interaction Configuration (VIC) - VISION OF VISIONS!* *~ ~ ~ Advancing How we Perceive and Use the Tool of Computers!* Timothy Rue What's *DONE* in all we do? *AI PK OI IP OP SF IQ ID KE* Email @ mailto:timrue at mindspring.com >INPUT->(Processing)->OUTPUT>v Web @ http://www.mindspring.com/~timrue/ ^<--------<----9----<--------< Search email/name @ http://www.dejanews.com for other puzzle parts/posts. From jason at jorendorff.com Mon Jan 21 15:44:24 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Mon, 21 Jan 2002 14:44:24 -0600 Subject: What does Python fix? In-Reply-To: <02012120452700.08314@arthur> Message-ID: Alex Martelli wrote: > Common Lisp does have vectors/array/however they're named, right? Even Scheme has vectors. ## Jason Orendorff http://www.jorendorff.com/ From fbartlet at wiley.com Thu Jan 3 10:22:04 2002 From: fbartlet at wiley.com (Frederick H. Bartlett) Date: 3 Jan 2002 07:22:04 -0800 Subject: Python and UTF-8 References: <84163ucnnmg7r6o5tp6k1tgj506l9rgt6q@4ax.com> <3C33A917.4506E731@gol.ge> Message-ID: Giorgi, I'm interested in your problem; I'm learning about encodings in Python for other purposes at the moment. I am somewhat familiar with the Georgian alphabet. (I once tried to translate an aria from paliashvili's _abessalom da eteri_ for my wife -- but I ended up translating from the Russian. No offense, but Georgian really is an *impossible* language!). There are certainly some interesting issues: Capitalization, for one. And do you want the reencoding to be, essentially, a transliteration? Perhaps we should take this offline; you can contact me at my personal email address, fbartlet (at) optonline (dot) net. Fred Giorgi Lekishvili wrote in message news:<3C33A917.4506E731 at gol.ge>... > Just a related topic: > > I have a similar problem: > > I would like to make an online service enabling to recode latin letters > into the georgian alphabet (quite independent, one of the 14 existing > ones). > > What I know are the the georgian encoding, see e.g., > http://www.paratype.com/default.asp?page=/library/languag/codepages.html?ncoding=17 > > and the rules the latin characters are to be substituted by the georgian > ones. > > What I do not know is the way I can forse Python to print the octals in > the right manner... > > I am affraid that this question is not for this group... If so, please, > accept my appologoes:( > > Best wishes, > Giorgi > > Brandvik wrote: > > > I'm making a small automated managing system for my website and I > > think I will go for Python and CGI. I have one question though: my > > website is in Norwegian and in valid XHTML. All characters need to be > > encoded in UTF-8. The way I'm currently doing it is that all articles > > go through me for formatting and validation. When switching to a CMS > > everybody with access to the system will be able to put articles on my > > website and this means that all kinds of formatting will be used. This > > will make the W3C validator choke and my site would not validate. > > > > Is it possible to make a python script that would change the character > > to UTF-8 no matter what the encoding of the input is? I have heard > > that Python has some great functions for Unicode formatting so this > > might be an easy and trivial task, but I'm new to Python so I really > > don't know... > > > > -Brandvik From sdm7g at Virginia.EDU Sun Jan 13 14:41:51 2002 From: sdm7g at Virginia.EDU (Steven Majewski) Date: Sun, 13 Jan 2002 14:41:51 -0500 (EST) Subject: tt = a, b = t In-Reply-To: Message-ID: On 13 Jan 2002, William Park wrote: > > How did 2 manage to propagate to tuptup through None? > > You just assigned '2' into 'None'. I thought 'None' is reserved > keyword. 2.3.1 Keywords The following identifiers are used as reserved words, or keywords of the language, and cannot be used as ordinary identifiers. They must be spelled exactly as written here: and del for is raise assert elif from lambda return break else global not try class except if or while continue exec import pass yield def finally in print From mcherm at destiny.com Thu Jan 3 09:25:48 2002 From: mcherm at destiny.com (Michael Chermside) Date: Thu, 03 Jan 2002 09:25:48 -0500 Subject: Who needs exceptions (was Re: Two languages, too similar, competing in the same space.) Message-ID: <3C3469EC.8060202@destiny.com> > Unfortunately, disaster cases such as corrupted memory DO happen, > and, in some kinds of applications, need to be dealt with (by a > graceful shutdown with good error reporting rather than a crash). [...] > So, while I WAS indeed talking about the far more common case of > resource exhaustion, the corruption case also needs to be dealt > with. [...] > In most cases, I've found that a separate "watchdog process" that > watches over the application process[es] is the best architecture > to deal with memory-corruption and similar problems. [...] > > That's not unrelated to "preallocate a tad of extra resources" -- > here, the "extra resource" is a process and some memory &c for it > (the errant process might not be in a condition to fork a NEW > process for error-reporting at the time of trouble -- better do > it earlier). But the extras need to be kept separate, "arm's > length", from the main operating capital, lest they too be > consumed in the case of a crash. Any parallel with prudent > financial management and supervision is entirely intended; Enron > doceat...!-) > > > Alex Thanks, Alex... very nice way to think about it. -- Michael Chermside From kragen at pobox.com Tue Jan 29 16:44:00 2002 From: kragen at pobox.com (Kragen Sitaker) Date: 29 Jan 2002 16:44:00 -0500 Subject: dbm interoperability between Perl and Python? References: <15446.52760.640887.508358@beluga.mojam.com> Message-ID: <83665k25pb.fsf@panacea.canonical.org> Roy Smith writes: > Anydbm.open() has the same behavior. On 2.0.1, you do anydbm.open > ("file.db"), but on 2.1.1, it's anydbm.open ("file"). The documentation > for either version doesn't really say one way or the other. The 2.1 way is > arguably the "correct" way, though. If you don't know what type of dbm file it is, you can't really know what the base name of the file is, can you? From peter at engcorp.com Mon Jan 28 00:34:16 2002 From: peter at engcorp.com (Peter Hansen) Date: Mon, 28 Jan 2002 00:34:16 -0500 Subject: Autocoding >Re: "Introduction to Ethics", References: <321.788T2944T10325794threeseas@earthlink.net> <87it9sn0jc.fsf@becket.becket.net> <6322.789T326T13093628threeseas@earthlink.net> <3296.790T2094T7025580threeseas@earthlink.net> <87r8od3wiy.fsf@piracy.red-bean.com> <83y9ijhcik.fsf@panacea.canonical.org> <3C5479A3.F649DCC5@engcorp.com> Message-ID: <3C54E2D8.6A5947C2@engcorp.com> Christopher Browne wrote: > > Peter Hansen writes: > > Christopher Browne wrote: > >> It sort of looks like the denizens of comp.sys.amiga.misc drove him > >> from there, and he as a result headed to comp.lang.python and > >> gnu.misc.discuss to spread his "vision." > > > I dug up pieces of the sordid history with the Amiga newsgroup, but > > I didn't find evidence that they actually drove him out. Do you > > have any details on how that process worked, or are you just > > guessing? > > I'm merely guessing, based on the consideration that discussion moved, > and that there's presumably some sort of "why." Damn! "Those who fail to learn from history.... " ;-) From Stefaan.Eeckels at ecc.lu Sun Jan 27 10:05:37 2002 From: Stefaan.Eeckels at ecc.lu (Stefaan A Eeckels) Date: Sun, 27 Jan 2002 16:05:37 +0100 Subject: Semantic analysis of one response (was Re: Autocoding project proposal.) References: <3C527184.240981C9@engcorp.com> <3370.791T1042T5853800threeseas@earthlink.net> <3C52F52D.D9461031@engcorp.com> <3C532F27.42B9C47@engcorp.com> <2812.791T1575T12885173threeseas@earthlink.net> Message-ID: <20020127160537.6c090976.Stefaan.Eeckels@ecc.lu> On Sun, 27 Jan 2002 01:42:06 GMT "Timothy Rue" wrote: > A shell having nine commands...... Oh, you're Richard Kulisz. -- Stefaan (GPG Fingerprint 25D8 551B 4C0F BF73 3283 21F1 5978 D158 7539 76E4) -- "Object-oriented programming is an exceptionally bad idea which could only have originated in California." --Edsger Dijkstra From info at mjais.de Mon Jan 7 17:12:08 2002 From: info at mjais.de (Markus Jais) Date: Mon, 07 Jan 2002 23:12:08 +0100 Subject: Preferred tool for folding XML into HTML References: <8a12e538.0201070737.6b9984e8@posting.google.com> Message-ID: Gerhard H?ring wrote: > Le 07/01/02 ? 18:39, Markus Jais ?crivit: >> Russell Turpin wrote: >> >> > This isn't really a Python question, but the Pythoneers are >> > smart folks, so I thought I would ask it here. Suppose a >> > development group is making a web app by using Python >> > back-end scripts to generate XML. The XML is desired for >> > automation and modularity. To create the interactive site, >> > the problem then reduces to folding the dynamic data, as >> > presented in XML, into static HTML pages. In other words, >> > the following translation is the last step in generating >> > each web page: >> > >> > XML (dynamic) + HTML template (static) -> final HTML >> > >> > What are now the preferred tools for doing this? >> > >> > Thanks! >> > >> > Russell >> >> >> a possibility for transforming xml into html ist xslt >> you get an open source xslt implementation for python at >> http://www.4suite.org > > Starting with PyXML 0.7, XSLT is integrated: http://pyxml.sf.net/ yes, but AFAIK not the newest version, so if you want the newest stuff go to 4suite.org markus > > Gerhard From pachy at 012.net.il Sat Jan 12 06:14:59 2002 From: pachy at 012.net.il (Tal Linzen) Date: Sat, 12 Jan 2002 13:14:59 +0200 Subject: Breaking out of nested loops Message-ID: <004301c19b5a$603e6bb0$5a0cc7d4@ussr6gwe8yu2pu> Good day. One feature I miss in python is the ability to break out of nested loops. I've searched the newsgroup archives, and found a few threads discussing the problem, with no apparent conclusion. The two solutions I've seen -- raising an exception, or putting the loop inside a function and using the return statement -- are unintuitive (meaning, I didn't come up with them myself :-) ). Know if anyone has drafted a PEP for a syntactic solution for this problem? Tal From markjunk at mceahern.com Thu Jan 17 13:32:44 2002 From: markjunk at mceahern.com (Mark McEahern) Date: Thu, 17 Jan 2002 18:32:44 GMT Subject: What does Python fix? References: Message-ID: "Michael Hudson" wrote in message news:uadvd3q56.fsf at python.net... > Well, in view of your preceding paragraph, why do you need to carry > on? Good point, thanks! I shouldn't barricade myself against a language before I try it. Had I done that, I might not have discovered the joy which is Python. Cheers, // mark From maxm at mxm.dk Wed Jan 23 15:36:52 2002 From: maxm at mxm.dk (Max M) Date: Wed, 23 Jan 2002 20:36:52 +0000 Subject: How to configure Python with IIS References: Message-ID: <3C4F1EE4.50408@mxm.dk> gtaker wrote: > Can anyone direct me to a how to on configuring python with IIS5.0 I'm > having problems understanding how to tell IIS about .cgi and how to use > python with .asp > win32all-146.exe As far as I can tell there is a bug in that version of win32all that makes it impossible to use Python in .asp. I solved it by installing Python 2.1.2 and win32all-140.exe instead. I have notified Mark Hammond. regards Max M From spahievi at vega.bg Sun Jan 13 08:27:03 2002 From: spahievi at vega.bg (Niki Spahiev) Date: Sun, 13 Jan 2002 15:27:03 +0200 Subject: comp.lang.python, FINAL NOTICE of Newsgroup Removal In-Reply-To: References: Message-ID: <1084000472.20020113152703@vega.bg> 13.1.2002, 02:59:45, Tim Peters wrote: TP> Nope! Anticipating this outcome, I arranged to vote twice to remove c.l.py, TP> then submitted ironclad evidence of this fraud to Usenet Master Control. TP> They had no choice but to agree the vote was rigged, so declared it null and TP> void. c.l.py's charter was then automatically extended, under clause TP> 49(b)7(iii), to January 31st, 3003. You mean until Python 3000 comes out right? -- Best regards, Niki Spahiev ______________________________________ VEGA(TM) Internet Service Provider Scanned and protected by Inflex Tova pismo e provereno i zashtiteno ot programite "Inflex/Antivir". From joshm at taconic.net Sun Jan 20 01:18:44 2002 From: joshm at taconic.net (Joshua Muskovitz) Date: Sun, 20 Jan 2002 01:18:44 -0500 Subject: DES encryption algorithm References: <151117467797818.Post@ithinknot.net><87sn96u4y8.fsf@psyche.dnsalias.org> <3c453a70_3@corp.newsgroups.com> <878zatk8mv.fsf@psyche.dnsalias.org> Message-ID: <3c4a5e1a_2@corp.newsgroups.com> "Carey Evans" wrote in message news:878zatk8mv.fsf at psyche.dnsalias.org... > 1. Function call in Python is relatively expensive, and there are a > lot of right shifts in DES. Yep. Luckily, my implementation wasn't used for particularly high traffic situations, so performance wasn't an issue. > 2. At least in the DES implementation I ported, all the right shifts > were by constant amounts, so I could expand them inline to > something like ((t >> 18) & 0x3fff). You were probably very lucky to have started with a decent implementation. Sadly, I was forced to port one which left *much* to be desired. Many have asked why I didn't just use a proper implementation. This was because my code had to interoperate with the previous version. I wasn't convinced that they had implemented DES properly, and the requirement that my version work the same was higher than the requirement that it work *correctly*. :-/ > 3. A good bit of the code was right-shifting 28-bit numbers, where > the top bit was always zero, so no change was needed. I only used my rshift() function in places where I wasn't able to prove that the value to be shifted was less than 2^31. I also substantially removed many of the function calls in the original implementation through refactoring. It actually performed quite well for what it needed to do. -- # Joshua Muskovitz # joshm at taconic.net def lyyrs(sig): return '-'.join(sig.split()+["ly y'rs"]) lyyrs('Hire me! I need the work!') -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From brueckd at tbye.com Wed Jan 9 21:26:08 2002 From: brueckd at tbye.com (brueckd at tbye.com) Date: Wed, 9 Jan 2002 18:26:08 -0800 (PST) Subject: Sockets, threads, and killing servers In-Reply-To: Message-ID: On 9 Jan 2002, Robin Munn wrote: > I've been playing around with the SocketServer module recently. It [snip] > A fully-functional example is below. Any comments? I'd be especially The only downside is if you're on a platform that doesn't have 'select' (e.g. Jython), but as long as that's not a problem then this way works pretty well. From phr-n2002a at nightsong.com Fri Jan 18 20:01:26 2002 From: phr-n2002a at nightsong.com (Paul Rubin) Date: 18 Jan 2002 17:01:26 -0800 Subject: Validating a secure certificate? References: <3k6h4ugjqgeshjmb8anmoj84q00feml23c@4ax.com> Message-ID: <7x665znogp.fsf@ruckus.brouhaha.com> Sherman writes: > Is there a way to validate the secure certificate of a remote site? Or > possibly just grab the certificate information? I haven't been able to > find much on this, so any help would be appreciated. > > Thanks in advance. What do you mean by "validate"? Of course you can check the signature-- that's the whole point of a certificate. And most SSL libraries can parse the certificate so you can read the contents. I don't know what the situation for Python bindings to OpenSSL is right now, though. From threeseas at earthlink.net Thu Jan 24 21:30:19 2002 From: threeseas at earthlink.net (Timothy Rue) Date: Fri, 25 Jan 2002 02:30:19 GMT Subject: Autocoding >Re: "Introduction to Ethics", References: <321.788T2944T10325794threeseas@earthlink.net> <87it9sn0jc.fsf@becket.becket.net> Message-ID: <6322.789T326T13093628threeseas@earthlink.net> On 23-Jan-02 17:51:51 ---name removed until ok'd for newgroups -- wrote: >"Timothy Rue" writes: >> I know enough to know that I know more than I need to know, to know the >> project I presented is a valid one. >Autocoding is a nice dream, but it's a little like world peace. It's >not just a matter of saying "here's a great idea, do this". World peace is alot closer than many realize and the more that do realize, the closer it gets. http://www.osearth.com/resources/wwwproject/ Knowledge is power, for having it alters how one reacts to situations and in this knowledge, that might just be saying no to those up the chain of command by a large enough number of people who know have seen another possibility, to cause an improvement. Sure there is more to world peace than what is at that link, but it is an effort that is moving forward becomming more and more inclusive of the big picture, open with exercises on solving world problems and even teaching the next generations. Many people have heard of preventitive healthcare, but does anyone talk about preventitive warfare? Where you spend less money solving problems that would otherwise lead to growing stress levels, in order to reduce world stress levels. Money has to move for there to be an ecomony, so where does the savings go? Common Wealth? We are learning what values people working together around the world can accomplish, beyond politics and economies, thanks to GNU. But GNU has so far been limited to those with focused skilled in programming. There are many more people that have a very clear idea of what they want to do with computers but don't have the tools that will allow them to do it for themselves within the resources of what they have available (considering their focus may very well be at being an expert at what they do for a living.) So it either doesn't get done or they have to pay to then teach a programmer what the solution is, what they want, and hope the student learns before they run out of money to pay the student. Yes, different perspective. There is much about current world happenings that can be followed back to US based trigger points being fired off, but identify them and setting laws against them, like anti-card counting in world stock markets - PBS - "trillion dollar bet", or where did the dot com investments come from? (I don't suppose you'd want to know the urls..) Anyways, autocoding is something that the knowledge base.... well much of it already exist in the form of unix style man pages and such references so commonly found not only in the field of programming but many fields. >From here its a matter of finding a use/integration/automation solutions (whatever size) here and there, really no different than how GNU software (whatever kernel) has developed/evolved. A little here, a bit there, an improvement then an addition, a bigger picture perspective leading to optimization, etc.. before you can see and get to c you have to go from a to b. What's missing is the common base/core tool that will allow anyone who wants to help, to do so. And a component or modular based system won't hurt but rather it can add much additional value, power and excitement to a system and it's use. This tool pretty much amounts to a small shell, and optionally a library, that contains nine commands with boring but logical command options. Of couse a GUI can be placed over top of it.... People put things together, component and modular based systems provide building blocks that people can use to build things with. Having an automation tool to help them put things together..... Writing a manual page can be very boring, but to write a manual page (or even simpler - convert one) that is also usable in a automation process, [at least - hardly changed at all, at most - containing directions for further automations as part of the definitions]... though it too may be boring, it may be a little more exciting. But for certain, such an option/tool doesn't exist at this time. Of course more than just manual pages can be handled, but its one place to start or work on, suggest, use as an example.... Sometimes before you can move forward in a given way, you gotta create the tool to do so. When the Video Toaster and Lightwave was first released, many thought everybody and their brother, sister, cousin, uncle, etc., were going to all become animators and video production artist. And that doing so would cause a flooding of the market, which would inturn cause a drop in wages to earn. But what really happened is that the best animators turned out to be those who studied film production. All that really happened is that we got alot better at animation. There is alot of stuff to do to create or convert the foundation of manual pages and overly reinvented code, automating the do's, don'ts, standards. The sort of stuff that most anyone can do. The sort of stuff the experts should find boring, but the typical user might find alot more exciting, especially if they are allowed to see it work and even make use of it themselves, to some degree in their learning. The way programs are done, the way a user has to interface with them, does condition the user to think in terms of the program or more specifically to think in terms of the programmer. Microsoft knows this as they influence the user to accept false constraints and even the insinuation that they, the user, is stupid. What a pathetic shell the DOS prompt is, what a pathetic user oriented Windows IPC called DDE, is. The GNU community can do much better than that. Even the Hurd concept of servers and translators is helpful to introducing the users to input/output translation components. In Fact, in the VIC, there is a place to put input and output filter, translator, etc.. If Hurd servers are easy enough for the non-programmer user to create (automated coding process.... - well what could be harder than a full linux system custom install/compile - but that's actually been done in an automated manner by at least two companies).... anyway such i/o translators/filters in the Hurd might just be one less thing that is needed to be done in the VIC, fo the Hurd.... I don't know, guess that is further down the road, somewhere past e or f maybe. but something you can't see until you get to d. From phr-n2002a at nightsong.com Wed Jan 2 00:24:44 2002 From: phr-n2002a at nightsong.com (Paul Rubin) Date: 01 Jan 2002 21:24:44 -0800 Subject: threading.py -> winthreading.c : Some results References: Message-ID: <7xn0zx8gv7.fsf@ruckus.brouhaha.com> "Tim Peters" writes: > However, Python's internal uses of locks-- and particularly the GIL --don't > need these unusual (relative to what platforms usually offer in the way of > native synch gimmicks) semantics. The GIL is "owned": a thread T that > acquires the GIL won't try to acquire it again while it's acquired, T will > eventually release it itself, and no other thread will attempt to release it > while T has it held. Most platforms have a more efficient synch > implementation for this simple usage, but we never got around to creating an > internal lock type to exploit this. Just about *any* mutex gimmick would > suffice except for a spin lock (the GIL can be held by a thread for an > arbitrarily long time): the GIL exists solely to enforce serialization. Is it feasible to replace the GIL with something else, that allows Python programs to use the parallelism on multi-cpu systems? From logiplexsoftware at earthlink.net Tue Jan 8 14:21:55 2002 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Tue, 8 Jan 2002 11:21:55 -0800 Subject: Closed-source considered harmful (was: JavaScript considered harmful) In-Reply-To: <3C3B3F84.AA414A18@stroeder.com> References: <3C3B3F84.AA414A18@stroeder.com> Message-ID: <20020108112155.7d0a0569.logiplexsoftware@earthlink.net> On Tue, 08 Jan 2002 19:50:44 +0100 Michael Str?der wrote: > Mark McEahern wrote: > > Hmm, I don't really understand how my car works. I don't think that has any > > impact on my ability to be a safe driver, though. > > Comparing software and cars is never valid for two reasons: > > 1. There are more strict laws regarding public traffic dedicated > to make life on public streets more safe. > > 2. People are willing to spend a lot of money for cars. On point 2, I'd have to say that I've probably spent more on computers and software than I have on cars. But since we're starting a list: 3. Cars are inherently open-source: anyone with knowledge and tools can work on them. 4. You don't have to close all your windows and restart your car after a new passenger gets in. 5. Installing a new stereo doesn't require upgrading your entire car. 6. A single broken window probably won't make your car crash. 7. The best cars are expensive, the best software is free* ;-) *Don't start Oleg! -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From brian at sweetapp.com Thu Jan 24 19:58:54 2002 From: brian at sweetapp.com (Brian Quinlan) Date: Thu, 24 Jan 2002 16:58:54 -0800 Subject: call method by name? In-Reply-To: Message-ID: <001f01c1a53b$76282340$445d4540@Dell2> Chris Liechti wrote: > > How to say this in Python? > > > > method_name = 'method1' > > a. at method_name() > > apply(a, method_name) This won't work. apply expects a callable as its first argument and a parameter list as its second argument. If you wanted to be verbose, you could write it as: apply(getattr(a, method_name),()) But the apply is really redundant: getattr(a, method_name)() Cheers, Brian From fperez528 at yahoo.com Tue Jan 15 06:46:15 2002 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Wed, 16 Jan 2002 11:14:15 +2328 Subject: Numeric - writing extentions References: Message-ID: Jesper Olsen wrote: > Today I downloaded and installed Numeric-20.3 from sourceforge > - I installed it from source, and it seems to work ok (with python 2.1.1). > > Now I want to write an extention where I use Numeric.array > You may want to take a serious look at weave (http://www.scipy.org/site_content/weave). It may be the case that you do need a full blown extension, but chances are some inlined C with weave, either using blitz() or inline() with blitz type factories may do. And it's *vastly* simpler to use. An example: #----------------------------------------------------------------------------- # Operating in-place in an existing Numeric array. def in_place_mult(num,mat): """In-place multiplication of a matrix by a scalar. """ nrow,ncol = mat.shape code = \ """ for(int i=0;i <3C45E6EE.7191EA00@ndh.net> Message-ID: <01f201c19f51$4ec427d0$5102020a@graphnet.com> > > > import ftplib > > > hostname = ftplib.FTP("192.168.13.21") > > > > I agree with the others that the failure may be due a wrong port. I'd like to assume that a) when I fail to provide a port to the ftp client, it will use the default port, and b) if I fail to provide a port to ftplib.FTP() it will use the default port, and c) in the same environment, for the same user, that default port will be the same. 8-) But I'll gladly stand corrected if that's an unwarranted assumption. > > > hostname.login("joeuser","mydogsname") > > > hostname.cwd("$SYSTEM.DATA") # see below > > > > Is the directory literally $SYSTEM.DATA or is SYSTEM some environment > > variable? AFAIK, ftplib doesn't support "interpolating" of environment > > variables. hehe. Yep. That's the actual string I type to cahnge directories on the server. Tandems are Funky. > > > hostname_numbers = hostname.retrlines("GET ALARMDATA") > > > > I think, it should be RETR instead of GET? Then, retrlines is not so > > similar to file.readlines. :-) From help(ftplib.FTP.retrlines): Thanks...I'm kinda new at this... > The bottom line, however, is that his client isn't connecting. Until he can > achieve a connection, the rest is just noise, right Bruce? Not so much noise, as much as not yet relevant, but educational nonetheless. My first step, before I start sniffing ports, is to fire up an ftp server on my own machine, and try to connect to127.0.0.1. If that fails, well, you'll be hearing about this again. Let's hope it doesn't come to that. That would just be too freaky. 8-) bkd From triplec1986 at hotmail.com Thu Jan 24 14:44:17 2002 From: triplec1986 at hotmail.com (Corey) Date: 24 Jan 2002 11:44:17 -0800 Subject: Making EXE'S in python References: Message-ID: Thanx. From pedro_rodriguez at club-internet.fr Tue Jan 22 05:07:33 2002 From: pedro_rodriguez at club-internet.fr (Pedro Rodriguez) Date: Tue, 22 Jan 2002 11:07:33 +0100 Subject: Hooks (Re: What does Python fix?) References: Message-ID: "hungjunglu" wrote: > --- In python-list at y..., "Andrew Dalke" wrote: >> I believe you refer to modifing a function in-place, so that > existing >> references to that function are modified. That indeed is hard, or even >> impossible in Python. > > I explicitly said IT IS POSSIBLE in Python. :) > There is at least one very well know module that use this property : 'timeoutsocket' by Timothy O'Malley. It enhances the standard 'socket' module. Fortunately, there is also some limit to what can be done : you can't overload methods on built in. Unfortunately I don't think that C extensions will support such a mechanism. Regards, -- Pedro From Scott.Daniels at Acm.Org Thu Jan 31 01:52:44 2002 From: Scott.Daniels at Acm.Org (Scott David Daniels) Date: Thu, 31 Jan 2002 06:52:44 GMT Subject: Elegant solution needed: Data manipulation References: Message-ID: <1103_1012459964@news.dsl-only.net> On Wed, 30 Jan 2002 19:42:24 -0600, "Jason Orendorff" wrote: > Mark wrote: > ... lots of great suff... > > # Step 1. Build your data structure out of objects. > class DataRow: > def __init__(self, height, weight, speed): > self.height = height > self.weight = weight > self.speed = speed I'd replace this with the following more general piece: class Data: def __init__(self, **kwargs): self.__dict__.update(kwargs) def __repr__(self): return ''.join(( self.__class__.__name__, '(', ', '.join(['%s=%r' % entry for entry in vars(self).items()]), ')')) > # You can write the part the reads it out of a file. > # Here is what the resulting data structure should be. > data = [ DataRow(3, 6, 12), > DataRow(5, 9, 20), > DataRow(4, 10, 15) ] In which case you'll need this to be: data = [ Data(height=3, width=6, speed=12), Data(height=5, width=9, speed=20), Data(height=4, width=10, speed=15) ] and everything else works the same way. The nice thing about this class is (1) it expands to whatever types you like, and (2) it prints nicely. -Scott -Scott From maxm at mxm.dk Fri Jan 11 09:00:31 2002 From: maxm at mxm.dk (maxm) Date: Fri, 11 Jan 2002 15:00:31 +0100 Subject: How do I pass dict as parameterlist in Python 1.52 ? References: <3C3EEE09.FB1EC781@metaslash.com> Message-ID: > apply(HTMLFile, ('manage_addots_UserForm', globals()), > {'formatTypes':ots_User.formatTypes}) Thanks! I will see if that works. I am not shure, as HTMLFile is a class. regards Max M From pinard at iro.umontreal.ca Tue Jan 22 09:20:52 2002 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 22 Jan 2002 09:20:52 -0500 Subject: What does Python fix? In-Reply-To: <20020122112501.UHNL29398.amsfep14-int.chello.nl@there> References: <20020122112501.UHNL29398.amsfep14-int.chello.nl@there> Message-ID: [,,,] > >Even Scheme has vectors. > Why 'even' Scheme ? In comparison to ...??? Many people consider Scheme has being a toy, and not any Lisp. In my correspondence with various people, I observed that this lack of praise is recurrent from people who like Common Lisp. I would expect that PL/I people despise Pascal in similar ways, for similar reasons. I do not take offence of remarks like the above, and you should not either. These only represent cultural differences, and I'm sure no harm was ever intended. For one, I am attracted to simplicity, and this is why I loved Pascal in its time, and have been very happy with Scheme before discovering Python. In my youth, I used Lisp a lot, and contributed Lisp interpreters, compilers and loaders. I also did my PL/I duties very carefully. In a word, I tasted complexity, my love for simplicity is not a purely intellectual exercise. :-) I made a few big applications with Gambit: a full Scheme implementation with nice and usable system interfaces for extensions. It also offers an optimising compiler producing C, which you can then turn into machine code. I got CPU intensive, difficult applications to fly at reasonable speed. We should not be overly snob or fussy: it's incredible all the good work you can do with toys :-), when these are well designed and implemented! -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From star7fire at yahoo.com Tue Jan 8 15:37:33 2002 From: star7fire at yahoo.com (star7fire) Date: Tue, 08 Jan 2002 20:37:33 -0000 Subject: Problems displaying Tkinter objects in Window NT Message-ID: I'm fairly new to Python. I downloaded the phone.py program by Jessie Weinstein from the games section of the Vaults of Parnassus listed on the www.python.org site. The opening Tkinter dialog which should be displayed does not show up. I am trying to run it on Windows NT. I am thinking that it there is a problem with the the line: self.master.bind('', self.show_me) method call. The show_me call back method seems not to be called. Any help anyone can give me is greatly appreciated since I need to do some GUI development using Python. Thanks. Star For convenience here is the script: """This is a program to create pictures of phone numbers. To see the graph of a phone number, just enter it in the text box at the top and press enter(or click on Show Me!). The constants and options work as follows: * SuperScale lets you modifiy the size of the graph, * LineWidth the width of the line, * salting turns on a bit of random jiggle for lines that start or end in the same place, * coloring makes each line a random color. Created by Jesse Weinstein. Released on Feb 19, 2001""" from Tkinter import * import random, string, re class PhoneDrawingMaker: #Tuneable Constants SuperScale=4 LineWidth=1 #Boolen options salting=0 coloring=0 DEBUG=0 #Interesting number to try: #(397) 426-8413 def __init__(self): """Set a few generated or non-tuneable constants and call make_dialog.""" self.PhoneKeyPad = {'1':(1,1), '2':(2,1), '3':(3,1), \ '4':(1,2), '5':(2,2), '6':(3,2), \ '7':(1,3), '8':(2,3), '9':(3,3), \ '*':(1,4), '0':(2,4), '#':(3,4)} self.Ltrs2NumsTbl=string.maketrans(\ string.uppercase, '2'*3+'3'*3+'4'*3+'5'*3+'6'*3+'7'*4+'8'*3+'9'*4) self.scale=18*self.SuperScale self.make_dialog() def make_dialog(self): """Create and display the interface.""" self.master=Tk() self.master.title('Phone Graphing Tool') Label(self.master, text="Phone Number:").grid(row=0) self.e = Entry(self.master) self.e.grid(row=0,column=1) self.c = Canvas(self.master, height=75*self.SuperScale, \ width=60*self.SuperScale, relief=RIDGE, bd='.02i') self.c.grid(row=1, column=1) self.b = Button(self.master, text="Show me!", command=self.show_me) self.b.grid(row=2, column=1) ## self.err = Label(self.master, wraplength='.6i') #text="No Error! XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX") ## self.err.grid(row=1) self.master.bind('', self.show_me) def show_me(self, event=None): """Callback: Fixup and draw the phone number.""" self.fixup() if not self.PhoneStr: return else: self.draw() def fixup(self): """Fixup the string by translating letters to numbers, and removing anything else. Also push the translated string back to the interface.""" self.PhoneStr=string.translate(self.e.get().upper(), self.Ltrs2NumsTbl) self.e.delete(0, END) self.e.insert(0, self.PhoneStr) self.PhoneStr=re.sub('[^0123456789*#]', '', self.PhoneStr) def draw(self): """Do the actual drawing. This is done using the PhoneKeyPad dict; it maps numbers to locations on a phone keypad. Then after checking for and processing salting and coloring options, a line just has to be drawn between each point returned from PhoneKeyPad.""" self.c.delete(ALL) pX=self.PhoneKeyPad[self.PhoneStr[0]][0]*self.scale pY=self.PhoneKeyPad[self.PhoneStr[0]][1]*self.scale if self.DEBUG: print print 'The Coords of each line created(without salt):' print '--------------------------------' for number in list(self.PhoneStr): if self.DEBUG: print pX,pY,'|', self.PhoneKeyPad[number][0] *self.scale,\ self.PhoneKeyPad[number][1]*self.scale salt = 0 if list(self.PhoneStr).count(number) > 1 and self.salting: salt=random.randint(-2,2) color = "black" if self.coloring: color = "#%02x%02x%02x" % (random.randint(0,255), random.randint(0,255), random.randint(0,255)) self.c.create_line(pX,pY, \ self.PhoneKeyPad[number][0] *self.scale+salt, \ self.PhoneKeyPad[number][1] *self.scale+salt, \ fill=color, width=self.LineWidth) pX=self.PhoneKeyPad[number][0]*self.scale+salt pY=self.PhoneKeyPad[number][1]*self.scale+salt It=PhoneDrawingMaker() From sholden at holdenweb.com Wed Jan 16 11:59:58 2002 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 16 Jan 2002 11:59:58 -0500 Subject: Redirecting stdin/stdout/setderr and os.execv References: <3C459B60.2020505@ua.ac.be> Message-ID: "Richard Philips" wrote ... > > How do I redirect stdin, stdout en stderr from within a python script > together with os.execv: > > > import os > import sys > > sys.stdout = open("/tmp/output","wb") > os.execv("/bin/ls", ["ls", "-ls"]) > > > does not redirect the stdout of the /bin/ls > > Any ideas on this ? > > I am looking for a replacement for os.system which is independent of the > pecularities of the shell in use. > You probably need the os.popen() function or one of its buddies popen2.popen2(), os.popen3(), popen2.popen3() , etc, which create file-like pipeline objects you can read the output from and write standard input to. In short, look in modules os and popen2 for names beginning with popen! regards STeve -- Consulting, training, speaking: http://www.holdenweb.com/ Python Web Programming: http://pydish.holdenweb.com/pwp/ From alanmk at hotmail.com Fri Jan 11 14:38:29 2002 From: alanmk at hotmail.com (Alan Kennedy) Date: 11 Jan 2002 11:38:29 -0800 Subject: zlib, gzip and HTTP compression. References: Message-ID: jj wrote in message news:... > dont use zlib, > http requires data in gzip format, zlip.compress returns quite > different structure. > so import gzip ... Thanks JJ. OK, I understand the problem better now. I read RFC 1952, which explains the structure of gzip files. And looking at python/Lib/gzip.py, it appears to construct exactly the structure required. So I reworked my code to use gzip, and I'm almost there. The first ~200 bytes of the HTML file now appear exactly as they should, but then it corrupts after that. Obviously the mechanism for communicating from the server to the client that I am sending gzipped data is working, but it looks like I'm sending gzipped data that is slightly corrupt, or I'm telling the client the wrong length, or some such. Close, but no cigar! There is obviously some small detail that I am missing, such as character translation during the print statement(?), one extra byte need somewhere, etc? Any hints anyone? The new code is presented below. TIA, Alan. ------------------------------------------ #! C:/python21/python.exe import string import os import gzip import StringIO # Use any old HTML file (which displays fine standalone) f = open("test.html") buf = f.read() f.close() def compressBuf(buf): zbuf = StringIO.StringIO() zfile = gzip.GzipFile(None, 'wb', 9, zbuf) zfile.write(buf) zfile.close() return zbuf.getvalue() acceptsGzip = 0 if string.find(os.environ["HTTP_ACCEPT_ENCODING"], "gzip") != -1: acceptsGzip = 1 zbuf = compressBuf(buf) print "Content-type: text/html" if acceptsGzip: print "Content-Encoding: gzip" print "Content-Length: %d" % (len(zbuf)) print # end of headers print zbuf # and then the buffer else: print # end of headers print buf # and then the buffer # end of script ------------------------------------------------------ From markjunk at mceahern.com Sat Jan 12 19:13:13 2002 From: markjunk at mceahern.com (Mark McEahern) Date: Sun, 13 Jan 2002 00:13:13 GMT Subject: postgres example References: Message-ID: "QdlatY" wrote: > And DB-API 2.0 is some standart linux database interface ?? Replace 'Linux' with 'Python' and I think that's an accurate description: http://www.python.org/topics/database/DatabaseAPI-2.0.html Cheers, // mark From pinard at iro.umontreal.ca Mon Jan 28 10:02:17 2002 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 28 Jan 2002 10:02:17 -0500 Subject: Sourceforge or Savannah or ... In-Reply-To: References: Message-ID: [Stephen Ferg] > Before making your decision, you should read this article at Free > Software Magazine. It describes a disturbing development for > SourceForge... > http://www.rons.net.cn/english/FSM/loic An interesting article, indeed, thanks for the URL. Lo?c Dachary has been involved in free software for many, many years, he owns my confidence, and the fact he contributed to setting up Savannah is a good point for Savannah. However, as a bit of counter-weight, I doubt Lo?c alone is heavy enough to protect Savannah users against FSF politics and administrators. The fact is that I've been avoiding FSF-administrated machines for years, for the sake of my own freedom, after having suffered various abuses from administrators there. I got that the FSF is about free programs, not free programmers. :-) To counter-weight my own counter-weight, this is also true that I'm overly protective for my own freedom, and the FSF might have evolved over all these years. Also, I'm in contact with some GNU maintainers that became my friends over the years, and if I except a few matters related to the FSF Web site, no one ever complained against FSF administrators, for years now. In particular, my friends seem to be fairly happy with Savannah. The ideal, in my opinion, is to use your own Web site if you can, so freedom stays distributed. This is our best bet in the long run. Freedom is more easily threatened, when everybody agreed to put it in a few big bags. Of course, you will not have all the bells and whistles that comes with big sites like Sourceforge or Savannah, but in a way, you'll get a better taste of simplicity, which is severely lacking in these times. :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From eric at enthought.com Sun Jan 6 03:02:00 2002 From: eric at enthought.com (eric jones) Date: Sun, 06 Jan 2002 08:02:00 GMT Subject: Real-world Python code 700 times slower than C References: Message-ID: Hey Brent, > I like the approach that the Perl Inline module takes where you can > put C code directly inline with your Perl code and the Inline module > compiles and caches the C code automatically. However the fact that > it's C (with all of its safety and portability problems) and the fact > that it relies on a C compiler to be properly installed and accessible > make this approach unappealing for general use. weave is a new package from the SciPy project that does this sort of thing. It isn't ready for release quite yet, but is pretty close. Comparing weave.inline() using Numeric arrays instead of lists to timings for straight C, I get: N_array = 10000 loops = 10000 compiled numeric2 (seconds): 0.912000060081 c version (seconds): 0.480000 So your 1.9 times slower using Python+inline() for this case. That's not so bad for this problem. And, for larger arrays, the descrepency gets even smaller: N_array = 100000 loops = 1000 compiled numeric2 (seconds): 3.97500002384 c version (seconds): 3.795000 Your comment about portabilitiy is an issue. To solve this, weave also allows you to build extension modules for distribution instead of compiling on the fly. Unfortunately, I found that using this approach was about 3 times slower on this problem than calling inline(). : | Don't quite get this -- and that's why it ain't released yet. If your interested in taking a peek though (and testing!!!), as Fernando mentioned, the web site is here: http://www.scipy.org/site_content/weave Hopefully I'll get this thing out the door sometime next week. see ya, eric ps: I also changed the Ramp() C code a tad bit to get a little more performance (both in the inline() and in the C version so the comparison is fair). ------------------------------ import time import weave from Numeric import * def Ramp(result, size, start, end): step = (end-start)/(size-1) for i in xrange(size): result[i] = start + step*i def Ramp_numeric1(result,size,start,end): code = """ double step = (end-start)/(size-1); double val = start; for (int i = 0; i < size; i++) *result_data++ = start + step*i; """ weave.inline(code,['result','size','start','end'],compiler='gcc') def Ramp_numeric2(result,size,start,end): code = """ double step = (end-start)/(size-1); double val = start; for (int i = 0; i < size; i++) { result_data[i] = val; val += step; } """ weave.inline(code,['result','size','start','end'],compiler='gcc') def main(): N_py = 200 N_c = 10000 ratio = float(N_c) / N_py arr = [0]*10000 t1 = time.time() for i in xrange(N_py): Ramp(arr, 10000, 0.0, 1.0) t2 = time.time() py_time = (t2 - t1) * ratio print 'python (seconds*ratio):', py_time print 'arr[500]:', arr[500] arr = array([0]*10000,Float64) # First call compiles function or loads from cache. # I'm not including this in the timing. Ramp_numeric1(arr, 10000, 0.0, 1.0) t1 = time.time() for i in xrange(N_c): Ramp_numeric1(arr, 10000, 0.0, 1.0) t2 = time.time() c_time = (t2 - t1) print 'compiled numeric1 (seconds, speed up):', c_time, py_time/ c_time print 'arr[500]:', arr[500] arr2 = array([0]*10000,Float64) # First call compiles function or loads from cache. # I'm not including this in the timing. Ramp_numeric2(arr, 10000, 0.0, 1.0) t1 = time.time() for i in xrange(N_c): Ramp_numeric2(arr, 10000, 0.0, 1.0) t2 = time.time() c_time = (t2 - t1) print 'compiled numeric2 (seconds, speed up):', c_time, py_time/ c_time print 'arr[500]:', arr[500] if __name__ == '__main__': main() -------------------------------- C:\home\ej\wrk\weave\examples>python ramp.py python (seconds*ratio): 132.20000267 arr[500]: 0.0500050005001 compiled numeric1 (seconds, speed up): 1.44200003147 91.6782245389 arr[500]: 0.0500050005001 compiled numeric2 (seconds, speed up): 0.912000060081 144.956133729 arr[500]: 0.0500050005001 -------------------------------- And the C version: #include #include void Ramp(double* result, int size, double start, double end) { double step = (end-start)/(size-1); double val = start; int i; for (i = 0; i < size; i++) { *result++ = val; val += step; } } void main() { double array[10000]; int i; clock_t t1, t2; float seconds; t1 = clock(); for (i = 0; i < 10000; i++) Ramp(array, 10000, 0.0, 1.0); t2 = clock(); seconds = (float)(t2-t1)/CLOCKS_PER_SEC; printf("c version (seconds): %f\n", seconds); printf("array[500]: %f\n", array[500]); } -------------------------------- C:\home\ej\wrk\weave\examples>ramp.exe c version (seconds): 0.480000 array[500]: 0.050005 From stephen.boulet at motorola.com Wed Jan 9 17:33:02 2002 From: stephen.boulet at motorola.com (Stephen Boulet) Date: Wed, 09 Jan 2002 16:33:02 -0600 Subject: [Q] How to use IDLE in redhat References: Message-ID: <3C3CC51E.1F9CA720@motorola.com> Just type in: python idle.py if you're launching from the command line. Otherwise double-click the idle.pyw icon. -- Stephen Young-Jin Lee wrote: > > Hi, I'm new to redhat. I was using Python in windows and now I was trying to > move to Redhat. > I thought it would be easy to use IDLE in redhat linux, but it turned out to > be a bit difficult. > After posting a few questions on the tutor at python.org list, I came to know > that I should setup IDLE by > "$ cd .../Tools/idle > $ python2.2 ./setup.py". > > When I tried the aboves, python asked me to specify the option and command, > but I have no idea what to do. > Here is the message I got: > usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] > or: setup.py --help [cmd1 cmd2] > or: setup.py --help-commands > or: setup.py cmd --help. > > I also tried "python2 ./setup.py idle", but it didn't work, either. > > Thanks in advance. > > YJ From tim.one at home.com Thu Jan 3 00:22:45 2002 From: tim.one at home.com (Tim Peters) Date: Thu, 3 Jan 2002 00:22:45 -0500 Subject: threading.py -> winthreading.c : Some results In-Reply-To: Message-ID: [Jason Orendorff] > It seems there's no demand for this right now. Ya, but people don't know what they need until after you give it to them and later take it away. Nobody *asked* for Stackless Python either, not to mention tabnanny.py . For that matter, Guido personally rammed Python down an uninterested world's constricted throat. > ut I'd like to submit what I have, so that in any case it can be > kept in reserve against the chance that someone will someday need it. > How should I do this...? Upload a patch to SourceForge. Then it won't get lost, it's with all the other contributed ideas that may actually go somwhere, and interested parties can (and will) play with it. From Cashad at naturallife.ca Thu Jan 10 02:44:07 2002 From: Cashad at naturallife.ca (Cashad at naturallife.ca) Date: Thu, 10 Jan 2002 00:44:07 -0700 Subject: They Laughed when I sat down and TOLD THEM Message-ID: <2530096-2200214107447628@naturallife.ca> My family and friends all laughed when I sat down and told them I had made thousands in this program: "AS SEEN ON ABC's 20/20", then I put my PAYPAL account REPORT on the table and LAUGHED BACK. The silence of reality set in immediately and then the rush was on, to sign up. What a feeling!!! JUDGE FOR YOURSELF AS SEEN ON TV ABC's 20/20: The TRUE story of a 15 yr. old boy who made over $70,000 on the internet in a matter of weeks. He designed a very simplified and low cost $30 - HOME BUSINESS EVER. It's honest, it's not MLM and best of all, IT'S SIMPLE. You won't be bugging your friends and family. A little time spent each day and only $30 invested and the program begins to work for itself. I figured if a 15 year old boy can do it so can I (a 34 year old IT Manager). Also our friends have placed this program on the internet, give you a ready made web site and also developed a system that prevents people from cheaters...!!! All this for $30, now what do you SAY!!! read for yourself.... at http://fortunemaker.net/tv/html/1920.html For more information email me at cashad at naturallife.ca OR VISIT OUR SITE http://fortunemaker.net/tv/html/19026.html MY Brief Story is; I had gotten a few emails about this program, but just deleted them. My curiosity was killing me. So, I finally decided not to delete it. I figured, "hey, it can't hurt to check it out". That decision has changed my life. Here you have the very same opportunity in front of you. If you take just five minutes to read through the program on the site mentioned http://fortunemaker.net/tv/html/19026.html it could make a huge difference in your financial status. Since this program aired on National TV, thousands are joining every day. You'll earn cash in a matter of a couple of weeks! I did. THIS IS NOT A SCAM ABC 20/20 PROVED THAT AND ITS JUST TOO....SIMPLE!!!! WE DO NOT SPAM. You are receiving this information via opt-in only. And you may opt-out at any time. If you are not interested and want confirmation of removal, and in compliance with proposed federal legislation (H.R. 3113 and S. 2542) and ll enacted state legislation, reply to this email with 'REMOVE' in the Subject line. From jimmy at retzlaff.com Tue Jan 22 04:51:27 2002 From: jimmy at retzlaff.com (Jimmy Retzlaff) Date: Tue, 22 Jan 2002 01:51:27 -0800 Subject: why is os.getcwd() printing the path in all caps on win2k? Message-ID: >> can anyone tell me why os.getcwd() prints out the path in all caps on >> win2k at least? It works fine on my Windows 2000 Server (SP2 w/IE6) using Python 2.2 (I'm quite sure it was the same on 2.1.1): Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.getcwd() 'C:\\Python22' There are several possible reasons within Windows for what you are seeing including UI settings and the file system of your partition. One possible reason for the difference is that your directories really are all caps and Explorer is lying to you when you look at it there. Some versions of Explorer (affected by version of Windows and version of IE) default to displaying an upper case name like C:\PYTHON as C:\Python. It's also possible that it's giving you the DOS/8.3 compatible name. Try this: >>> os.mkdir(r'c:\longDirectoryName') >>> os.chdir(r'c:\longDirectoryName') >>> os.getcwd() 'c:\\longDirectoryName' Depending on how things are set up, you could see something like 'C:\\LONGDI~1' which is the DOS/8.3 compatible name. You can also see the 8.3 names by doing "dir /x" at a command prompt. If you get an exception in the above snippet, then it's likely that your file system doesn't support long file names (and hence mixed case) at all. Jimmy From robpy2002 at yahoo.com Thu Jan 17 21:43:45 2002 From: robpy2002 at yahoo.com (Rob) Date: 17 Jan 2002 18:43:45 -0800 Subject: newbie: Python vs VB Message-ID: Hello, I am currently using VB to create COM components. I have become very interested in using Python and have a few questions I'm hoping someone can answer... 1. What are some of the benefits to using Python over VB for creating COM components? 2. Can I create Com components in Python which support object pooling? (cant do this in VB) 3. Any limitations in Python with regards to creating COM components. Thanks!!! Rob. From tjreedy at home.com Mon Jan 28 12:57:10 2002 From: tjreedy at home.com (Terry Reedy) Date: Mon, 28 Jan 2002 17:57:10 GMT Subject: Autocoding evolves from........ References: <4314.793T504T6883966threeseas@earthlink.net> <_Jf58.7084$X64.3174958@news1.rdc2.pa.home.com> Message-ID: "Terry Reedy" wrote an accidental quote without comment that I did not know I had sent until it showed up. Whoops. Sorry. see real response sent later. From jgardn at alumni.washington.edu Thu Jan 17 16:32:07 2002 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Fri, 18 Jan 2002 06:32:07 +0900 Subject: Socket server In-Reply-To: References: Message-ID: <200201172147.g0HLlBO31567@my.knctv.co.kr> On Friday 18 January 2002 03:39 am, Hugo Martires wrote: > I have a server that answer a single client, but now i need moore > clients. > > Witch is the best way to make a server socket that answer's the call's > of many clients ? > I have to use threads ? Queues ? > > Can any one send me a simple example ? > "Simple Example" - it's not so simple anymore. Depending on what you want to do, your options are: - Forking. Each new call is answered by forking off a child process. The child process does all the work, and when it is done, it dies. This is how Apache does it. You can get it into all kinds of fun problems, like keeping some children alive, telling those children to die after so many times, etc... Your level of complexity depends on what you want. - Threading. Each new call is answered with a new thread. This entails all that threading is about. It gives you similar results as the above, except each thread can play with the parent in the way that threads like to do. - Multiplexing. You run in a tight loop, waiting until there is something to read or until one of the sockets is ready to write to. The simplest example of this is much more complicated than the above two, but it really isn't that hard. This is the best bet for MUDs and such. And you can't really make it much better. However, windows doesn't treat sockets like files, and so you run into some interesting problems on windows that just aren't issues on a real operating system. (Like, you can run a select call on stdin, stdout, and stderr.) Code for each of these abounds on the internet. Take a google search. Look through the modules for SocketServer and its children. You will find the modules remarkable readable, even to a newbie. Jonathan From duncan at NOSPAMrcp.co.uk Mon Jan 21 04:24:45 2002 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Mon, 21 Jan 2002 09:24:45 +0000 (UTC) Subject: What does Python fix? References: <101aca4.0201180912.288820ce@posting.google.com> Message-ID: martti at bellsouth.net (JMarttila) wrote in news:101aca4.0201180912.288820ce at posting.google.com: > So I vastly prefer when > someone just puts their response AT THE TOP. I don't have to wade > through vast amounts of quoted text which I ALREADY READ. The newsreader I use has a command to skip over all the quoted text and put the cursor on the first non-quoted line. No wading required. Although it is better when people snip the quotes. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From skip at pobox.com Tue Jan 8 12:27:08 2002 From: skip at pobox.com (Skip Montanaro) Date: Tue, 8 Jan 2002 11:27:08 -0600 Subject: large arrays in python (scientific) In-Reply-To: <3rF_7.363276$5A3.137981998@news1.rdc2.pa.home.com> References: <3rF_7.363276$5A3.137981998@news1.rdc2.pa.home.com> Message-ID: <15419.11244.9649.364576@beluga.mojam.com> >> I have a data set that contains values for positions in 3D space. >> There are about 2 million data points (128x128x128). Terry> Do you actually have one value for each cell? Or do you just mean Terry> the number of possible cells? Are the values measured (a bit hard Terry> to believe for 2 million)? or generated by a function such as the Terry> one you want to fit? A 128x128x128 data volume of measured data is not that hard to imagine. Ever had a CT or MRI scan? Poke around http://public.kitware.com/VTK/ a bit... Skip From andreyw at mailandnews.com Fri Jan 25 05:00:43 2002 From: andreyw at mailandnews.com (andreyw) Date: 25 Jan 2002 02:00:43 -0800 Subject: "print int" would be nice References: <3C4FC93A.7020201@thomas-guettler.de> Message-ID: <76d5d34e.0201250200.652d9af2@posting.google.com> grante at visi.com (Grant Edwards) wrote in message news:... >The problem with having the compiler "auto-magically" convert >values from one type to another... The problem is not so common. All we need is redefine '+' operation for strings. I read in UserString.py : def __add__(self, other): if isinstance(other, UserString): return self.__class__(self.data + other.data) elif isinstance(other, StringType) or isinstance(other, UnicodeType): return self.__class__(self.data + other) else: return self.__class__(self.data + str(other)) (I did not try to use this.) Andreyw From chris.gonnerman at newcenturycomputers.net Fri Jan 25 11:43:41 2002 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Fri, 25 Jan 2002 10:43:41 -0600 Subject: OT (maybe): Shareable Mail References: <00a201c1a5a2$9c42e800$0101010a@local> Message-ID: <005101c1a5bf$738028c0$0101010a@local> ----- Original Message ----- From: "Justin Sheehy" > "Chris Gonnerman" writes: > > > I have two customers who need to be able to share one email > > address (including local mailboxes) between several LAN- > > connected machines at the same time. This is in support > > of a centralized email address, i.e. sales at customersite.com. > > Any/all employees should be able to list all messages, reply > > to any message, and there should be a record kept of who > > handled any replied-to message. All messages and replies > > must be kept (or be able to be kept) indefinitely as they > > represent business records. > > It sounds like what they really need is an email-capable > issue-tracking system. There are loads of these out there that work > well, some free, some commercial. > > -Justin Any suggestions? From derekt at dstc.qut.edu.au Thu Jan 10 01:43:43 2002 From: derekt at dstc.qut.edu.au (Derek Thomson) Date: Thu, 10 Jan 2002 16:43:43 +1000 Subject: re module - error with non-greedy matches References: <3C3C4FFA.1040104@dstc.qut.edu.au> Message-ID: <3C3D381F.2030907@dstc.qut.edu.au> Hi Paul, Paul Wright wrote: > In article <3C3C4FFA.1040104 at dstc.qut.edu.au>, > Derek Thomson wrote: > >>I'm having some trouble porting a Perl program to Python. It extracts C >>functions from the source and performs some analysis. >> > > This is peripherally related to your question, but: when I'm doing > analysis of C, I usually connect Python to Exuberent Ctags > via a pipe, rather than trying to parse C with > regexps. No, I wouldn't try parsing C with regexes. The above is pretty much all the parsing needed. > (Actually, I usually get ctags to do the hard stuff and then do > the easy stuff in Python with regexps). I'd recommend this method as a > workaround. ctags -x is a useful option, as it produces nicely > delimited output. I'm sure this works, but I really need to know that Python regexes aren't broken before I can seriously use Python for all my scripting needs. I use it for some things (CORBA, GUIs, Java/C/C++ scripting) but I'd like to try it as a drop-in replacement for Perl. Yes, I realize that some things are done differently in different languages, but the re module documentation clearly states that non-greedy matching is supported, and it's something I do need on the odd occasion. Thanks anyway for the help! Regards, Derek. From phd at phd.pp.ru Thu Jan 3 08:31:38 2002 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 3 Jan 2002 16:31:38 +0300 Subject: Zope external methods and Python: Access to object with a dot in the name In-Reply-To: <3b13b89e.0201030515.4b5635f2@posting.google.com>; from guillaume.sauzon@caramail.com on Thu, Jan 03, 2002 at 05:15:20AM -0800 References: <3b13b89e.0201030515.4b5635f2@posting.google.com> Message-ID: <20020103163138.A21186@phd.pp.ru> On Thu, Jan 03, 2002 at 05:15:20AM -0800, Guillaume SAUZON wrote: > |-images > | > |-hello.jpg > |-other.jpg > > So, if I try to access the hello.jpg image, to get the height, I will > type something like: > size = self.images.hello.jpg.height size = getattr(self, "hello.jpg").height Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From chrishbarker at attbi.com Wed Jan 9 14:29:28 2002 From: chrishbarker at attbi.com (Chris Barker) Date: Wed, 09 Jan 2002 11:29:28 -0800 Subject: extending with C References: Message-ID: <3C3C9A18.FEE6CDB7@attbi.com> Alex Martelli wrote: > Some would choose to use Numpy arrays instead. Yup. I was about to suggest that. > However, Numpy is a > separate (and largish) package, while module array is part of any > Python distribution, so, unless there's something else arrayish that > you need to do, I don't think Numpy is "better" in this context. Alex is right. If all you need to do is pass a 1-d "array" of floats to a C extension, the standard array module would be just fine, and perhaps easier than NumPy. However, it is highly unlikely that you are doing enough with a large enough array of floats that you need a C extension, and NOT doing anything else that would benefit from NumPy. In fact, if you are writing this C extension to get performance (rather than interface with existing code), you may very well not need it you were to use NumPy. It's well worth checking out. http://sourceforge.net/projects/numpy -Chris -- Christopher Barker, Ph.D. ChrisHBarker at attbi.net --- --- --- ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From gcordova at sismex.com Thu Jan 24 10:08:59 2002 From: gcordova at sismex.com (=?iso-8859-1?Q?Gustavo_C=F3rdova_Avila?=) Date: Thu, 24 Jan 2002 09:08:59 -0600 Subject: Self hosting Python? (was: Python is just as good as C++ for real apps) In-Reply-To: <8a12e538.0201232216.558b0a7a@posting.google.com> Message-ID: > > Gustavo C?rdova Avila wrote in message > news:... > > p = Memory.BytePointer() > > dict = { lotsa stuff } > > # Assign to "p" the address in memory of dict. > > p = dict > > That last statement isn't doing what you think it is doing. > An assignment wipes out the history of a variable, so after > the snippet above, p and dict are the same dictionary, both > have type "dict", and the first statement has NO effect on > the current state of p. To create a pointer type, you would > need something like: > > import Memory > D = {"eggs": "spam"} > ptrToD = Memory.AddrOf(D) > Damn! My C++ roots are showing. :P I forgot that you can't redefine "=". But you got the drift :) -gus From boud at rempt.xs4all.nl Sat Jan 19 14:39:42 2002 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 19 Jan 2002 19:39:42 GMT Subject: Help with pysignals with QT References: <3c49bfaf$1@news1.homechoice.co.uk> Message-ID: root wrote: > I have been trying various permutations around this for several days > without success, I dont know if the signal isn't being emitd or if theres > something wrong with my connect statement. Here's a working version. (I've taken the liberty of changing confusing statements like test=test() to test=Test().) from qt import * import sys class Test(QObject): def __init__(self): QObject.__init__(self) def send(self): print "about to emit" self.emit(PYSIGNAL("pySig"),()) print "emit" class Message: def hello(self): print "The slot called" class Join: def __init__(self): print "in join" self.m = Message() self.t = Test() QObject.connect(self.t, PYSIGNAL('pySig'), self.m.hello) print "connected" j = Join() j.t.send() First, you don't need the QApplication object. QObject.connect is a static in C++, and a class method in Python, so you call it directly. Secondly, you initially didn't call send() on the right object. I take it you know already about the book at http://www.opendocs.org? It should have been printed now, and I expect to be very busy setting up the web forum with downloads of updated code, errata and so on. -- Boudewijn Rempt | http://www.valdyas.org From rony.steelandt at bucodi.com Fri Jan 18 09:20:31 2002 From: rony.steelandt at bucodi.com (Rony) Date: 18 Jan 2002 06:20:31 -0800 Subject: Windows - use modem from python? References: Message-ID: Search for serial in the FAQ: http://grail.cnri.reston.va.us/cgi-bin/faqw.py Question 4.68 points to the siomodule and Python-DX; the first seems most relevant: http://www.python.org/ftp/python/contrib/System/siomodule.README "Craig H. Anderson" wrote in message news:... > Greetings, > > I've got a project coming up that will use a modem to call > a bulletin board system. The client wants to automate a time > consuming data entry task. How should I access the modem? > Years ago I would open COM1 from a C program and read/write > ATDT/status directly. Is there an easy Windows 98 interface to > modems? I've started looking at TAPI docs and it is just > confusing me so far. > > Thanks > Craigha at attbi.com From rowland at webperformanceinc.com Tue Jan 15 16:57:43 2002 From: rowland at webperformanceinc.com (Rowland Smith) Date: Tue, 15 Jan 2002 21:57:43 GMT Subject: How to access a module's namespace within the module at import Message-ID: <3C44A60B.5050800@webperformanceinc.com> I have a module that has a number of classes defined. In the module initialization code I want to look at the __dict__ of the module and examine the classes that have been defined. Using sys.modules[ 'module_name' ] doesn't work because the module import has not finished when the code that looks at sys.modules runs. The cleanest solution is to examine the module from another module, but due to the current design and recursive imports it gets ugly. Thanks, Rowland From logiplexsoftware at earthlink.net Fri Jan 25 20:33:04 2002 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 25 Jan 2002 17:33:04 -0800 Subject: Python MSVC++ binaries considered evil In-Reply-To: <3C51F4D4.1070709@skippinet.com.au> References: <20020124150036.5efae915.logiplexsoftware@earthlink.net> <3C51F4D4.1070709@skippinet.com.au> Message-ID: <20020125173304.21dc7a69.logiplexsoftware@earthlink.net> On Sat, 26 Jan 2002 00:13:12 GMT Mark Hammond wrote: > Cliff Wells wrote: > > What I was trying to say is that for a Windows user to actually do the > > compilation with a free compiler, it is nowhere near as simple as it is for > > say Linux, where gcc is the standard. Obviously Python itself is very > > portable. I also won't disagree that VC++ may in fact be the best Windows > > compiler (probably for reasons best left to the antitrust courts). > > You are still missing Tim's point. Most professional Windows developers > tend to have MSVC. This means that for most professional Windows > developers it is in many ways *simpler* than Linux - no configure or > install. I don't disagree. In fact I _have_ VC++ (not that I use it much). I'm not arguing that it isn't very simple _if_ you have VC++. But, if you have Python on Windows, you will need to shell out at least $100 if you ever want to compile C modules for Python, or Python itself for that matter. Personally, I would dump VC in 0.1 seconds if the Python source included Makefiles for FreeBCC (or some other free compiler). What I am saying is that for people without VC it is not so simple. If there were no free compilers available for Win32 this would be moot (and not so long ago this was the case, more or less), but it isn't the case today. Besides, I wasn't aware that Python was targeted exclusively at professional programmers. > Python is that way on Windows because people found it not working for > them, and contributed build changes back until it did. This exact thing > has started happening with the free compilers now too, which is excellent. Yes, hopefully this entire discussion will become irrelevant. > However, asking for it to happen wont make it happen. You asked for it > to happen, and Tim told you why the main Python guys are not making it > happen. Again, I didn't ask. If I say "wow, nice car" it doesn't mean I asked you to buy it for me ;-) > ... > > Since I was replying to your post, maybe you misinterpreted my intention, > > but I wasn't suggesting that PythonLabs should be responsible for it. This > > list _is_ "the community" so I was discussing it here. > > Discussions don't make it happen either ;-) The precedents have been > set, and basic support is already in the code base - it just needs work. I only halfway agree with you. Discussions can be the catalyst for something to happen. If the discussion in this thread hadn't occurred, I can pretty much guarantee that I wouldn't be downloading FreeBCC this weekend to give it a try - it simply wasn't on my mind. > > This is of course the classic problem with the Windows platform: everyone > > uses (or believes everyone else does) Microsoft tools so everyone who > > doesn't want to drop $$$ for them is left out (or at least left looking for > > pre-built binaries). > > Nor complaining... You are correct, and I will stop complaining about MS immediately. Actually... that's a lie. ;-) > > I guess we can hold our breath for the day when MS > > includes a basic C/C++ compiler and libraries with the OS. > > Or, you can hold your breath waiting for the day for someone in the > Python community to make it happen. Why not you? I said I was going to look at it in my last post... can I have a day or two? Besides, that particular remark was aimed at MS, not the Python community. I have an unconscious tendency to take jabs at MS at random intervals, if you haven't noticed. > Microsoft today have the best Windows compiler. It was not that many > years ago when it had the *only* 32-bit Windows compiler. I believe > they have a right to charge money for such a tool, while applauding any > (free or otherwise) competitors that offer a reasonable choice. Hm. I thought Intel had the first 32-bit compiler, but I'm probably wrong. Regardless, my main point is that in order for people to contribute to open-source Python on Win32 there is a cost of entry. This seems likely to reduce the number of potential contributors (besides the other reasons discussed earlier). I know that if I didn't need VC++ at work I wouldn't have it at all, as much for political reasons as cost. This affects not only the Python core, but probably to a greater extent extension writers who hope to gather support for their projects - they post their code on SF or somewhere and Windows users can't help because they know they can't compile it without VC++. A common sentiment among open-source developers is if someone wants a feature added or a bug fixed, the best thing is to try to do it yourself. On Linux (or any platform where gcc actually works) that's entirely reasonable, but expecting people to shell out $$$ to Microsoft in order to be able to help on Windows isn't (IMVHO). > > Still, I think I'll look at it this weekend. > > Excellent - that's the spirit! :-) I should have put that at the _top_ of my post and maybe I could have avoided your earlier suggestions that I'm too lame do it myself. Sheesh! :-P BTW, thanks for your excellent contributions to Python. Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 "Then with your new power you'll accomplish all sorts of cool stuff in no time, and We'll All Be Sorry. At that point you can either gloat a bit, and then relent, or go ahead and send the robot army after us." - Quinn Dunkan From andtherewaswater at yahoo.com Thu Jan 10 02:09:16 2002 From: andtherewaswater at yahoo.com (A.A) Date: Thu, 10 Jan 2002 11:09:16 +0400 Subject: Instructions in book don't work References: Message-ID: <3C3D3E1C.A04214C7@yahoo.com> Dan, The code should be: >>> class Address: # Note the TWO underscores ... def __init__(self, Hs, St, Town, Zip): ... self.Hs_Number = Hs ... self.Street = St ... self.Town = Town ... self.Zip_Code = Zip Regards, A.A. > Dan Hamm wrote: > > This is my very first attempt at using a newsgroup, so please bear > with me. I am totally new to programming, and picked up the book "Lean > to Program Using Python" by Alan Gauld. The problem I am trying to > solve is this: > > On page 51 the author shows demonstration code for setting up a class > - > > >>> class Address: > ... def _init_(self, Hs, St, Town, Zip): > ... self.Hs_Number = Hs > ... self.Street = St > ... self.Town = Town > ... self.Zip_Code = Zip > > Then follows it up with the instructions to type in the following - > > >>> addr = Address(7,"High St.","Anytown","12345") > >>> print addr.Hs_Number, addr.Street > > My problem is when I type the first line of the second set of > instructions (addr = Address(7, ...) I get the following error - > > Traceback (most recent call last): > File "", line 1, in ? > TypeError: this constructor takes no arguments > > I've checked to make sure I copied exactly what was in the book, but > it just doesn't seem to work. Can anyone tell me where I went wrong? From chris.gonnerman at newcenturycomputers.net Tue Jan 29 21:21:30 2002 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Tue, 29 Jan 2002 20:21:30 -0600 Subject: OT again... is there an IMAP expert in the house? Message-ID: <011901c1a934$d8391e20$0101010a@local> "Donn Cave" wrote in message news:... > > You'd have to train the users to avoid reply by SMTP. There might > also be a problem with client seen/unseen expiration, if you want > people to keep seeing that message until it's answered or something. > This is unlikely to work, as the replies will need to be directed back to the original sender via email. Issue tracking software seems to be the best choice right now. Thanks for the information though. From aahz at panix.com Sun Jan 20 09:27:53 2002 From: aahz at panix.com (Aahz Maruch) Date: 20 Jan 2002 06:27:53 -0800 Subject: Why aren't colons optional? References: <3C49FED0.8C0F254E@tds.net> <3C4AAA46.BC5D570E@tds.net> Message-ID: In article <3C4AAA46.BC5D570E at tds.net>, Edward K. Ream wrote: > >Thanks to all who replied. To summarize the responses: This is not a >parser issue; apparently Guido believes colons increase readability. >Also, making trailing colons optional would impact many tools. FYI, I've added FAQ entry 6.32 to address this issue. -- --- Aahz <*> (Copyright 2002 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "I support family values -- Addams family values" --www.nancybuttons.com From skip at pobox.com Fri Jan 11 23:25:47 2002 From: skip at pobox.com (Skip Montanaro) Date: Fri, 11 Jan 2002 22:25:47 -0600 Subject: true = 1 In-Reply-To: References: Message-ID: <15423.47819.981154.762058@12-248-41-177.client.attbi.com> Mark> I don't know whether this has ever been proposed, but how about Mark> built-in "constants" for true and false? Yup. There are even Py_True and Py_False objects available at the C level. For one reason or another (mostly because 1 and 0 work well enough I think), they've never been exposed to the Python programmer. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From fredrik at pythonware.com Tue Jan 1 08:20:11 2002 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 01 Jan 2002 13:20:11 GMT Subject: tkicon (was Re: Icons and Tkinter!....From PRJoshi) References: <1$--$$_----__-$_%$@news.noc.cabal.int> Message-ID: Alex Martelli wrote: > Anybody knows where tkicon sources suitable for current > releases of Python and Tk might hide...? http://effbot.org/downloads/ From tyler.w.wilson at gte.net Fri Jan 4 20:08:11 2002 From: tyler.w.wilson at gte.net (Tyler W. Wilson) Date: Sat, 05 Jan 2002 01:08:11 GMT Subject: Problem with callbacks from C to Python Message-ID: <_lsZ7.1089$q46.118494@dfiatx1-snr1.gtei.net> I am working on an extension in module in C, and there is a place where i need to call back into the interpreter. I have set up the interface like this: object.set_callback(self.method) I get the function pointer okay on the C side, but later, when I try to call it, I crash in Python22.dll (Python.exe). Here is the code on the C side: static PyObject *ds_Media_set_callback(PyObject *self, PyObject *args) { ds_MediaObject *mo = (ds_MediaObject *)self; PyObject *callback=0; if (!PyArg_ParseTuple(args, "O", &callback)) { return 0; } if (!PyCallable_Check(callback)) { return 0; } Py_XINCREF(callback); Py_XDECREF(mo->callback); mo->callback = callback; Py_INCREF(Py_None); return Py_None; } // This is called indirectly from DirectShow, through the window proc, then through the function // down below // static void ds_Media_on_callback(ds_MediaObject *self, long event, long param1, long param2) { switch (event) { case EC_COMPLETE: if (self->callback) { PyObject *arglist = Py_BuildValue("(i)", EC_COMPLETE); PyObject *result = PyEval_CallObject(self->callback, arglist); // <<<<<--- CRASH HERE! Py_XDECREF(result); Py_XDECREF(arglist); } break; default: break; } } I tried the other PyEval functions - PyEval_CallFuntion and PyEval_CallMethod - but they crash too. Any ideas? Additional info? Thanks, Tyler From syring at email.com Thu Jan 10 17:26:19 2002 From: syring at email.com (Karl M. Syring) Date: Thu, 10 Jan 2002 23:26:19 +0100 Subject: Closed-source considered harmful (was: JavaScript considered harmful) References: <3dg05gdclu.fsf_-_@ute.mems-exchange.org> <20020108194311.B9790@phd.pp.ru> <15419.10608.809713.882585@beluga.mojam.com> Message-ID: "Alex Martelli" schrieb > "Karl M. Syring" wrote in message > news:a1kfl6$quf8e$1 at ID-7529.news.dfncis.de... > > "Alex Martelli" schrieb > > > "Karl M. Syring" wrote in message > > > news:a1ibhn$qt4bg$1 at ID-7529.news.dfncis.de... > > > ... > > > > Once upon a time, there was a company that controlled the hardware and > > the > > > > software market. Although some people say that it induced a statsi of > 20 > > > > years, it was finally toppled. > > > > > > Interesting -- WHICH "twenty years" were the "stasis"? Perhaps those > > > which saw the birth and wildfire-like spread of Unix, C, relational > > > database management systems, Pascal, interactive terminals, ... ?-) Well, PDP-7 assembler, a.k.a C is an ab...normality and Algol60 was very similar to Pascal. ITS systems had interactive terminals, remember emacs was born there and made it's way form there to Multics (http://www.multicians.org/mepap.html) and then to Unix systems. > > > > I will not engage in alternative history lines, but I think bad languages > > and bad computer architectures have prevailed for a very long time, even > as > > Ah yes -- no doubt the emergence of VMS from Digital Equipment, Pascal > from Zurich ETH, Unix and C from AT&T, etc, were all due to that "company > that controlled the hardware and the software market". Hmm, VMS is a very endangered species these days and Delphi's creator has defected to the evil empire. Nothing to C. > > people knew better (*). Of course, the bad language problem has got even > > worse. > > Indeed -- today, we're reduced to using Python... oh woe is me! Even in the darkest times, there is a glimmer of reason. Karl M. Syring From phr-n2002a at nightsong.com Mon Jan 14 18:12:42 2002 From: phr-n2002a at nightsong.com (Paul Rubin) Date: 14 Jan 2002 15:12:42 -0800 Subject: Python on Tandy Model 102? References: Message-ID: <7xpu4c1q8l.fsf@ruckus.brouhaha.com> "Tim Peters" writes: > [Dan Hamm] > > I know this is a weird question, but does anyone know if > > someone has ported Python to be able to use it on an old Tandy > > Model 102 laptop? This machine> has a small Basic interpreter, > > and I was just thinking it might be able to handle Python as well. > > [Sean 'Shaleh' Perry] > > would enough python to be usable fit on a tandy? > > Not even in a ballpark in the same galaxy. The Model 102 had 24KB RAM, > expandable to a whopping 32KB (I paid about $80.00 for an 8KB upgrade chip > for my Model 100 way back when). I think the model 100 came with 8k, and the 102 was the "improved" version. There's certainly no way to get the current Python implementations to work (the usual meaning of "port") usefully on those machines. However it might be feasible to implement some Python subset from scratch, in a way that could fit, and still have a Python-like programming experience. It would be sort of like running Lisp on a PDP-8, which various people did at different times. You couldn't exactly develop large applications but it could be kind of cool nontheless. From montanaro at tttech.com Wed Jan 23 09:08:37 2002 From: montanaro at tttech.com (montanaro at tttech.com) Date: Wed, 23 Jan 2002 08:08:37 -0600 Subject: Hooks, aspect-oriented programming, and design by contract In-Reply-To: References: Message-ID: <15438.50149.145878.29445@dynamic2.tttech1.ttt> Alex> One simple (maybe even silly) example: I can write a metaclass Alex> that does substantially nothing different from builtin type (the Alex> normal metaclass of all except classic classes) EXCEPT emit a Alex> message upon each instantiation: Alex> import types Alex> class mymeta(type): Alex> def __call__(self, *arg, **kw): Alex> print "Creating instance of", self.__name__ Alex> return type.__call__(self, *arg, **kw) Alex> def makeaclassandafewinstances(): Alex> class justaclass: Alex> def __del__(self): print "destroying an instance" Alex> a = justaclass() Alex> b = justaclass() Alex> __metaclass__ = type Alex> makeaclassandafewinstances() Alex> __metaclass__ = mymeta Alex> makeaclassandafewinstances() Alex, This confuses me a bit. I assumed looking at your code that all that was necessary was that there be an object with the name "__metaclass__" in-scope at class definition time. I was surprised that this slight modification of your example doesn't work: import types class mymeta(type): def __call__(self, *arg, **kw): print "Creating instance of", self.__name__ return type.__call__(self, *arg, **kw) def makeaclassandafewinstances(__metaclass__=type): print "using", __metaclass__ class justaclass: def __del__(self): print "destroying an instance" a = justaclass() b = justaclass() makeaclassandafewinstances(type) makeaclassandafewinstances(mymeta) Running it, I get using destroying an instance destroying an instance using destroying an instance destroying an instance In PEP 253 Guido said: - a class statement can contain a __metaclass__ declaration, specifying the metaclass to be used to create the new class Which lead me to this modification: def makeaclassandafewinstances(meta=type): print "using", meta class justaclass: __metaclass__ = meta def __del__(self): print "destroying an instance" a = justaclass() b = justaclass() which does work. This, however: def makeaclassandafewinstances(__metaclass__=type): print "using", __metaclass__ class justaclass: __metaclass__ = __metaclass__ def __del__(self): print "destroying an instance" a = justaclass() b = justaclass() didn't, yielding a NameError for __metaclass__. Can you explain why your version works (__metaclass__ as a global), while the two versions with __metaclass__ as a local didn't and the version using meta as a local did? Thx, -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From rony.steelandt at bucodi.com Tue Jan 29 11:51:54 2002 From: rony.steelandt at bucodi.com (Rony) Date: 29 Jan 2002 08:51:54 -0800 Subject: Rue the day... References: Message-ID: "Chris Gonnerman" wrote in message news:... > Guys, I know we have the reputation as the nicest bunch of nerds on > the 'Net, but Rue is consuming more of our time and bandwidth than spam. > Despite his comments to the contrary, no one on this list gives him > any credence. Yes it's true that there is a nice bunch here. BUT what keeps me amazing here, is : 1. How you keep defending the Python language over and over again. Don't understand me wrong, Python is a VERY good language and we are using it for years now, like a lot of you. But each time some guy asks here a question like 'Should i use Python of Perl' or 'Python or C for a real world application' evrybody here starts here to defend Python. IMHO this is useless, since allready the question is stupid... The language you want to choose depends on a lot of items and not only wether you have to use brackets of indents to structure code block, or to have to declare variables or not. Even the developmentspeed issues like you see here often depends on a lot of things, we have as an example 2 C goeroes in house that develop at the speed of other python applications, only the applications will be different and THAT is the reason that some application is written in C and others in Python... So if someone asks if he should use Python , the only real answer could be 'Have a look at it, try it and decide... you're a big boy'. 2. How you keep answerring the same questions over and over again. Style 'WIch IDE to use to develop with python' or worse 'Does python have a compiler'. If you think this is just a small part of the question here, take google and do a search on IDE or compiler on this group. But it's true you are a great bunch here . Rony > > Realize that he lives on this BS. His "project" does not exist except > in his fevered brain; VIC seems to be everything and nothing. He's been > "working" on it for something like, what, 10 years, and it is still > no more than a website and some Python code that seems to do nothing. > > It doesn't matter whether your response is kind or cruel, agreeable or > argumentative, it's the *attention* he craves. Just don't talk to him. > Not at all, even if he calls you terrible names. If we ignore him long > enough, he'll eventually go away. > > Chris Gonnerman -- chris.gonnerman at newcenturycomputers.net > http://newcenturycomputers.net From fperez at pizero.colorado.edu Fri Jan 25 13:45:25 2002 From: fperez at pizero.colorado.edu (Fernando =?iso-8859-1?Q?P=E9rez?=) Date: Fri, 25 Jan 2002 11:45:25 -0700 Subject: [ANN] istring interpolated strings release 1.0 References: Message-ID: <3C51A7C5.EC3B8CE1@pizero.colorado.edu> Very nice, I'm a big fan of interpolation in Python like this. Would you care to comment on the differences between your work and the 'classic' (in the sense that it's old and has been hotly discussed here in the past) interpolation class Itpl found at http://web.lfw.org/python/ ? This is what inspired PEP 215 (http://python.sourceforge.net/peps/pep-0215.html) Regards, F. From tdelaney at avaya.com Mon Jan 28 21:58:49 2002 From: tdelaney at avaya.com (Delaney, Timothy) Date: Tue, 29 Jan 2002 13:58:49 +1100 Subject: Autocoding evolves from........ Message-ID: > From: Timothy Rue [mailto:threeseas at earthlink.net] > > On 28-Jan-02 12:28:00 Courageous wrote: > >>Start here: We exist (one item) > > >There is something fundamentally wrong with your ability to > coherently > >present yourself. > > >C// > > There are plenty of people who understand me, so that leave > me to believe > the problem is your inability to comprehend. Takes all kinds > of people to > make the world go round. > > Peoples minds work differently. In particular, it appears that the minds of nearly everyone on c.l.py work very differently from yours. You have managed to confuse some of the clearest-thinking people I have ever involved myself with. This leads me to the question ... "Where do *you* think the problem begins?" I know where I think it begins - and it's not with the posters of c.l.py. Tim Delaney From qmoto at dsl-only.net Sun Jan 27 17:27:43 2002 From: qmoto at dsl-only.net (Paul Fredrickson) Date: Sun, 27 Jan 2002 14:27:43 -0800 Subject: Help understanding how modules are found? Message-ID: I'm upgrading python to 2.2 on windows, and I've had this problem every time I upgrade. After installing python itself (which works great), I try to install the python imaging library, which only installs to c:\py21. I move _imaging.pyd and _imagingtk.pyd to the DLLS dir of my python installation, and the PIL directory to the base dir, and the PIL.pth file. I don't know what that's for, it just contains "PIL" When I do an import Image, it works fine. im = Image.open("filename.gif"), works fine. im.show() craps out saying the _imaging C module is not installed. My question is: where is it looking? I realize Image.open is using the python code in the PIL directory, so it hasn't loaded the C module, but where else would it look if DLLS isn't the correct place? Certainly some of you also run PIL on windows? right? If someone knows how the interpreter looks for modules and could help me out, that would be great. Paul (I've never needed to recompile my interpreter and the PIL before, that doesn't seem necessary) From aahz at panix.com Sun Jan 20 00:55:29 2002 From: aahz at panix.com (Aahz Maruch) Date: 19 Jan 2002 21:55:29 -0800 Subject: need dict to maintain order References: Message-ID: In article , Jason Orendorff wrote: > >In this *particular* case I think it's unambiguously better. >If the directory exists, it's foolish to try to create it again; >if it *doesn't* exist, and you try to create it, and fail >(permission denied; or device failure), then it's foolish to >proceed and start putting files in that directory. Right? One of the stock arguments in favor of try/except in cases like this is that your test/create sequence is not an atomic operation. Therefore you need to wrap os.mkdir() in a try/except *anyway* (not even talking about potential problems such as lack of permissions), so why bother doing the test in the first place? -- --- Aahz <*> (Copyright 2002 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "I support family values -- Addams family values" --www.nancybuttons.com From oren-py-l at hishome.net Tue Jan 29 03:59:32 2002 From: oren-py-l at hishome.net (Oren Tirosh) Date: Tue, 29 Jan 2002 03:59:32 -0500 Subject: eval(repr(x)) == x In-Reply-To: <83aduxhp2m.fsf@panacea.canonical.org> References: <20020127092626.GA61284@hishome.net> <83aduxhp2m.fsf@panacea.canonical.org> Message-ID: <20020129085932.GA21494@hishome.net> On Mon, Jan 28, 2002 at 09:24:17PM -0500, Kragen Sitaker wrote: > Oren Tirosh writes: > > On Sun, Jan 27, 2002 at 08:33:28AM -0500, Fran?ois Pinard wrote: > > > I wonder if `repr' could not be made to produce a string which includes > > > a non-binary pickle of a complex object, combined with a modification to > > > the standard Python reading device understanding the convention, and able > > > to recreate the original from the pickle data in the string. > > > > No need to modify Python for this. It all depends on you and how you write > > your object. Just make sure the entire object state can be reconstructed > > using the arguments to its constructor and write a __repr__ method that > > prints out this constructor call. As long as your objects are purely > > hierarchical it can even work recursively. > > That only works for types you write, eh? It already works for most builtin types (int, str, float, list, tuple, dict). This was a discussion about how to make it work for user-defined type, too. The original post of this thread was about whether it should also work for named objects such as types, classes functions and modules. Oren From aahz at panix.com Wed Jan 23 22:09:17 2002 From: aahz at panix.com (Aahz Maruch) Date: 23 Jan 2002 19:09:17 -0800 Subject: Book Royalties References: <83hepck4f5.fsf@panacea.canonical.org> <3C4F6E7E.B0B29462@optonline.net> Message-ID: In article <3C4F6E7E.B0B29462 at optonline.net>, Frederick H. Bartlett wrote: > >You should construct a test for any prospective editor to ensure actual >knowledge of English. Many copyeditors -- as well as most readers -- no >longer recognize such things as dangling modifiers, the proper use of >the subjunctive, or the distinctions among ensure/assure/insure. I >sometimes worry that even who/whom and me/I are on their way out. *sigh* You would think that a proper assurance of editing capability would ensure that the work need not be insured. But you would be wrong. -- --- Aahz <*> (Copyright 2002 by aahz at pobox.com) Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/ Androgynous poly kinky vanilla queer het Pythonista "I support family values -- Addams family values" --www.nancybuttons.com From eric.brunel at pragmadev.com Wed Jan 30 04:36:44 2002 From: eric.brunel at pragmadev.com (Eric Brunel) Date: Wed, 30 Jan 2002 09:36:44 +0000 Subject: Text to Speech References: <1103_1012320649@news.tin.it> Message-ID: Hi, > I'm a phyton newbie... and I do not know how to start... anyone knowing > where to find a text2speech library or some documented algorithms for > converting a text files in phonems and to pass phonems to my avatar? Take also a look at the MBROLA project pages @ http://festvox.org/mbrola/ Under the link "text to speech", you'll find a lot of text to speech tools for all platforms and OSes that may interest you. HTH - eric - From christophertavares at earthlink.net Sun Jan 13 05:21:38 2002 From: christophertavares at earthlink.net (Chris Tavares) Date: Sun, 13 Jan 2002 10:21:38 GMT Subject: Suggestions for 2002 References: Message-ID: "Raymond Hettinger" wrote in message news:a1qqpd$kvp$1 at bob.news.rcn.net... [... snip ...] > ---------------- > Suggestion #2: Add new built-in functions: xmap, xfilter, and xzip. > For what it's worth, there's already an xmap implementation in C in one of the mxTools packages - I'm not sure which one it ended up in when Marc reorganized. I wrote it quite a while ago (back in the 1.4 timeframe I think). -Chris From mac at die.spammer.die.dgp.toronto.edu Fri Jan 18 23:22:38 2002 From: mac at die.spammer.die.dgp.toronto.edu (Maciej Kalisiak) Date: Sat, 19 Jan 2002 04:22:38 GMT Subject: pdb and filter scripts (stdin conflict) Message-ID: Hello all, Most programs are debugged by doing "import pdb", then "pdb.run('main()')". But what is the accepted practice for debugging 'filter' scripts (i.e., something that takes input on stdin and spits out the result on stdout)? The problem of course is that both the program being debugged as well as the debugger itself take their input from stdin, which means that the input to the program has to be given manually (instead of being able to pipe it in: "program < my_input"). -- Maciej Kalisiak | | http://www.dgp.toronto.edu/~mac [McQ] PGP->finger|www; (0x39AC36F5) 9F BB 9E 11 F0 1E 5D 20 0B 31 3D 37 47 D0 67 C7 GE/CS d- s++:+ a- C++(+++) ULAI++ P+++ L+++ E+++ W++ N- o? K? !w--- O- M- V-- PS PE+ Y+ PGP+ t+ 5 !X-- R+ tv-- b+>++++ DI+ G+ e>+++>++++(*) h--- r+++ y? From usenet at thinkspot.net Sun Jan 20 02:02:45 2002 From: usenet at thinkspot.net (Sheila King) Date: Sat, 19 Jan 2002 23:02:45 -0800 Subject: CGI POST Method... References: Message-ID: On Sat, 19 Jan 2002 22:15:01 -0800, Sheila King wrote in comp.lang.python in article : > Is there a way I can send data to my form, with POST Method, so that I > don't have to create hidden input fields in my form? > > I have a form, with input fields, and of course this data is stored in the > cgi Storage object, but I want to send additional data that cannot be seen > by the visitor to the web page to the form, using Post method. OK, never mind...I found the answer to my question (finally). >From Programming Python, 2nd ed. by Mark Lutz, page 725: """In general, there are a variety of ways to pass or retain state information between CGI script executions: * Hardcoded URL parameters in dynamically generated hyperlinks and embedded in web pages (...) * Hidden form input fields that are attached to form data and embedded in web pages, but not displayed on web pages * HTTP "cookies" that are stored on the client machine and transferred between client and server in HTTP message headers * General server-side data stores that include databases, persistent object shelves, flat files, and so on.""" -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From max at alcyone.com Tue Jan 8 15:31:07 2002 From: max at alcyone.com (Erik Max Francis) Date: Tue, 08 Jan 2002 12:31:07 -0800 Subject: Style question: 'return None' vs 'pass' in do-nothing methods? References: Message-ID: <3C3B570B.6D39780D@alcyone.com> "Elf M. Sternberg" wrote: > I'm using Webware for a project and noticed that in version > 0.6 > Chuck finally included support for cascading style sheets. I had put > my > own support into the project I was working on, and I notice that there > seems to be a stylistic difference between what he did and what I did. > For pages that don't need it (such as redirects), I defined it as: > > def stylesheet(self): > return None > > Whereas Webware used: > > def writeStyleSheet(self): > pass > > Is there a reason for favoring one over the other? Pure style issue. I tend to use an explicit return None if the routine really is a function and its value (None or not) will be used, or pass if it's a producedure whose return value won't be checked. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From aleax at aleax.it Tue Jan 22 03:28:36 2002 From: aleax at aleax.it (Alex Martelli) Date: Tue, 22 Jan 2002 09:28:36 +0100 Subject: new.instancemethod and new style classes References: Message-ID: "Mark McEahern" wrote in message news:mailman.1011683911.18673.python-list at python.org... > The instancemethod of the new module does not work with new style classes: ... > Is this by design? Currently, yes; function new_instancemethod in Modules\newmodule.c deliberately uses the O! (type-checked) style of argument for its third argument, demanding that it be of Py_ClassType. Whether that typecheck is actually _needed_ is less clear to me; new_instancemethod just delegates, after checking args, to PyMethod_New in file Objects\classobject.c, but it appears to me that PyMethod_New can also be called (and is e.g. in Objects\funcobject.c) with a third argument that is a type, not a classic-class. So maybe the type-check in new_instancemethod could be softened without ill effects (but I don't understand it enough to be sure). Alex From oliphant at ee.byu.edu Tue Jan 15 11:41:05 2002 From: oliphant at ee.byu.edu (Travis Oliphant) Date: Tue, 15 Jan 2002 11:41:05 -0500 Subject: large arrays in python (scientific) In-Reply-To: References: Message-ID: > > it'll help me predict memory requirements for constructs. > > Oh, it's terrible. Each float is a heap-allocated object; > then each tuple is another heap-allocated object containing > pointers to the objects it contains. > > I was surprised that SciPy requests the input data in that form. > Numeric does have an efficient array type, after all... > This is Scientific Python not SciPy. They are different. SciPy is "bigger" and requires Numeric to work as most things are done with the more efficiently stored Numeric arrays. -Travis From jason at jorendorff.com Thu Jan 24 04:11:33 2002 From: jason at jorendorff.com (Jason Orendorff) Date: Thu, 24 Jan 2002 03:11:33 -0600 Subject: def __init__(self) --> TypeError: Not a sequence? In-Reply-To: <3c4fcdd1$1_1@nopics.sjc> Message-ID: Ixokai wrote: > I'm confused :) > > Stripped down code w/ Python2.2: > > class _ObjectStore(object): > def __init__(self): > self.blah = basic-initialization-for-everything > > class _SpecificThingyStore(_ObjectStore): > def __init__(self): > super(_SpecificThingStore, self).__init__() > self.blah2 = specific-initialiation-for-everything > > Then, at import, I receive: "TypeError: Not a sequence" at each of the > __init__ lines. I am baffled. :) What am I not understanding here? :) This code won't import because "for" is a keyword. It works for me if I put "basic-initialization-for-everything" and "specific-initialization-for-everything" in quotes. If you could post some actual error messages, it might help. ## Jason Orendorff http://www.jorendorff.com/ From nhodgson at bigpond.net.au Mon Jan 28 19:06:11 2002 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Tue, 29 Jan 2002 00:06:11 GMT Subject: Autocoding >Re: "Introduction to Ethics", References: <321.788T2944T10325794threeseas@earthlink.net> <87it9sn0jc.fsf@becket.becket.net> <6322.789T326T13093628threeseas@earthlink.net> <3296.790T2094T7025580threeseas@earthlink.net> <87r8od3wiy.fsf@piracy.red-bean.com> <83y9ijhcik.fsf@panacea.canonical.org> Message-ID: Kragen Sitaker: > Can you explain what he sees VIC as, please? I really want to know, > but I can't figure it out. VIC appears to be what was called in the 80s a "software bus": systems software that manages the flow of data between processes and provides facilities to control that flow. The term seems to be used mainly for distributed systems now and there are too many poor matches on Google to find a decent reference to show. I've worked on some software bus systems and they are often caused by an architect hyper-generalizing: "OK, we have some tabular cost data, interactive forms, and video feeds that need to be displayed on the user's terminal so how about we publish them all over one mechanism with an integrated query language". Such systems often provide high-paying long-term employment with little real possibility of concrete outcomes. Contractor heaven! Neil From jwbaxter at spamcop.net Tue Jan 29 21:23:32 2002 From: jwbaxter at spamcop.net (John W. Baxter) Date: Tue, 29 Jan 2002 18:23:32 -0800 Subject: OT again... is there an IMAP expert in the house? References: <01f201c1a7b7$34ebb1c0$0101010a@local> <022601c1a7c1$f5367c80$0101010a@local> <2FF2F00E52@kserver.org> <0730AFCEC413B6C2.179E313D52DC8EC5.95825B8852993CFB@lp.airnews.net> <3c55d867$1_5@news.newsgroups.com> Message-ID: <290120021823321945%jwbaxter@spamcop.net> In article <3c55d867$1_5 at news.newsgroups.com>, Brad Clements wrote: > Nope, Imap allows concurrent access. Not sure about POP3. The POP3 server we use prevents concurrent access. It provides for new mail to arrive during a session, but that mail is not available to the user until the next session (the POP3 server doesn't see it during the session). I don't know how much of that is "POP3" and how much is "this POP3 server". --John From aleax at aleax.it Fri Jan 11 09:42:57 2002 From: aleax at aleax.it (Alex Martelli) Date: Fri, 11 Jan 2002 15:42:57 +0100 Subject: An interesting difference between classic and new style objects References: Message-ID: "Oren Tirosh" wrote in message news:mailman.1010695218.16009.python-list at python.org... > Actually, the title of this thread is misleading. I don't mind too much if > there are certain differences between classic and new style objects. The > problem is that Python code and builtin functions don't have the same view > of a new style object. A builtin function sees only the methods the object > had at the time it was instantiated while Python code can see methods that > have been added or modified by assignment. You have a good point here. Either way, this discrepancy cannot be a good thing. Actually, as long as you can mess with the class, it's not strictly true that what rules (for builtin) are "the methods the object had at the time it was instantiated": class Funny(object): def __repr__(self): return "very funny" x = Funny() print repr(x) print x.__repr__() def soandso(): return "somewhat funny" x.__repr__ = soandso def unfunny(self): return "not funny at all" Funny.__repr__ = unfunny print repr(x) print x.__repr__() Rather, it's an issue of methods obtained from the object class versus methods obtained directly from the object, in builtin as opposed to Python-coded functions, in new-style vs classic classes. The above code prints very funny very funny not funny at all somewhat funny while, removing the (object) derivation of class Funny, it would print: very funny very funny somewhat funny somewhat funny Calling x.__repr__() explicitly does work the same way in each case, but repr(x) doesn't. Passing strange. > Is the modification of an object's methods an officially supported language > feature or is this considered messing with internal stuff? Good question. I don't know the answer for sure... it should be the former (as such modifications have always worked), but it's not clear to me any more if it's intended to be that way, or tagged as 'messing with internals'. Maybe we can get this clarified by somebody who's more in-the-know...? Alex From eric at enthought.com Fri Jan 25 15:49:45 2002 From: eric at enthought.com (eric jones) Date: Fri, 25 Jan 2002 20:49:45 GMT Subject: Python Extension Designer / Builder. References: Message-ID: Hey Gustavo, weave has something like this built into it. Instead of using XML, you describe the module layout directly within Python. It currently supports extension functions. classes/types are planned. Type conversions are handled by "type conversion factories" and can be customized to your needs. Everything is done directly in Python. Perhaps there is a benefit to XML over this, but it isn't obvious to me. Here is an example. # simple_ext_example.py def build_module(): import weave # define the module mod = weave.ext_module('example_mod') # declare a function to put in the module a = 1 # this is effectively a type declaration ext_code = """ int val = a+1; return_val = Py::new_reference_to(Py::Int(val)); """ func = weave.ext_function('increment',ext_code,['a']) # add the function to the module mod.add_function(func) # compile it! mod.compile() if __name__ == '__main__': try: # try importing the module import example_mod except ImportError: # if it doesn't exist, build it. build_module() import example_mod print 'result (desired=2):', example_mod.increment(1) And here is the output from running this from the command line: C:\home\ej\wrk\junk\scipy\weave\examples>python simple_ext.py example_mod.cpp Creating library C:\DOCUME~1\eric\LOCALS~1\Temp\python21_intermediate\Release \example_mod.lib and object C:\DOCUME~1\eric\LOCALS~1\Temp\python21_intermediate \Release\example_mod.exp result (desired=2): 2 C:\home\ej\wrk\junk\scipy\weave\examples>python simple_ext.py result (desired=2): 2 see ya, eric From alanmk at hotmail.com Thu Jan 31 06:34:06 2002 From: alanmk at hotmail.com (Alan Kennedy) Date: 31 Jan 2002 03:34:06 -0800 Subject: Idle wait for outstanding threads? References: <4v7g5uccpi2s9inb88uiq1cfdvlq6k5csi@4ax.com> Message-ID: Michael, Thanks for the suggestion. Michael Kelly wrote in message > There is a module called Futures that simplifies manipulating > subtasks using threads. It might not be what you need in this > case but should be a good candidate for your library even so. > It uses the metaphor of waiting for a function result. You > launch your thread then call a method that returns the result. > You can block or not block but the basic idea is that if the > main thread has no other tasks you block on the function > result to wait for thread completion. Indeed, this is the paradigm that I am trying to implement: function calls evaluated in separate threads. BTW, the URL is http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/84317 > If appropriate for your program I guess you would launch > all your tasks and then finish up main thread business, > then block on all the thread method results etc.. However, "Future" is not what I need, as far as I can tell. The recipe provided for Future relates only to a single thread (I think). I launch a function in a separate thread (Future) and then do a blocking wait, which does a non/blocking 'wait' on a threading.Condition var until the function call thread has 'notify'ed on the Condition. But if I want to wait on more than one "Future", it is not possible, because I cannot do a blocking 'wait' on more than one Condition var at a time. Instead I have to do a non-blocking wait on each of the "Future"s separately: I'm back to the busy wait, i.e. a tight while loop that consumes a lot of CPU. Really what I need is a threading equivalent of the "select" call for file descriptors. "select" allows me to block on multiple file descriptors simultaneously, and return when something arrives on any one of them. I need something equivalent for threads, that allows me to block on multiple 'thread.lock's or multiple 'threading.Condition's at the same time. Also, something that had a timeout as well, just like the "select" call, would be ideal. Regards, Alan. From navead at hotmail.com Thu Jan 3 15:07:09 2002 From: navead at hotmail.com (navead) Date: 3 Jan 2002 12:07:09 -0800 Subject: Displaying X11 on Tk Message-ID: Hi, I currently have a program which is written in python using Tk, and also I have a program written in C/C++ which uses X11, what I want to do is in the C program rather than display to X11, I would like to have it display on my Tk winddow... I am thinking I probably have to write a wrapper for the Xlib, so that it calls Tk functions, but this can be a hassle. if anyone knows about any package which may already exist, or maybe another method of getting around this problem, I would greatly appreciate it if you would email me. thanks, Navead From simon at uggs.demon.co.uk Thu Jan 24 19:29:29 2002 From: simon at uggs.demon.co.uk (Simon Foster) Date: Fri, 25 Jan 2002 00:29:29 GMT Subject: sleep? References: <15438.57573.270387.886814@dynamic2.tttech1.ttt> Message-ID: <3c50a676.17101300@news.demon.co.uk> On Thu, 24 Jan 2002 03:51:24 -0600, montanaro at tttech.com wrote: > > Max> could it be taht this isn't possible in win? > >Dunno. You can test the signal.alarm call from the interpreter prompt: > > >>> import signal > >>> signal.alarm(1) > 0 > >After 1 second I get: > > >>> Alarm clock > >and Python exits (because I had no handler set up for SIGALRM). > >I think asyncore works on Windows, so my alarms module should work, though I >only wrote it a few days ago and it hasn't been tried on Windows yet. > >Skip No, there is no 'alarm' method on Windows Python 2.2c1 (#27, Dec 14 2001, 13:15:16) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import signal >>> signal.alarm(1) Traceback (most recent call last): File "", line 1, in ? AttributeError: 'module' object has no attribute 'alarm' >>> dir( signal ) ['NSIG', 'SIGABRT', 'SIGBREAK', 'SIGFPE', 'SIGILL', 'SIGINT', 'SIGSEGV', 'SIGTER M', 'SIG_DFL', 'SIG_IGN', '__doc__', '__name__', 'default_int_handler', 'getsign al', 'signal'] >>> -- Simon Foster Cheltenham England From cliechti at gmx.net Thu Jan 3 10:19:43 2002 From: cliechti at gmx.net (Chris Liechti) Date: 3 Jan 2002 16:19:43 +0100 Subject: Numeric and the new division operator References: Message-ID: [posted and mailed] mjbarber at ascc.artsci.wustl.edu (Michael James Barber) wrote in news:a11rau$h3h at ascc.artsci.wustl.edu: > > I run into a problem when using the new "true division" operator in > conjunction with Numeric. Do others see this too? > > I can't imagine what I could be doing wrong with what is below, but I > hope someone can enlighten me if it is a usage problem. The problem is > only in Numeric, btw - it works fine with floats and integers. > > > Python 2.2 (#124, Dec 22 2001, 17:36:41) [CW CARBON GUSI2 THREADS GC] > on mac > Type "copyright", "credits" or "license" for more information. >>>> from Numeric import arange >>>> x = arange(10) >>>> x > array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) >>>> x / 10 > array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) >>>> x / 10. > array([ 0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]) >>>> # classic division works as expected ... >>>> # now let's try true division ... >>>> from __future__ import division x/10 > Traceback (most recent call last): > File "", line 1, in ? > TypeError: unsupported operand type(s) for /: 'array' and 'int' >>>> x / 10. > Traceback (most recent call last): > File "", line 1, in ? > TypeError: unsupported operand type(s) for /: 'array' and 'float' >>>> # oh, dear from the docs: --------- __div__(self, other) __truediv__(self, other) The division operator (/) is implemented by these methods. The __truediv__() method is used when __future__.division is in effect, otherwise __div__() is used. If only one of these two methods is defined, the object will not support division in the alternate context; TypeError will be raised instead. --------- so i think they have not implemented __truediv__. maybe it would suffuce to say "__truediv__ = __div__" in the Nummeric classes, but i don't know them. -- Chris From chris.gonnerman at newcenturycomputers.net Thu Jan 17 09:01:59 2002 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Thu, 17 Jan 2002 08:01:59 -0600 Subject: os.startfile() References: Message-ID: <001001c19f5f$a0d66840$0101010a@local> Hmm. Could you maybe include a runable example? Like, with arguments listed? Hopefully you aren't calling os.startfile() with no args as the example implies. What kind of file are you starting? ----- Original Message ----- From: "maximilianscherr" > sorry, i'm very new to python. it's just a test script: > > import os > > os.rename(...) > os.startfile() > os.rename(...) > > i thought this would work, but it exits after the startfile call, > probably it's not hard to make, but i don't know how. From ptkwt at shell1.aracnet.com Mon Jan 14 16:09:56 2002 From: ptkwt at shell1.aracnet.com (Phil Tomson) Date: Mon, 14 Jan 2002 21:09:56 GMT Subject: Ruby Impressions References: <9u064uc19eh877c5ov3afodf98rkdov7dq@4ax.com> Message-ID: In article <9u064uc19eh877c5ov3afodf98rkdov7dq at 4ax.com>, Michael Kelly wrote: >On Sun, 13 Jan 2002 23:35:23 -0000, "czrpb" >wrote: > >>This pretty much closed the book on Ruby for me--another language >>which simply wanted to do "cool things" but did/does not care about >>readability. > > >Anyway, I guess with the shrinking market there's a lot >of paranoia about which languages will survive but I >don't think Perl/Python/Ruby people cutting each >other up is going to help much. Quite right, though I'm not sure the language market is indeed shrinking (though I suspect that you were referring to the economy) - There is plenty of room for Perl and Python and Ruby. If you're referring to the shrinking economy - I suspect that that will have little effect on the open source languages, in fact it might be slightly positive for them since the tools are free. >Seems like winning >converts from people new to scripting who venture >into C# because they know C might be more fruitful. >Show them what else is possible.. that type of thing. Or, that non-type of thing (meaning dynamic languages) ;-) Most programmers you talk to have a statically typed view of the world - they have no idea what dynamically typed languages like Ruby or Python can do for them. I recently attended a talk on generic programming which ended up being a talk on C++ templates. Throughout the whole thing I kept thinking that generic programming comes naturally in a dynamic language, you don't have to go through all the contortions that are needed in a compile-time, statically-typed language like C++. OOP in general 'feels' very different in a dynamically typed language vs a statically typed one. Polymorphism, for example, seems much easier to really use to your advantage in a dynamically typed language. But again, most programmers out there have no idea that there are any other languages besides C/C++, Java (or C#) and this heavily influences their worldview. So, Pythonistas and Rubyists should see themselves as being on the same side of this particular argument. Phil From martin at v.loewis.de Sun Jan 13 16:42:57 2002 From: martin at v.loewis.de (Martin v. Loewis) Date: 13 Jan 2002 22:42:57 +0100 Subject: tt = a, b = t References: <5bl34uc7rumgpnbloe4o5cttotuiaj99g0@4ax.com> Message-ID: rihad writes: > tup = 1, 2 > tuptup = a, None = tup > > >>> tup > (1, 2) > >>> a > 1 > >>> tuptup > (1, 2) > > How did 2 manage to propagate to tuptup through None? Besides the issue of assigning to None, please notice that the assignment to tuptup happens *before* the tuple unpacking, see http://www.python.org/doc/current/ref/assignment.html # ... and assigns the single resulting object to each of the target # lists, from left to right. Regards, Martin From marklists at mceahern.com Wed Jan 23 11:48:53 2002 From: marklists at mceahern.com (Mark McEahern) Date: Wed, 23 Jan 2002 08:48:53 -0800 Subject: DateTime bug? In-Reply-To: <3C4E8A5A.D5614DB1@snakefarm.org> Message-ID: Carsten Gaebler wrote: > I'm using Python 2.2 with the eGenix MX extensions 2.0.3. It seems the > DateTime module has a bug: fwiw, this works on cygwin on win2k: $ python Python 2.2 (#1, Dec 31 2001, 15:21:18) [GCC 2.95.3-5 (cygwin special)] on cygwin Type "help", "copyright", "credits" or "license" for more information. >>> import mx.DateTime >>> print mx.DateTime.__version__ 2.0.3 >>> mx.DateTime.ISO.WeekTime(2002, 4, 1) >>> // mark From nick at methodmaker.co.nz Sun Jan 6 04:11:59 2002 From: nick at methodmaker.co.nz (Nicholas) Date: 6 Jan 2002 01:11:59 -0800 Subject: Object versions in Python Message-ID: Come in Python gurus, is there some prefered method for versioning modules, packages and/or classes in Python? - Nick From tim_one at email.msn.com Sun Jan 27 23:04:14 2002 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 27 Jan 2002 23:04:14 -0500 Subject: Autocoding project proposal. In-Reply-To: <1203.792T1153T13844459threeseas@earthlink.net> Message-ID: Uncle Timmy sez: there's been nothing constructive in this thread for some time. Stop feeding it now, or Guido will come to your house at 3:27am (GMT: Guido Mean Time), and make horrible, horrible faces at you. write-a-python-program!-it's-more-fun-and-far-less-scary-ly y'rs - tim From phr-n2002a at nightsong.com Sun Jan 13 02:20:18 2002 From: phr-n2002a at nightsong.com (Paul Rubin) Date: 12 Jan 2002 23:20:18 -0800 Subject: Suggestions for 2002 References: <7xd70e96do.fsf@ruckus.brouhaha.com> Message-ID: <7xr8ouyax9.fsf@ruckus.brouhaha.com> Richard Jones writes: > > Oops, lemme try again. The idea is that a,b=c,d is supposed to > > simulate doing the assignments in parallel. So I'd expect a,b = c,d > > to work as something like (using C-style pointer notation): > > ... having to resort to using a pointer notation merely reinforces > my feeling that you're not thinking about the problem in a very > Pythonesque way. Python doesn't have the pointer/scalar split that > other languages seem so burdened by (hello, C and *blech* > Perl). There's just labels on values. The left hand side of an > assignment operation defines what labels are being applied to the > right hand side of an operation. No pointers, no magic... That a,b=c,d produces such an unexpected result in Python suggests that the Pythonesque way is not always optimal. Note that the Python designers found it worthwhile to add the weak reference module to allow breaking out of the Pythonesque model. I'm not sure if you can do a,b=c,d as I proposed using weak references instead of pointers. From James_Althoff at i2.com Thu Jan 24 16:12:39 2002 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 24 Jan 2002 13:12:39 -0800 Subject: [Jython/Java] Which books, which IDEs, which other tools? Message-ID: [Jonathan Hogg] >Heh. The prototype *was* written completely in Jython. Unfortunately, >a pretty firm requirement was that the final version be written in >Java. > >That's investment banks for you ;-) > >Jonathan But the Jython interpreter *is* 100% pure Java. So your prototype already is *in* Java. Yes, it so happens that your "Java" program processes some files that *look* like Python. But what's the harm in that? Jim From threeseas at earthlink.net Sat Jan 26 15:03:14 2002 From: threeseas at earthlink.net (Timothy Rue) Date: Sat, 26 Jan 2002 20:03:14 GMT Subject: Autocoding project proposal. References: <83bsfkk31e.fsf@panacea.canonical.org> <743.789T1807T13135321threeseas@earthlink.net> <5372.791T2458T1516056threeseas@earthlink.net> Message-ID: <5203.791T524T9503446threeseas@earthlink.net> On 26-Jan-02 08:07:27 Jonathan Hogg wrote: >On 26/1/2002 6:44, in article 5372.791T2458T1516056threeseas at earthlink.net, >"Timothy Rue" wrote: >> One of the things needed in a computer environment is the three primary >> user interfaces of the command line, the graphical user interface and the >> side door port to applications and other functionality. The port that >> allows the user to communicate to the application or functionality in the >> scriptable vocabulary of the given functionality/application. >> >> where the VIC comes in is in handeling the dictionaries of the various >> applications/functionality and acting as a central control point that can >> spawn off instances of itself in order to handel greater levels of >> complexity in a parrallel manner. >[I'm coming into this discussion late, so forgive me if I've missed >something obvious - though everyone else seems to be as confused.] >Is this in anyway related to something like AppleScript? > >This is Apple's attempt to provide a framework where non-programmers can >communicate to different applications and link them together to perform >tasks. The central idea is the concept of a "dictionary" for each >application, and the AppleScript language which presents these dictionaries >to the user. >[Side note: I don't mean to be derogatory with the term "non-programmers". I >just mean people that are more comfortable communicating with natural >language than the highly artificial and low-level computer languages that >programmers typically use.] >> Here is an example of using the VIC in voice/speech controlled... >> >> http://groups.google.com/groups?selm=13506.301T771T10734137%40mindspring.co >> m >For instance, this previous post you refer to discusses telling the computer >to format a floppy (vocally, but I presume the idea includes textually): > "Computer utility format name f u n drive D F 0 go". >This task is achieved in AppleScript by using the dictionary of the Finder >(the file management application on a Mac) to ask it to perform the task: > tell application "Finder" to erase disk "Bob" >[Slightly different since the Mac doesn't identify disks by the drive >they're in.] >In this instance, "erase disk" is not a part of the AppleScript language, >but a part of the interface made available by the Finder. I can write >scripts that ask for something from application A using its dictionary, and >then pass the information to application B for processing using the >dictionary for application B, all within a single script, all using a very >natural English-like grammar (natural if you speak English that is). >I don't really see how this relates to auto-coding though. A programmer >still wrote the application, it's just that Apple encourages programmers to >make available the functionality of their program through the "side door" >you mention so that non-programmers can use it. >Am I getting close? This is an example of the third user interface. This applescript is something of a language itself that can make use of other vocabularies of programs. It's interesting to note that Apple focused on the second user interface, the GUI but dropped the first one, the command line. Today with OSX I believe they may now have all three. Applescript does seem to be somewhat closed system oriented. That is Limited within the language included in it and other applications vocabulary. But then that is to be expected of a scripting language, even with it's flexable natural language like use. The VIC is different in that it is not a scripting language but rather more like a physical mechanical device with gears to shift, cycles to complete and patterns to match in determing what output it will produce given the input it receives. I don't expect anyone to understand anymore. I've pretty much come to the conclusion that I'm not going to get any help with this, no matter what I do. Think about it. IS the idea of applescript or the side door port to applications and other functionality that new? the fact is Programmers have had this sort of interface for a long time in vaious form such as APIs. There can only be one reason why this side door concept hasn't been made more generally available to the typical end user. If you don't let the user do it then you can do it and sell it to the user. It really is that simple! The Amiga computer has long had all three user interfaces. But that doesn't stop the mindset of what amounts to greed. The Arexx port is usually used only thru the use of the Arexx language. Only a smaller number of applications can make use of it without arexx. There really is no excuse to not have made available to the user all three interfaces in a user friendly manner. --- *3 S.E.A.S - Virtual Interaction Configuration (VIC) - VISION OF VISIONS!* *~ ~ ~ Advancing How we Perceive and Use the Tool of Computers!* Timothy Rue What's *DONE* in all we do? *AI PK OI IP OP SF IQ ID KE* Email @ mailto:timrue at mindspring.com >INPUT->(Processing)->OUTPUT>v Web @ http://www.mindspring.com/~timrue/ ^<--------<----9----<--------< From bernhard at intevation.de Fri Jan 4 10:05:08 2002 From: bernhard at intevation.de (Bernhard Reiter) Date: 4 Jan 2002 15:05:08 GMT Subject: PythonWare: Anyone using for real projects? References: Message-ID: [Posted and mailed] Hello David, thanks for your reply to my critic of your article. I understand from your reply that you know about the difference between a program that you might get without paying a licensing fee or one that you get with enough freedom. For me as a developer freedom makes a difference because it effects the long term availability and costs of the technology. Furthermore I can fix timecritical bugs and adapt the software if it comes with enough freedom. We can probably agree that these points are of some interest to the technical reader. My critic relates to that your use of "commercial" vs "free" will not work out the details of what you mean by "free". "free" is used ambiguosly. Furthermode it is not clear that software coming gratis or software having freedom can also be commercial. That means having commercial grade support or quality and being developed by professionals for money. For many readers an attribute like "free" in the contrast of "commercial" will interpreted negatively towards these qualities. You guessed rightfully that I am also interested in the political quality of the software business. Though, the heard of the critic of your article is not a political issue as I tried to explain above. Several authors feed the common misconception about commercial software and its contrast being "Free" or "free" Software. I merely wanted to point his out. Best regards, Bernhard In article , "Dr. David Mertz" writes: > bernhard at intevation.de (Bernhard Reiter) wrote: >> http://www.webreview.com/2001/07_20/developers/index02.shtml >|First: The reviewer makes the mistake to equal "proprietory" >|software with "commercial" software. In fact Free Software can be >|commercial. > > As said reviewer, I have to protest that I make no such mistake. I > wrote exactly what I meant, and used all the words accurately. > > Reiter is, of course, correct that Free Software can be commercial. The > short review doesn't say anything about that one way or the other, > because those issues simply were not topical. In practice--despite > legal technicalities of licenses that certain "enthusiasts" like to > observe--if some software is Free, I'm going to be able to obtain it > without paying money. But it might well be worth paying the money > either because of support that comes with that or out of principled > support for the developers. > > In the above review, I don't mention Free Software at all. I *do* > contrast PythonWorks with the *free* Idle, PythonWin and MacPython. > That's not a comment on the license terms of the latter three; as Reiter > should recognize, the lower case says that you don't pay money for the > latter ones. For Webreview, that's exactly the contrast most readers > are worried about. The site just isn't one that has a lot of interest > in discussing freedom... and I write articles because I get paid money > for doing so (although I subsequently make the articles Free, and > obtainable from my own website). When I write for places where readers > worry about the political principles of licenses, I mention those; when > I don't, I don't. > > Yours, David... -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From pete at shinners.org Sat Jan 5 17:50:06 2002 From: pete at shinners.org (Pete Shinners) Date: Sat, 05 Jan 2002 22:50:06 GMT Subject: Pygame Font Challenge Message-ID: <3C37836C.3070701@shinners.org> last december, the users of pygame had a quick contest to see what they could create for different text-based special effects. different entries were animated or still renders. all the entries are meant to be used in programs of your own choice. making it easy to implement these text renderers into your own game. some of the different entries are: crystal, dropshadow, outline, static take a look at what was created on the pygame fontcontest page, http://www.pygame.org/fontcontest.shtml From aleax at aleax.it Thu Jan 17 09:14:32 2002 From: aleax at aleax.it (Alex Martelli) Date: Thu, 17 Jan 2002 15:14:32 +0100 Subject: Slowness in compile()/eval() References: Message-ID: "Pedro Rodriguez" wrote in message news:pan.2002.01.17.14.19.06.888663.2742 at club-internet.fr... > Hello, > > while investigating on lazy evaluations, I found these strange > results while doing some timings. I expected that using : > d = eval(code) > where > code = compile("i+i", '', 'eval') This uses a GLOBAL variable named 'i'... > should give an execution time of the same magnitude as : > d = f(i) > where > def f(i): return i+i ...while this uses a LOCAL one. > it turns out to be almost 4x slower. > > Investigating with the dis module, I noticed that the result of > compile uses LOAD_NAME where a function uses LOAD_FAST. Is this > due to local namespace lookup ? Right. Local is faster than global, exactly because it can be loaded without a lookup (LOAD_NAME). Change your function to: def f(): return i+i and the time difference should just about go away. > It turns out that using something like (with some tweaks) : > code = compile("def f(i):\n return i*i\n", '', 'exec') > eval(code) > gives the expected computation time. > > I think I must be missing something on evaluation, but what ? I don't think you're necessarily missing anything. Alex From wurmy at earthlink.net Thu Jan 17 01:34:45 2002 From: wurmy at earthlink.net (Hans Nowak) Date: Thu, 17 Jan 2002 06:34:45 GMT Subject: Serious privacy leak in Python for Windows References: <3C44A774.5DFCDE15@computerbytesman.com> <3C45D535.9040006@mxm.dk> <3C45E519.1020104@mxm.dk> <8Rt18.2504$58.2154156@newssrv26.news.prodigy.com> Message-ID: <3C467063.467B996F@earthlink.net> dsavitsk wrote: > > > > "Max m" wrote in message news:3C45D535.9040006 at mxm.dk... > > In fact if VBScript was a sex partner, that I woke with in my arms, it > > would be so ugly that I would chew my arm of to avoid waking it up in > > the morning ;-) > > i find it difficult to believe that any person could be so unattractive that > chewing one's arm off would be less disruptive to their sleep than simply > gently moving one's arm. You haven't worked with VBScript, eh? ;-) --Hans (base64.decodestring('d3VybXlAZWFydGhsaW5rLm5ldA==') # decode for email address ;-) Site:: http://www.awaretek.com/nowak/ From rdeviasse at sympatico.ca Wed Jan 2 21:23:48 2002 From: rdeviasse at sympatico.ca (Robert N. Deviasse) Date: Wed, 2 Jan 2002 21:23:48 -0500 Subject: Mono and Python References: <3dheq44v45.fsf@ute.mems-exchange.org> Message-ID: "Andrew Kuchling" wrote in message news:3dheq44v45.fsf at ute.mems-exchange.org... > Similarly, I think MS would like people to use the CLI/CLR and > therefore entices them with the run-any-language-you-like carrot. But > only C# and VB will run really quickly -- remember, the .net port of > Python ran about 10 times slower than MS's anointed languages, That's a poor example. Take a look at their whitepaper: http://www.activestate.com/Initiatives/NET/Research.html It basically says: Compiler -------- The Python for .NET compiler is written using CPython. It compiles Python source code, and uses the .NET Reflection::Emit library to generate a .NET assembly. The COM Interoperability features of .NET are used to access the Reflection::Emit library. This particular strategy was chosen to minimize the implementation time. ... The primary drawback to this approach is the speed of the compiler. Much of the abstract syntax tree (AST) manipulation code is also written in Python code, and as this is one of the most CPU intensive areas of the compiler, we suffer a significant speed penalty. Further, the use of Reflection::Emit via COM is also causing us some performance problems. Some of these problems are due to the speed of the Python COM bindings, but Reflection::Emit itself and/or the COM interoperability layers are also costing us significant time. They basically chose the extremely slow approach in order to implement it quickly. COM itself is slow, but writing a CPU intensive part of the code in Python sure doesn't help performance. Later on, they say: The Python for .NET runtime defines a .NET interface (IPyType) that captures Python's semantics. The definition of this interface is almost identical to the existing CPython type object, which is the object primarily responsible for object semantics in CPython. ... The Python for .NET runtime also exposes an API for use by the compiler, working almost exclusively with the PyObject structures. The runtime also provides a function for creating a new PyObject at runtime, given nothing but an anonymous .NET object reference. The compiler will frequently generate calls to create these PyObject structures (often storing the result in a variable), and also pass these PyObject structures back into the runtime as needed. This isn't a bad approach, but why did they use non-portable COM to implement this? They should have been able to use PInvoke() to directly access the Python data structures. It would be far more portable and efficient. > because the CLR isn't well-suited to dynamic languages Could you elaborate what you mean? Some usages of types can be inferred, but for the general case, couldn't the following table-driven class take care of the problem? class FunctionDispatchTable { // ... delegate void MemberFunction(object[] arguments); object addFunction(string functionName, MemberFunction memberfunction); object dispatch(string functionName, params object[] arguments); }; > -- and oh sorry, > version 2.0 will probably break all those other languages, and at that > point you'll just give up and write C# and VB code. Could you elaborate? Looking at the template and functional additions to the CLR, I don't see any reason why this would be the case. http://research.microsoft.com/projects/clrgen/ http://research.microsoft.com/projects/ilx/ From knight at baldmt.com Fri Jan 11 09:39:56 2002 From: knight at baldmt.com (Steven Knight) Date: Fri, 11 Jan 2002 08:39:56 -0600 (CST) Subject: ANNOUNCE: SCons 0.03 now available Message-ID: Version 0.03 of SCons has been released and is available for download from the SCons web site: http://www.scons.org/ Or through the download link at the SCons project page at SourceForge: http://sourceforge.net/projects/scons/ RPM and Debian packages and a Win32 installer are all available, in addition to the traditional .tar.gz files. This release contains: -- significant performance improvements -- support for command-line redirection -- building from lex (.l) and yacc (.y) files -- the InstallAs method -- more than a few bug fixes SCons is a software construction tool (build tool, make tool) written in Python. Its design is based on the design which won the Software Carpentry build tool competition in August 2000 (in turn derived from the Perl-based Cons build tool). Distinctive features of SCons include: - configuration files are Python scripts, allowing the full use of a real scripting language to solve build problems - a modular architecture allows the SCons Build Engine to be embedded in other Python software - a global view of all dependencies; no multiple passes to get everything built - the ability to scan files for implicit dependencies (#include files); - improved parallel build (-j) support - use of MD5 signatures to decide if a file has changed - easily extensible through user-defined Builder and Scanner objects An scons-users mailing list has been created for those interested in getting started using SCons. You can subscribe at: http://lists.sourceforge.net/lists/listinfo/scons-users Alternatively, we invite you to subscribe to the low-volume scons-announce mailing list to receive notification when new versions of SCons become available: http://lists.sourceforge.net/lists/listinfo/scons-announce Special thanks to Charles Crain, Steve Leblanc, and Anthony Roach for their contributions to this release. On behalf of the SCons team, --SK From aleax at aleax.it Tue Jan 15 15:29:01 2002 From: aleax at aleax.it (Alex Martelli) Date: Tue, 15 Jan 2002 20:29:01 GMT Subject: Function Overloading Without Typechecking References: Message-ID: Michael Chermside wrote: ... > Well, that's fine, but I have gotten used to having method overloading > in Java and C++. So I like to write things like this: > > def spamThemAll(stuffToSpam): > if type(stuffToSpam) in types.StringTypes: > stuffToSpam = stuffToSpam.split() ... > So what do I do? I can think of a few possibilities: ... > How do those of you who are more experienced with this handle this issue? def spamThemAll(stuffToSpam): # split if splittable try: stuffToSpam = stuffToSpam.split() except AttributeError: pass # etc General approach: decide what it means in context for an object x to "be a string". In this specific context, it seems to mean "have a .split() method", so just try to use that method as you think it should be usable, and use a try/except to handle the possibility that no such method is in fact there. Situations of this kind make up a majority of cases. Another case, rarer but by no means rare, is something like the need to treat a string as 'atomic' (a "scalar") as opposed to lists, tuples, and other "true" sequences (while in Python itself, a string is a sequence). For that need I generally synthesize a simple test: try: mysteryObject+'' except TypeError: try: for x in mysteryObject: break except TypeError: isSequence = 0 else: isSequence = 1 else: isSequence = 0 # string-like object -> non-sequence Similarly, I might 'test for Numeric' by similarly trying a + 0, etc. Rarest, but still interesting (I did hit upon it once or twice) is the case I address in a Cookbook recipe, http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52291 I guess it was a bit silly of me to touch only upon the rarest of cases of "type-checking" needs rather than directly address the typical interesting cases best covered by "easier to get forgiveness than permission" (try/except) rather than "look before you leap" (type testing) -- but I was keen to show that even when it _seems_ type checking is the only alternative, it still _isn't_ (...mostly...). And, the need I cover in the recipe had in fact come up recently for me when I posted it -- sometimes unusual occurrences are closer to our attention just because of their unusual nature. Still, there are plenty of examples of "egfp" and its preferability to "lbyl" in the Cookbook, albeit not as sharp as recipe 52291:-). Alex From mlh at vier.idi.ntnu.no Wed Jan 23 10:05:11 2002 From: mlh at vier.idi.ntnu.no (Magnus Lie Hetland) Date: Wed, 23 Jan 2002 15:05:11 +0000 (UTC) Subject: indexed() generator References: Message-ID: In article , Delaney, Timothy wrote: >A perhaps better method would be: > >def indexed (seq, start=0) > i = start > for obj in seq: > yield i, obj > i += 1 > >(sometimes a non-zero start index is wanted). Perhaps you should add a step while you're at it? And maybe even stop (in case you don't want the entire sequence)? Just keeping some similarity with range()... >Tim Delaney > -- -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.org From ssthapa at classes.cs.uchicago.edu Thu Jan 3 16:58:44 2002 From: ssthapa at classes.cs.uchicago.edu (Suchandra Thapa) Date: Thu, 03 Jan 2002 21:58:44 GMT Subject: ANNOUNCE: ciphon 0.3.5 References: Message-ID: Thomas Heller wrote: > >All I get when ciphon.py starts is: > >Updating servers.xml and packages.xml, please wait > File "C:\Python22\lib\ftplib.py", line 216, in getresp > raise error_perm, resp >ftplib.error_perm: 504 Sorry, that address is excluded for security reasons. > >(BTW: I've updated ciphon 0.3.4 to run on windows, and would like to >port these changes to 0.3.5) That's curious, I think there is some wierd interaction between anonftpd (the server), ftplib , and windows that is causing this. Do you get the same problems with python 2.2 and ciphon 0.3.4? Also, I would like to get a copy of your patches if you think it's ready. -- ---------------------------------------------------------------------------- | Suchandra Thapa | "There are only two kinds of math . s-thapa-11 at NOSPAMalumni.uchicago.edu | books. Those you cannot read beyond | the first sentence, and those you | can not read beyond the first page." | -C.N. Yang ---------------------------------------------------------------------------- From aleax at aleax.it Fri Jan 4 04:41:17 2002 From: aleax at aleax.it (Alex Martelli) Date: Fri, 4 Jan 2002 10:41:17 +0100 Subject: What is the number of the PEP for adding indention to Python? References: Message-ID: "Quentin Crain" wrote in message news:mailman.1010124306.24290.python-list at python.org... ... > Python? If so, is there a document which explains why those design > decisions that relate to the developer as a human were made, along with > citations? If not, why is this always left out, not addressed, ignored? In Python's case, my very personal and unofficial opinion about the last question is that Guido van Rossum is outstanding at making the right design decisions, while rationalizing and explaining why they are right is not his core skill. This is far from an unusual phenomenon. In Renaissance times, the idea that different people have different skills was not mainstream, the theory being that an Architect would be just as good at talking about his designs, as at designing them and supervising the building process. That's the theory. Some specific architects may have almost approached it (Alberti, Palladio). But some of the most outstanding practitioners, even then, were DOERS, *NOT* talkers: for example, Biagio Rossetti's _writings_ about what he was doing, and why, are feeble and fortunately almost non-existent. He clearly knew what he was doing, but the way he "talked" about it was in brick and stone, not pen and paper. One can immerse oneself in the large area of the town of Ferrara that he single-handedly designed, and try to "get" the why's of its excellence directly, or plunge into Bruno Zevi's "Saper vedere la citta`" and take advantage of Zevi's nonpareil skill for rationalization and exposition (...but note that Zevi, one of the greatest _theoreticians_ and _polemists_ in post-war Architecture, didn't design a single building, much less a town, worth of notice in the many obituaries that marked his death two years ago... the ability to think verbally and express the why's and wherefore's, and the ability to actually conceive and effect well-functioning innovation, are NOT really all that correlated, whatever the Renaissance may have thought about that...!-). Alex From rjones at ekit-inc.com Thu Jan 17 19:54:59 2002 From: rjones at ekit-inc.com (Richard Jones) Date: Fri, 18 Jan 2002 11:54:59 +1100 Subject: OT: top-posting vs. inline responses In-Reply-To: References: Message-ID: <200201180055.AAA29095@crown.off.ekorp.com> On Fri, 18 Jan 2002 11:42, Mark McEahern wrote: > Paul Jackson wrote: > > Does someone have a simple explanation of why such > > top posting is bad form? I don't like it either, > > but I am unable to articulate why I don't like it. > > I personally don't mind top-posting. It beats the hell out of someone who > lazily quotes pages upon pages of text and then says at the bottom, "Yeah, > I agree." I think that top-posting makes it much easier to just include reams of irrelevant information. Forcing people to actually respond inline makes them think more about: > o Try to be mindful of your reader's attention span. > o Try to provide just enough context (whether before or after). IMHO :) Richard From pinard at iro.umontreal.ca Mon Jan 28 15:45:57 2002 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 28 Jan 2002 15:45:57 -0500 Subject: Tim said! [Re: Autocoding evolves from........] In-Reply-To: References: <4314.793T504T6883966threeseas@earthlink.net> Message-ID: [Courageous] > There is something fundamentally wrong with your ability to coherently > present yourself. Let me agree with Tim, and suggest that we end this thread, everybody. Do not feed it. Let's keep `python-list' a comfortable place to live. Let's stop. Right now! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From gcordova at sismex.com Wed Jan 23 12:02:28 2002 From: gcordova at sismex.com (=?iso-8859-1?Q?Gustavo_C=F3rdova_Avila?=) Date: Wed, 23 Jan 2002 11:02:28 -0600 Subject: FW: How are exceptions actually implemented in assembly? Message-ID: I accidently sent this directly to Hung Jung. I'm forwarding it to the list. > (1) goto statements: this is how subroutines/functions are > implemented, with pushing and popping of stacks. > > (2) interrupts: actual microprocessor interruptions. You jump to > another address when something "bad" or "urgent" happens. and you could add: (3) cpu exception: jump to a known location upon hitting an unknown instruction, or instruction-prefix ("A-line" programming on atari ST comes to mind). > So, how is C (hence Python) exception handling actually implemented? I > searched the web without hitting answers. My guess is that it is > choice (1), with a call to a sub-block of code having one extra item > in the return stack. If so, is exception handling actually kind of > resource-intensive? (extra codes, extra memory that propagate down the > code block structure?) Or are exceptions implemented in some smart way > that doesn't drain too much resources? Just curious. Hmmm... I'd hazard the following guess: 1. Allocate an exception information block for the program. 2. Define an "exception vector", where to jump upon an exception. 3. Upon entering a try { ... } catch(err) { ... } blocks: 3.1 Allocate a "local" exception information block (which is, "err"). 3.2 Substitute the "exception vector" with the address of the catch(err) { ... } block, storing the old address. 4. Upon encountering an exception, store all relevant information into the exception block and jump to the address pointed to by the exception vector. 5. Check if the exception captured is "compatible" with the exceptions you're trying to catch: 5.1 If not, restore older exception vector and jump there. 5.2 If so, then continue with catch() {...} block. 6. The "final" exception handler (the original one) just kills the program and displays a message. It's kinda simplistic, but I think we can begin from here. I'd do it like this in an assembly language program. Maybe I'd use a CPU exception vector to jump to a known location with a single opcode, it's simplest like that, but that's subject to availability. > (This is related to the Aspect thread... exception handling being > often mentioned as an "aspect", but I have not seen any code example > in Aspect Oriented Programming that actually implements exception > handling as an aspect.) > > thanks, > > Hung Jung I hope this helps. -gus From sdm7g at Virginia.EDU Fri Jan 11 14:35:17 2002 From: sdm7g at Virginia.EDU (Steven Majewski) Date: Fri, 11 Jan 2002 14:35:17 -0500 (EST) Subject: lingusitic history of English [was: Ruby Impressions] In-Reply-To: Message-ID: I caught the tail end of a talk by a linguist on the radio (NPR): he was explaining how isolated languages are the ones with extremely subtle and complicated grammars -- things like 15 or 16 genders for example. Languages in isolation tend toward complication and the languages of primitive tribes are anything but primitive. It is prolonged contact with other language speakers that tends to simplify a language. Think of pidgin-English for an example of what happens. English started out as pidgin-German, and got even more diluted and simplified after the Norman invasion. ( The grammar shrank while the vocabulary grew. ) -- Steve Majewski On Fri, 11 Jan 2002 James_Althoff at i2.com wrote: > > Robin Becker wrote: > >I believe linguistic history of English is that it's a mix of Anglo- > >Saxon and Norman French translated through the great vowel shift into > >what we currently call Modern English. Clearly there are a lot of other > >lumps in the mix but I think the closest modern match is Ost Frisian > >which is closely related to German. > > Not forgetting, of course, the contribution of Old Norse from those living > in the Danelaw -- especially the resultant simplification of grammar due to > the intermingling of Scandinavians with Anglo-Saxons living across the > Danelaw boundary. From chris.gonnerman at newcenturycomputers.net Wed Jan 2 23:11:46 2002 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Wed, 2 Jan 2002 22:11:46 -0600 Subject: Can't download paos and chautauqua References: Message-ID: <00f001c1940c$e9f747a0$0101010a@local> The ftp server mentioned has hardly anything under the users directory. If I had to guess, I'd say Carlos doesn't live there anymore. The software listed is all for Python 1.4... ----- Original Message ----- From: "Tim Reuter" Newsgroups: comp.lang.python To: Sent: Wednesday, January 02, 2002 4:44 PM Subject: Can't download paos and chautauqua > It is not possible to download the sources from Mr. Maltzahns site: > ( http://www.cs.colorado.edu/~carlosm/software.html ) > ftp://ftp.cs.colorado.edu/users/carlosm/paos-1.4.tar.gz > ftp://ftp.cs.colorado.edu/users/carlosm/chautauqua-1.4.tar.gz > If there's anybody out there who can help, please mail me. > > Thanks in advance > Tim > -- > http://mail.python.org/mailman/listinfo/python-list > > From tchur at optushome.com.au Wed Jan 30 16:48:28 2002 From: tchur at optushome.com.au (Tim Churches) Date: Thu, 31 Jan 2002 08:48:28 +1100 Subject: O.T. (slightly) -- anyone successfully using wasp? (python html preprocessor) References: Message-ID: <3C586A2C.FEA38576@optushome.com.au> Moss Hart wrote: > > Hi. As per subject line I'm trying to set up WASP, a python-based html > templating facility which has been referred to on this group from time > to time by its author Robin Parmar.( > http://www.execulink.com/~robin1/wasp/readme.html ) > If anyone's successfully running it, I'm interested in configuration > issues under Apache/linux. The docs focus on a virtual server setup > and I'm using the main server option, plus as mentioned above learning > as I go. > > I'm attempting to set it up on Apache and have had difficulties. The > author seems currently to be incommunicado (to me at least). I've put > a lot of time into it and would like to get it right. I'm trying to > verify whether I've got Apache config problems (O.T.) or perhaps > Python environment problems -- my problem seems to relate to the > python script hanging after importing a specific module that comes > with the system. Had to compile and install 2.1.2 to run it which I > had never done before. It might be too late for you to change horses for this project, but for future projects I would recommend that you take a look at Albatross, by Object Craft - see http://www.object-craft.com.au Dave Cole of Object Craft has announced Albatross on this list previously, but to re-iterate, Albatross is a free, open source Web application toolkit which allows embedding of Python code in HTML but goes far beyond that to provide an architecture which allows you to cleanly separate your application presentation layer from the program logic. It also offers multiple ways of preserving Web application state through various mixin classes. As such, it is very close to Wasp in what it sets out to achieve. It currently comes with 125 pages of detailed documentation (more is on the way), the Object Craft guys are very helpful (there are three of them, so someone is always around to answer questions) and they offer paid support contracts (priced in Australian dollars, so they are remarkably cheap if you are paying with US$ or Euros or Sterling). So far, despite its relatively early version numbering (V0.05 so far) I've found only one minor bug and that was fixed by Object Craft within 12 hours. Also two spelling mistakes in the documentation...tut, tut. Disclaimer: Although I have no financial interest in Object Craft, we have engaged the Object Craft guys on a contract to help us build a rather complex Web application, so I do have an ulterior motive in seeing Albatross taken up and used by others in order to spread future development and support costs. Cheers, Tim C From logiplexsoftware at earthlink.net Thu Jan 31 19:03:13 2002 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Thu, 31 Jan 2002 16:03:13 -0800 Subject: Defending the Python lanuage... In-Reply-To: References: <20020130073810.382$1b@news.newsreader.com> Message-ID: <20020131160313.5b985374.logiplexsoftware@earthlink.net> On Fri, 1 Feb 2002 09:04:42 +1100 Peter Milliken wrote: > I guess that is me then (jaded for life, I mean :-)). I have seen managers > advocating the use of a language purely based upon the fact that they > believed they could hire programmers with the appropriate experience more > easily and programmers advocating the use of a language because it would > look good on their resume. So much of what you say here Cliff, I don't > believe or agree with :-) I am too "jaded" :-). For instance, I have never, > ever seen a language choice based upon technical merit and with a decent > study into what is or isn't available - something that managers would like > to see and something that programmers should do! In over 20 years of > programming I have only ever seen the choice made for one (or more) of the > above decisions i.e. "I can get more programmers for language X than > language Y" or "language X on my resume makes me more employable" - BTW, > both arguments are perfectly valid but hardly take into account the "big > picture". Please, please, please don't rain on my optimism! ;-) Believe me, I've had my share of that type: "we have to run Nyetware on our server because --insert reason that has nothing to do with server function/performance--". I even worked at a site where a perfectly functioning Linux server was replaced with thousands of dollars worth of proprietary software/hardware that didn't provide any additional functionality. Linux just didn't seem "professional" enough for them (this was back in the 1.2 days). > I have even seen managers rejecting a language because they tried it > themselves one afternoon and couldn't get something to compile! The language > was a strongly type checked language i.e. you had to actually sit down and > think and plan before you attempted to dash out some code - that is why he > failed because he wasn't used to thinking about his code before hand :-). While I don't disbelieve you (I know they're out there), I am merely claiming that there are an equal if not greater number of managers who just want to get the job done (in a timely fashion, at the least possible expense) and are willing to rely on the expertise of their engineers to accomplish that. I myself have experienced both ends of the spectrum (and some in between). A manager who thinks he or she can test these tools themselves are fooling themselves. Perhaps Bob from accounting could evaluate debuggers while the manager is testing language features? > How many programmers or managers can at least point to a paper comparing > various languages? Not too many, I'll bet! :-) Yet we should *all* be able > to do it just as a professional piece of knowledge. How many "papers" do you > have in your desk drawers that contain information about benefits/drawbacks > of different languages? (I am using "you" and "your" in the generic sense > here, no personal attack or comment implied :-)). I don't know any > programmers that I have worked with over the last 20+ years who have any > such information ferreted away for when they need it (of course there must > be some, otherwise we wouldn't be having discussions like this and there > wouldn't be newsgroups like comp.software-eng :-)). True, to a certain extent. Probably most do like I do: I see a review (in Python's case I saw it in Linux Journal sometime in the mid-90's) and they decide to evaluate it on a test application. While this may not be the most thorough research, it's probably the most practical, given the time-crunch most of us operate under. The unfortunate truth is that very few individuals can make a real evaluation of a language in a short period. I doubt that these studies amount to much as there is obviously more to a language than the language itself. Even if a language is the best ever and studies show that it increases productivity 2000% (on what? developing quicksort routines?), it's worthless if it can't do X and we need X. For instance, if I were to set out to develop a graphical email client, would Dylan be a good choice? Maybe. What GUI toolkits does it support? On what platforms? Does it have an SMTP library? These would be the sort of question I would be asking, even if I had already decided that Dylan was the greatest language ever and had built a small shrine to it in my bedroom (next to Winona Ryder's, of course... ah wait, that's supposed to be a secret...) > > However, your last statement that managers make _all_ the decisions was an > > unfortunate one. It's better if the technicians make the decisions and > > then managers _approve_ them. This may be splitting hairs, but when it > > comes to deciding on things like what language to develop in, who is going > > to be better informed: the people /using/ that language or someone who is > > more focused on the overall picture? Tool choices are a detail and best > > left to those using the tools. Managers should focus on personnel > > coordination, feature specifications, overall design, etc - the big > > picture. It's when they start trying to specify which > > editor/debugger/compiler will be used that friction occurs. Granted, if > > you have a team and one person wants to do things differently than > everyone > > else, management needs to step in, but if there is a general consensus > > amongst your developers, then you need to listen, or be prepared to look > > for new developers when your existing ones start looking elsewhere for > > employment. If you won't use the technology they prefer, they'll find > > someone who will. > > Agreed (somewhat :-)), a managers job is to "smooth the way", however, they > do have a vested interest in productivity - I think we would all agree to > that one? :-) Absolutely. If that isn't the manager's primary interest then they're in the wrong job. I simply question whether they know enough about the details to really make an informed decision about these relatively low-level things (the customer won't know what editor/language was used to develop the application... unless you put "Python Powered" on it somewhere). > Interesting point here about tools - in my experience ( :-)) programmers > rarely look for the most productive tools, they seem to be very narrow > minded when it comes to tools at the personal level i.e. editors are your > prime example - I have seen many cases of a more efficient (and more > productive) editor being bypassed by programmers because they happend to use > editor X. Then again, whether an editor is productive is usually more a matter of how proficient you are in that editor than any special features the editor has (unless it's notepad.exe we're talking about). I have even walked behind people retyping the same line over and > over again (with appropriate minor variations) and totally ignoring the > cut/paste option of the editor! :-) At the time I believe it was a simple > reflection of boredom, but you can lead a horse to water but you can't make > him drink! :-) I thought I qualified my statements about engineers with the word "competent" :) I question your analogy because anyone that incompetent /must/ drink... heavily. Witness the debate about code reviews - you can dig up piles > of literature and statistics that show code reviews are good for > productlivity but it is a rare programming shop that pays anything but lip > service to it (if they pretend to do them at all!) For those who want to > dispute this one, when was the last time you spent an hour reviewing every > 150 lines of code? :-) Got me there ;) Does staring at a lovely piece of code and patting yourself on the back count as a code review? > For example, who uses an editor with language sensitive features i.e. it > generates code templates for you? Everyone acknowledges that many initial > passes through a compiler (or interpretor) are aborted due to a missing ':' > or ';' - the statistics are there, so why don't we all use an editor that > generates this stuff for us? Not many people (in my experience :-)) use such > a tool, but the productivity benefits are obvious. Usually the problem with these sort of tools is that it takes too much time to set up and use them, and further, I suspect that the benefits are somewhat negated by consistently having to "hit key sequence to generate template, go back and edit template" versus occasionally "make a typo that I have to fix". Then again, I suppose taking the time to become proficient with these tools would probably make a difference, so I won't disagree. > So, I'll remain at one of my earlier statements to this newsgroup :-), the > software industry is not a profession, it is a cottage industry and looks to > remain that way for some considerable time :-). No doubt the terms "engineer" and "science" are stretched to their limits in this field. "Art" seems more appropriate, although I've seen some code that would defy that categorization as well. I seem to recall a study that showed that language skills were a better indicator of an individual's potential to become proficient in programming than mathematics or engineering skills, so perhaps that's not surprising. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 "Then with your new power you'll accomplish all sorts of cool stuff in no time, and We'll All Be Sorry. At that point you can either gloat a bit, and then relent, or go ahead and send the robot army after us." - Quinn Dunkan From fbartlet at wiley.com Thu Jan 3 11:29:43 2002 From: fbartlet at wiley.com (Frederick H. Bartlett) Date: 3 Jan 2002 08:29:43 -0800 Subject: printing from Word using win32com References: <3C2D2007.AD251D51@optonline.net> <3C32AC2E.3030704@skippinet.com.au> Message-ID: Thanks, all, for your help and hints. This function works: def simpleSample(): myWord = Dispatch('Word.Application') myWord.Visible = 0 myDoc = myWord.Documents.Add(MYDIR + '\\sampFile.doc') something = myWord.ActiveDocument.Paragraphs numParas = something.Count i = 1 while i < numParas: i = i + 1 try: print something.Item(i).Range().encode('utf-8') except UnicodeError: print "XXX There was a Unicode Error." myWord.Quit() I think I understand Python objects; I'm sure I don't understand Microsoft objects. *sigh* Why should utf-8 work where latin-1 doesn't? I thought M$ used (sort of) latin 1? (But I guess that's OT for a Python ng.) Fred From infinitystwin.SPAM at IS.BAD.yahoo.com Thu Jan 31 23:16:13 2002 From: infinitystwin.SPAM at IS.BAD.yahoo.com (Greg Krohn) Date: Thu, 31 Jan 2002 22:16:13 -0600 Subject: Python References: <3C59FF86.9B211598@upenn.edu> Message-ID: "your_name" wrote in message news:3C59FF86.9B211598 at upenn.edu... > I'm trying to write a Python script that looks up the current value of > the NASDAQ on 2 different webpages and compares the values. I'm having > some difficulties in figuring out how to grab the index values off of > the websites. The codes i'm familar with are below. any suggestions? > > > import urllib > cnnnasdaq="http://money.cnn.com/markets/nasdaq.html" > cnnpage=urllib.urlopen(cnnnasdaq).read() > > > sandpindex=re.search(r'(S&P 500)(.*?)(\d+\d+)', data, > re.IGNORECASE|re.DOTALL) First off, that's got to be the most descriptive subject line ever. ;) If Emile's re-free code doesn't float your boat, try this: import re, urllib from xml.sax.saxutils import escape def getmarket(symbol): symbol = escape(symbol) pat = re.compile(r'"charttext">%s.*?"chartdata">(\d+(.\d+)*)' % symbol, re.IGNORECASE|re.DOTALL) match = pat.search(urllib.urlopen("http://money.cnn.com/markets/nasdaq.html ").read()) if match: return match.group(1) else: return None print getmarket('s&p 500') greg From ivo at nospamAmaze.nl Thu Jan 31 05:31:29 2002 From: ivo at nospamAmaze.nl (ivo at nospamAmaze.nl) Date: 31 Jan 2002 10:31:29 GMT Subject: Fun with lambda and map References: <3c566a21.22129828@news.t-online.de> Message-ID: Gerson Kurz wrote: : primes = lambda o:map(lambda a:filter(None,(map(lambda i:map(lambda : x:a.__setitem__(x,0),range(2*i,o,i)),range(2,o)),a)[1])[1:],[range(o)])[0] : print primes(20) : fibonacci = lambda x:map(lambda o:(map(lambda c:map(lambda : l:o.__setslice__(l[0],l[1],l[2]),([o[2]+3,o[2]+4,[o[0]]],[0,3,[o[1],reduce(lambda : x,o:x+o,o[:2]),o[2]+1]])),range(x)),o)[1],[[1,1,0]+range(x)])[0][3:] : print fibonacci(20) I implemented some of the pure (?) lambda calculus in python: http://vanderwijk.info/lambda Who needs '+' , 'if' and numbers? :) Ivo -- Drs. I.R. van der Wijk -=- Brouwersgracht 132 Amaze Internet Services V.O.F. 1013 HA Amsterdam -=- Tel: +31-20-4688336 Linux/Web/Zope/SQL Fax: +31-20-4688337 Network Solutions Web: http://www.amaze.nl/ Consultancy Email: ivo at nospamAmaze.nl -=- From peter at engcorp.com Tue Jan 29 01:43:23 2002 From: peter at engcorp.com (Peter Hansen) Date: Tue, 29 Jan 2002 01:43:23 -0500 Subject: beeping noise on windows References: Message-ID: <3C56448B.58833301@engcorp.com> Greg Krohn wrote: > > > back on my Apple II+ i could write the line > > "print Ctrl-G" > > and the computer would beep. Is there a command as simple to make windows > > beep for me? -- from python? > > It works for me. Not in PythonWin, though. Just with the standard Python. > It's ASCII 7, BTW. So "print chr(7)" will work, too. For the record, this is normally interpreted only by the DOS prompt itself, which is where stdout is meaningful. And the regular escape "\a" is an alias for that (ASCII name BEL for obvious reasons). Try "echo ^G" (where you type the keystroke Ctrl-G to get that) at the DOS prompt for the same effect. From uberto at usa.net Fri Jan 4 05:15:27 2002 From: uberto at usa.net (Uberto Barbini) Date: 4 Jan 2002 02:15:27 -0800 Subject: Zope Documentation (was RE: Python Popularity: Questions and Comments) References: <3C2E55A6.D873E301@engcorp.com> Message-ID: > before that). I would now describe an app server as "an operating > system for building web applications," and I think this is > different from what J2EE offers (some libraries to help you build > certain types of web apps). Not all app server are intended for internet and J2EE is not a app server, OracleAS is it. Anyway I can see you point but someone have really used Zope for a PetShop-like project? Have you some link? No paper I've read about Zope discuss it. My own Zope experience doesn't go beyond DHTML but I'd change employer for working in Python instead of Java or Vb. > It might be worth assigning a team member to delve into it for a > few weeks and prototype something. That way you'd have a local > expert to evaluate it rather than relying on marketing hype/unhype. I need some very good reason before they could agree with it. Bye Uberto From MaximilianScherr at T-Online.de Wed Jan 23 14:10:50 2002 From: MaximilianScherr at T-Online.de (maximilianscherr) Date: Wed, 23 Jan 2002 19:10:50 -0000 Subject: sleep? In-Reply-To: Message-ID: i don't quite understand how threading works. could you give me an example? --- In python-list at y..., ivo at n... wrote: > maximilianscherr wrote: > : is there anything like sleep() but which not blocks the script? > : i mean like in 10 minutes start that function > > Use a separate thread that blocks for 10 minutes and then invokes > your method. > > Ivo > > > -- > Drs. I.R. van der Wijk -=- > Brouwersgracht 132 Amaze Internet Services V.O.F. > 1013 HA Amsterdam -=- > Tel: +31-20-4688336 Linux/Web/Zope/SQL > Fax: +31-20-4688337 Network Solutions > Web: http://www.amaze.nl/ Consultancy > Email: ivo at n... -=- > > -- > http://mail.python.org/mailman/listinfo/python-list From phd at phd.pp.ru Wed Jan 16 05:04:33 2002 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 16 Jan 2002 13:04:33 +0300 Subject: what's wrong with this cookie script In-Reply-To: ; from qdlaty@ikom.pl on Wed, Jan 16, 2002 at 09:56:47AM +0000 References: Message-ID: <20020116130433.D31277@phd.pp.ru> On Wed, Jan 16, 2002 at 09:56:47AM +0000, QdlatY wrote: > c["email"]["expires"] = 99999999 > > I tried this on windows apache. Anyway, after i rerun IE, the cookie does > not exists. I think 99999999 is too low. And don't forget to test it with other browsers - Netscape, Mozilla... Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From writeson at earthlink.net Fri Jan 25 08:16:24 2002 From: writeson at earthlink.net (Doug Farrell) Date: 25 Jan 2002 05:16:24 -0800 Subject: wxPython and overloading wxTextCtrl Message-ID: <88bc63c6.0201250516.90b8e91@posting.google.com> Hi all, I'm trying to write a class like this: from wxPython.wx import * class myTextCtrl(wxTextCtrl): def __init__(self, ......) wxTextCtrl.__init__(self, ......) so that I can have my derived class handle the OnSetFocus() event and have the control automatically select and highlight the current text in the control when the user moves to that control. This is the behavior of most, if not all, windows programs. However, I'm having trouble getting the class definition write so it will run without a traceback. In the wxPython source code for controls.py I see that wxTextCtrl is defined as follows: class wxTextCtrl(wxTextCtrlPtr): def __init__(self,*_args,**_kwargs): self.this = apply(controlsc.new_wxTextCtrl,_args,_kwargs) self.thisown = 1 self._setOORInfo(self) And that's it. When I try to define my class like this: class myTextCtrl(wxTextCtrl): def __init__(self, *_args, **_kwargs): wxTextCtrl.__init__(self, *_args, **_kwargs) I get a traceback. Does anyone have any ideas how I should do what I'm attempting to do? Thanks, Doug Farrell From dsh8290 at rit.edu Sat Jan 26 14:25:20 2002 From: dsh8290 at rit.edu (dman) Date: Sat, 26 Jan 2002 14:25:20 -0500 Subject: undesired interraction between property and __setattr__ Message-ID: <20020126192520.GA5614@dman.ddts.net> Hi All, I'm back :-). I'm doing some work with version 2.2 and found that the new property() feature is just what I'm looking for for part of my work. The old __setattr__ is what I want for the rest. However, I found an undesired interraction between the two. This code snippet shows what happens : ~~~~~~~~~~~~~~~~~~~~ class Struct( object ) : pass class C( object ) : def __init__( self ) : self._s = Struct() def getx( self ) : print "getx!" return self._s.the_x def setx( self , value ) : print "setx!" , value self._s.the_x = value x = property( getx , setx ) def __setattr__( self , name , value ) : if name == "_s" : self.__dict__[name] = value else : print name , "=>" , value setattr( self._s , name , value ) o = C() o.x = 1 ~~~~~~~~~~~~~~~~~~~~ The "Struct" class is just a stand-in to make the example shorter. In reality I want to enhance an existing class using composition (hence the __(get|set)attr__ pair, though get isn't shown here). For some of the attributes, however, I want to rename them or add additional functionality. For those, "properties" are the right solution. The problem is that the setx() method is never called. Through googling I found this message by Tim Peters : http://groups.google.com/groups?hl=en&selm=mailman.1002067383.24001.python-list%40python.org that explains how the properties thing actually works. (Thanks Tim. The documentation I was able to find is a bit parse and magical :-)) This led me to the following "solution" : ~~~~~~~~~~~~~~~~~~~~ class Struct( object ) : pass class C( object ) : def __init__( self ) : self._s = Struct() def getx( self ) : print "getx!" return self._s.the_x def setx( self , value ) : print "setx!" , value self._s.the_x = value x = property( getx , setx ) def __setattr__( self , name , value ) : if name == "_s" : self.__dict__[name] = value elif name in self.__class__.__dict__ : self.__dict__[ name ] = self.__class__.__dict__[ name ] self.__dict__[ name ].__set__( self , value ) else : print name , "=>" , value setattr( self._s , name , value ) o = C() o.x = 1 ~~~~~~~~~~~~~~~~~~~~ Notice the extra 'elif' in __setattr__. I haven't tested it thoroughly (what happens if a name is duplicated or something?), but it works in the correct case. Is this the proper/ideal solution, or is there something I'm missing, or is this a bug in python? TIA, -D -- Q: What is the difference betwee open-source and commercial software? A: If you have a problem with commercial software you can call a phone number and they will tell you it might be solved in a future version. For open-source sofware there isn't a phone number to call, but you get the solution within a day. From skip at pobox.com Sat Jan 12 10:13:34 2002 From: skip at pobox.com (Skip Montanaro) Date: Sat, 12 Jan 2002 09:13:34 -0600 Subject: HTTPLib and POST problem with '?' In-Reply-To: <3C4042EB.30208.167FD1B@localhost> References: <3C4042EB.30208.167FD1B@localhost> Message-ID: <15424.21150.57394.74837@12-248-41-177.client.attbi.com> Ladislav> If I use example from Python doc like this Ladislav> #################### Ladislav> import httplib, urllib Ladislav> params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0}) Ladislav> h = httplib.HTTP("www.musi-cal.com:80") Ladislav> h.putrequest("POST", "/cgi-bin/script.cgi") ... Ladislav> ################ Ladislav> it works well but only if the script is like Ladislav> http://www.musi-cal.com/cgi-bin/script.cgi Ladislav> but if the script is like Ladislav> http://www.musi-cal.com/cgi-bin/script.cgi?name=Paul Ladislav> (note a part after ? ) it means that PUTREQUEST should be Ladislav> h.putrequest("POST", "/cgi-bin/script.cgi?name=Paul") Ladislav> but httplib ignores everything after '?' and sends only Ladislav> /cgi-bin/script.cgi Ladislav> again You can change things a couple ways: * If you want to use the POST method, you must always send the parameters using a call to the send() method of the HTTP object. In this case, you had params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0}) ... h.send(params) If you want the parameter to be "name" with a value of "Paul", change the call that sets params to params = urllib.urlencode({'name': 'Paul'}) * Use the GET method instead of the POST method: h = httplib.HTTP("www.musi-cal.com:80") h.putrequest("GET", "/cgi-bin/script.cgi?name=Paul") h.putheader('Accept', 'text/plain') h.putheader('Host', 'www.musi-cal.com') h.endheaders() reply, msg, hdrs = h.getreply() In any case, make sure when you test your code you are communicating with a web server that you know and that actually has the URL you are interested in. As the webmaster of www.musi-cal.com I can tell you with a fair degree of certainty there is no CGI script here named "script.cgi". -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From phd at phd.pp.ru Tue Jan 1 17:49:25 2002 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 2 Jan 2002 01:49:25 +0300 Subject: The (superlow)quality of software (was Re: Python Popularity: Questions and Comments) In-Reply-To: ; from sholden@holdenweb.com on Tue, Jan 01, 2002 at 05:30:39PM -0500 References: Message-ID: <20020102014925.A8298@phd.pp.ru> On Tue, Jan 01, 2002 at 05:30:39PM -0500, Steve Holden wrote: > Look at Unix, look at TCP/IP. Both fundamental technologies in supporting > today's computing environment, both approximating thirty years old, both not > really starting to achieve "market dominance" until they were twenty years > down their development tracks. It simply takes a long time for a technology > to mature to mass usability. Neither UNIX nor TCP/IP are suitable for mass use. They are here by accident, not because they are mature. Just a few points. UNIX is old and outdated; there are many ideas that still does not appear in the UNIX world; UNIX has usability problems; UNIX lacks standard desktop and office suite. TCP/IP is vulnerable to many kinds of attacks; it lacks QoS (bandwidth-on-demand, e.g., or guaranteed connectivity). (I am playing a devil advocate here, of course.) > ... and what do Microsoft have that's twenty years old and worth > keeping? ... The most important thing - the name. (If you follow my posts you know I hate it, because I am afraid of its power. But it's still *the* name). Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From woodsplitter at rocketmail.com Tue Jan 1 00:41:32 2002 From: woodsplitter at rocketmail.com (stalin) Date: 31 Dec 2001 21:41:32 -0800 Subject: Client-side web scripting in Python? References: <8abfe95a.0112311037.35fb4c2@posting.google.com> Message-ID: <7876a8ea.0112312141.72142df@posting.google.com> rolffreimuth at hotmail.com (Rolf) wrote: > I am considering writing a simple application in Python. I am > evaluating the possibility of writing the GUI for the app as a static > HTML page that uses client-side script. I agree with Paul that this is a bad idea if the general Internet user is your target audience, but I suspect you know that. You're probably developing an intranet application or a 'classic desktop application' with a DHTML interface. > Python does not seem to know about the document object which is > accessible from Javascript. It seems necessary to be able to > use that document object in order to modify the contents of the > page. You're absolutely right that it's necessary to access the document object in order to dynamically modify page contents. Javascript establishes various aliases for the purpose of convenience ('document' is actually 'window.document', 'alert' is actually 'window.alert', etc.). If I recall correctly, older version of the Win32 bindings for Python did not establish these shortcuts; the programmer had to refer to objects by their fully qualified names. An easy way to circumvent this is to establish the aliases yourself as global variables at the beginning of the first
Even when I'm doing an IE-specific project, I try to stick to the W3C standard rather using Microsoft-specific methods/properties. E.g.: document.getElementById('coolSiteList') rather than document.all.coolSiteList . This soothes my conscience and makes the code more portable to other browsers if future support for them is desirable. Even so, I wouldn't put anything IE-specific on the Internet; only on intranets or client-side apps with a DHTML interface.
From marklists at mceahern.com Thu Jan 17 17:51:46 2002 From: marklists at mceahern.com (Mark McEahern) Date: Thu, 17 Jan 2002 14:51:46 -0800 Subject: Python 2.2, creating new types from base types In-Reply-To: Message-ID: This is somewhat of an orthogonal suggestion, but have you considered writing a series of unit tests that verify the functionality/usage you're looking for? In other words, assume your class already existed. What would usage of it look like and what results would it produce? That's something you can (imho, should) codify into a unit test before you even begin implementation. Cheers, // mark From jknapka at earthlink.net Thu Jan 17 16:43:20 2002 From: jknapka at earthlink.net (Joseph A Knapka) Date: Thu, 17 Jan 2002 21:43:20 GMT Subject: What does Python fix? References: Message-ID: <3C46EDB5.9716A897@earthlink.net> Fran?ois Pinard wrote: > > [Mark McEahern] > > > As for Lisp's parentheses, I've never used Lisp, but when I look at > > examples, I have to control my overwhelming desire to vomit when I see that > > profusion of parentheses. > > Of course, whoever reads LISP code (and I still like LISP, even if I prefer > Python) looks at the indentation to understand it, not the parentheses. Yes. Lisp is conceptually beautiful, much more so than any other languages I've used (though Forth and Prolog come close:-), but the parens are just unbearable. McCarthy, it seems, actually wanted Lisp to have syntax; I wonder what that would have looked like? Someone should write a Lisp system that uses indentation a la Python instead of parens. That would rock. Especially if it compiled to Python bytecode and could use the entire Python library. Hmm.... I guess the result might be called "Python." Cheers, -- Joe "I should like to close this book by sticking out any part of my neck which is not yet exposed, and making a few predictions about how the problem of quantum gravity will in the end be solved." --- Physicist Lee Smolin, "Three Roads to Quantum Gravity" From sholden at holdenweb.com Wed Jan 2 06:43:51 2002 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 2 Jan 2002 06:43:51 -0500 Subject: O'Reilly book production (was Re: Wine applicability) References: Message-ID: "A. Keyton Weissinger" wrote in message news:mailman.1009568013.22371.python-list at python.org... > I've written two books for O'Reilly, one of which has two editions out. The > Word template works very well for me. Now FrameMaker, their production > application sucks, but fortunately you rarely have to deal with that. > Gasp! FrameMaker sucks??!!?? It's a while since I used it, but I used to know it well -- I was the first UK reseller for the package, and sold it to many corporates for their long document requirements. When I think of the trouble Word has given me over the years I simply don't understand how anyone writing a book could prefer Word to FrameMaker. This after just having written a book with Word, and having watched it go through the production processes. Shudder. one-man's-meat-ly y'rs - steve -- http://www.holdenweb.com/ From chironsw at swbell.net Fri Jan 11 10:08:40 2002 From: chironsw at swbell.net (Greg Goodman) Date: Fri, 11 Jan 2002 15:08:40 GMT Subject: A change to a class attribute does not propagate - bug or feature? References: <84b16e14.0201092325.242c10df@posting.google.com> Message-ID: <3C3EFE65.B4DC6E34@swbell.net> The default value of the Name parameter gets evaluated exactly once, the first time the newClass.__init__() code is executed. Ever afterward, the default Name is what it is, regardless of subsequent changes to baseClass.ClassId. > class newClass(baseClass): > def __init__(self, Name = "newClass" + str(baseClass.ClassId)): > baseClass.__init__(self, Name)class newClass(baseClass): If you want the default defaut newClass Name to be dependent on the _current_ baseClass.ClassId, try this: class newClass(baseClass): def __init__(self, Name = None): if not Name: Name = "newClass" + str(baseClass.ClassId) baseClass.__init__(self, Name) Hope this helps, Greg From caw at cs.mu.oz.au Mon Jan 14 06:30:24 2002 From: caw at cs.mu.oz.au (Chris Wright) Date: Mon, 14 Jan 2002 22:30:24 +1100 Subject: Converting "normal" functions into generators Message-ID: <3C42C150.CCF66201@cs.mu.oz.au> I'd like to be able to convert any arbitary function into a generator, "yield"-ing some constant after each statement. for the simple case: def easy(x): y = x / 2 z = y / 3 + 5 if y > 10: return y else: return x would turn into: def easy(x): y = x / 2 yield AConstantValue z = y / 3 + 5 yield AConstantValue if y > 10: return y else: return x A simple regexp substitution might be difficult: eg: def plain(x): d = { 1 : "one", 2 : "two" } y = x + \ 1 could be tricky I want to do this so that I can have a collection of functions and call them one at a time, and have them execute one statement at a time. Threads don't give me the control I need. Is there a sensible way to do this? (I've read the library references regarding the modules that let me play with the AST of a piece of python code...and I was hoping for a more simple solution!) cheers and thanks Chris Wright From phr-n2002a at nightsong.com Wed Jan 23 21:08:19 2002 From: phr-n2002a at nightsong.com (Paul Rubin) Date: 23 Jan 2002 18:08:19 -0800 Subject: Book Royalties References: <83hepck4f5.fsf@panacea.canonical.org> Message-ID: <7x7kq8lcvg.fsf@ruckus.brouhaha.com> Kragen Sitaker writes: > I have a question. How can a self-publisher find a decent editor and > indexer? Those are fairly specialized skills, and the editors and > indexers used by most of the books I've liked in the past are > employees of book publishers, so I don't expect that they are > available for freelance work --- right? I don't know about indexing but there's bazillions of freelance editors out there hungry for work. From dsh8290 at rit.edu Tue Jan 29 17:29:47 2002 From: dsh8290 at rit.edu (dman) Date: Tue, 29 Jan 2002 17:29:47 -0500 Subject: Rue the day... In-Reply-To: References: <20020129100947.7821b096.logiplexsoftware@earthlink.net> Message-ID: <20020129222947.GA8598@dman.ddts.net> On Tue, Jan 29, 2002 at 09:22:28PM +0000, Donn Cave wrote: | Quoth Steve Arnold : | ... | | In a sense, a language is just another tool (albeit, a rather | | important one) and you should generally choose the right tool for | | the right job. The practical answer to this is dependent on both | | the tools the programmer is familiar with, and the project | | requirements. | ... | | However, I have seen too many projects (most of them in the millions | | of $'s range) have trouble because of a poor choice in languages and | | tools (and lack of SE knowledge, no process, etc, etc). This | | happens mostly because some management dweeb only hears industry | | hype and propaganda (can you say Java?), and many programmers seem | | actually afraid of learning another language. IMHO, a competent | | programmer (and any software engineer) should not care if he/she | | already knows a particular language or not. They should be good at | | what they do regardless. | | Note an apparent contradiction at the first clip point and the second. | At first, which tools the programmer is familiar with does matter, then | later he or she shouldn't care. Which is it? Both. First, if you aren't familiar with a tool it will be difficult to use it (at first, anyways). Though when you know several tools, exactly which tool is used is less important. -D -- If we claim to be without sin, we deceive ourselves and the truth is not in us. I John 1:8 From czl at iname.com Sat Jan 26 05:07:05 2002 From: czl at iname.com (charles) Date: 26 Jan 2002 02:07:05 -0800 Subject: jython - how to call command.com? Message-ID: <7e1335c.0201260207.47ac2faf@posting.google.com> I'm using Jython on Windows. How can I execute from it a DOS command line, wait till it finishes and return? Can't find that in FAQ nor in docs. From paul1brian at yahoo.com Wed Jan 9 05:31:12 2002 From: paul1brian at yahoo.com (Paul Brian) Date: Wed, 9 Jan 2002 10:31:12 -0000 Subject: Line continuation for a string > 79 characters Message-ID: <1010572270.23636.0.nnrp-08.c1c3e1d9@news.demon.co.uk> Dear all, probably a foolish question, but how do I break up a string that has more than 79 characters so it looks pretty / adheres to style guides? eg filename = '\\myroot\\somefolder...arbitrarty path...\\yetanotherfolder\\foo.txt' I can do this filename = '\\myroot\\somefolder\\someotherfolder\ \\anotherfolder\\stillanotherfolder\ \\yetanotherfolder\\foo.txt' but it just confuses me is there a better way or do I just stay confused and get over it? cheers P Brian From sholden at holdenweb.com Tue Jan 22 10:41:12 2002 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 22 Jan 2002 10:41:12 -0500 Subject: Redhat and Python 2.x.x References: <20020120.140037.937370163.2885@attbi.com> <3C4B5C7A.F9D0483B@engcorp.com> Message-ID: "Gordon McMillan" wrote in message news:Xns919E62109CF6Bgmcmhypernetcom at 199.171.54.213... > Steve Holden wrote: > > > It would be useful to define some sort of "shared" area into which > > modules/packages acceptable to several different distributions could be > > installed once. However, extending this to mutliple versions would get > > confusing: a directory for 1.5.2 and 2.0 packages, a directory for 2.0, > > 2.1 and 2.2 packages, etc. > > While the source might be the same, the .pycs aren't, so somebody > would suffer greatly. > Indeed, I wasn't thinking about writing .pyc's. However, this optimization gains so much it would clearly not be an effective solution to deny the interpreter that possibility (though this often happens on web servers, for example, particularly during development). To avoid a loss of efficiency I guess the compiled files would need to be written into a different directory from the source, which would be picked up from the PYTHONPATH before the source directory. This would also need to be version-dependent so the different versions didn't conflict. Hmm, this is getting a bit too much like hackery. Oh, well. regards Steve -- Consulting, training, speaking: http://www.holdenweb.com/ Python Web Programming: http://pydish.holdenweb.com/pwp/ From loewis at informatik.hu-berlin.de Sun Jan 6 11:24:08 2002 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 06 Jan 2002 17:24:08 +0100 Subject: Win32com and Unicode References: Message-ID: Gerhard =?iso-8859-15?Q?H=E4ring?= writes: > I think you could set the default encoding scheme in your > sitecustomize.py like I described here: > > http://www.faqts.com/knowledge_base/view.phtml/aid/11712/fid/562 While this would solve the problem, I'd advise against that approach. Changing site.py is that every user needs to do individually, and it becomes impossible to test an application reliably if your users might all have set the default encoding to a different value. > Or you can convert manually to ISO-8859-1 using the .encode() method of > the string class. That is much better (although "mbcs" and "cp1252" are probably much alternatives on Windows, for European use). Explicit is better than implicit. Regards, Martin From sholden at holdenweb.com Wed Jan 16 07:37:25 2002 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 16 Jan 2002 07:37:25 -0500 Subject: IID and CLSCTX_INPROC_SERVER References: <3C44F7C8.8010803@skippinet.com.au> Message-ID: "Mark Hammond" wrote ... > Steve Holden wrote: > > > At present I'm using a COM object declared as an in-proc server. This > > appears to have the disadvantage that the IIS (4) process caches the > > object's class definition, so when I change the code there appears to be > > nothing I can do short of rebooting NT to force IIS to recognize the new > > definition. > > > This is not really IIS's fault, but the way Python handles modules. A > Python COM object is loaded from a standard Python module. So, what > win32com does is, basically: > > import yourmodule > klass = yourmodule.YourClass() > > The problem is that this is all done in the same runtime, so the import > statement will be cached for 2nd and subsequent imports. Even if IIS > attempts to unload the Python DLL, Python COM refuses and does not > unload (mainly due to perf issues). > > > Can someone tell me a) whether it's possible to re-initialise with a new > > object definition without rebooting, and/or b) whether this situation will > > be alleviated if I move to using CLSCTX_LOCAL_SERVER? > > > > I'm not really quite clear enough on the details of COM object registration, > > creating and destruction to see my way through the woods here. > > > It should be possible to have your ASP code explicitly reload() the > module. Eg, you could simply execute some ASP code that does: > > import yourmodule > reload(yourmodule) > # create the COM object used > > Alternatively, consider using the "Python.Interpreter" COM object to > explicitly import and reload the module. > More things to try: thanks, Mark. regards Steve -- http://www.holdenweb.com/ From chris.gonnerman at newcenturycomputers.net Sun Jan 27 20:06:17 2002 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Sun, 27 Jan 2002 19:06:17 -0600 Subject: OT (maybe): Shareable Mail References: <200201272341.g0RNfNC26675@mbuna.arbhome.com.au> Message-ID: <015201c1a797$ff0b1060$0101010a@local> ----- Original Message ----- From: "Anthony Baxter" > >>> "Chris Gonnerman" wrote > > Neither Roundup nor rt support Windoze as a server platform. > > While I am constitutionally against the chewing-gum-and-baling- > > wire method of OS design, for my smaller customer it is the > > best value proposition... (dang it hurts to have to say that...) > > Are you sure roundup doesn't work with Windows? I'm pretty sure it does... I just finished reading the docs, and I see that it does. However, as I understand it, inbound emails need [issue] at the start of the subject to get processed. What happens to those that don't? From tim_one at email.msn.com Sun Jan 27 23:12:53 2002 From: tim_one at email.msn.com (Tim Peters) Date: Sun, 27 Jan 2002 23:12:53 -0500 Subject: Python MSVC++ binaries considered evil In-Reply-To: Message-ID: [Tim Roberts] > ... > Microsoft introduced a new style of import library in Visual C++ 6.0, > and the Win32 Pythons ship with the new style import libraries. The new > style is SIGNIFICANTLY smaller than the old style import libraries, but > they are not downward compatible: they cannot be used with Borland C++, > nor even with Visual C++ 5.0. > > So, it's not the .DLLs that are broken, but rather the .LIBs that get you > there. Many VC5 users reported that the VC6-compiled Python distributions worked fine with their VC5 compiles after they installed the last service pack for VC5 (I believe that was SP3). The only hint about that I ever found on MS's website was a short and vague statement about "binary compatibility issues" fixed in the last SP. From johnroth at ameritech.net Fri Jan 25 14:26:27 2002 From: johnroth at ameritech.net (John Roth) Date: Fri, 25 Jan 2002 11:26:27 -0800 Subject: Calendars and recurring events References: Message-ID: "Dave Swegen" wrote in message news:mailman.1011954759.15321.python-list at python.org... > I'm about to write a calendar, which I hope will eventually support > events. Now I know how I'm going to go about most of the task, but the > one aspect that has me stumped is recurring events. > > I'd like the user to be able to specify "repeat once a year", "repeat > until ddmmyyyy", "repeat every two weeks", "repeat first Monday of the > month" etc etc. > > The only way I can think of doing it is by having an Event class, which > contains the details of the recurrence. As Events are created they are > placed into a list (or possibly a dbm keyed using a unique Event id). > > My problem is that any time I want a view of events (say a one month > view), the program is going to have to traverse the whole list, and ask > if that event is due to be repeated for every day in that view. For one > month that would be ~30 traversals of the list, which seems disgusting in > its innefficiency. It might be possible to mitigate it somewhat by > cacheing results into a second hash (using the date as the key), but > that only seems like a small improvement. That's the hard way of doing it. The last time I did something like that (setting up the projected schedule in a mainframe shop) the program did the entire month for one job, then the entire month for the next, and so forth. The iterator idea proposed sounds real nice for that. You just call the iterator for the beginning date you want, and then kill it when it generates a date after your ending. This way, you only process each event once. One thing to watch out for: if you allow real complex things, like "third work day after the last Friday of the month," you may have to process the previous and next month in order to get everything. John Roth From starx at pacbell.net Tue Jan 22 04:36:00 2002 From: starx at pacbell.net (Philip Swartzleonard) Date: 22 Jan 2002 09:36:00 GMT Subject: why is os.getcwd() printing the path in all caps on win2k? References: <6bd9f01b.0201212244.122cae13@posting.google.com> Message-ID: sameer || Mon 21 Jan 2002 10:44:38p: > can anyone tell me why os.getcwd() prints out the path in all caps on > win2k at least? e.g. > > > ActivePython 2.1.1, build 212 (ActiveState) > Python 2.1.1 (#20, Jul 26 2001, 11:38:51) [MSC 32 bit (Intel)] on > win32 > Type "copyright", "credits" or "license" for more information. >>>> import os, shutil os.getcwd() 'C:\\PROGRAMS\\PYTHON\\LJ' Maybe because the path really IS all uppercase, and windows is hiding it from you in other cases? In 98, from exploerer window, menu view, item folder 'options', tab 'view', set 'files and folders', option 'allow all uppercase names'. You have to enable this and disable 'hide file exentions for known types' to prevent windows from hiding anything from you. (Well, it always hides .lnk and .pif extentions i think). -- Philip Sw "Starweaver" [rasx] :: From alank at NOSPAM.com Mon Jan 21 18:58:38 2002 From: alank at NOSPAM.com (Alan Klietz) Date: Mon, 21 Jan 2002 17:58:38 -0600 Subject: PEP proposal for user.py (win32 part) References: Message-ID: This is wrong. The Personal folder (CSIDL_PERSONAL) and the HOMEPATH are two entirely distinct concepts on Windows. On NT the Personal folder by default is kept with the *roaming* user profile data, i.e., stuff that should move from computer to computer as you move around the domain. The default value under NT is %USERPROFILE%\Personal, e.g., C:\WINNT\Profiles\alan\Personal. It is entirely distinct from HOMEDRIVE/HOMESHARE/HOMEPATH. The latter is for documents that should stay on the file server. HOMEDRIVE/HOMESHARE/HOMEPATH come from the the password database (the SAM). They are set with the "Home Folder" property in User Manager (on W2K MSC under "Users and Groups"). Unfortunately the default is pretty stupid, HOMEDRIVE=C: and HOMEPATH=\. When HOMEPATH is set to something else you can assume the systadmin pointed it to a real home folder (*not* the Personal folder). Unfortunately a lot of people confuse Personal and HOMEx. The Internet Explorer development made the infamous mistake of storing cached web pages under the former, so every time you roamed to another computer you had to wait for 200MB of cached web pages to be copied over to your new location. On W2K the default Personal folder changed to "%USERPROFILE%\My Documents", where %USERPROFILE% is now "C:\Documents and Settings\Alan". But the stupid default for HOMEDRIVE/HOMEPATH didn't change. The Personal folder doesn't roam on Win98 (but not Win95) so the confusion isn't as harmful. (Neither one exists on Win95). -Alan P.S. You should never dig into the registry for the Personal folder. It varies depending on Terminal Server and I think some XP weirdness. You have to use SHGetSpecialFolderLocation(CSIDL_PERSONAL), available on all versions of Windows except Win95 w/o MSIE. And I assume you meant HKEY_CURRENT_USER, not HKEY_LOCAL_MACHINE. The latter returns the Personal folder only for Administrator. "Gillou" wrote in message news:a2hglj$v6b$1 at norfair.nerim.net... > Hi community, > > The actual detection for the ".pythonrc.py" file does not work with Windows > 95/98 and perhaps others (ME ?) because the environment variables HOMEPATH > and HOMEDRIVE are unset by default. > Im my Win2K box, HOMEPATH is '\' and HOMEDRIVE is 'C:'. Combination of both > don't give the user "HOME" directory for Windows. > > This replacement proposal will find the personal user folder (typically > "...\My Documents") in the Windows registry. > > Replace the code beween... > > elif os.name == 'nt': # Contributed by Jeff Bauer > > ...and... > > pythonrc = os.path.join(home, ".pythonrc.py") > > ...by the (indented) following ... > > import _winreg > shellkeyId = 'Software\\Microsoft\\Windows\\CurrentVersion\\explorer\\Shell > Folders' > shellkey = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, shellkeyId) > home = _winreg.QueryValueEx(shellkey, 'Personal')[0] > _winreg.CloseKey(shellkey) > > This has been successfully tested with Windows 98se, Windows 2000 pro and > Python 2.1.2. > Can you please reply in this thread if this works on other Win32 platforms > (95/ME/NT/XP). > Any other comment ? > > --Gillou > > > From Pekka.Pessi at nokia.com Sun Jan 13 11:48:25 2002 From: Pekka.Pessi at nokia.com (Pekka Pessi) Date: 13 Jan 2002 18:48:25 +0200 Subject: n++ < 10 syntax error?? References: Message-ID: In message rihad writes: >while n++ < 10: > pass >Gives a syntax error. Changing n++ to ++n compiles fine.... What the >hell is going on??? >(P.S. I know I can use the "for n in range(10)" idiom, but what's >wrong with n++?) There is no postincrement operator in Python. There is no preincrement either, but ++n parses as + + n (which equals to - - n): >>> n = 1 >>> ++n 1 >>> ++n == --n 1 Pekka From niemeyer at conectiva.com Tue Jan 22 08:06:57 2002 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Tue, 22 Jan 2002 11:06:57 -0200 Subject: Hooks, aspect-oriented programming, and design by contract In-Reply-To: <5.1.0.14.0.20020122113701.00a6fb80@n/a> References: <5.1.0.14.0.20020122113701.00a6fb80@n/a> Message-ID: <20020122110657.A1079@ibook.distro.conectiva> > Hi, > maybe I'm just reinventing the wheel, but I just noted that Alex's > Aspecter function can easily be twitched to enforce some kind of design by > contract (which of course can be considered an aspect). > Here's my first shot at it. Corrections and improvements are much welcome. Here is some code I've written to play around with metaclasses. It may give you some ideas. -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] -------------- next part -------------- from types import FunctionType CONTRACT_NONE = 0 CONTRACT_PRE = 1 CONTRACT_POST = 2 CONTRACT_INV = 3 ContractLevel = CONTRACT_INV # Trick to work with 2.1 and 2.2 if not __builtins__.__dict__.get("object"): class object: pass class ContractMeta(object): def __init__(self, name, bases, namespace): self.__name__ = name self.__bases__ = bases self.__namespace__ = namespace def __call__(self): return ContractInstance(self) class ContractInstance: def __init__(self, klass): self.__klass__ = klass def __getattr__(self, name): namespace = self.__klass__.__namespace__ try: attr = namespace[name] except KeyError: raise AttributeError, name if type(attr) is FunctionType: inv = namespace.get("invariant") if name == "invariant": return ContractSpecialMethod(attr, self, None, ContractInvError) if name[-4:] == "_pre": return ContractSpecialMethod(attr, self, inv, ContractPreError) if name[-5:] == "_post": return ContractSpecialMethod(attr, self, inv, ContractPostError) pre = namespace.get(name+"_pre") post = namespace.get(name+"_post") return ContractMethod(name, attr, self, inv, pre, post) return attr class ContractSpecialMethod: """Handle calling of pre/post conditions and invariant.""" def __init__(self, function, instance, invariant, exception): self.__function = function self.__instance = instance self.__invariant = invariant self.__exception = exception def __call__(self, *parm, **kw): if self.__invariant: try: self.__invariant(self.__instance) except AssertionError, msg: raise ContractInvError(msg) try: self.__function(*(self.__instance,)+parm, **kw) except AssertionError, msg: raise self.__exception(msg) class ContractMethod: """Handle calling of usual methods.""" def __init__(self, name, function, instance, inv, pre, post): self.__name = name self.__function = function self.__instance = instance self.__inv = inv self.__pre = pre self.__post = post def __call__(self, *parm, **kw): namespace = self.__instance.__klass__.__namespace__ if self.__inv: try: self.__inv(self.__instance) except AssertionError, msg: raise ContractInvError(msg) if self.__pre: try: self.__pre(*(self.__instance,)+parm, **kw) except AssertionError, msg: raise ContractPreError(msg) result = self.__function(*(self.__instance,)+parm, **kw) if self.__post: try: self.__post(*(self.__instance, result)+parm, **kw) except AssertionError, msg: raise ContractPostError(msg) if self.__inv: try: self.__inv(self.__instance) except AssertionError, msg: raise ContractInvError(msg) return result class ContractError(AssertionError): pass class ContractPreError(ContractError): pass class ContractPostError(ContractError): pass class ContractInvError(ContractError): pass Contract = ContractMeta("Contract", (), {}) if __name__ == "__main__": # Usage example class A(Contract): def invariant(self): print "invariant()" def a(self): print "a()" def a_pre(self): print "a_pre()" def a_post(self, result): print "a_post()" a = A() a.a() # vim:ts=4:sw=4 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From peter at engcorp.com Thu Jan 31 23:39:57 2002 From: peter at engcorp.com (Peter Hansen) Date: Thu, 31 Jan 2002 23:39:57 -0500 Subject: calling upper constructor References: <3C5A04E9.3040502@sunet.ru> Message-ID: <3C5A1C1D.10F4B14D@engcorp.com> Yura Ushakhow wrote: > > What do you do to call __init__ of an upper class? > Like > > class base: > def __init__(self): > a = 1 > class abc(base): > def __init__(self): > # how do I call base's init here? Try this: base.__init__(self) By the way, if you're just starting out, I'll point out a possible mistake in the above. If you expected "a = 1" to create a variable inside the instance created, you'll find it won't work. You need to use "self.a = 1" or you'll just be making a useless local variable. > Couldn't find it in the docs.. Neither could I, with a few minutes searching. Curious. -Peter From montanaro at tttech.com Wed Jan 23 05:55:02 2002 From: montanaro at tttech.com (montanaro at tttech.com) Date: Wed, 23 Jan 2002 04:55:02 -0600 Subject: PyDict_Next doc buglet In-Reply-To: References: Message-ID: <15438.38534.328724.432261@dynamic2.tttech1.ttt> Robin> Looking at the 2.1.2 docs Doc/api/dictObjects.html it is not Robin> clear whether the output PyObjects have been borrowed or properly Robin> incremented. It's quite rare in the Python C API to use reference parameters the way PyDict_Next does. Fred Drake took a refcounts.dat file I created ages ago and updated the doc generation to indicate the refcount effect on function return values of type PyObject *. I just updated that function's doc section. All told, I only counted six functions in the concrete types section and one in the abstract types section that take PyObject** parameters. Robin> Looking in the code it seems they are borrowed, but isn't it a Robin> bug that this isn't made clear in the documentation. This is correct. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From DeepBleu at DeepBleu.org Fri Jan 11 19:38:59 2002 From: DeepBleu at DeepBleu.org (DeepBleu) Date: Sat, 12 Jan 2002 00:38:59 GMT Subject: "python powered"? References: Message-ID: It can mean different things: 1. On Win PC running IIS, it may mean that the Hammond's Python ActiveX Scripting engine is installed so that you can use Python via ASP pages. 2. Python is installed so that you can use it in your CGI programs on Sun, Wintel etc.... 3. Zope is installed so that you can use it (Zope is based on Python). All in all any web server/framewrk that allows you to use Python in scripting for the web. DeepBleu "ellen" wrote in message news:a1naqg$2uf$1 at panix3.panix.com... > > > pardon my ignorance, i know little about python, > but i've seen the "python powered" icon in several > websites. what exactly does it mean? are these > python cgi scripts? or python servlets? or what? > > e. From jnials at nials.org Mon Jan 21 03:18:39 2002 From: jnials at nials.org (Jon Nials) Date: Mon, 21 Jan 2002 02:18:39 -0600 Subject: win32net problem and question Message-ID: I am working my way (ok, jumping all over the place) through the O'Reilly "Python programming on Win32" book and I built the following python script import win32net import win32netcon def ReportServers(): resume = 0 serverTypes = win32netcon.SV_TYPE_ALL while 1: data, total, resume = win32net.NetServerEnum(None, 101, serverTypes, resume) for server in data: print data if resume == 0: break if __name__ == "__main__": ReportServers() I'm getting the following traceback..... Traceback (most recent call last): File "C:\Python22\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "C:\tmp\PyCom\ReportServers.py", line 15, in ? ReportServers() File "C:\tmp\PyCom\ReportServers.py", line 8, in ReportServers data, total, resume = win32net.NetServerEnum(None, 1, serverTypes, resume) TypeError: The object can not be converted to a Unicode object Which I don't understand, because it looks like the win32net code returns a PyUnicode object which should handle it. Anyway, I'm running this on Windows XP. BTW, I've picked this stuff up to learn something about Win32 programming. I'm a unix geek, but I'm an *unemployed* unix geek -Jon From gmcm at hypernet.com Thu Jan 3 15:05:08 2002 From: gmcm at hypernet.com (Gordon McMillan) Date: 03 Jan 2002 20:05:08 GMT Subject: frozen win32com problem References: Message-ID: Robin Becker wrote: > I am attempting to implement a frozen python win32com object. > We are using a variant of Gordon McMillan's 4.x installer framework > to create a python.exe which works fine. Most .pycs are in a .pyz file, > but the win32/lib files and win32com/server+client files are in > the real file system. > > I have only got pythoncom21.dll, pywintypes21.dll, win32api.pyd and > win32trace.pyd on the target system. > > I find that I can use my objects if I manually register them to use my > localserver only. So I have a working setup except for registration on > the target machine. localserver only applies if you're using LOCAL_SERVER. > When I try to use the standard command line registration/unregistration > mechanism I'm getting an error from > win32com.server.register._cat_registrar > > eg with the cut down file \tmp\dingo.py > > import pythoncom > def _cat_registrar(): > return pythoncom.CoCreateInstance( > pythoncom.CLSID_StdComponentCategoriesMgr, > None, > pythoncom.CLSCTX_INPROC_SERVER, > pythoncom.IID_ICatRegister > ) > > print 'CLSID_StdComponentCategoriesMgr', > pythoncom.CLSID_StdComponentCategoriesMgr print 'CLSCTX_INPROC_SERVER', > pythoncom.CLSCTX_INPROC_SERVER print 'IID_ICatRegister', > pythoncom.IID_ICatRegister print _cat_registrar() > > > C:\ReportLab>\tmp\dingo.py > CLSID_StdComponentCategoriesMgr > CLSCTX_INPROC_SERVER 1 > IID_ICatRegister > Traceback (most recent call last): > File "C:\tmp\dingo.py", line 13, in ? > print _cat_registrar() > File "C:\tmp\dingo.py", line 7, in _cat_registrar > pythoncom.IID_ICatRegister > pywintypes.com_error: (-2147221164, 'Class not registered', None, None) > > > this is on an NT4 system that has no python/pythonwin etc. Any ideas > what I'm missing/haven't registered? You seem to be asking for INPROC_SERVER. That means COM loads pythoncomXX.dll which (implicitly) loads pythonXX.dll. There's no chance for the import hooks to get installed. Unless you upgrade to release 5. -- Gordon http://www.mcmillan-inc.com/ From access at thomas-guettler.de Wed Jan 2 07:04:29 2002 From: access at thomas-guettler.de (Thomas Guettler) Date: Wed, 02 Jan 2002 13:04:29 +0100 Subject: zope: which adapter for oracle? Message-ID: <3C32F74D.2020503@thomas-guettler.de> There are two adapters for zope: http://www.zope.org/Products/DCOracle and http://www.zope.org/Members/matt/dco2 Can someone compare these adapters? What are the (dis)advantages? thomas (I know that it is OT, but I can't subscribe to the zope mailinglist at the moment) From jpt.d at rogers.com Thu Jan 10 06:36:38 2002 From: jpt.d at rogers.com (Jeffrey Drake) Date: Thu, 10 Jan 2002 11:36:38 GMT Subject: ENC: math module References: Message-ID: <3c3d7c93.1742966@nntp> Please post in text only (plain text). HTML just messages many newsreaders up. Especially some of the linux ones. On Thu, 10 Jan 2002 08:42:50 -0300, "Alves, Carlos Alberto - Coelce" wrote: >This message is in MIME format. Since your mail reader does not understand >this format, some or all of this message may not be legible. > >------_=_NextPart_001_01C199CB.EEA8B850 >Content-Type: text/plain; > charset="ISO-8859-1" > >Yes, You must use the complete reference to the object >just like this: > >import math >math.exp(10) or math.sqrt(10) > >Or, on the other hand, you can use the explicity form of import statement >(from import object) if you don't want use the form above. See >below: > >from math import exp,sqrt >exp(10) >sqrt(4) > >-----Mensagem original----- >De: gombosk at vas.birosag.hu [mailto:gombosk at vas.birosag.hu] >Enviada em: quinta-feira, 10 de janeiro de 2002 07:00 >Para: Jason Orendorff >Cc: python-list at python.org >Assunto: math module > > > >I have a problem with math module: > >I import math module, because to call exp(x) or sqrt(x) does not work. > >Do I need anything else to do? > >>>> import math >>>> exp(10) >Traceback (most recent call last): > File "", line 1, in ? >NameError: name 'exp' is not defined > >This is the problem... > >Katalin > > >-- >http://mail.python.org/mailman/listinfo/python-list > >------_=_NextPart_001_01C199CB.EEA8B850 >Content-Type: text/html; > charset="ISO-8859-1" >Content-Transfer-Encoding: quoted-printable > > > > >charset=3DISO-8859-1"> >5.5.2653.12"> >ENC: math module > > > >

Yes, You must use the complete reference to the = >object <modulename.object> just like this: >

> >

import math >
math.exp(10) or math.sqrt(10) >

> >

Or, on the other hand, you can use the explicity form = >of import statement (from <modulename> import object) if you = >don't want use the form above. See below:

> >

from math import exp,sqrt >
exp(10) >
sqrt(4) >

> >

-----Mensagem original----- >
De: gombosk at vas.birosag.hu [HREF=3D"mailto:gombosk at vas.birosag.hu">mailto:gombosk at vas.birosag.hu= >] >
Enviada em: quinta-feira, 10 de janeiro de 2002 = >07:00 >
Para: Jason Orendorff >
Cc: python-list at python.org >
Assunto: math module >

>
>
> >

I have a problem with math module: >

> >

I import math module, because to call exp(x) or = >sqrt(x) does not work. >

> >

Do I need anything else to do? >

> >

>>> import math >
>>> exp(10) >
Traceback (most recent call last): >
  File "<stdin>", line 1, in = >? >
NameError: name 'exp' is not defined >

> >

This is the problem... >

> >

Katalin >

>
> >

-- >
HREF=3D"http://mail.python.org/mailman/listinfo/python-list" = >TARGET=3D"_blank">http://mail.python.org/mailman/listinfo/python-list> >

> > > >------_=_NextPart_001_01C199CB.EEA8B850-- > From nigel.hewett at kuhuna.com Sun Jan 6 16:07:11 2002 From: nigel.hewett at kuhuna.com (Nigel Hewett) Date: Sun, 6 Jan 2002 21:07:11 -0000 Subject: syntax error line 72? Message-ID: <1010351206.2678.0.nnrp-12.9e988878@news.demon.co.uk> can anyone assist running 1.5.2 python on raq4 with this script and getting - ears the script it syntax errors on line 72 while (t < cur_time()): t += 86400 return t the script >>>>> #!/usr/bin/python # # Copyright (C) 2000-2001 Jasper Jongmans. All rights reserved. # # $Id: frontend.py,v 1.32 2001/05/16 13:43:38 aprogas Exp $ # ### IMPORTS ### {{{1 # official modules import cgi import ftplib import httplib import robotparser import shelve import string import sys import time import urlparse import whrandom # project modules #sys.path.append('/home/webget/www/webget/') # uncomment if core.py is not in the same dir as frontend.py/backend.py from core import * # }}}1 ### GLOBALS ### {{{1 db_file = webget_path+'webget.db' # use an absolute path # }}}1 ### FUNCTIONS ### {{{1 def add(uri, fetch_time): # {{{2 'Puts the specified URI in the queue to be fetched at the specified time' id = give_id() while db.has_key(id): id = give_id() # FIXME - will loop forever if all IDs are taken status, filesize = prefetch(uri) add_time = cur_time() last_change_time = cur_time() filerrors = [] db[id] = uri, status, filesize, fetch_time, add_time, last_change_time, filerrors # }}}2 def delete(id): # {{{2 'Removes the specified ID from the database file' # For this functions it is useless to update the last_change_time. del db[id] # }}}2 def epoch2human_time(t): # {{{2 'Converts a epoch-time (in whole seconds) to a human-readable time' t = time.localtime(t) t = time.strftime('%Y/%m/%d %H:%M', t) return t # }}}2 def give_id(): # {{{2 'Returns a random integer' return whrandom.randint(1,65535) # }}}2 def input2epoch_time(t): # {{{2 'Converts a shutdown(8)-like time to an epoch-time (in whole seconds)' Y, m, d, H, M, s, w, j, D = time.localtime(cur_time()) try: if len(t) == 12: Y, m, d, H, M = time.strptime(t, '%Y%m%d%H%M')[:5] elif len(t) == 10: Y, m, d, H, M = time.strptime(t, '%y%m%d%H%M')[:5] elif len(t) == 8: m, d, H, M = time.strptime(t, '%m%d%H%M')[1:5] elif len(t) == 6: d, H, M = time.strptime(t, '%d%H%M')[2:5] elif len(t) == 4: H, M = time.strptime(t, '%H%M')[3:5] elif len(t) == 2: M = time.strptime(t, '%M')[4] else: warnings.append('Invalid fetch time, current time implied.') except ValueError: warnings.append('Invalid fetch time, current time implied.') t = Y, m, d, H, M, s, w, j, D t = time.mktime(t) t = int(t) while (t < cur_time()): t += 86400 return t # }}}2 def page_details(id): # {{{2 'Prints out detailed information about the entry specified with id' global contents uri, status, filesize, fetch_time, add_time, last_change_time, filerrors = db[id] contents += '
\n'
	contents += 'ID: %s\n' % id
	contents += 'URI: %s\n' % uri
	contents += 'Status: %s\n' % status
	contents += 'Filesize: %s\n' % filesize
	contents += 'Fetch time: %s\n' % epoch2human_time(fetch_time)
	contents += 'Time added: %s\n' % epoch2human_time(add_time)
	contents += 'Last change: %s\n' % epoch2human_time(last_change_time)
	contents += 'Errors:\n'
	for filerror in filerrors:
		contents += '	%s\n' % filerror
	contents += '
\n' contents += '
\n' # }}}2 def page_errors(errors): # {{{2 'Prints out all errors' print '

Errors

' print '
' for error in errors: print '%s
' % error print '
' # }}}2 def page_footer(): # {{{2 'Prints a generic page footer' print '''\ \ ''' # }}}2 def page_header(): # {{{2 'Prints a generic page header' print '''\ Cache-Control: no-cache Pragma: no-cache Content-Type: text/html Webget %s

Webget %s


\ ''' % (version, version) # }}}2 def page_list(): # {{{2 'Prints the list of URIs' global contents if mass_submission: submission = '